From e2256cff446fa74d32c78688e2e7cac0b161c52b Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Wed, 6 Dec 2023 19:11:57 -0500 Subject: [PATCH 01/89] Adding OvenOpState test scripts and ciTests.json file --- .../certification/Test_TC_OVENOPSTATE_1_1.yml | 155 ++++++++ .../certification/Test_TC_OVENOPSTATE_2_2.yml | 335 ++++++++++++++++++ src/app/tests/suites/ciTests.json | 2 + src/python_testing/TC_OVENOPSTATE_2_1.py | 201 +++++++++++ src/python_testing/TC_OVENOPSTATE_2_3.py | 158 +++++++++ 5 files changed, 851 insertions(+) create mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml create mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml create mode 100644 src/python_testing/TC_OVENOPSTATE_2_1.py create mode 100644 src/python_testing/TC_OVENOPSTATE_2_3.py diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml new file mode 100644 index 00000000000000..d4f43410a0f50e --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml @@ -0,0 +1,155 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: 3.1.1. [TC-OVENOPSTATE-1.1] Global attributes with server as DUT +PICS: + - OVENOPSTATE.S + +config: + nodeId: 0x12344321 + cluster: "Oven Operational State" + endpoint: 1 + +tests: + - label: "Step 1: Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "Step 2: TH reads the ClusterRevision attribute from the DUT" + command: "readAttribute" + attribute: "ClusterRevision" + response: + value: 1 + constraints: + type: int16u + + - label: "Step 3: TH reads the FeatureMap attribute from the DUT" + command: "readAttribute" + attribute: "FeatureMap" + response: + value: 0 + constraints: + type: bitmap32 + + - label: "Step 4a: TH reads the AttributeList attribute from the DUT" + PICS: PICS_EVENT_LIST_ENABLED + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: + [0, 1, 3, 4, 5, 65528, 65529, 65530, 65531, 65532, 65533] + + - label: "Step 4a: TH reads the AttributeList attribute from the DUT" + PICS: "!PICS_EVENT_LIST_ENABLED" + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [0, 1, 3, 4, 5, 65528, 65529, 65531, 65532, 65533] + + - label: + "Step 4b: TH reads from the DUT the optional attribute(CountdownTime) + in the AttributeList from the DUT" + PICS: OVENOPSTATE.S.A0002 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [2] + + - label: "Step 5a: TH reads from the DUT the EventList attribute." + PICS: PICS_EVENT_LIST_ENABLED + command: "readAttribute" + attribute: "EventList" + response: + constraints: + type: list + contains: [0x00] + + - label: + "Step 5b: TH reads from the DUT the optional + event(OperationCompletion) in EventList." + PICS: PICS_EVENT_LIST_ENABLED && OVENOPSTATE.S.E01 + command: "readAttribute" + attribute: "EventList" + response: + constraints: + type: list + contains: [0x01] + + - label: "Step 6a: Read the optional command(Start) in AcceptedCommandList" + PICS: OVENOPSTATE.S.C02.Rsp + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [1, 2] + + - label: "Step 6b: Read the optional command(Stop) in AcceptedCommandList" + PICS: OVENOPSTATE.S.C01.Rsp + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [1] + + - label: "Step 6c: Read the optional command(Pause) in AcceptedCommandList" + PICS: OVENOPSTATE.S.C00.Rsp + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [0, 3] + + - label: "Step 6d: Read the optional command(Resume) in AcceptedCommandList" + PICS: OVENOPSTATE.S.C03.Rsp + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [0, 3] + + - label: "Step 7: Read the global attribute: GeneratedCommandList" + PICS: + "!OPSTATE.S.C00.Rsp && !OPSTATE.S.C01.Rsp && !OPSTATE.S.C02.Rsp && + !OPSTATE.S.C03.Rsp" + command: "readAttribute" + attribute: "GeneratedCommandList" + response: + value: [] + constraints: + type: list + + - label: "Step 7: Read the global attribute: GeneratedCommandList" + PICS: + (OPSTATE.S.C00.Rsp || OPSTATE.S.C01.Rsp || OPSTATE.S.C02.Rsp || + OPSTATE.S.C03.Rsp) + command: "readAttribute" + attribute: "GeneratedCommandList" + response: + constraints: + type: list + contains: [4] \ No newline at end of file diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml new file mode 100644 index 00000000000000..9527eb47a18cbd --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml @@ -0,0 +1,335 @@ +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default + +name: 3.2.2. [TC-OVENOPSTATE-2.2] Start and Stop commands with DUT as Server + +PICS: + - OVENOPSTATE.S + +config: + nodeId: 0x12344321 + cluster: "Basic Information" + endpoint: 0 + +tests: + - label: "Note" + verification: | + This is a simulated example log for instructional purposes only. In real scenarios, the actual log may vary depending on the feature implementation in Reference App. + disabled: true + + - label: + "Step 1: Commission DUT to TH (can be skipped if done in a preceding + test)" + verification: | + OVENOPSTATE.S.C01 && OVENOPSTATE.S.C02 + disabled: true + + - label: + "Step 2: Manually put the DUT into a state wherein it can receive a + Start Command" + verification: | + Manually put the DUT into a state wherein it can receive a Start Command + disabled: true + + - label: "Step 3: TH reads from the DUT the OperationalStateList attribute" + PICS: OVENOPSTATE.S.A0003 + verification: | + ./chip-tool operationalstate read operational-state-list 1 1 + + Via the TH (chip-tool), verify: + - all entries include an ID (enum8) and a label (string) + - all provided IDs are in the allowed range + - the list includes IDs for Error (0x03), Running (0x01), and Stopped (0x00) + + [1689674049.504261][17222:17224] CHIP:DMG: } + [1689674049.504390][17222:17224] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0003 DataVersion: 2102885775 + [1689674049.504440][17222:17224] CHIP:TOO: OperationalStateList: 4 entries + [1689674049.504462][17222:17224] CHIP:TOO: [1]: { + [1689674049.504469][17222:17224] CHIP:TOO: OperationalStateID: 0 + [1689674049.504476][17222:17224] CHIP:TOO: } + [1689674049.504484][17222:17224] CHIP:TOO: [2]: { + [1689674049.504490][17222:17224] CHIP:TOO: OperationalStateID: 1 + [1689674049.504495][17222:17224] CHIP:TOO: } + [1689674049.504503][17222:17224] CHIP:TOO: [3]: { + [1689674049.504508][17222:17224] CHIP:TOO: OperationalStateID: 2 + [1689674049.504514][17222:17224] CHIP:TOO: } + [1689674049.504521][17222:17224] CHIP:TOO: [4]: { + [1689674049.504527][17222:17224] CHIP:TOO: OperationalStateID: 3 + [1689674049.504533][17222:17224] CHIP:TOO: } + [1689674049.504605][17222:17224] CHIP:EM: <<< [E:22830i S:37151 M:4250114 (Ack:140781365)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674049.504620][17222:17224] CHIP:IN: (S) Sending msg 4250114 on secure session with LSID: 37151 + disabled: true + + - label: "Step 4: TH sends Start command to the DUT" + PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool operationalstate start 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674139.018639][17233:17235] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674139.018658][17233:17235] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674139.018704][17233:17235] CHIP:TOO: OperationalCommandResponse: { + [1689674139.018712][17233:17235] CHIP:TOO: commandResponseState: { + [1689674139.018719][17233:17235] CHIP:TOO: ErrorStateID: 0 + [1689674139.018726][17233:17235] CHIP:TOO: } + [1689674139.018732][17233:17235] CHIP:TOO: } + [1689674139.018755][17233:17235] CHIP:DMG: ICR moving to [AwaitingDe] + [1689674139.018818][17233:17235] CHIP:EM: <<< [E:26021i S:33879 M:235550100 (Ack:58905970)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674139.018837][17233:17235] CHIP:IN: (S) Sending msg 235550100 on secure session with LSID: 33879 + [1689674139.018885][17233:17235] CHIP:EM: Flushed pending ack for MessageCounter:58905970 on exchange 26021i + disabled: true + + - label: "Step 5: TH reads from the DUT the OperationalState attribute" + PICS: OVENOPSTATE.S.A0004 + verification: | + ./chip-tool operationalstate read operational-state 1 1 + + Via the TH (chip-tool), verify: + - the response has an OperationalStateID field that is set to 0x01 (Running) + + [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 + [1689674196.878727][17249:17251] CHIP:DMG: } + [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 + [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { + [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 + [1689674196.878847][17249:17251] CHIP:TOO: } + [1689674196.878914][17249:17251] CHIP:EM: <<< [E:56939i S:28614 M:63040141 (Ack:57012545)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674196.878928][17249:17251] CHIP:IN: (S) Sending msg 63040141 on secure session with LSID: 28614 + disabled: true + + - label: "Step 6: TH reads from the DUT the OperationalError attribute" + PICS: OVENOPSTATE.S.A0005 + verification: | + ./chip-tool operationalstate read operational-error 1 1 + + Via the TH (chip-tool), verify: + - the response contains the ErrorStateId set to NoError(0x00) + + [1689674342.832448][17274:17276] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0005 DataVersion: 2102885775 + [1689674342.832482][17274:17276] CHIP:TOO: OperationalError: { + [1689674342.832500][17274:17276] CHIP:TOO: ErrorStateID: 0 + [1689674342.832509][17274:17276] CHIP:TOO: } + [1689674342.832570][17274:17276] CHIP:EM: <<< [E:37158i S:10451 M:72875113 (Ack:195983315)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674342.832585][17274:17276] CHIP:IN: (S) Sending msg 72875113 on secure session with LSID: 10451 + [1689674342.832614][17274:17276] CHIP:EM: Flushed pending ack for MessageCounter:195983315 on exchange 37158i + disabled: true + + - label: "Step 7: TH reads from the DUT the CountdownTime attribute" + PICS: OVENOPSTATE.S.A0002 + verification: | + ./chip-tool operationalstate read countdown-time 1 1 + + Via the TH (chip-tool), verify: + - that CountdownTime attribute contains either null our a uint32 value + - if non-null, verify that the value is in the range 1 to 259200 + - store the value in 'initialcountdown-time' + + [1689674384.271623][17278:17280] CHIP:DMG: InteractionModelRevision = 1 + [1689674384.271625][17278:17280] CHIP:DMG: } + [1689674384.271649][17278:17280] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 2102885775 + [1689674384.271662][17278:17280] CHIP:TOO: CountdownTime: null + [1689674384.271683][17278:17280] CHIP:EM: <<< [E:24665i S:47371 M:757241 (Ack:152992659)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674384.271687][17278:17280] CHIP:IN: (S) Sending msg 757241 on secure session with LSID: 47371 + [1689674384.271696][17278:17280] CHIP:EM: Flushed pending ack for MessageCounter:152992659 on exchange 24665i + disabled: true + + - label: "Step 8: TH reads from the DUT the PhaseList attribute" + PICS: OVENOPSTATE.S.A0000 + verification: | + ./chip-tool operationalstate read phase-list 1 1 + + Via the TH (chip-tool), verify: + - that PhaseList attribute value contains either null or a list of strings. + + If not null, receord the number of entries in the list as 'phase-list-size'; execute step 7. + If null, go to step 8. + + [1689674447.761859][17290:17292] CHIP:DMG: InteractionModelRevision = 1 + [1689674447.761865][17290:17292] CHIP:DMG: } + [1689674447.761938][17290:17292] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0000 DataVersion: 2102885775 + [1689674447.761972][17290:17292] CHIP:TOO: PhaseList: null + [1689674447.762041][17290:17292] CHIP:EM: <<< [E:58737i S:13847 M:251354926 (Ack:137738036)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674447.762055][17290:17292] CHIP:IN: (S) Sending msg 251354926 on secure session with LSID: 13847 + [1689674447.762109][17290:17292] CHIP:EM: Flushed pending ack for MessageCounter:137738036 on exchange 58737i + disabled: true + + - label: "Step 9: TH reads from the DUT the CurrentPhase attribute" + PICS: OVENOPSTATE.S.A0001 + verification: | + ./chip-tool operationalstate read current-phase 1 1 + + Via the TH (chip-tool), verify: + - that the CurrentPhase attribute value contains contains a uint8 value + - that the value is between 0 and 'phase-list-size - 1'. + + [1689674497.950563][17299:17301] CHIP:DMG: } + [1689674497.950635][17299:17301] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0001 DataVersion: 2102885775 + [1689674497.950664][17299:17301] CHIP:TOO: CurrentPhase: null + [1689674497.950737][17299:17301] CHIP:EM: <<< [E:64019i S:52010 M:245677798 (Ack:138696372)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674497.950752][17299:17301] CHIP:IN: (S) Sending msg 245677798 on secure session with LSID: 52010 + [1689674497.950798][17299:17301] CHIP:EM: Flushed pending ack for MessageCounter:138696372 on exchange 64019i + [1689674497.950899][17299:17299] CHIP:CTL: Shutting down the commissioner + disabled: true + + - label: + "Step 10: TH waits for a vendor defined wait time, this being a period + of time less than the expected duration of the operation that has been + started" + verification: | + TH waits for a vendor defined wait time, this being a period of time less than the expected duration of the operation that has been started + disabled: true + + - label: "Step 11: TH reads from the DUT the CountdownTime attribute" + PICS: OVENOPSTATE.S.A0002 + verification: | + ./chip-tool operationalstate read countdown-time 1 1 + + + Via the TH (chip-tool), verify: + - that CountdownTime attribute contains either null our a uint32 value + - if non-null, verify that the value is in the range 1 to 259200 + - that the value is approximately 'initialcountdown-time minus the vendor defined wait time' + + + [1689674623.673661][17320:17322] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 2102885775 + [1689674623.673697][17320:17322] CHIP:TOO: CountdownTime: null + [1689674623.673755][17320:17322] CHIP:EM: <<< [E:42152i S:37580 M:19654175 (Ack:176515710)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674623.673768][17320:17322] CHIP:IN: (S) Sending msg 19654175 on secure session with LSID: 37580 + [1689674623.673795][17320:17322] CHIP:EM: Flushed pending ack for MessageCounter:176515710 on exchange 42152i + disabled: true + + - label: "Step 12: TH sends Start command to the DUT" + PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool operationalstate start 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674637.555734][17326:17328] CHIP:DMG: + [1689674637.555742][17326:17328] CHIP:DMG: InteractionModelRevision = 1 + [1689674637.555751][17326:17328] CHIP:DMG: }, + [1689674637.555784][17326:17328] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674637.555805][17326:17328] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674637.555853][17326:17328] CHIP:TOO: OperationalCommandResponse: { + [1689674637.555862][17326:17328] CHIP:TOO: commandResponseState: { + [1689674637.555872][17326:17328] CHIP:TOO: ErrorStateID: 0 + [1689674637.555883][17326:17328] CHIP:TOO: } + [1689674637.555891][17326:17328] CHIP:TOO: } + [1689674637.555913][17326:17328] CHIP:DMG: ICR moving to [AwaitingDe] + [1689674637.555956][17326:17328] CHIP:EM: <<< [E:28742i S:49023 M:139320570 (Ack:91983883)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674637.555971][17326:17328] CHIP:IN: (S) Sending msg 139320570 on secure session with LSID: 49023 + [1689674637.556001][17326:17328] CHIP:EM: Flushed pending ack for MessageCounter:91983883 on exchange 28742i + disabled: true + + - label: "Step 13: TH sends Stop command to the DUT" + PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool operationalstate stop 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674653.322963][17330:17332] CHIP:DMG: }, + [1689674653.322994][17330:17332] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674653.323014][17330:17332] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674653.323058][17330:17332] CHIP:TOO: OperationalCommandResponse: { + [1689674653.323066][17330:17332] CHIP:TOO: commandResponseState: { + [1689674653.323076][17330:17332] CHIP:TOO: ErrorStateID: 0 + [1689674653.323085][17330:17332] CHIP:TOO: } + [1689674653.323094][17330:17332] CHIP:TOO: } + [1689674653.323113][17330:17332] CHIP:DMG: ICR moving to [AwaitingDe] + [1689674653.323154][17330:17332] CHIP:EM: <<< [E:62878i S:64455 M:173921517 (Ack:216732582)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674653.323168][17330:17332] CHIP:IN: (S) Sending msg 173921517 on secure session with LSID: 64455 + [1689674653.323195][17330:17332] CHIP:EM: Flushed pending ack for MessageCounter:216732582 on exchange 62878i + [1689674653.323284][17330:17330] CHIP:CTL: Shutting down the commissioner + disabled: true + + - label: "Step 14: TH reads from the DUT the OperationalState attribute" + PICS: OVENOPSTATE.S.A0004 + verification: | + ./chip-tool operationalstate read operational-state 1 1 + + Via the TH (chip-tool), verify: + - the response has an OperationalStateID field that is set to 0x00 (Stopped) + + [1689674675.459656][17333:17335] CHIP:DMG: } + [1689674675.459738][17333:17335] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 + [1689674675.459772][17333:17335] CHIP:TOO: OperationalState: { + [1689674675.459790][17333:17335] CHIP:TOO: OperationalStateID: 0 + [1689674675.459799][17333:17335] CHIP:TOO: } + [1689674675.459869][17333:17335] CHIP:EM: <<< [E:17771i S:16165 M:1572532 (Ack:102448631)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674675.459886][17333:17335] CHIP:IN: (S) Sending msg 1572532 on secure session with LSID: 16165 + [1689674675.459930][17333:17335] CHIP:EM: Flushed pending ack for MessageCounter:102448631 on exchange 17771i + disabled: true + + - label: "Step 15: TH sends Stop command to the DUT" + PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool operationalstate stop 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674689.588712][17337:17339] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674689.588722][17337:17339] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674689.588745][17337:17339] CHIP:TOO: OperationalCommandResponse: { + [1689674689.588749][17337:17339] CHIP:TOO: commandResponseState: { + [1689674689.588757][17337:17339] CHIP:TOO: ErrorStateID: 0 + [1689674689.588762][17337:17339] CHIP:TOO: } + [1689674689.588765][17337:17339] CHIP:TOO: } + [1689674689.588775][17337:17339] CHIP:DMG: ICR moving to [AwaitingDe] + [1689674689.588802][17337:17339] CHIP:EM: <<< [E:63921i S:35027 M:16881995 (Ack:220265764)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674689.588810][17337:17339] CHIP:IN: (S) Sending msg 16881995 on secure session with LSID: 35027 + disabled: true + + - label: + "Step 16: Manually put the DUT into a state wherein it cannot receive + a Start Command" + PICS: OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME + verification: | + Manually put the DUT into a state wherein it cannot receive a Start Command + disabled: true + + - label: "Step 17: TH sends Start command to the DUT" + PICS: + OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp && + OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool operationalstate start 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x01 (UnableToStartOrResume) + + [1689674700.385183][17340:17342] CHIP:DMG: }, + [1689674700.385214][17340:17342] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674700.385233][17340:17342] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674700.385266][17340:17342] CHIP:TOO: OperationalCommandResponse: { + [1689674700.385274][17340:17342] CHIP:TOO: commandResponseState: { + [1689674700.385281][17340:17342] CHIP:TOO: ErrorStateID: 1 + [1689674700.385289][17340:17342] CHIP:TOO: } + [1689674700.385295][17340:17342] CHIP:TOO: } + [1689674700.385311][17340:17342] CHIP:DMG: ICR moving to [AwaitingDe] + [1689674700.385361][17340:17342] CHIP:EM: <<< [E:55029i S:46795 M:80501191 (Ack:176711722)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674700.385375][17340:17342] CHIP:IN: (S) Sending msg 80501191 on secure session with LSID: 46795 + [1689674700.385419][17340:17342] CHIP:EM: Flushed pending ack for MessageCounter:176711722 on exchange 55029i + disabled: true \ No newline at end of file diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 18a069f267e33e..135a28de40b87f 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -164,6 +164,7 @@ "Test_TC_OO_2_4" ], "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], + "OvenOperationalState":["Test_TC_OVENOPSTATE_1_1"], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], "PressureMeasurement": [ "Test_TC_PRS_1_1", @@ -397,6 +398,7 @@ "OccupancySensing", "OnOff", "OperationalState", + "OvenOperationalState", "PowerSource", "PressureMeasurement", "PumpConfigurationControl", diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py new file mode 100644 index 00000000000000..18bb6419f539aa --- /dev/null +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -0,0 +1,201 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main +from mobly import asserts + +# This test requires several additional command line arguments +# run with +# --int-arg PIXIT_ENDPOINT: + + +class TC_OVENOPSTATE_2_1(MatterBaseTest): + + async def read_mod_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.OperationalState + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + async def read_and_validate_opstate(self, step, expected_state): + self.print_step(step, "Read OperationalState attribute") + operational_state = await self.read_mod_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.OperationalState.Attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, expected_state, + "OperationalState(%s) should equal %s" % (operational_state, expected_state)) + + async def read_and_validate_operror(self, step, expected_error): + self.print_step(step, "Read OperationalError attribute") + operational_error = await self.read_mod_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.OperationalState.Attributes.OperationalError) + logging.info("OperationalError: %s" % (operational_error)) + asserts.assert_equal(operational_error.errorStateID, expected_error, + "errorStateID(%s) should equal %s" % (operational_error.errorStateID, expected_error)) + + @async_test_body + async def test_TC_OPSTATE_2_1(self): + + asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, + "PIXIT_ENDPOINT must be included on the command line in " + "the --int-arg flag as PIXIT_ENDPOINT:") + + self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] + + attributes = Clusters.OperationalState.Attributes + + self.print_step(1, "Commissioning, already done") + + if self.check_pics("OPSTATE.S.A0000"): + self.print_step(2, "Read PhaseList attribute") + phase_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.PhaseList) + + if phase_list == NullValue: + logging.info("PhaseList is null") + else: + logging.info("PhaseList: %s" % (phase_list)) + + phase_list_len = len(phase_list) + + asserts.assert_less_equal(phase_list_len, 32, + "PhaseList length(%d) must be less than 32!" % phase_list_len) + + if self.check_pics("OPSTATE.S.A0001"): + self.print_step(3, "Read CurrentPhase attribute") + current_phase = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentPhase) + logging.info("CurrentPhase: %s" % (current_phase)) + + if phase_list == NullValue: + asserts.assert_true(current_phase == NullValue, "CurrentPhase(%s) should be null" % current_phase) + else: + asserts.assert_true(0 <= current_phase and current_phase < phase_list_len, + "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) + + if self.check_pics("OPSTATE.S.A0002"): + self.print_step(4, "Read CountdownTime attribute") + countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.CountdownTime) + + logging.info("CountdownTime: %s" % (countdown_time)) + if countdown_time is not NullValue: + asserts.assert_true(0 <= countdown_time <= 259200, + "CountdownTime(%s) must be between 0 and 259200" % countdown_time) + + if self.check_pics("OPSTATE.S.A0003"): + self.print_step(5, "Read OperationalStateList attribute") + operational_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalStateList) + + logging.info("OperationalStateList: %s" % (operational_state_list)) + + defined_states = [state.value for state in Clusters.OperationalState.Enums.OperationalStateEnum + if state is not Clusters.OperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] + + for state in operational_state_list: + in_range = (0x80 <= state.operationalStateID <= 0xBF) + asserts.assert_true(state.operationalStateID in defined_states or in_range, + "Found a OperationalStateList entry with invalid ID value!") + if in_range: + asserts.assert_true(state.operationalStateLabel is not None, + "The OperationalStateLabel should be populated") + if state.operationalStateID == Clusters.OperationalState.Enums.OperationalStateEnum.kError: + error_state_present = True + + asserts.assert_true(error_state_present, "The OperationalStateList does not have an ID entry of Error(0x03)") + + if self.check_pics("OPSTATE.S.A0004"): + self.print_step(6, "Read OperationalState attribute") + operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalState) + + logging.info("OperationalState: %s" % (operational_state)) + + in_range = (0x80 <= operational_state <= 0xBF) + asserts.assert_true(operational_state in defined_states or in_range, "OperationalState has an invalid ID value!") + + if self.check_pics("OPSTATE.S.M.ST_STOPPED"): + self.print_step("6a", "Manually put the device in the stopped state") + input("Press Enter when done.\n") + await self.read_and_validate_opstate(step="6b", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kStopped) + if self.check_pics("OPSTATE.S.M.ST_RUNNING"): + self.print_step("6c", "Manually put the device in the running state") + input("Press Enter when done.\n") + await self.read_and_validate_opstate(step="6d", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kRunning) + if self.check_pics("OPSTATE.S.M.ST_PAUSED"): + self.print_step("6e", "Manually put the device in the paused state") + input("Press Enter when done.\n") + await self.read_and_validate_opstate(step="6f", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kPaused) + if self.check_pics("OPSTATE.S.M.ST_ERROR"): + self.print_step("6g", "Manually put the device in the error state") + input("Press Enter when done.\n") + await self.read_and_validate_opstate(step="6h", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kError) + if self.check_pics("OPSTATE.S.M.ST_PREHEATING"): + self.print_step("6i", "Manually put the device in the preheating state") + input("Press Enter when done.\n") + await self.read_and_validate_opstate(step="6j", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kPreheating) + if self.check_pics("OPSTATE.S.M.ST_PREHEATED"): + self.print_step("6k", "Manually put the device in the preheated state") + input("Press Enter when done.\n") + await self.read_and_validate_opstate(step="6l", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kPreheated) + if self.check_pics("OPSTATE.S.M.ST_COOLINGDOWN"): + self.print_step("6m", "Manually put the device in the coolingdown state") + input("Press Enter when done.\n") + await self.read_and_validate_opstate(step="6n", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kCoolingDown) + if self.check_pics("OPSTATE.S.M.ST_SELFCLEANING"): + self.print_step("6o", "Manually put the device in the selfclean state") + input("Press Enter when done.\n") + await self.read_and_validate_opstate(step="6p", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kSelfCleaning) + + if self.check_pics("OPSTATE.S.A0005"): + self.print_step(7, "Read OperationalError attribute") + operational_error = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalError) + + logging.info("OperationalError: %s" % (operational_error)) + + # Defined Errors + defined_errors = [error.value for error in Clusters.OperationalState.Enums.ErrorStateEnum + if error is not Clusters.OperationalState.Enums.ErrorStateEnum.kUnknownEnumValue] + + in_range = (0x80 <= operational_error.errorStateID <= 0xBF) + asserts.assert_true(operational_error.errorStateID in defined_errors + or in_range, "OperationalError has an invalid ID value!") + if in_range: + asserts.assert_true(operational_error.errorStateLabel is not None, "ErrorStateLabel should be populated") + + if self.check_pics("OPSTATE.S.M.ERR_NO_ERROR"): + self.print_step("7a", "Manually put the device in the no error state") + input("Press Enter when done.\n") + await self.read_and_validate_operror(step="7b", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kNoError) + if self.check_pics("OPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME"): + self.print_step("7c", "Manually put the device in the unable to start or resume error state") + input("Press Enter when done.\n") + await self.read_and_validate_operror(step="7d", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kUnableToStartOrResume) + if self.check_pics("OPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION"): + self.print_step("7e", "Manually put the device in the unable to complete operation error state") + input("Press Enter when done.\n") + await self.read_and_validate_operror(step="7f", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kUnableToCompleteOperation) + if self.check_pics("OPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE"): + self.print_step("7g", "Manually put the device in the command invalid error state") + input("Press Enter when done.\n") + await self.read_and_validate_operror(step="7h", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState) + + +if __name__ == "__main__": + default_matter_test_main() \ No newline at end of file diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py new file mode 100644 index 00000000000000..e52acfa3474629 --- /dev/null +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -0,0 +1,158 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging +import time + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches +from mobly import asserts + +# This test requires several additional command line arguments +# run with +# --int-arg PIXIT_ENDPOINT: + + +class TC_OVENOPSTATE_2_3(MatterBaseTest): + + async def read_mod_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.OperationalState + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + async def send_pause_cmd(self) -> Clusters.Objects.OperationalState.Commands.Pause: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OperationalState.Commands.Pause(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OperationalState.Commands.OperationalCommandResponse), + "Unexpected return type for Pause") + return ret + + async def send_resume_cmd(self) -> Clusters.Objects.OperationalState.Commands.Resume: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OperationalState.Commands.Resume(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OperationalState.Commands.OperationalCommandResponse), + "Unexpected return type for Resume") + return ret + + @async_test_body + async def test_TC_OPSTATE_2_3(self): + + asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, + "PIXIT_ENDPOINT must be included on the command line in " + "the --int-arg flag as PIXIT_ENDPOINT:") + + self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] + + asserts.assert_true(self.check_pics("OPSTATE.S.A0003"), "OPSTATE.S.A0003 must be supported") + asserts.assert_true(self.check_pics("OPSTATE.S.A0004"), "OPSTATE.S.A0004 must be supported") + asserts.assert_true(self.check_pics("OPSTATE.S.C00.Rsp"), "OPSTATE.S.C00.Rsp must be supported") + asserts.assert_true(self.check_pics("OPSTATE.S.C03.Rsp"), "OPSTATE.S.C03.Rsp must be supported") + + attributes = Clusters.OperationalState.Attributes + + self.print_step(1, "Commissioning, already done") + + self.print_step(2, "Manually put the device in a state where it can receive a Pause command") + input("Press Enter when done.\n") + + self.print_step(3, "Read OperationalStateList attribute") + op_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalStateList) + + logging.info("OperationalStateList: %s" % (op_state_list)) + + defined_states = [state.value for state in Clusters.OperationalState.Enums.OperationalStateEnum + if state is not Clusters.OperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] + + state_ids = set([s.operationalStateID for s in op_state_list]) + + asserts.assert_true(all(id in state_ids for id in defined_states), "OperationalStateList is missing a required entry") + + self.print_step(4, "Send Pause command") + ret = await self.send_pause_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + self.print_step(5, "Read OperationalState attribute") + operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OperationalState.Enums.OperationalStateEnum.kPaused, + "OperationalState ID should be Paused(0x02)") + + if self.check_pics("OPSTATE.S.A0002"): + self.print_step(6, "Read CountdownTime attribute") + initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.CountdownTime) + logging.info("CountdownTime: %s" % (initial_countdown_time)) + if initial_countdown_time is not NullValue: + in_range = (1 <= initial_countdown_time <= 259200) + asserts.assert_true(initial_countdown_time is NullValue or in_range, + "invalid CountdownTime(%s). Must be in between 1 and 259200, or null " % initial_countdown_time) + + self.print_step(7, "Waiting for 5 seconds") + time.sleep(5) + + self.print_step(8, "Read CountdownTime attribute") + countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CountdownTime) + logging.info("CountdownTime: %s" % (countdown_time)) + asserts.assert_true(countdown_time != 0 or countdown_time == NullValue, + "invalid CountdownTime(%s). Must be a non zero integer, or null" % countdown_time) + asserts.assert_equal(countdown_time, initial_countdown_time, "CountdownTime(%s) does not equal to the intial CountdownTime(%s)" + % (countdown_time, initial_countdown_time)) + + self.print_step(9, "Send Pause command") + ret = await self.send_pause_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + self.print_step(10, "Send Resume command") + ret = await self.send_resume_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + self.print_step(11, "Read OperationalState attribute") + operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OperationalState.Enums.OperationalStateEnum.kRunning, + "OperationalState(%s) should be Running(0x01)" % operational_state) + + self.print_step(12, "Send Resume command") + ret = await self.send_resume_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + self.print_step(13, "Manually put the device in a state where it cannot receive a Pause command") + input("Press Enter when done.\n") + + self.print_step(14, "Send Pause command") + ret = await self.send_pause_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, + Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, + "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) + + self.print_step(15, "Manually put the device in a state where it cannot receive a Resume command") + input("Press Enter when done.\n") + + self.print_step(16, "Send Resume command") + ret = await self.send_resume_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, + Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, + "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) + + +if __name__ == "__main__": + default_matter_test_main() \ No newline at end of file From 7d18b1817979457942d3e293ce7ae77885b39624 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 7 Dec 2023 00:15:09 +0000 Subject: [PATCH 02/89] Restyled by whitespace --- .../suites/certification/Test_TC_OVENOPSTATE_1_1.yml | 10 +++++----- .../suites/certification/Test_TC_OVENOPSTATE_2_2.yml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml index d4f43410a0f50e..da7b2f265c170d 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml @@ -29,7 +29,7 @@ tests: values: - name: "nodeId" value: nodeId - + - label: "Step 2: TH reads the ClusterRevision attribute from the DUT" command: "readAttribute" attribute: "ClusterRevision" @@ -37,7 +37,7 @@ tests: value: 1 constraints: type: int16u - + - label: "Step 3: TH reads the FeatureMap attribute from the DUT" command: "readAttribute" attribute: "FeatureMap" @@ -75,7 +75,7 @@ tests: constraints: type: list contains: [2] - + - label: "Step 5a: TH reads from the DUT the EventList attribute." PICS: PICS_EVENT_LIST_ENABLED command: "readAttribute" @@ -131,7 +131,7 @@ tests: constraints: type: list contains: [0, 3] - + - label: "Step 7: Read the global attribute: GeneratedCommandList" PICS: "!OPSTATE.S.C00.Rsp && !OPSTATE.S.C01.Rsp && !OPSTATE.S.C02.Rsp && @@ -152,4 +152,4 @@ tests: response: constraints: type: list - contains: [4] \ No newline at end of file + contains: [4] diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml index 9527eb47a18cbd..880cb8f09e1187 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml @@ -332,4 +332,4 @@ tests: [1689674700.385361][17340:17342] CHIP:EM: <<< [E:55029i S:46795 M:80501191 (Ack:176711722)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) [1689674700.385375][17340:17342] CHIP:IN: (S) Sending msg 80501191 on secure session with LSID: 46795 [1689674700.385419][17340:17342] CHIP:EM: Flushed pending ack for MessageCounter:176711722 on exchange 55029i - disabled: true \ No newline at end of file + disabled: true From 2dfffeb72c55587b7cb25306f47545ba7db7da6f Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 7 Dec 2023 00:15:11 +0000 Subject: [PATCH 03/89] Restyled by prettier-json --- src/app/tests/suites/ciTests.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 135a28de40b87f..36b2bea234b102 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -164,7 +164,7 @@ "Test_TC_OO_2_4" ], "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], - "OvenOperationalState":["Test_TC_OVENOPSTATE_1_1"], + "OvenOperationalState": ["Test_TC_OVENOPSTATE_1_1"], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], "PressureMeasurement": [ "Test_TC_PRS_1_1", From a37a1dc3787a598cad8f38780ea6da365f6e0fe4 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 7 Dec 2023 00:15:16 +0000 Subject: [PATCH 04/89] Restyled by prettier-yaml --- .../suites/certification/Test_TC_OVENOPSTATE_1_1.yml | 8 ++++---- .../suites/certification/Test_TC_OVENOPSTATE_2_2.yml | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml index da7b2f265c170d..e5a86eed5f525a 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml @@ -14,12 +14,12 @@ name: 3.1.1. [TC-OVENOPSTATE-1.1] Global attributes with server as DUT PICS: - - OVENOPSTATE.S + - OVENOPSTATE.S config: - nodeId: 0x12344321 - cluster: "Oven Operational State" - endpoint: 1 + nodeId: 0x12344321 + cluster: "Oven Operational State" + endpoint: 1 tests: - label: "Step 1: Wait for the commissioned device to be retrieved" diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml index 880cb8f09e1187..4e723deb9f08a4 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml @@ -311,8 +311,8 @@ tests: - label: "Step 17: TH sends Start command to the DUT" PICS: - OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp && - OVENOPSTATE.S.C04.Tx + OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp + && OVENOPSTATE.S.C04.Tx verification: | ./chip-tool operationalstate start 1 1 From 23ba65849bbf18778229a60689a970be8a1e2d9f Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Thu, 7 Dec 2023 00:15:34 +0000 Subject: [PATCH 05/89] Restyled by autopep8 --- src/python_testing/TC_OVENOPSTATE_2_1.py | 2 +- src/python_testing/TC_OVENOPSTATE_2_3.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index 18bb6419f539aa..0846bbdb5d18d5 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -198,4 +198,4 @@ async def test_TC_OPSTATE_2_1(self): if __name__ == "__main__": - default_matter_test_main() \ No newline at end of file + default_matter_test_main() diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py index e52acfa3474629..4898b3cc662664 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_3.py +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -155,4 +155,4 @@ async def test_TC_OPSTATE_2_3(self): if __name__ == "__main__": - default_matter_test_main() \ No newline at end of file + default_matter_test_main() From 698eb4dcd1a19c7a6e1750f7fb630f0faab6340f Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Mon, 18 Dec 2023 14:23:36 -0500 Subject: [PATCH 06/89] added OvenOpstate2_4 and updated other files --- src/app/tests/suites/certification/PICS.yaml | 89 +++++ .../Test_TC_OVENOPSTATE_1_1.yaml | 155 ++++++++ .../Test_TC_OVENOPSTATE_2_2.yaml | 335 ++++++++++++++++++ .../Test_TC_OVENOPSTATE_2_4.yaml | 94 +++++ .../tests/suites/certification/ci-pics-values | 33 ++ src/app/tests/suites/ciTests.json | 2 +- src/app/tests/suites/manualTests.json | 2 + src/python_testing/TC_OVENOPSTATE_2_1.py | 46 +-- src/python_testing/TC_OVENOPSTATE_2_3.py | 12 +- 9 files changed, 730 insertions(+), 38 deletions(-) create mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml create mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index a6f9974e59d182..4356518d45b0fc 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -8710,6 +8710,95 @@ PICS: command?" id: OPSTATE.S.C04.Tx + + # + #Oven Operational State + # + - label: + "Does the device implement the Operational State cluster as a server?" + id: OVENOPSTATE.S + + - label: + "Does the device implement the Operational State cluster as a client?" + id: OVENOPSTATE.C + + # ManuallyControlled + + - label: "Does the DUT support testing the Stopped(0x00) operational state" + id: OVENOPSTATE.S.M.ST_STOPPED + + - label: "Does the DUT support testing the Running(0x01) operational state" + id: OVENOPSTATE.S.M.ST_RUNNING + + - label: "Does the DUT support testing the Paused(0x02) operational state" + id: OVENOPSTATE.S.M.ST_PAUSED + + - label: "Does the DUT support testing the Error(0x03) operational state?" + id: OVENOPSTATE.S.M.ST_ERROR + + - label: "Does the DUT support testing the NoError(0x00) error state?" + id: OVENOPSTATE.S.M.ERR_NO_ERROR + + - label: + "Does the DUT support testing the UnableToStartOrResume(0x01) error + state?" + id: OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME + + - label: + "Does the DUT support testing the UnableToCompleteOperation(0x02) + error state?" + id: OVENOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION + + - label: + "Does the DUT support testing the CommandInvalidInState(0x03) error + state?" + id: OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE + + #Server Attributes + - label: "Does the device implement the PhaseList attribute?" + id: OVENOPSTATE.S.A0000 + + - label: "Does the device implement the CurrentPhase attribute?" + id: OVENOPSTATE.S.A0001 + + - label: "Does the device implement the CountdownTime attribute?" + id: OVENOPSTATE.S.A0002 + + - label: "Does the device implement the OperationalStateList attribute?" + id: OVENOPSTATE.S.A0003 + + - label: "Does the device implement the OperationalState attribute?" + id: OVENOPSTATE.S.A0004 + + - label: "Does the device implement the OperationalError attribute?" + id: OVENOPSTATE.S.A0005 + #Events Generated + + - label: "Does the device generate the OperationalError event?" + id: OVENOPSTATE.S.E00 + + - label: "Does the device generate the OperationCompltion event?" + id: OVENOPSTATE.S.E01 + + #Server Commands Received + - label: "Does the device implement receiving the Pause command?" + id: OVENOPSTATE.S.C00.Rsp + + - label: "Does the device implement receiving the Stop command?" + id: OVENOPSTATE.S.C01.Rsp + + - label: "Does the device implement receiving the Start command?" + id: OVENOPSTATE.S.C02.Rsp + + - label: "Does the device implement receiving the Resume command?" + id: OVENOPSTATE.S.C03.Rsp + + #Commands generated + - label: + "Does the device implement generating the OperationalCommandResponse + command?" + id: OVENOPSTATE.S.C04.Tx + # Smoke CO Alarm Cluster Test Plan - label: "Does the device implement the SMOKECO cluster as a server?" id: SMOKECO.S diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml new file mode 100644 index 00000000000000..e5a86eed5f525a --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml @@ -0,0 +1,155 @@ +# Copyright (c) 2021 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: 3.1.1. [TC-OVENOPSTATE-1.1] Global attributes with server as DUT +PICS: + - OVENOPSTATE.S + +config: + nodeId: 0x12344321 + cluster: "Oven Operational State" + endpoint: 1 + +tests: + - label: "Step 1: Wait for the commissioned device to be retrieved" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "Step 2: TH reads the ClusterRevision attribute from the DUT" + command: "readAttribute" + attribute: "ClusterRevision" + response: + value: 1 + constraints: + type: int16u + + - label: "Step 3: TH reads the FeatureMap attribute from the DUT" + command: "readAttribute" + attribute: "FeatureMap" + response: + value: 0 + constraints: + type: bitmap32 + + - label: "Step 4a: TH reads the AttributeList attribute from the DUT" + PICS: PICS_EVENT_LIST_ENABLED + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: + [0, 1, 3, 4, 5, 65528, 65529, 65530, 65531, 65532, 65533] + + - label: "Step 4a: TH reads the AttributeList attribute from the DUT" + PICS: "!PICS_EVENT_LIST_ENABLED" + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [0, 1, 3, 4, 5, 65528, 65529, 65531, 65532, 65533] + + - label: + "Step 4b: TH reads from the DUT the optional attribute(CountdownTime) + in the AttributeList from the DUT" + PICS: OVENOPSTATE.S.A0002 + command: "readAttribute" + attribute: "AttributeList" + response: + constraints: + type: list + contains: [2] + + - label: "Step 5a: TH reads from the DUT the EventList attribute." + PICS: PICS_EVENT_LIST_ENABLED + command: "readAttribute" + attribute: "EventList" + response: + constraints: + type: list + contains: [0x00] + + - label: + "Step 5b: TH reads from the DUT the optional + event(OperationCompletion) in EventList." + PICS: PICS_EVENT_LIST_ENABLED && OVENOPSTATE.S.E01 + command: "readAttribute" + attribute: "EventList" + response: + constraints: + type: list + contains: [0x01] + + - label: "Step 6a: Read the optional command(Start) in AcceptedCommandList" + PICS: OVENOPSTATE.S.C02.Rsp + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [1, 2] + + - label: "Step 6b: Read the optional command(Stop) in AcceptedCommandList" + PICS: OVENOPSTATE.S.C01.Rsp + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [1] + + - label: "Step 6c: Read the optional command(Pause) in AcceptedCommandList" + PICS: OVENOPSTATE.S.C00.Rsp + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [0, 3] + + - label: "Step 6d: Read the optional command(Resume) in AcceptedCommandList" + PICS: OVENOPSTATE.S.C03.Rsp + command: "readAttribute" + attribute: "AcceptedCommandList" + response: + constraints: + type: list + contains: [0, 3] + + - label: "Step 7: Read the global attribute: GeneratedCommandList" + PICS: + "!OPSTATE.S.C00.Rsp && !OPSTATE.S.C01.Rsp && !OPSTATE.S.C02.Rsp && + !OPSTATE.S.C03.Rsp" + command: "readAttribute" + attribute: "GeneratedCommandList" + response: + value: [] + constraints: + type: list + + - label: "Step 7: Read the global attribute: GeneratedCommandList" + PICS: + (OPSTATE.S.C00.Rsp || OPSTATE.S.C01.Rsp || OPSTATE.S.C02.Rsp || + OPSTATE.S.C03.Rsp) + command: "readAttribute" + attribute: "GeneratedCommandList" + response: + constraints: + type: list + contains: [4] diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml new file mode 100644 index 00000000000000..4e723deb9f08a4 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -0,0 +1,335 @@ +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default + +name: 3.2.2. [TC-OVENOPSTATE-2.2] Start and Stop commands with DUT as Server + +PICS: + - OVENOPSTATE.S + +config: + nodeId: 0x12344321 + cluster: "Basic Information" + endpoint: 0 + +tests: + - label: "Note" + verification: | + This is a simulated example log for instructional purposes only. In real scenarios, the actual log may vary depending on the feature implementation in Reference App. + disabled: true + + - label: + "Step 1: Commission DUT to TH (can be skipped if done in a preceding + test)" + verification: | + OVENOPSTATE.S.C01 && OVENOPSTATE.S.C02 + disabled: true + + - label: + "Step 2: Manually put the DUT into a state wherein it can receive a + Start Command" + verification: | + Manually put the DUT into a state wherein it can receive a Start Command + disabled: true + + - label: "Step 3: TH reads from the DUT the OperationalStateList attribute" + PICS: OVENOPSTATE.S.A0003 + verification: | + ./chip-tool operationalstate read operational-state-list 1 1 + + Via the TH (chip-tool), verify: + - all entries include an ID (enum8) and a label (string) + - all provided IDs are in the allowed range + - the list includes IDs for Error (0x03), Running (0x01), and Stopped (0x00) + + [1689674049.504261][17222:17224] CHIP:DMG: } + [1689674049.504390][17222:17224] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0003 DataVersion: 2102885775 + [1689674049.504440][17222:17224] CHIP:TOO: OperationalStateList: 4 entries + [1689674049.504462][17222:17224] CHIP:TOO: [1]: { + [1689674049.504469][17222:17224] CHIP:TOO: OperationalStateID: 0 + [1689674049.504476][17222:17224] CHIP:TOO: } + [1689674049.504484][17222:17224] CHIP:TOO: [2]: { + [1689674049.504490][17222:17224] CHIP:TOO: OperationalStateID: 1 + [1689674049.504495][17222:17224] CHIP:TOO: } + [1689674049.504503][17222:17224] CHIP:TOO: [3]: { + [1689674049.504508][17222:17224] CHIP:TOO: OperationalStateID: 2 + [1689674049.504514][17222:17224] CHIP:TOO: } + [1689674049.504521][17222:17224] CHIP:TOO: [4]: { + [1689674049.504527][17222:17224] CHIP:TOO: OperationalStateID: 3 + [1689674049.504533][17222:17224] CHIP:TOO: } + [1689674049.504605][17222:17224] CHIP:EM: <<< [E:22830i S:37151 M:4250114 (Ack:140781365)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674049.504620][17222:17224] CHIP:IN: (S) Sending msg 4250114 on secure session with LSID: 37151 + disabled: true + + - label: "Step 4: TH sends Start command to the DUT" + PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool operationalstate start 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674139.018639][17233:17235] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674139.018658][17233:17235] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674139.018704][17233:17235] CHIP:TOO: OperationalCommandResponse: { + [1689674139.018712][17233:17235] CHIP:TOO: commandResponseState: { + [1689674139.018719][17233:17235] CHIP:TOO: ErrorStateID: 0 + [1689674139.018726][17233:17235] CHIP:TOO: } + [1689674139.018732][17233:17235] CHIP:TOO: } + [1689674139.018755][17233:17235] CHIP:DMG: ICR moving to [AwaitingDe] + [1689674139.018818][17233:17235] CHIP:EM: <<< [E:26021i S:33879 M:235550100 (Ack:58905970)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674139.018837][17233:17235] CHIP:IN: (S) Sending msg 235550100 on secure session with LSID: 33879 + [1689674139.018885][17233:17235] CHIP:EM: Flushed pending ack for MessageCounter:58905970 on exchange 26021i + disabled: true + + - label: "Step 5: TH reads from the DUT the OperationalState attribute" + PICS: OVENOPSTATE.S.A0004 + verification: | + ./chip-tool operationalstate read operational-state 1 1 + + Via the TH (chip-tool), verify: + - the response has an OperationalStateID field that is set to 0x01 (Running) + + [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 + [1689674196.878727][17249:17251] CHIP:DMG: } + [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 + [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { + [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 + [1689674196.878847][17249:17251] CHIP:TOO: } + [1689674196.878914][17249:17251] CHIP:EM: <<< [E:56939i S:28614 M:63040141 (Ack:57012545)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674196.878928][17249:17251] CHIP:IN: (S) Sending msg 63040141 on secure session with LSID: 28614 + disabled: true + + - label: "Step 6: TH reads from the DUT the OperationalError attribute" + PICS: OVENOPSTATE.S.A0005 + verification: | + ./chip-tool operationalstate read operational-error 1 1 + + Via the TH (chip-tool), verify: + - the response contains the ErrorStateId set to NoError(0x00) + + [1689674342.832448][17274:17276] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0005 DataVersion: 2102885775 + [1689674342.832482][17274:17276] CHIP:TOO: OperationalError: { + [1689674342.832500][17274:17276] CHIP:TOO: ErrorStateID: 0 + [1689674342.832509][17274:17276] CHIP:TOO: } + [1689674342.832570][17274:17276] CHIP:EM: <<< [E:37158i S:10451 M:72875113 (Ack:195983315)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674342.832585][17274:17276] CHIP:IN: (S) Sending msg 72875113 on secure session with LSID: 10451 + [1689674342.832614][17274:17276] CHIP:EM: Flushed pending ack for MessageCounter:195983315 on exchange 37158i + disabled: true + + - label: "Step 7: TH reads from the DUT the CountdownTime attribute" + PICS: OVENOPSTATE.S.A0002 + verification: | + ./chip-tool operationalstate read countdown-time 1 1 + + Via the TH (chip-tool), verify: + - that CountdownTime attribute contains either null our a uint32 value + - if non-null, verify that the value is in the range 1 to 259200 + - store the value in 'initialcountdown-time' + + [1689674384.271623][17278:17280] CHIP:DMG: InteractionModelRevision = 1 + [1689674384.271625][17278:17280] CHIP:DMG: } + [1689674384.271649][17278:17280] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 2102885775 + [1689674384.271662][17278:17280] CHIP:TOO: CountdownTime: null + [1689674384.271683][17278:17280] CHIP:EM: <<< [E:24665i S:47371 M:757241 (Ack:152992659)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674384.271687][17278:17280] CHIP:IN: (S) Sending msg 757241 on secure session with LSID: 47371 + [1689674384.271696][17278:17280] CHIP:EM: Flushed pending ack for MessageCounter:152992659 on exchange 24665i + disabled: true + + - label: "Step 8: TH reads from the DUT the PhaseList attribute" + PICS: OVENOPSTATE.S.A0000 + verification: | + ./chip-tool operationalstate read phase-list 1 1 + + Via the TH (chip-tool), verify: + - that PhaseList attribute value contains either null or a list of strings. + + If not null, receord the number of entries in the list as 'phase-list-size'; execute step 7. + If null, go to step 8. + + [1689674447.761859][17290:17292] CHIP:DMG: InteractionModelRevision = 1 + [1689674447.761865][17290:17292] CHIP:DMG: } + [1689674447.761938][17290:17292] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0000 DataVersion: 2102885775 + [1689674447.761972][17290:17292] CHIP:TOO: PhaseList: null + [1689674447.762041][17290:17292] CHIP:EM: <<< [E:58737i S:13847 M:251354926 (Ack:137738036)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674447.762055][17290:17292] CHIP:IN: (S) Sending msg 251354926 on secure session with LSID: 13847 + [1689674447.762109][17290:17292] CHIP:EM: Flushed pending ack for MessageCounter:137738036 on exchange 58737i + disabled: true + + - label: "Step 9: TH reads from the DUT the CurrentPhase attribute" + PICS: OVENOPSTATE.S.A0001 + verification: | + ./chip-tool operationalstate read current-phase 1 1 + + Via the TH (chip-tool), verify: + - that the CurrentPhase attribute value contains contains a uint8 value + - that the value is between 0 and 'phase-list-size - 1'. + + [1689674497.950563][17299:17301] CHIP:DMG: } + [1689674497.950635][17299:17301] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0001 DataVersion: 2102885775 + [1689674497.950664][17299:17301] CHIP:TOO: CurrentPhase: null + [1689674497.950737][17299:17301] CHIP:EM: <<< [E:64019i S:52010 M:245677798 (Ack:138696372)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674497.950752][17299:17301] CHIP:IN: (S) Sending msg 245677798 on secure session with LSID: 52010 + [1689674497.950798][17299:17301] CHIP:EM: Flushed pending ack for MessageCounter:138696372 on exchange 64019i + [1689674497.950899][17299:17299] CHIP:CTL: Shutting down the commissioner + disabled: true + + - label: + "Step 10: TH waits for a vendor defined wait time, this being a period + of time less than the expected duration of the operation that has been + started" + verification: | + TH waits for a vendor defined wait time, this being a period of time less than the expected duration of the operation that has been started + disabled: true + + - label: "Step 11: TH reads from the DUT the CountdownTime attribute" + PICS: OVENOPSTATE.S.A0002 + verification: | + ./chip-tool operationalstate read countdown-time 1 1 + + + Via the TH (chip-tool), verify: + - that CountdownTime attribute contains either null our a uint32 value + - if non-null, verify that the value is in the range 1 to 259200 + - that the value is approximately 'initialcountdown-time minus the vendor defined wait time' + + + [1689674623.673661][17320:17322] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 2102885775 + [1689674623.673697][17320:17322] CHIP:TOO: CountdownTime: null + [1689674623.673755][17320:17322] CHIP:EM: <<< [E:42152i S:37580 M:19654175 (Ack:176515710)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674623.673768][17320:17322] CHIP:IN: (S) Sending msg 19654175 on secure session with LSID: 37580 + [1689674623.673795][17320:17322] CHIP:EM: Flushed pending ack for MessageCounter:176515710 on exchange 42152i + disabled: true + + - label: "Step 12: TH sends Start command to the DUT" + PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool operationalstate start 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674637.555734][17326:17328] CHIP:DMG: + [1689674637.555742][17326:17328] CHIP:DMG: InteractionModelRevision = 1 + [1689674637.555751][17326:17328] CHIP:DMG: }, + [1689674637.555784][17326:17328] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674637.555805][17326:17328] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674637.555853][17326:17328] CHIP:TOO: OperationalCommandResponse: { + [1689674637.555862][17326:17328] CHIP:TOO: commandResponseState: { + [1689674637.555872][17326:17328] CHIP:TOO: ErrorStateID: 0 + [1689674637.555883][17326:17328] CHIP:TOO: } + [1689674637.555891][17326:17328] CHIP:TOO: } + [1689674637.555913][17326:17328] CHIP:DMG: ICR moving to [AwaitingDe] + [1689674637.555956][17326:17328] CHIP:EM: <<< [E:28742i S:49023 M:139320570 (Ack:91983883)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674637.555971][17326:17328] CHIP:IN: (S) Sending msg 139320570 on secure session with LSID: 49023 + [1689674637.556001][17326:17328] CHIP:EM: Flushed pending ack for MessageCounter:91983883 on exchange 28742i + disabled: true + + - label: "Step 13: TH sends Stop command to the DUT" + PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool operationalstate stop 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674653.322963][17330:17332] CHIP:DMG: }, + [1689674653.322994][17330:17332] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674653.323014][17330:17332] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674653.323058][17330:17332] CHIP:TOO: OperationalCommandResponse: { + [1689674653.323066][17330:17332] CHIP:TOO: commandResponseState: { + [1689674653.323076][17330:17332] CHIP:TOO: ErrorStateID: 0 + [1689674653.323085][17330:17332] CHIP:TOO: } + [1689674653.323094][17330:17332] CHIP:TOO: } + [1689674653.323113][17330:17332] CHIP:DMG: ICR moving to [AwaitingDe] + [1689674653.323154][17330:17332] CHIP:EM: <<< [E:62878i S:64455 M:173921517 (Ack:216732582)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674653.323168][17330:17332] CHIP:IN: (S) Sending msg 173921517 on secure session with LSID: 64455 + [1689674653.323195][17330:17332] CHIP:EM: Flushed pending ack for MessageCounter:216732582 on exchange 62878i + [1689674653.323284][17330:17330] CHIP:CTL: Shutting down the commissioner + disabled: true + + - label: "Step 14: TH reads from the DUT the OperationalState attribute" + PICS: OVENOPSTATE.S.A0004 + verification: | + ./chip-tool operationalstate read operational-state 1 1 + + Via the TH (chip-tool), verify: + - the response has an OperationalStateID field that is set to 0x00 (Stopped) + + [1689674675.459656][17333:17335] CHIP:DMG: } + [1689674675.459738][17333:17335] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 + [1689674675.459772][17333:17335] CHIP:TOO: OperationalState: { + [1689674675.459790][17333:17335] CHIP:TOO: OperationalStateID: 0 + [1689674675.459799][17333:17335] CHIP:TOO: } + [1689674675.459869][17333:17335] CHIP:EM: <<< [E:17771i S:16165 M:1572532 (Ack:102448631)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674675.459886][17333:17335] CHIP:IN: (S) Sending msg 1572532 on secure session with LSID: 16165 + [1689674675.459930][17333:17335] CHIP:EM: Flushed pending ack for MessageCounter:102448631 on exchange 17771i + disabled: true + + - label: "Step 15: TH sends Stop command to the DUT" + PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool operationalstate stop 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674689.588712][17337:17339] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674689.588722][17337:17339] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674689.588745][17337:17339] CHIP:TOO: OperationalCommandResponse: { + [1689674689.588749][17337:17339] CHIP:TOO: commandResponseState: { + [1689674689.588757][17337:17339] CHIP:TOO: ErrorStateID: 0 + [1689674689.588762][17337:17339] CHIP:TOO: } + [1689674689.588765][17337:17339] CHIP:TOO: } + [1689674689.588775][17337:17339] CHIP:DMG: ICR moving to [AwaitingDe] + [1689674689.588802][17337:17339] CHIP:EM: <<< [E:63921i S:35027 M:16881995 (Ack:220265764)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674689.588810][17337:17339] CHIP:IN: (S) Sending msg 16881995 on secure session with LSID: 35027 + disabled: true + + - label: + "Step 16: Manually put the DUT into a state wherein it cannot receive + a Start Command" + PICS: OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME + verification: | + Manually put the DUT into a state wherein it cannot receive a Start Command + disabled: true + + - label: "Step 17: TH sends Start command to the DUT" + PICS: + OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp + && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool operationalstate start 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x01 (UnableToStartOrResume) + + [1689674700.385183][17340:17342] CHIP:DMG: }, + [1689674700.385214][17340:17342] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674700.385233][17340:17342] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674700.385266][17340:17342] CHIP:TOO: OperationalCommandResponse: { + [1689674700.385274][17340:17342] CHIP:TOO: commandResponseState: { + [1689674700.385281][17340:17342] CHIP:TOO: ErrorStateID: 1 + [1689674700.385289][17340:17342] CHIP:TOO: } + [1689674700.385295][17340:17342] CHIP:TOO: } + [1689674700.385311][17340:17342] CHIP:DMG: ICR moving to [AwaitingDe] + [1689674700.385361][17340:17342] CHIP:EM: <<< [E:55029i S:46795 M:80501191 (Ack:176711722)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674700.385375][17340:17342] CHIP:IN: (S) Sending msg 80501191 on secure session with LSID: 46795 + [1689674700.385419][17340:17342] CHIP:EM: Flushed pending ack for MessageCounter:176711722 on exchange 55029i + disabled: true diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml new file mode 100644 index 00000000000000..cd17ebe10cc468 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml @@ -0,0 +1,94 @@ +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: 202.2.4. [TC-OVENOPSTATE-2.4] Mandatory Events with DUT as Server + +PICS: + - OVENOPSTATE.S + +config: + nodeId: 0x12344321 + cluster: "Oven Operational State" + endpoint: 1 + +tests: + - label: "Step 1: Commission DUT to TH" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "Step 2: Set up a subscription to the OperationalError event" + PICS: OVENOPSTATE.S.E00 + command: "subscribeEvent" + event: "OperationalError" + minInterval: 10 + maxInterval: 5000 + + - label: + "Step 3: At the DUT take the vendor defined action to generate an + OperationalError event" + PICS: OVENOPSTATE.S.E00 && PICS_SKIP_SAMPLE_APP + verification: | + After the subscription interval via the TH (chip-tool) verify: + - reception of an OperationalError Event + - ErrorStateID is a defined error + - If the ErrorStateID is manufacturer specific, inclusion of an ErrorStateLabel, not present otherwise + - Optionally an ErrorStateDetails + + NOTE : There's a PIXIT value controlling the ability to execute that ({PIXIT_ERROREVENTGEN}), which as the test case notes, requires vendor specific actions to generated the error at the DUT. This is dependent on the vendor app supporting this. The SDK as it stands won't provide the error, this may be testable by some of the vendors depending on their implementations. + + + [1692859386.707176][6658:6660] CHIP:EM: Rxd Ack; Removing MessageCounter:212756536 from Retrans Table on exchange 36888i + [1692859386.707295][6658:6660] CHIP:DMG: ReportDataMessage = + [1692859386.707360][6658:6660] CHIP:DMG: { + [1692859386.707416][6658:6660] CHIP:DMG: SubscriptionId = 0x97bb846c, + [1692859386.707477][6658:6660] CHIP:DMG: InteractionModelRevision = 10 + [1692859386.707533][6658:6660] CHIP:DMG: } + [1692859386.707621][6658:6660] CHIP:DMG: MoveToState ReadClient[0xffff80011a90]: Moving to [AwaitingSu] + [1692859386.707815][6658:6660] CHIP:EM: <<< [E:36888i S:54523 M:212756537 (Ack:12760634)] (S) Msg TX to 1:0000000000000001 [853D] --- Type 0001:01 (IM:StatusResponse) + [1692859386.707901][6658:6660] CHIP:IN: (S) Sending msg 212756537 on secure session with LSID: 54523 + [1692859386.708167][6658:6660] CHIP:DL: HandlePlatformSpecificBLEEvent 32793 + [1692859386.708237][6658:6660] CHIP:DL: HandlePlatformSpecificBLEEvent 32793 + [1692859386.749217][6658:6660] CHIP:EM: >>> [E:36888i S:54523 M:12760635 (Ack:212756537)] (S) Msg RX from 1:0000000000000001 [853D] --- Type 0001:04 (IM:SubscribeResponse) + [1692859386.749285][6658:6660] CHIP:EM: Found matching exchange: 36888i, Delegate: 0xffff80011aa0 + [1692859386.749350][6658:6660] CHIP:EM: Rxd Ack; Removing MessageCounter:212756537 from Retrans Table on exchange 36888i + [1692859386.749417][6658:6660] CHIP:DMG: SubscribeResponse is received + [1692859386.749489][6658:6660] CHIP:DMG: SubscribeResponseMessage = + [1692859386.749538][6658:6660] CHIP:DMG: { + [1692859386.749584][6658:6660] CHIP:DMG: SubscriptionId = 0x97bb846c, + [1692859386.749637][6658:6660] CHIP:DMG: MaxInterval = 0x6, + [1692859386.749687][6658:6660] CHIP:DMG: InteractionModelRevision = 10 + [1692859386.749734][6658:6660] CHIP:DMG: } + [1692859386.749787][6658:6660] CHIP:DMG: Subscription established with SubscriptionID = 0x97bb846c MinInterval = 5s MaxInterval = 6s Peer = 01:0000000000000001 + [1692859386.749843][6658:6660] CHIP:DMG: MoveToState ReadClient[0xffff80011a90]: Moving to [Subscripti] + cluster: "LogCommands" + command: "UserPrompt" + arguments: + values: + - name: "message" + value: "Enter 'y' after success" + - name: "expectedValue" + value: "y" + + - label: "Step 4: TH reads from the DUT the OperationalState attribute" + PICS: OVENOPSTATE.S.A0004 && PICS_SKIP_SAMPLE_APP + command: "readAttribute" + attribute: "OperationalState" + response: + value: 0x03 + constraints: + type: enum8 \ No newline at end of file diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 77167aa6f46673..0b044b0c684ee1 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -1798,6 +1798,39 @@ OPSTATE.S.C04.Tx=1 OPSTATE.S.E00=1 OPSTATE.S.E01=1 + +# Oven Operational State + +OVENOPSTATE.S=1 +OVENOPSTATE.C=1 +#ManuallyControlled + +OVENOPSTATE.S.M.ST_STOPPED=1 +OVENOPSTATE.S.M.ST_RUNNING=1 +OVENOPSTATE.S.M.ST_PAUSED=1 +OVENOPSTATE.S.M.ST_ERROR=1 +OVENOPSTATE.S.M.ERR_NO_ERROR=1 +OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME=1 +OVENOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION=1 +OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE=1 + +# Server Attributes +OVENOPSTATE.S.A0000=1 +OVENOPSTATE.S.A0001=1 +OVENOPSTATE.S.A0002=1 +OVENOPSTATE.S.A0003=1 +OVENOPSTATE.S.A0004=1 +OVENOPSTATE.S.A0005=1 +OVENOPSTATE.S.C00.Rsp=1 +OVENOPSTATE.S.C01.Rsp=1 +OVENOPSTATE.S.C02.Rsp=1 +OVENOPSTATE.S.C03.Rsp=1 +OVENOPSTATE.S.C04.Tx=1 + +# Server Events +OVENOPSTATE.S.E00=1 +OVENOPSTATE.S.E01=1 + # Thermostat # Server TSTAT.S=1 diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 36b2bea234b102..0b70969249b73c 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -164,7 +164,7 @@ "Test_TC_OO_2_4" ], "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], - "OvenOperationalState": ["Test_TC_OVENOPSTATE_1_1"], + "OvenOperationalState": ["Test_TC_OVENOPSTATE_1_1","Test_TC_OVENOPSTATE_2_4"], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], "PressureMeasurement": [ "Test_TC_PRS_1_1", diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index 74e1d33ba99fdd..df7a51c20b1242 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -265,6 +265,7 @@ ], "OnOff": ["Test_TC_OO_2_3"], "OperationalState": ["Test_TC_OPSTATE_2_2"], + "OvenOperationalState": ["Test_TC_OVENOPSTATE_2_2","Test_TC_OVENOPSTATE_2_4"], "RelativeHumidityMeasurement": ["Test_TC_RH_2_2"], "SmokeCOAlarm": [], "RefrigeratorAlarm": ["Test_TC_REFALM_2_2", "Test_TC_REFALM_2_3"], @@ -337,6 +338,7 @@ "LaundryWasherMode", "OnOff", "OperationalState", + "OvenOperationalState", "RelativeHumidityMeasurement", "SmokeCOAlarm", "RefrigeratorAlarm", diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index 0846bbdb5d18d5..97bcfea3c421c7 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -50,7 +50,7 @@ async def read_and_validate_operror(self, step, expected_error): "errorStateID(%s) should equal %s" % (operational_error.errorStateID, expected_error)) @async_test_body - async def test_TC_OPSTATE_2_1(self): + async def test_TC_OVENOPSTATE_2_1(self): asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, "PIXIT_ENDPOINT must be included on the command line in " @@ -62,7 +62,7 @@ async def test_TC_OPSTATE_2_1(self): self.print_step(1, "Commissioning, already done") - if self.check_pics("OPSTATE.S.A0000"): + if self.check_pics("OVENOPSTATE.S.A0000"): self.print_step(2, "Read PhaseList attribute") phase_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.PhaseList) @@ -76,7 +76,7 @@ async def test_TC_OPSTATE_2_1(self): asserts.assert_less_equal(phase_list_len, 32, "PhaseList length(%d) must be less than 32!" % phase_list_len) - if self.check_pics("OPSTATE.S.A0001"): + if self.check_pics("OVENOPSTATE.S.A0001"): self.print_step(3, "Read CurrentPhase attribute") current_phase = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentPhase) logging.info("CurrentPhase: %s" % (current_phase)) @@ -87,7 +87,7 @@ async def test_TC_OPSTATE_2_1(self): asserts.assert_true(0 <= current_phase and current_phase < phase_list_len, "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) - if self.check_pics("OPSTATE.S.A0002"): + if self.check_pics("OVENOPSTATE.S.A0002"): self.print_step(4, "Read CountdownTime attribute") countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CountdownTime) @@ -97,7 +97,7 @@ async def test_TC_OPSTATE_2_1(self): asserts.assert_true(0 <= countdown_time <= 259200, "CountdownTime(%s) must be between 0 and 259200" % countdown_time) - if self.check_pics("OPSTATE.S.A0003"): + if self.check_pics("OVENOPSTATE.S.A0003"): self.print_step(5, "Read OperationalStateList attribute") operational_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.OperationalStateList) @@ -119,7 +119,7 @@ async def test_TC_OPSTATE_2_1(self): asserts.assert_true(error_state_present, "The OperationalStateList does not have an ID entry of Error(0x03)") - if self.check_pics("OPSTATE.S.A0004"): + if self.check_pics("OVENOPSTATE.S.A0004"): self.print_step(6, "Read OperationalState attribute") operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.OperationalState) @@ -129,40 +129,24 @@ async def test_TC_OPSTATE_2_1(self): in_range = (0x80 <= operational_state <= 0xBF) asserts.assert_true(operational_state in defined_states or in_range, "OperationalState has an invalid ID value!") - if self.check_pics("OPSTATE.S.M.ST_STOPPED"): + if self.check_pics("OVENOPSTATE.S.M.ST_STOPPED"): self.print_step("6a", "Manually put the device in the stopped state") input("Press Enter when done.\n") await self.read_and_validate_opstate(step="6b", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kStopped) - if self.check_pics("OPSTATE.S.M.ST_RUNNING"): + if self.check_pics("OVENOPSTATE.S.M.ST_RUNNING"): self.print_step("6c", "Manually put the device in the running state") input("Press Enter when done.\n") await self.read_and_validate_opstate(step="6d", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kRunning) - if self.check_pics("OPSTATE.S.M.ST_PAUSED"): + if self.check_pics("OVENOPSTATE.S.M.ST_PAUSED"): self.print_step("6e", "Manually put the device in the paused state") input("Press Enter when done.\n") await self.read_and_validate_opstate(step="6f", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kPaused) - if self.check_pics("OPSTATE.S.M.ST_ERROR"): + if self.check_pics("OVENOPSTATE.S.M.ST_ERROR"): self.print_step("6g", "Manually put the device in the error state") input("Press Enter when done.\n") await self.read_and_validate_opstate(step="6h", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kError) - if self.check_pics("OPSTATE.S.M.ST_PREHEATING"): - self.print_step("6i", "Manually put the device in the preheating state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6j", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kPreheating) - if self.check_pics("OPSTATE.S.M.ST_PREHEATED"): - self.print_step("6k", "Manually put the device in the preheated state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6l", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kPreheated) - if self.check_pics("OPSTATE.S.M.ST_COOLINGDOWN"): - self.print_step("6m", "Manually put the device in the coolingdown state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6n", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kCoolingDown) - if self.check_pics("OPSTATE.S.M.ST_SELFCLEANING"): - self.print_step("6o", "Manually put the device in the selfclean state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6p", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kSelfCleaning) - if self.check_pics("OPSTATE.S.A0005"): + if self.check_pics("OVENOPSTATE.S.A0005"): self.print_step(7, "Read OperationalError attribute") operational_error = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.OperationalError) @@ -179,19 +163,19 @@ async def test_TC_OPSTATE_2_1(self): if in_range: asserts.assert_true(operational_error.errorStateLabel is not None, "ErrorStateLabel should be populated") - if self.check_pics("OPSTATE.S.M.ERR_NO_ERROR"): + if self.check_pics("OVENOPSTATE.S.M.ERR_NO_ERROR"): self.print_step("7a", "Manually put the device in the no error state") input("Press Enter when done.\n") await self.read_and_validate_operror(step="7b", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kNoError) - if self.check_pics("OPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME"): + if self.check_pics("OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME"): self.print_step("7c", "Manually put the device in the unable to start or resume error state") input("Press Enter when done.\n") await self.read_and_validate_operror(step="7d", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kUnableToStartOrResume) - if self.check_pics("OPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION"): + if self.check_pics("OVENOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION"): self.print_step("7e", "Manually put the device in the unable to complete operation error state") input("Press Enter when done.\n") await self.read_and_validate_operror(step="7f", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kUnableToCompleteOperation) - if self.check_pics("OPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE"): + if self.check_pics("OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE"): self.print_step("7g", "Manually put the device in the command invalid error state") input("Press Enter when done.\n") await self.read_and_validate_operror(step="7h", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState) diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py index 4898b3cc662664..c1aac443d37c30 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_3.py +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -47,7 +47,7 @@ async def send_resume_cmd(self) -> Clusters.Objects.OperationalState.Commands.Re return ret @async_test_body - async def test_TC_OPSTATE_2_3(self): + async def test_TC_OVENOPSTATE_2_3(self): asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, "PIXIT_ENDPOINT must be included on the command line in " @@ -55,10 +55,10 @@ async def test_TC_OPSTATE_2_3(self): self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] - asserts.assert_true(self.check_pics("OPSTATE.S.A0003"), "OPSTATE.S.A0003 must be supported") - asserts.assert_true(self.check_pics("OPSTATE.S.A0004"), "OPSTATE.S.A0004 must be supported") - asserts.assert_true(self.check_pics("OPSTATE.S.C00.Rsp"), "OPSTATE.S.C00.Rsp must be supported") - asserts.assert_true(self.check_pics("OPSTATE.S.C03.Rsp"), "OPSTATE.S.C03.Rsp must be supported") + asserts.assert_true(self.check_pics("OVENOPSTATE.S.A0003"), "OVENOPSTATE.S.A0003 must be supported") + asserts.assert_true(self.check_pics("OVENOPSTATE.S.A0004"), "OVENOPSTATE.S.A0004 must be supported") + asserts.assert_true(self.check_pics("OVENOPSTATE.S.C00.Rsp"), "OVENOPSTATE.S.C00.Rsp must be supported") + asserts.assert_true(self.check_pics("OVENOPSTATE.S.C03.Rsp"), "OVENOPSTATE.S.C03.Rsp must be supported") attributes = Clusters.OperationalState.Attributes @@ -92,7 +92,7 @@ async def test_TC_OPSTATE_2_3(self): asserts.assert_equal(operational_state, Clusters.OperationalState.Enums.OperationalStateEnum.kPaused, "OperationalState ID should be Paused(0x02)") - if self.check_pics("OPSTATE.S.A0002"): + if self.check_pics("OVENOPSTATE.S.A0002"): self.print_step(6, "Read CountdownTime attribute") initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CountdownTime) From 14f10b4be1434d377660d9347452e15371c9c182 Mon Sep 17 00:00:00 2001 From: Prakash Ravi <68609205+prakashece@users.noreply.github.com> Date: Mon, 18 Dec 2023 14:25:03 -0500 Subject: [PATCH 07/89] Delete src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml --- .../certification/Test_TC_OVENOPSTATE_1_1.yml | 155 ------------------ 1 file changed, 155 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml deleted file mode 100644 index e5a86eed5f525a..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yml +++ /dev/null @@ -1,155 +0,0 @@ -# Copyright (c) 2021 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: 3.1.1. [TC-OVENOPSTATE-1.1] Global attributes with server as DUT -PICS: - - OVENOPSTATE.S - -config: - nodeId: 0x12344321 - cluster: "Oven Operational State" - endpoint: 1 - -tests: - - label: "Step 1: Wait for the commissioned device to be retrieved" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Step 2: TH reads the ClusterRevision attribute from the DUT" - command: "readAttribute" - attribute: "ClusterRevision" - response: - value: 1 - constraints: - type: int16u - - - label: "Step 3: TH reads the FeatureMap attribute from the DUT" - command: "readAttribute" - attribute: "FeatureMap" - response: - value: 0 - constraints: - type: bitmap32 - - - label: "Step 4a: TH reads the AttributeList attribute from the DUT" - PICS: PICS_EVENT_LIST_ENABLED - command: "readAttribute" - attribute: "AttributeList" - response: - constraints: - type: list - contains: - [0, 1, 3, 4, 5, 65528, 65529, 65530, 65531, 65532, 65533] - - - label: "Step 4a: TH reads the AttributeList attribute from the DUT" - PICS: "!PICS_EVENT_LIST_ENABLED" - command: "readAttribute" - attribute: "AttributeList" - response: - constraints: - type: list - contains: [0, 1, 3, 4, 5, 65528, 65529, 65531, 65532, 65533] - - - label: - "Step 4b: TH reads from the DUT the optional attribute(CountdownTime) - in the AttributeList from the DUT" - PICS: OVENOPSTATE.S.A0002 - command: "readAttribute" - attribute: "AttributeList" - response: - constraints: - type: list - contains: [2] - - - label: "Step 5a: TH reads from the DUT the EventList attribute." - PICS: PICS_EVENT_LIST_ENABLED - command: "readAttribute" - attribute: "EventList" - response: - constraints: - type: list - contains: [0x00] - - - label: - "Step 5b: TH reads from the DUT the optional - event(OperationCompletion) in EventList." - PICS: PICS_EVENT_LIST_ENABLED && OVENOPSTATE.S.E01 - command: "readAttribute" - attribute: "EventList" - response: - constraints: - type: list - contains: [0x01] - - - label: "Step 6a: Read the optional command(Start) in AcceptedCommandList" - PICS: OVENOPSTATE.S.C02.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [1, 2] - - - label: "Step 6b: Read the optional command(Stop) in AcceptedCommandList" - PICS: OVENOPSTATE.S.C01.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [1] - - - label: "Step 6c: Read the optional command(Pause) in AcceptedCommandList" - PICS: OVENOPSTATE.S.C00.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [0, 3] - - - label: "Step 6d: Read the optional command(Resume) in AcceptedCommandList" - PICS: OVENOPSTATE.S.C03.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [0, 3] - - - label: "Step 7: Read the global attribute: GeneratedCommandList" - PICS: - "!OPSTATE.S.C00.Rsp && !OPSTATE.S.C01.Rsp && !OPSTATE.S.C02.Rsp && - !OPSTATE.S.C03.Rsp" - command: "readAttribute" - attribute: "GeneratedCommandList" - response: - value: [] - constraints: - type: list - - - label: "Step 7: Read the global attribute: GeneratedCommandList" - PICS: - (OPSTATE.S.C00.Rsp || OPSTATE.S.C01.Rsp || OPSTATE.S.C02.Rsp || - OPSTATE.S.C03.Rsp) - command: "readAttribute" - attribute: "GeneratedCommandList" - response: - constraints: - type: list - contains: [4] From 5f8d6f73f9440c2166518feca2b441609e5a62a8 Mon Sep 17 00:00:00 2001 From: Prakash Ravi <68609205+prakashece@users.noreply.github.com> Date: Mon, 18 Dec 2023 14:25:28 -0500 Subject: [PATCH 08/89] Delete src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml --- .../certification/Test_TC_OVENOPSTATE_2_2.yml | 335 ------------------ 1 file changed, 335 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml deleted file mode 100644 index 4e723deb9f08a4..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yml +++ /dev/null @@ -1,335 +0,0 @@ -# Copyright (c) 2023 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default - -name: 3.2.2. [TC-OVENOPSTATE-2.2] Start and Stop commands with DUT as Server - -PICS: - - OVENOPSTATE.S - -config: - nodeId: 0x12344321 - cluster: "Basic Information" - endpoint: 0 - -tests: - - label: "Note" - verification: | - This is a simulated example log for instructional purposes only. In real scenarios, the actual log may vary depending on the feature implementation in Reference App. - disabled: true - - - label: - "Step 1: Commission DUT to TH (can be skipped if done in a preceding - test)" - verification: | - OVENOPSTATE.S.C01 && OVENOPSTATE.S.C02 - disabled: true - - - label: - "Step 2: Manually put the DUT into a state wherein it can receive a - Start Command" - verification: | - Manually put the DUT into a state wherein it can receive a Start Command - disabled: true - - - label: "Step 3: TH reads from the DUT the OperationalStateList attribute" - PICS: OVENOPSTATE.S.A0003 - verification: | - ./chip-tool operationalstate read operational-state-list 1 1 - - Via the TH (chip-tool), verify: - - all entries include an ID (enum8) and a label (string) - - all provided IDs are in the allowed range - - the list includes IDs for Error (0x03), Running (0x01), and Stopped (0x00) - - [1689674049.504261][17222:17224] CHIP:DMG: } - [1689674049.504390][17222:17224] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0003 DataVersion: 2102885775 - [1689674049.504440][17222:17224] CHIP:TOO: OperationalStateList: 4 entries - [1689674049.504462][17222:17224] CHIP:TOO: [1]: { - [1689674049.504469][17222:17224] CHIP:TOO: OperationalStateID: 0 - [1689674049.504476][17222:17224] CHIP:TOO: } - [1689674049.504484][17222:17224] CHIP:TOO: [2]: { - [1689674049.504490][17222:17224] CHIP:TOO: OperationalStateID: 1 - [1689674049.504495][17222:17224] CHIP:TOO: } - [1689674049.504503][17222:17224] CHIP:TOO: [3]: { - [1689674049.504508][17222:17224] CHIP:TOO: OperationalStateID: 2 - [1689674049.504514][17222:17224] CHIP:TOO: } - [1689674049.504521][17222:17224] CHIP:TOO: [4]: { - [1689674049.504527][17222:17224] CHIP:TOO: OperationalStateID: 3 - [1689674049.504533][17222:17224] CHIP:TOO: } - [1689674049.504605][17222:17224] CHIP:EM: <<< [E:22830i S:37151 M:4250114 (Ack:140781365)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674049.504620][17222:17224] CHIP:IN: (S) Sending msg 4250114 on secure session with LSID: 37151 - disabled: true - - - label: "Step 4: TH sends Start command to the DUT" - PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674139.018639][17233:17235] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674139.018658][17233:17235] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674139.018704][17233:17235] CHIP:TOO: OperationalCommandResponse: { - [1689674139.018712][17233:17235] CHIP:TOO: commandResponseState: { - [1689674139.018719][17233:17235] CHIP:TOO: ErrorStateID: 0 - [1689674139.018726][17233:17235] CHIP:TOO: } - [1689674139.018732][17233:17235] CHIP:TOO: } - [1689674139.018755][17233:17235] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674139.018818][17233:17235] CHIP:EM: <<< [E:26021i S:33879 M:235550100 (Ack:58905970)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674139.018837][17233:17235] CHIP:IN: (S) Sending msg 235550100 on secure session with LSID: 33879 - [1689674139.018885][17233:17235] CHIP:EM: Flushed pending ack for MessageCounter:58905970 on exchange 26021i - disabled: true - - - label: "Step 5: TH reads from the DUT the OperationalState attribute" - PICS: OVENOPSTATE.S.A0004 - verification: | - ./chip-tool operationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x01 (Running) - - [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 - [1689674196.878727][17249:17251] CHIP:DMG: } - [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { - [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 - [1689674196.878847][17249:17251] CHIP:TOO: } - [1689674196.878914][17249:17251] CHIP:EM: <<< [E:56939i S:28614 M:63040141 (Ack:57012545)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674196.878928][17249:17251] CHIP:IN: (S) Sending msg 63040141 on secure session with LSID: 28614 - disabled: true - - - label: "Step 6: TH reads from the DUT the OperationalError attribute" - PICS: OVENOPSTATE.S.A0005 - verification: | - ./chip-tool operationalstate read operational-error 1 1 - - Via the TH (chip-tool), verify: - - the response contains the ErrorStateId set to NoError(0x00) - - [1689674342.832448][17274:17276] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0005 DataVersion: 2102885775 - [1689674342.832482][17274:17276] CHIP:TOO: OperationalError: { - [1689674342.832500][17274:17276] CHIP:TOO: ErrorStateID: 0 - [1689674342.832509][17274:17276] CHIP:TOO: } - [1689674342.832570][17274:17276] CHIP:EM: <<< [E:37158i S:10451 M:72875113 (Ack:195983315)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674342.832585][17274:17276] CHIP:IN: (S) Sending msg 72875113 on secure session with LSID: 10451 - [1689674342.832614][17274:17276] CHIP:EM: Flushed pending ack for MessageCounter:195983315 on exchange 37158i - disabled: true - - - label: "Step 7: TH reads from the DUT the CountdownTime attribute" - PICS: OVENOPSTATE.S.A0002 - verification: | - ./chip-tool operationalstate read countdown-time 1 1 - - Via the TH (chip-tool), verify: - - that CountdownTime attribute contains either null our a uint32 value - - if non-null, verify that the value is in the range 1 to 259200 - - store the value in 'initialcountdown-time' - - [1689674384.271623][17278:17280] CHIP:DMG: InteractionModelRevision = 1 - [1689674384.271625][17278:17280] CHIP:DMG: } - [1689674384.271649][17278:17280] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 2102885775 - [1689674384.271662][17278:17280] CHIP:TOO: CountdownTime: null - [1689674384.271683][17278:17280] CHIP:EM: <<< [E:24665i S:47371 M:757241 (Ack:152992659)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674384.271687][17278:17280] CHIP:IN: (S) Sending msg 757241 on secure session with LSID: 47371 - [1689674384.271696][17278:17280] CHIP:EM: Flushed pending ack for MessageCounter:152992659 on exchange 24665i - disabled: true - - - label: "Step 8: TH reads from the DUT the PhaseList attribute" - PICS: OVENOPSTATE.S.A0000 - verification: | - ./chip-tool operationalstate read phase-list 1 1 - - Via the TH (chip-tool), verify: - - that PhaseList attribute value contains either null or a list of strings. - - If not null, receord the number of entries in the list as 'phase-list-size'; execute step 7. - If null, go to step 8. - - [1689674447.761859][17290:17292] CHIP:DMG: InteractionModelRevision = 1 - [1689674447.761865][17290:17292] CHIP:DMG: } - [1689674447.761938][17290:17292] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0000 DataVersion: 2102885775 - [1689674447.761972][17290:17292] CHIP:TOO: PhaseList: null - [1689674447.762041][17290:17292] CHIP:EM: <<< [E:58737i S:13847 M:251354926 (Ack:137738036)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674447.762055][17290:17292] CHIP:IN: (S) Sending msg 251354926 on secure session with LSID: 13847 - [1689674447.762109][17290:17292] CHIP:EM: Flushed pending ack for MessageCounter:137738036 on exchange 58737i - disabled: true - - - label: "Step 9: TH reads from the DUT the CurrentPhase attribute" - PICS: OVENOPSTATE.S.A0001 - verification: | - ./chip-tool operationalstate read current-phase 1 1 - - Via the TH (chip-tool), verify: - - that the CurrentPhase attribute value contains contains a uint8 value - - that the value is between 0 and 'phase-list-size - 1'. - - [1689674497.950563][17299:17301] CHIP:DMG: } - [1689674497.950635][17299:17301] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0001 DataVersion: 2102885775 - [1689674497.950664][17299:17301] CHIP:TOO: CurrentPhase: null - [1689674497.950737][17299:17301] CHIP:EM: <<< [E:64019i S:52010 M:245677798 (Ack:138696372)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674497.950752][17299:17301] CHIP:IN: (S) Sending msg 245677798 on secure session with LSID: 52010 - [1689674497.950798][17299:17301] CHIP:EM: Flushed pending ack for MessageCounter:138696372 on exchange 64019i - [1689674497.950899][17299:17299] CHIP:CTL: Shutting down the commissioner - disabled: true - - - label: - "Step 10: TH waits for a vendor defined wait time, this being a period - of time less than the expected duration of the operation that has been - started" - verification: | - TH waits for a vendor defined wait time, this being a period of time less than the expected duration of the operation that has been started - disabled: true - - - label: "Step 11: TH reads from the DUT the CountdownTime attribute" - PICS: OVENOPSTATE.S.A0002 - verification: | - ./chip-tool operationalstate read countdown-time 1 1 - - - Via the TH (chip-tool), verify: - - that CountdownTime attribute contains either null our a uint32 value - - if non-null, verify that the value is in the range 1 to 259200 - - that the value is approximately 'initialcountdown-time minus the vendor defined wait time' - - - [1689674623.673661][17320:17322] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 2102885775 - [1689674623.673697][17320:17322] CHIP:TOO: CountdownTime: null - [1689674623.673755][17320:17322] CHIP:EM: <<< [E:42152i S:37580 M:19654175 (Ack:176515710)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674623.673768][17320:17322] CHIP:IN: (S) Sending msg 19654175 on secure session with LSID: 37580 - [1689674623.673795][17320:17322] CHIP:EM: Flushed pending ack for MessageCounter:176515710 on exchange 42152i - disabled: true - - - label: "Step 12: TH sends Start command to the DUT" - PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674637.555734][17326:17328] CHIP:DMG: - [1689674637.555742][17326:17328] CHIP:DMG: InteractionModelRevision = 1 - [1689674637.555751][17326:17328] CHIP:DMG: }, - [1689674637.555784][17326:17328] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674637.555805][17326:17328] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674637.555853][17326:17328] CHIP:TOO: OperationalCommandResponse: { - [1689674637.555862][17326:17328] CHIP:TOO: commandResponseState: { - [1689674637.555872][17326:17328] CHIP:TOO: ErrorStateID: 0 - [1689674637.555883][17326:17328] CHIP:TOO: } - [1689674637.555891][17326:17328] CHIP:TOO: } - [1689674637.555913][17326:17328] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674637.555956][17326:17328] CHIP:EM: <<< [E:28742i S:49023 M:139320570 (Ack:91983883)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674637.555971][17326:17328] CHIP:IN: (S) Sending msg 139320570 on secure session with LSID: 49023 - [1689674637.556001][17326:17328] CHIP:EM: Flushed pending ack for MessageCounter:91983883 on exchange 28742i - disabled: true - - - label: "Step 13: TH sends Stop command to the DUT" - PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate stop 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674653.322963][17330:17332] CHIP:DMG: }, - [1689674653.322994][17330:17332] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674653.323014][17330:17332] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674653.323058][17330:17332] CHIP:TOO: OperationalCommandResponse: { - [1689674653.323066][17330:17332] CHIP:TOO: commandResponseState: { - [1689674653.323076][17330:17332] CHIP:TOO: ErrorStateID: 0 - [1689674653.323085][17330:17332] CHIP:TOO: } - [1689674653.323094][17330:17332] CHIP:TOO: } - [1689674653.323113][17330:17332] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674653.323154][17330:17332] CHIP:EM: <<< [E:62878i S:64455 M:173921517 (Ack:216732582)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674653.323168][17330:17332] CHIP:IN: (S) Sending msg 173921517 on secure session with LSID: 64455 - [1689674653.323195][17330:17332] CHIP:EM: Flushed pending ack for MessageCounter:216732582 on exchange 62878i - [1689674653.323284][17330:17330] CHIP:CTL: Shutting down the commissioner - disabled: true - - - label: "Step 14: TH reads from the DUT the OperationalState attribute" - PICS: OVENOPSTATE.S.A0004 - verification: | - ./chip-tool operationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x00 (Stopped) - - [1689674675.459656][17333:17335] CHIP:DMG: } - [1689674675.459738][17333:17335] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674675.459772][17333:17335] CHIP:TOO: OperationalState: { - [1689674675.459790][17333:17335] CHIP:TOO: OperationalStateID: 0 - [1689674675.459799][17333:17335] CHIP:TOO: } - [1689674675.459869][17333:17335] CHIP:EM: <<< [E:17771i S:16165 M:1572532 (Ack:102448631)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674675.459886][17333:17335] CHIP:IN: (S) Sending msg 1572532 on secure session with LSID: 16165 - [1689674675.459930][17333:17335] CHIP:EM: Flushed pending ack for MessageCounter:102448631 on exchange 17771i - disabled: true - - - label: "Step 15: TH sends Stop command to the DUT" - PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate stop 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674689.588712][17337:17339] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674689.588722][17337:17339] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674689.588745][17337:17339] CHIP:TOO: OperationalCommandResponse: { - [1689674689.588749][17337:17339] CHIP:TOO: commandResponseState: { - [1689674689.588757][17337:17339] CHIP:TOO: ErrorStateID: 0 - [1689674689.588762][17337:17339] CHIP:TOO: } - [1689674689.588765][17337:17339] CHIP:TOO: } - [1689674689.588775][17337:17339] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674689.588802][17337:17339] CHIP:EM: <<< [E:63921i S:35027 M:16881995 (Ack:220265764)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674689.588810][17337:17339] CHIP:IN: (S) Sending msg 16881995 on secure session with LSID: 35027 - disabled: true - - - label: - "Step 16: Manually put the DUT into a state wherein it cannot receive - a Start Command" - PICS: OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME - verification: | - Manually put the DUT into a state wherein it cannot receive a Start Command - disabled: true - - - label: "Step 17: TH sends Start command to the DUT" - PICS: - OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp - && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x01 (UnableToStartOrResume) - - [1689674700.385183][17340:17342] CHIP:DMG: }, - [1689674700.385214][17340:17342] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674700.385233][17340:17342] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674700.385266][17340:17342] CHIP:TOO: OperationalCommandResponse: { - [1689674700.385274][17340:17342] CHIP:TOO: commandResponseState: { - [1689674700.385281][17340:17342] CHIP:TOO: ErrorStateID: 1 - [1689674700.385289][17340:17342] CHIP:TOO: } - [1689674700.385295][17340:17342] CHIP:TOO: } - [1689674700.385311][17340:17342] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674700.385361][17340:17342] CHIP:EM: <<< [E:55029i S:46795 M:80501191 (Ack:176711722)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674700.385375][17340:17342] CHIP:IN: (S) Sending msg 80501191 on secure session with LSID: 46795 - [1689674700.385419][17340:17342] CHIP:EM: Flushed pending ack for MessageCounter:176711722 on exchange 55029i - disabled: true From 416103f94da937bd17131c26da44cfd8cf4d0312 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 18 Dec 2023 19:25:45 +0000 Subject: [PATCH 09/89] Restyled by whitespace --- src/app/tests/suites/certification/PICS.yaml | 2 +- src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 4356518d45b0fc..048f0eb0b528cc 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -8753,7 +8753,7 @@ PICS: "Does the DUT support testing the CommandInvalidInState(0x03) error state?" id: OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE - + #Server Attributes - label: "Does the device implement the PhaseList attribute?" id: OVENOPSTATE.S.A0000 diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml index cd17ebe10cc468..e8a3169b9c6983 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml @@ -91,4 +91,4 @@ tests: response: value: 0x03 constraints: - type: enum8 \ No newline at end of file + type: enum8 From 8388dcaf009439ccb6b5577709bf66d82acd7f6c Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 18 Dec 2023 19:25:46 +0000 Subject: [PATCH 10/89] Restyled by prettier-json --- src/app/tests/suites/ciTests.json | 5 ++++- src/app/tests/suites/manualTests.json | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 0b70969249b73c..228a8687a12aec 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -164,7 +164,10 @@ "Test_TC_OO_2_4" ], "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], - "OvenOperationalState": ["Test_TC_OVENOPSTATE_1_1","Test_TC_OVENOPSTATE_2_4"], + "OvenOperationalState": [ + "Test_TC_OVENOPSTATE_1_1", + "Test_TC_OVENOPSTATE_2_4" + ], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], "PressureMeasurement": [ "Test_TC_PRS_1_1", diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index df7a51c20b1242..3bbf49ceaa5fe1 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -265,7 +265,10 @@ ], "OnOff": ["Test_TC_OO_2_3"], "OperationalState": ["Test_TC_OPSTATE_2_2"], - "OvenOperationalState": ["Test_TC_OVENOPSTATE_2_2","Test_TC_OVENOPSTATE_2_4"], + "OvenOperationalState": [ + "Test_TC_OVENOPSTATE_2_2", + "Test_TC_OVENOPSTATE_2_4" + ], "RelativeHumidityMeasurement": ["Test_TC_RH_2_2"], "SmokeCOAlarm": [], "RefrigeratorAlarm": ["Test_TC_REFALM_2_2", "Test_TC_REFALM_2_3"], From 00ec6a04434ddbe51166b7a16baae8beeb6ae52d Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 18 Dec 2023 19:25:54 +0000 Subject: [PATCH 11/89] Restyled by prettier-yaml --- src/app/tests/suites/certification/PICS.yaml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 048f0eb0b528cc..767e6a6abd982f 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -8710,7 +8710,6 @@ PICS: command?" id: OPSTATE.S.C04.Tx - # #Oven Operational State # From 8beee5e3ffe9dcd51297db2cfcf494a60899086e Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Wed, 20 Dec 2023 17:04:00 -0500 Subject: [PATCH 12/89] updated test scripts --- .../suites/certification/Test_TC_OVENOPSTATE_1_1.yaml | 10 +++++----- .../suites/certification/Test_TC_OVENOPSTATE_2_2.yaml | 2 +- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml index e5a86eed5f525a..88f16af36cd7e0 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml @@ -1,4 +1,4 @@ -# Copyright (c) 2021 Project CHIP Authors +# Copyright (c) 2023 Project CHIP Authors # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -134,8 +134,8 @@ tests: - label: "Step 7: Read the global attribute: GeneratedCommandList" PICS: - "!OPSTATE.S.C00.Rsp && !OPSTATE.S.C01.Rsp && !OPSTATE.S.C02.Rsp && - !OPSTATE.S.C03.Rsp" + "!OVENOPSTATE.S.C00.Rsp && !OVENOPSTATE.S.C01.Rsp && !OVENOPSTATE.S.C02.Rsp && + !OVENOPSTATE.S.C03.Rsp" command: "readAttribute" attribute: "GeneratedCommandList" response: @@ -145,8 +145,8 @@ tests: - label: "Step 7: Read the global attribute: GeneratedCommandList" PICS: - (OPSTATE.S.C00.Rsp || OPSTATE.S.C01.Rsp || OPSTATE.S.C02.Rsp || - OPSTATE.S.C03.Rsp) + (OVENOPSTATE.S.C00.Rsp || OVENOPSTATE.S.C01.Rsp || OVENOPSTATE.S.C02.Rsp || + OVENOPSTATE.S.C03.Rsp) command: "readAttribute" attribute: "GeneratedCommandList" response: diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml index 4e723deb9f08a4..b5a0f2fee5e8ed 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -52,7 +52,7 @@ tests: - all entries include an ID (enum8) and a label (string) - all provided IDs are in the allowed range - the list includes IDs for Error (0x03), Running (0x01), and Stopped (0x00) - +OVENOPSTATE [1689674049.504261][17222:17224] CHIP:DMG: } [1689674049.504390][17222:17224] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0003 DataVersion: 2102885775 [1689674049.504440][17222:17224] CHIP:TOO: OperationalStateList: 4 entries From cc5a1570441bde9043e0cff084cd9861637420ad Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Wed, 20 Dec 2023 17:09:04 -0500 Subject: [PATCH 13/89] updated Test_TC_OVENOPSTATE_2_2.yaml --- src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml index b5a0f2fee5e8ed..4e723deb9f08a4 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -52,7 +52,7 @@ tests: - all entries include an ID (enum8) and a label (string) - all provided IDs are in the allowed range - the list includes IDs for Error (0x03), Running (0x01), and Stopped (0x00) -OVENOPSTATE + [1689674049.504261][17222:17224] CHIP:DMG: } [1689674049.504390][17222:17224] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0003 DataVersion: 2102885775 [1689674049.504440][17222:17224] CHIP:TOO: OperationalStateList: 4 entries From e76b7712a16c0655ce3e0098eb9b67654d1737c5 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 20 Dec 2023 22:09:59 +0000 Subject: [PATCH 14/89] Restyled by prettier-yaml --- .../suites/certification/Test_TC_OVENOPSTATE_1_1.yaml | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml index 88f16af36cd7e0..3552b0b9c3e47e 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml @@ -134,8 +134,8 @@ tests: - label: "Step 7: Read the global attribute: GeneratedCommandList" PICS: - "!OVENOPSTATE.S.C00.Rsp && !OVENOPSTATE.S.C01.Rsp && !OVENOPSTATE.S.C02.Rsp && - !OVENOPSTATE.S.C03.Rsp" + "!OVENOPSTATE.S.C00.Rsp && !OVENOPSTATE.S.C01.Rsp && + !OVENOPSTATE.S.C02.Rsp && !OVENOPSTATE.S.C03.Rsp" command: "readAttribute" attribute: "GeneratedCommandList" response: @@ -145,8 +145,8 @@ tests: - label: "Step 7: Read the global attribute: GeneratedCommandList" PICS: - (OVENOPSTATE.S.C00.Rsp || OVENOPSTATE.S.C01.Rsp || OVENOPSTATE.S.C02.Rsp || - OVENOPSTATE.S.C03.Rsp) + (OVENOPSTATE.S.C00.Rsp || OVENOPSTATE.S.C01.Rsp || + OVENOPSTATE.S.C02.Rsp || OVENOPSTATE.S.C03.Rsp) command: "readAttribute" attribute: "GeneratedCommandList" response: From 0907c0041b9872aca9d23dd923d6130d7556f6b4 Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Mon, 8 Jan 2024 22:46:13 -0500 Subject: [PATCH 15/89] updated yamls and ran zap regen --- .../Test_TC_OVENOPSTATE_1_1.yaml | 2 +- .../Test_TC_OVENOPSTATE_2_4.yaml | 2 +- .../python/chip/clusters/__init__.py | 4 +- .../zap-generated/test/Commands.h | 702 ++++++++++++++++++ 4 files changed, 706 insertions(+), 4 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml index 3552b0b9c3e47e..fd70f795b6f085 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml @@ -18,7 +18,7 @@ PICS: config: nodeId: 0x12344321 - cluster: "Oven Operational State" + cluster: "Oven Cavity Operational State" endpoint: 1 tests: diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml index e8a3169b9c6983..4820fba4eab995 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml @@ -19,7 +19,7 @@ PICS: config: nodeId: 0x12344321 - cluster: "Oven Operational State" + cluster: "Oven Cavity Operational State" endpoint: 1 tests: diff --git a/src/controller/python/chip/clusters/__init__.py b/src/controller/python/chip/clusters/__init__.py index 6e846c68f5cb08..2c460316136a60 100644 --- a/src/controller/python/chip/clusters/__init__.py +++ b/src/controller/python/chip/clusters/__init__.py @@ -33,7 +33,7 @@ Identify, IlluminanceMeasurement, KeypadInput, LaundryWasherControls, LaundryWasherMode, LevelControl, LocalizationConfiguration, LowPower, MediaInput, MediaPlayback, ModeSelect, NetworkCommissioning, NitrogenDioxideConcentrationMeasurement, OccupancySensing, OnOff, OnOffSwitchConfiguration, - OperationalCredentials, OperationalState, OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, + OperationalCredentials, OperationalState, OvenOperationalState, OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm25ConcentrationMeasurement, PowerSource, PowerSourceConfiguration, PressureMeasurement, ProxyConfiguration, ProxyDiscovery, ProxyValid, PulseWidthModulation, PumpConfigurationAndControl, RadonConcentrationMeasurement, @@ -54,7 +54,7 @@ HepaFilterMonitoring, IcdManagement, Identify, IlluminanceMeasurement, KeypadInput, LaundryWasherControls, LaundryWasherMode, LevelControl, LocalizationConfiguration, LowPower, MediaInput, MediaPlayback, ModeSelect, NetworkCommissioning, NitrogenDioxideConcentrationMeasurement, - OccupancySensing, OnOff, OnOffSwitchConfiguration, OperationalCredentials, OperationalState, + OccupancySensing, OnOff, OnOffSwitchConfiguration, OperationalCredentials, OperationalState, OvenOperationalState, OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm25ConcentrationMeasurement, PowerSource, PowerSourceConfiguration, PressureMeasurement, ProxyConfiguration, diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 1c9892f1a4c767..4e9d6acc066fb3 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -184,6 +184,8 @@ class TestList : public Command { printf("Test_TC_OO_2_2\n"); printf("Test_TC_OO_2_4\n"); printf("Test_TC_OPSTATE_1_1\n"); + printf("Test_TC_OVENOPSTATE_1_1\n"); + printf("Test_TC_OVENOPSTATE_2_4\n"); printf("Test_TC_PS_1_1\n"); printf("Test_TC_PS_2_1\n"); printf("Test_TC_PRS_1_1\n"); @@ -89181,6 +89183,704 @@ class Test_TC_OPSTATE_1_1 : public TestCommandBridge { } }; +class Test_TC_OVENOPSTATE_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OVENOPSTATE_1_1() + : TestCommandBridge("Test_TC_OVENOPSTATE_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OVENOPSTATE_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap attribute from the DUT\n"); + err = TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT\n"); + if (ShouldSkip("OVENOPSTATE.S.A0002")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5a: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5b: TH reads from the DUT the optional event(OperationCompletion) in EventList.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && OVENOPSTATE.S.E01")) { + NextTest(); + return; + } + NextTest(); + return; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: Read the optional command(Start) in AcceptedCommandList\n"); + if (ShouldSkip("OVENOPSTATE.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep6aReadTheOptionalCommandStartInAcceptedCommandList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6b: Read the optional command(Stop) in AcceptedCommandList\n"); + if (ShouldSkip("OVENOPSTATE.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep6bReadTheOptionalCommandStopInAcceptedCommandList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6c: Read the optional command(Pause) in AcceptedCommandList\n"); + if (ShouldSkip("OVENOPSTATE.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6cReadTheOptionalCommandPauseInAcceptedCommandList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6d: Read the optional command(Resume) in AcceptedCommandList\n"); + if (ShouldSkip("OVENOPSTATE.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep6dReadTheOptionalCommandResumeInAcceptedCommandList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: Read the global attribute: GeneratedCommandList\n"); + if (ShouldSkip("!OVENOPSTATE.S.C00.Rsp && !OVENOPSTATE.S.C01.Rsp && !OVENOPSTATE.S.C02.Rsp && !OVENOPSTATE.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: Read the global attribute: GeneratedCommandList\n"); + if (ShouldSkip("(OVENOPSTATE.S.C00.Rsp || OVENOPSTATE.S.C01.Rsp || OVENOPSTATE.S.C02.Rsp || OVENOPSTATE.S.C03.Rsp)")) { + NextTest(); + return; + } + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_13(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 14; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aReadTheOptionalCommandStartInAcceptedCommandList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: Read the optional command(Start) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6a: Read the optional command(Start) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bReadTheOptionalCommandStopInAcceptedCommandList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: Read the optional command(Stop) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6b: Read the optional command(Stop) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cReadTheOptionalCommandPauseInAcceptedCommandList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: Read the optional command(Pause) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6c: Read the optional command(Pause) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6dReadTheOptionalCommandResumeInAcceptedCommandList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: Read the optional command(Resume) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6d: Read the optional command(Resume) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OVENOPSTATE_2_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OVENOPSTATE_2_4() + : TestCommandBridge("Test_TC_OVENOPSTATE_2_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OVENOPSTATE_2_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_2_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_2_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Set up a subscription to the OperationalError event\n"); + if (ShouldSkip("OVENOPSTATE.S.E00")) { + NextTest(); + return; + } + err = TestStep2SetUpASubscriptionToTheOperationalErrorEvent_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: At the DUT take the vendor defined action to generate an OperationalError event\n"); + if (ShouldSkip("OVENOPSTATE.S.E00 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep3AtTheDutTakeTheVendorDefinedActionToGenerateAnOperationalErrorEvent_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the OperationalState attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0004 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheOperationalStateAttribute_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2SetUpASubscriptionToTheOperationalErrorEvent_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + if (err != nil) { + NSLog(@"Step 2: Set up a subscription to the OperationalError event: Error: %@", err); + } else { + NSLog(@"Step 2: Set up a subscription to the OperationalError event: Success"); + } + }]; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +TestStep3AtTheDutTakeTheVendorDefinedActionToGenerateAnOperationalErrorEvent_2() +{ + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); +} + +CHIP_ERROR TestStep4ThReadsFromTheDutTheOperationalStateAttribute_3() +{ + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the OperationalState attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the OperationalState attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("operationalState", "enum8", "enum8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; +} +} +; + class Test_TC_PS_1_1 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced @@ -193556,6 +194256,8 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), From 65ef6b3a351a2e02ee607d7ee7534fe8297be738 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 9 Jan 2024 04:11:15 +0000 Subject: [PATCH 16/89] Restyled by isort --- src/controller/python/chip/clusters/__init__.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/controller/python/chip/clusters/__init__.py b/src/controller/python/chip/clusters/__init__.py index 2c460316136a60..b4eab770936d68 100644 --- a/src/controller/python/chip/clusters/__init__.py +++ b/src/controller/python/chip/clusters/__init__.py @@ -33,11 +33,12 @@ Identify, IlluminanceMeasurement, KeypadInput, LaundryWasherControls, LaundryWasherMode, LevelControl, LocalizationConfiguration, LowPower, MediaInput, MediaPlayback, ModeSelect, NetworkCommissioning, NitrogenDioxideConcentrationMeasurement, OccupancySensing, OnOff, OnOffSwitchConfiguration, - OperationalCredentials, OperationalState, OvenOperationalState, OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, - OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm10ConcentrationMeasurement, - Pm25ConcentrationMeasurement, PowerSource, PowerSourceConfiguration, PressureMeasurement, ProxyConfiguration, - ProxyDiscovery, ProxyValid, PulseWidthModulation, PumpConfigurationAndControl, RadonConcentrationMeasurement, - RefrigeratorAlarm, RefrigeratorAndTemperatureControlledCabinetMode, RelativeHumidityMeasurement, RvcCleanMode, + OperationalCredentials, OperationalState, OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, + OvenOperationalState, OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, + Pm10ConcentrationMeasurement, Pm25ConcentrationMeasurement, PowerSource, PowerSourceConfiguration, + PressureMeasurement, ProxyConfiguration, ProxyDiscovery, ProxyValid, PulseWidthModulation, + PumpConfigurationAndControl, RadonConcentrationMeasurement, RefrigeratorAlarm, + RefrigeratorAndTemperatureControlledCabinetMode, RelativeHumidityMeasurement, RvcCleanMode, RvcOperationalState, RvcRunMode, Scenes, SmokeCoAlarm, SoftwareDiagnostics, Switch, TargetNavigator, TemperatureControl, TemperatureMeasurement, Thermostat, ThermostatUserInterfaceConfiguration, ThreadNetworkDiagnostics, TimeFormatLocalization, TimeSynchronization, From 5a76f8ef72ce69c08bea31a1665f7cc6f7f2bc1c Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 9 Jan 2024 14:28:54 +0000 Subject: [PATCH 17/89] Restyled by isort --- src/controller/python/chip/clusters/__init__.py | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/src/controller/python/chip/clusters/__init__.py b/src/controller/python/chip/clusters/__init__.py index e906f679ec2acc..0e91bcf53b2e38 100644 --- a/src/controller/python/chip/clusters/__init__.py +++ b/src/controller/python/chip/clusters/__init__.py @@ -25,19 +25,6 @@ from . import Attribute, CHIPClusters, Command from .Objects import (AccessControl, AccountLogin, Actions, ActivatedCarbonFilterMonitoring, AdministratorCommissioning, AirQuality, ApplicationBasic, ApplicationLauncher, AudioOutput, BallastConfiguration, BarrierControl, BasicInformation, - BinaryInputBasic, Binding, BooleanState, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, - CarbonMonoxideConcentrationMeasurement, Channel, ColorControl, ContentLauncher, Descriptor, DiagnosticLogs, - DishwasherAlarm, DishwasherMode, DoorLock, ElectricalMeasurement, EnergyEvse, EthernetNetworkDiagnostics, - FanControl, FaultInjection, FixedLabel, FlowMeasurement, FormaldehydeConcentrationMeasurement, - GeneralCommissioning, GeneralDiagnostics, GroupKeyManagement, Groups, HepaFilterMonitoring, IcdManagement, - Identify, IlluminanceMeasurement, KeypadInput, LaundryWasherControls, LaundryWasherMode, LevelControl, - LocalizationConfiguration, LowPower, MediaInput, MediaPlayback, ModeSelect, NetworkCommissioning, - NitrogenDioxideConcentrationMeasurement, OccupancySensing, OnOff, OnOffSwitchConfiguration, - OperationalCredentials, OperationalState, OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, - OvenOperationalState, OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, - Pm10ConcentrationMeasurement, Pm25ConcentrationMeasurement, PowerSource, PowerSourceConfiguration, - PressureMeasurement, ProxyConfiguration, ProxyDiscovery, ProxyValid, PulseWidthModulation, - PumpConfigurationAndControl, RadonConcentrationMeasurement, RefrigeratorAlarm, BinaryInputBasic, Binding, BooleanState, BooleanStateConfiguration, BridgedDeviceBasicInformation, CarbonDioxideConcentrationMeasurement, CarbonMonoxideConcentrationMeasurement, Channel, ColorControl, ContentLauncher, Descriptor, DeviceEnergyManagement, DiagnosticLogs, DishwasherAlarm, DishwasherMode, @@ -47,7 +34,7 @@ KeypadInput, LaundryWasherControls, LaundryWasherMode, LevelControl, LocalizationConfiguration, LowPower, MediaInput, MediaPlayback, ModeSelect, NetworkCommissioning, NitrogenDioxideConcentrationMeasurement, OccupancySensing, OnOff, OnOffSwitchConfiguration, OperationalCredentials, OperationalState, - OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, OzoneConcentrationMeasurement, + OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, OvenOperationalState, OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm25ConcentrationMeasurement, PowerSource, PowerSourceConfiguration, PressureMeasurement, ProxyConfiguration, ProxyDiscovery, ProxyValid, PulseWidthModulation, PumpConfigurationAndControl, RadonConcentrationMeasurement, RefrigeratorAlarm, From 18353b6b34f7ac04ac8fc668ee515f28ab617157 Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Thu, 11 Jan 2024 13:05:35 -0500 Subject: [PATCH 18/89] updated __init__.py --- src/controller/python/chip/clusters/__init__.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/controller/python/chip/clusters/__init__.py b/src/controller/python/chip/clusters/__init__.py index 0e91bcf53b2e38..b8ad225f47d38f 100644 --- a/src/controller/python/chip/clusters/__init__.py +++ b/src/controller/python/chip/clusters/__init__.py @@ -34,7 +34,7 @@ KeypadInput, LaundryWasherControls, LaundryWasherMode, LevelControl, LocalizationConfiguration, LowPower, MediaInput, MediaPlayback, ModeSelect, NetworkCommissioning, NitrogenDioxideConcentrationMeasurement, OccupancySensing, OnOff, OnOffSwitchConfiguration, OperationalCredentials, OperationalState, - OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, OvenOperationalState, OzoneConcentrationMeasurement, + OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, OvenCavityOperationalState, OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm25ConcentrationMeasurement, PowerSource, PowerSourceConfiguration, PressureMeasurement, ProxyConfiguration, ProxyDiscovery, ProxyValid, PulseWidthModulation, PumpConfigurationAndControl, RadonConcentrationMeasurement, RefrigeratorAlarm, @@ -55,7 +55,7 @@ HepaFilterMonitoring, IcdManagement, Identify, IlluminanceMeasurement, KeypadInput, LaundryWasherControls, LaundryWasherMode, LevelControl, LocalizationConfiguration, LowPower, MediaInput, MediaPlayback, ModeSelect, NetworkCommissioning, NitrogenDioxideConcentrationMeasurement, - OccupancySensing, OnOff, OnOffSwitchConfiguration, OperationalCredentials, OperationalState, OvenOperationalState, + OccupancySensing, OnOff, OnOffSwitchConfiguration, OperationalCredentials, OperationalState, OvenCavityOperationalState, OtaSoftwareUpdateProvider, OtaSoftwareUpdateRequestor, OzoneConcentrationMeasurement, Pm1ConcentrationMeasurement, Pm10ConcentrationMeasurement, Pm25ConcentrationMeasurement, PowerSource, PowerSourceConfiguration, PressureMeasurement, ProxyConfiguration, From 9b21400da90d1cef46f67df673f2a8b9c67ebb74 Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Mon, 15 Jan 2024 19:32:01 -0500 Subject: [PATCH 19/89] updated citests and mannual tests --- src/app/tests/suites/ciTests.json | 4 ++-- src/app/tests/suites/manualTests.json | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index e2a464778da4cc..517276378087a0 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -173,7 +173,7 @@ "Test_TC_OO_2_4" ], "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], - "OvenOperationalState": [ + "OvenCavityOperationalState": [ "Test_TC_OVENOPSTATE_1_1", "Test_TC_OVENOPSTATE_2_4" ], @@ -413,7 +413,7 @@ "OccupancySensing", "OnOff", "OperationalState", - "OvenOperationalState", + "OvenCavityOperationalState", "PowerSource", "PressureMeasurement", "PumpConfigurationControl", diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index 0bd56cce1b6960..a25d1ed4e39164 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -261,7 +261,7 @@ "LaundryWasherMode": ["Test_TC_LWM_1_2"], "OnOff": ["Test_TC_OO_2_3"], "OperationalState": ["Test_TC_OPSTATE_2_2"], - "OvenOperationalState": [ + "OvenCavityOperationalState": [ "Test_TC_OVENOPSTATE_2_2", "Test_TC_OVENOPSTATE_2_4" ], @@ -337,7 +337,7 @@ "LaundryWasherMode", "OnOff", "OperationalState", - "OvenOperationalState", + "OvenCavityOperationalState", "RelativeHumidityMeasurement", "SmokeCOAlarm", "RefrigeratorAlarm", From da5cd70813b5d16ebe0021da22f6b39c53fbb892 Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Tue, 16 Jan 2024 16:31:49 -0500 Subject: [PATCH 20/89] updated python scripts --- src/python_testing/TC_OVENOPSTATE_2_1.py | 68 ++++++++++++------------ src/python_testing/TC_OVENOPSTATE_2_3.py | 58 ++++++++++---------- 2 files changed, 63 insertions(+), 63 deletions(-) diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index 97bcfea3c421c7..26fbe5064e7d63 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -30,22 +30,22 @@ class TC_OVENOPSTATE_2_1(MatterBaseTest): async def read_mod_attribute_expect_success(self, endpoint, attribute): - cluster = Clusters.Objects.OperationalState + cluster = Clusters.Objects.OvenCavityOperationalState return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) async def read_and_validate_opstate(self, step, expected_state): - self.print_step(step, "Read OperationalState attribute") + self.print_step(step, "Read OvenCavityOperationalState attribute") operational_state = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OperationalState.Attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) + endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OvenCavityOperationalState) + logging.info("OvenCavityOperationalState: %s" % (operational_state)) asserts.assert_equal(operational_state, expected_state, - "OperationalState(%s) should equal %s" % (operational_state, expected_state)) + "OvenCavityOperationalState(%s) should equal %s" % (operational_state, expected_state)) async def read_and_validate_operror(self, step, expected_error): self.print_step(step, "Read OperationalError attribute") operational_error = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OperationalState.Attributes.OperationalError) - logging.info("OperationalError: %s" % (operational_error)) + endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OvenCavityOperationalError) + logging.info("OvenCavityOperationalError: %s" % (operational_error)) asserts.assert_equal(operational_error.errorStateID, expected_error, "errorStateID(%s) should equal %s" % (operational_error.errorStateID, expected_error)) @@ -58,7 +58,7 @@ async def test_TC_OVENOPSTATE_2_1(self): self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] - attributes = Clusters.OperationalState.Attributes + attributes = Clusters.OvenCavityOperationalState.Attributes self.print_step(1, "Commissioning, already done") @@ -98,64 +98,64 @@ async def test_TC_OVENOPSTATE_2_1(self): "CountdownTime(%s) must be between 0 and 259200" % countdown_time) if self.check_pics("OVENOPSTATE.S.A0003"): - self.print_step(5, "Read OperationalStateList attribute") + self.print_step(5, "Read OvenCavityOperationalStateList attribute") operational_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalStateList) + attribute=attributes.OvenCavityOperationalStateList) - logging.info("OperationalStateList: %s" % (operational_state_list)) + logging.info("OvenCavityOperationalStateList: %s" % (operational_state_list)) - defined_states = [state.value for state in Clusters.OperationalState.Enums.OperationalStateEnum - if state is not Clusters.OperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] + defined_states = [state.value for state in Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum + if state is not Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kUnknownEnumValue] for state in operational_state_list: in_range = (0x80 <= state.operationalStateID <= 0xBF) asserts.assert_true(state.operationalStateID in defined_states or in_range, - "Found a OperationalStateList entry with invalid ID value!") + "Found a OvenCavityOperationalStateList entry with invalid ID value!") if in_range: asserts.assert_true(state.operationalStateLabel is not None, - "The OperationalStateLabel should be populated") - if state.operationalStateID == Clusters.OperationalState.Enums.OperationalStateEnum.kError: + "The OvenCavityOperationalStateLabel should be populated") + if state.operationalStateID == Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kError: error_state_present = True - asserts.assert_true(error_state_present, "The OperationalStateList does not have an ID entry of Error(0x03)") + asserts.assert_true(error_state_present, "The OvenCavityOperationalStateList does not have an ID entry of Error(0x03)") if self.check_pics("OVENOPSTATE.S.A0004"): - self.print_step(6, "Read OperationalState attribute") + self.print_step(6, "Read OvenCavityOperationalState attribute") operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) + attribute=attributes.OvenCavityOperationalState) - logging.info("OperationalState: %s" % (operational_state)) + logging.info("OvenCavityOperationalState: %s" % (operational_state)) in_range = (0x80 <= operational_state <= 0xBF) - asserts.assert_true(operational_state in defined_states or in_range, "OperationalState has an invalid ID value!") + asserts.assert_true(operational_state in defined_states or in_range, "OvenCavityOperationalState has an invalid ID value!") if self.check_pics("OVENOPSTATE.S.M.ST_STOPPED"): self.print_step("6a", "Manually put the device in the stopped state") input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6b", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kStopped) + await self.read_and_validate_opstate(step="6b", expected_state=Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kStopped) if self.check_pics("OVENOPSTATE.S.M.ST_RUNNING"): self.print_step("6c", "Manually put the device in the running state") input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6d", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kRunning) + await self.read_and_validate_opstate(step="6d", expected_state=Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kRunning) if self.check_pics("OVENOPSTATE.S.M.ST_PAUSED"): self.print_step("6e", "Manually put the device in the paused state") input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6f", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kPaused) + await self.read_and_validate_opstate(step="6f", expected_state=Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kPaused) if self.check_pics("OVENOPSTATE.S.M.ST_ERROR"): self.print_step("6g", "Manually put the device in the error state") input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6h", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kError) + await self.read_and_validate_opstate(step="6h", expected_state=Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kError) if self.check_pics("OVENOPSTATE.S.A0005"): - self.print_step(7, "Read OperationalError attribute") + self.print_step(7, "Read OvenCavityOperationalError attribute") operational_error = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalError) + attribute=attributes.OvenCavityOperationalError) - logging.info("OperationalError: %s" % (operational_error)) + logging.info("OvenCavityOperationalError: %s" % (operational_error)) # Defined Errors - defined_errors = [error.value for error in Clusters.OperationalState.Enums.ErrorStateEnum - if error is not Clusters.OperationalState.Enums.ErrorStateEnum.kUnknownEnumValue] + defined_errors = [error.value for error in Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum + if error is not Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnknownEnumValue] in_range = (0x80 <= operational_error.errorStateID <= 0xBF) asserts.assert_true(operational_error.errorStateID in defined_errors @@ -166,19 +166,19 @@ async def test_TC_OVENOPSTATE_2_1(self): if self.check_pics("OVENOPSTATE.S.M.ERR_NO_ERROR"): self.print_step("7a", "Manually put the device in the no error state") input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7b", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kNoError) + await self.read_and_validate_operror(step="7b", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError) if self.check_pics("OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME"): self.print_step("7c", "Manually put the device in the unable to start or resume error state") input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7d", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kUnableToStartOrResume) + await self.read_and_validate_operror(step="7d", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnableToStartOrResume) if self.check_pics("OVENOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION"): self.print_step("7e", "Manually put the device in the unable to complete operation error state") input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7f", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kUnableToCompleteOperation) + await self.read_and_validate_operror(step="7f", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnableToCompleteOperation) if self.check_pics("OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE"): self.print_step("7g", "Manually put the device in the command invalid error state") input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7h", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState) + await self.read_and_validate_operror(step="7h", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState) if __name__ == "__main__": diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py index c1aac443d37c30..4a235e786522de 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_3.py +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -31,18 +31,18 @@ class TC_OVENOPSTATE_2_3(MatterBaseTest): async def read_mod_attribute_expect_success(self, endpoint, attribute): - cluster = Clusters.Objects.OperationalState + cluster = Clusters.Objects.OvenCavityOperationalState return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) - async def send_pause_cmd(self) -> Clusters.Objects.OperationalState.Commands.Pause: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OperationalState.Commands.Pause(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OperationalState.Commands.OperationalCommandResponse), + async def send_pause_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Pause: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Pause(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OvenCavityOperationalCommandResponse), "Unexpected return type for Pause") return ret - async def send_resume_cmd(self) -> Clusters.Objects.OperationalState.Commands.Resume: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OperationalState.Commands.Resume(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OperationalState.Commands.OperationalCommandResponse), + async def send_resume_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Resume: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Resume(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OvenCavityOperationalCommandResponse), "Unexpected return type for Resume") return ret @@ -60,37 +60,37 @@ async def test_TC_OVENOPSTATE_2_3(self): asserts.assert_true(self.check_pics("OVENOPSTATE.S.C00.Rsp"), "OVENOPSTATE.S.C00.Rsp must be supported") asserts.assert_true(self.check_pics("OVENOPSTATE.S.C03.Rsp"), "OVENOPSTATE.S.C03.Rsp must be supported") - attributes = Clusters.OperationalState.Attributes + attributes = Clusters.OvenCavityOperationalState.Attributes self.print_step(1, "Commissioning, already done") self.print_step(2, "Manually put the device in a state where it can receive a Pause command") input("Press Enter when done.\n") - self.print_step(3, "Read OperationalStateList attribute") + self.print_step(3, "Read OvenCavityOperationalStateList attribute") op_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalStateList) + attribute=attributes.OvenCavityOperationalStateList) - logging.info("OperationalStateList: %s" % (op_state_list)) + logging.info("OvenCavityOperationalStateList: %s" % (op_state_list)) - defined_states = [state.value for state in Clusters.OperationalState.Enums.OperationalStateEnum - if state is not Clusters.OperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] + defined_states = [state.value for state in Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum + if state is not Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kUnknownEnumValue] state_ids = set([s.operationalStateID for s in op_state_list]) - asserts.assert_true(all(id in state_ids for id in defined_states), "OperationalStateList is missing a required entry") + asserts.assert_true(all(id in state_ids for id in defined_states), "OvenCavityOperationalStateList is missing a required entry") self.print_step(4, "Send Pause command") ret = await self.send_pause_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - self.print_step(5, "Read OperationalState attribute") + self.print_step(5, "Read OvenCavityOperationalState attribute") operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OperationalState.Enums.OperationalStateEnum.kPaused, - "OperationalState ID should be Paused(0x02)") + attribute=attributes.OvenCavityOperationalState) + logging.info("OvenCavityOperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kPaused, + "OvenCavityOperationalState ID should be Paused(0x02)") if self.check_pics("OVENOPSTATE.S.A0002"): self.print_step(6, "Read CountdownTime attribute") @@ -115,24 +115,24 @@ async def test_TC_OVENOPSTATE_2_3(self): self.print_step(9, "Send Pause command") ret = await self.send_pause_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) self.print_step(10, "Send Resume command") ret = await self.send_resume_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - self.print_step(11, "Read OperationalState attribute") + self.print_step(11, "Read OvenCavityOperationalState attribute") operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OperationalState.Enums.OperationalStateEnum.kRunning, + attribute=attributes.OvenCavityOperationalState) + logging.info("OvenCavityOperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kRunning, "OperationalState(%s) should be Running(0x01)" % operational_state) self.print_step(12, "Send Resume command") ret = await self.send_resume_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) self.print_step(13, "Manually put the device in a state where it cannot receive a Pause command") @@ -141,7 +141,7 @@ async def test_TC_OVENOPSTATE_2_3(self): self.print_step(14, "Send Pause command") ret = await self.send_pause_cmd() asserts.assert_equal(ret.commandResponseState.errorStateID, - Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, + Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) self.print_step(15, "Manually put the device in a state where it cannot receive a Resume command") @@ -150,7 +150,7 @@ async def test_TC_OVENOPSTATE_2_3(self): self.print_step(16, "Send Resume command") ret = await self.send_resume_cmd() asserts.assert_equal(ret.commandResponseState.errorStateID, - Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, + Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) From 9bf20706eeae3ae332f1046a3be8038f644f33f4 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 16 Jan 2024 21:35:17 +0000 Subject: [PATCH 21/89] Restyled by autopep8 --- src/python_testing/TC_OVENOPSTATE_2_1.py | 3 ++- src/python_testing/TC_OVENOPSTATE_2_3.py | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index 26fbe5064e7d63..d029deb2abd51a 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -127,7 +127,8 @@ async def test_TC_OVENOPSTATE_2_1(self): logging.info("OvenCavityOperationalState: %s" % (operational_state)) in_range = (0x80 <= operational_state <= 0xBF) - asserts.assert_true(operational_state in defined_states or in_range, "OvenCavityOperationalState has an invalid ID value!") + asserts.assert_true(operational_state in defined_states or in_range, + "OvenCavityOperationalState has an invalid ID value!") if self.check_pics("OVENOPSTATE.S.M.ST_STOPPED"): self.print_step("6a", "Manually put the device in the stopped state") diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py index 4a235e786522de..6ebcd4759b70c9 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_3.py +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -78,7 +78,8 @@ async def test_TC_OVENOPSTATE_2_3(self): state_ids = set([s.operationalStateID for s in op_state_list]) - asserts.assert_true(all(id in state_ids for id in defined_states), "OvenCavityOperationalStateList is missing a required entry") + asserts.assert_true(all(id in state_ids for id in defined_states), + "OvenCavityOperationalStateList is missing a required entry") self.print_step(4, "Send Pause command") ret = await self.send_pause_cmd() From 604b09aaa5f1535989036d376ada3bbf6baedb16 Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Tue, 16 Jan 2024 19:55:19 -0500 Subject: [PATCH 22/89] updated step3 to automated test in 2_2 --- .../Test_TC_OVENOPSTATE_2_2.yaml | 39 +++++++------------ 1 file changed, 13 insertions(+), 26 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml index 4e723deb9f08a4..ca4d6f2ea026c9 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -45,32 +45,19 @@ tests: - label: "Step 3: TH reads from the DUT the OperationalStateList attribute" PICS: OVENOPSTATE.S.A0003 - verification: | - ./chip-tool operationalstate read operational-state-list 1 1 - - Via the TH (chip-tool), verify: - - all entries include an ID (enum8) and a label (string) - - all provided IDs are in the allowed range - - the list includes IDs for Error (0x03), Running (0x01), and Stopped (0x00) - - [1689674049.504261][17222:17224] CHIP:DMG: } - [1689674049.504390][17222:17224] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0003 DataVersion: 2102885775 - [1689674049.504440][17222:17224] CHIP:TOO: OperationalStateList: 4 entries - [1689674049.504462][17222:17224] CHIP:TOO: [1]: { - [1689674049.504469][17222:17224] CHIP:TOO: OperationalStateID: 0 - [1689674049.504476][17222:17224] CHIP:TOO: } - [1689674049.504484][17222:17224] CHIP:TOO: [2]: { - [1689674049.504490][17222:17224] CHIP:TOO: OperationalStateID: 1 - [1689674049.504495][17222:17224] CHIP:TOO: } - [1689674049.504503][17222:17224] CHIP:TOO: [3]: { - [1689674049.504508][17222:17224] CHIP:TOO: OperationalStateID: 2 - [1689674049.504514][17222:17224] CHIP:TOO: } - [1689674049.504521][17222:17224] CHIP:TOO: [4]: { - [1689674049.504527][17222:17224] CHIP:TOO: OperationalStateID: 3 - [1689674049.504533][17222:17224] CHIP:TOO: } - [1689674049.504605][17222:17224] CHIP:EM: <<< [E:22830i S:37151 M:4250114 (Ack:140781365)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674049.504620][17222:17224] CHIP:IN: (S) Sending msg 4250114 on secure session with LSID: 37151 - disabled: true + command: "readAttribute" + attribute: "OperationalStateList" + response: + value: + [ + { OperationalStateID: 0 }, + { OperationalStateID: 1 }, + { OperationalStateID: 2 }, + { OperationalStateID: 3 }, + ] + + constraints: + type: list - label: "Step 4: TH sends Start command to the DUT" PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx From 83b968a245171ebf940d68a1ebb3e32caca54168 Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Tue, 16 Jan 2024 20:03:06 -0500 Subject: [PATCH 23/89] updated citests.json --- src/app/tests/suites/ciTests.json | 1 + 1 file changed, 1 insertion(+) diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 517276378087a0..5df9a0c8f68d06 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -175,6 +175,7 @@ "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], "OvenCavityOperationalState": [ "Test_TC_OVENOPSTATE_1_1", + "Test_TC_OVENOPSTATE_2_2", "Test_TC_OVENOPSTATE_2_4" ], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], From 163c8105fc8e96c1be42e01af5f43cd628697dad Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Wed, 17 Jan 2024 15:30:41 -0500 Subject: [PATCH 24/89] updated Tests and ciTest file --- .../Test_TC_OVENOPSTATE_2_2.yaml | 39 ++++++++++++------- src/app/tests/suites/ciTests.json | 1 - 2 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml index ca4d6f2ea026c9..4e723deb9f08a4 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -45,19 +45,32 @@ tests: - label: "Step 3: TH reads from the DUT the OperationalStateList attribute" PICS: OVENOPSTATE.S.A0003 - command: "readAttribute" - attribute: "OperationalStateList" - response: - value: - [ - { OperationalStateID: 0 }, - { OperationalStateID: 1 }, - { OperationalStateID: 2 }, - { OperationalStateID: 3 }, - ] - - constraints: - type: list + verification: | + ./chip-tool operationalstate read operational-state-list 1 1 + + Via the TH (chip-tool), verify: + - all entries include an ID (enum8) and a label (string) + - all provided IDs are in the allowed range + - the list includes IDs for Error (0x03), Running (0x01), and Stopped (0x00) + + [1689674049.504261][17222:17224] CHIP:DMG: } + [1689674049.504390][17222:17224] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0003 DataVersion: 2102885775 + [1689674049.504440][17222:17224] CHIP:TOO: OperationalStateList: 4 entries + [1689674049.504462][17222:17224] CHIP:TOO: [1]: { + [1689674049.504469][17222:17224] CHIP:TOO: OperationalStateID: 0 + [1689674049.504476][17222:17224] CHIP:TOO: } + [1689674049.504484][17222:17224] CHIP:TOO: [2]: { + [1689674049.504490][17222:17224] CHIP:TOO: OperationalStateID: 1 + [1689674049.504495][17222:17224] CHIP:TOO: } + [1689674049.504503][17222:17224] CHIP:TOO: [3]: { + [1689674049.504508][17222:17224] CHIP:TOO: OperationalStateID: 2 + [1689674049.504514][17222:17224] CHIP:TOO: } + [1689674049.504521][17222:17224] CHIP:TOO: [4]: { + [1689674049.504527][17222:17224] CHIP:TOO: OperationalStateID: 3 + [1689674049.504533][17222:17224] CHIP:TOO: } + [1689674049.504605][17222:17224] CHIP:EM: <<< [E:22830i S:37151 M:4250114 (Ack:140781365)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) + [1689674049.504620][17222:17224] CHIP:IN: (S) Sending msg 4250114 on secure session with LSID: 37151 + disabled: true - label: "Step 4: TH sends Start command to the DUT" PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 5df9a0c8f68d06..517276378087a0 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -175,7 +175,6 @@ "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], "OvenCavityOperationalState": [ "Test_TC_OVENOPSTATE_1_1", - "Test_TC_OVENOPSTATE_2_2", "Test_TC_OVENOPSTATE_2_4" ], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], From 83016e2a93c284228c279a5d3698c6916cad1e4f Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Thu, 18 Jan 2024 13:54:21 -0300 Subject: [PATCH 25/89] Revert "updated Tests and ciTest file" This reverts commit 163c8105fc8e96c1be42e01af5f43cd628697dad. --- .../Test_TC_OVENOPSTATE_2_2.yaml | 39 +++++++------------ src/app/tests/suites/ciTests.json | 1 + 2 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml index 4e723deb9f08a4..ca4d6f2ea026c9 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -45,32 +45,19 @@ tests: - label: "Step 3: TH reads from the DUT the OperationalStateList attribute" PICS: OVENOPSTATE.S.A0003 - verification: | - ./chip-tool operationalstate read operational-state-list 1 1 - - Via the TH (chip-tool), verify: - - all entries include an ID (enum8) and a label (string) - - all provided IDs are in the allowed range - - the list includes IDs for Error (0x03), Running (0x01), and Stopped (0x00) - - [1689674049.504261][17222:17224] CHIP:DMG: } - [1689674049.504390][17222:17224] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0003 DataVersion: 2102885775 - [1689674049.504440][17222:17224] CHIP:TOO: OperationalStateList: 4 entries - [1689674049.504462][17222:17224] CHIP:TOO: [1]: { - [1689674049.504469][17222:17224] CHIP:TOO: OperationalStateID: 0 - [1689674049.504476][17222:17224] CHIP:TOO: } - [1689674049.504484][17222:17224] CHIP:TOO: [2]: { - [1689674049.504490][17222:17224] CHIP:TOO: OperationalStateID: 1 - [1689674049.504495][17222:17224] CHIP:TOO: } - [1689674049.504503][17222:17224] CHIP:TOO: [3]: { - [1689674049.504508][17222:17224] CHIP:TOO: OperationalStateID: 2 - [1689674049.504514][17222:17224] CHIP:TOO: } - [1689674049.504521][17222:17224] CHIP:TOO: [4]: { - [1689674049.504527][17222:17224] CHIP:TOO: OperationalStateID: 3 - [1689674049.504533][17222:17224] CHIP:TOO: } - [1689674049.504605][17222:17224] CHIP:EM: <<< [E:22830i S:37151 M:4250114 (Ack:140781365)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674049.504620][17222:17224] CHIP:IN: (S) Sending msg 4250114 on secure session with LSID: 37151 - disabled: true + command: "readAttribute" + attribute: "OperationalStateList" + response: + value: + [ + { OperationalStateID: 0 }, + { OperationalStateID: 1 }, + { OperationalStateID: 2 }, + { OperationalStateID: 3 }, + ] + + constraints: + type: list - label: "Step 4: TH sends Start command to the DUT" PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index e5a98185cde853..2831f86635538e 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -175,6 +175,7 @@ "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], "OvenCavityOperationalState": [ "Test_TC_OVENOPSTATE_1_1", + "Test_TC_OVENOPSTATE_2_2", "Test_TC_OVENOPSTATE_2_4" ], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], From 9aecda45517c266331cac773a1b1e640b9cd4b09 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Fri, 19 Jan 2024 14:32:41 -0300 Subject: [PATCH 26/89] updated according review --- .../Test_TC_OVENOPSTATE_2_2.yaml | 4 +- .../tests/suites/certification/ci-pics-values | 12 ++--- src/python_testing/TC_OVENOPSTATE_2_1.py | 52 +++++++++---------- src/python_testing/TC_OVENOPSTATE_2_3.py | 34 ++++++------ 4 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml index ca4d6f2ea026c9..0278ff085b201c 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -20,8 +20,8 @@ PICS: config: nodeId: 0x12344321 - cluster: "Basic Information" - endpoint: 0 + cluster: "Oven Cavity Operational State" + endpoint: 1 tests: - label: "Note" diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 7b048b53e7212d..61c3592316f2e3 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -1835,15 +1835,15 @@ OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE=1 # Server Attributes OVENOPSTATE.S.A0000=1 OVENOPSTATE.S.A0001=1 -OVENOPSTATE.S.A0002=1 +OVENOPSTATE.S.A0002=0 OVENOPSTATE.S.A0003=1 OVENOPSTATE.S.A0004=1 OVENOPSTATE.S.A0005=1 -OVENOPSTATE.S.C00.Rsp=1 -OVENOPSTATE.S.C01.Rsp=1 -OVENOPSTATE.S.C02.Rsp=1 -OVENOPSTATE.S.C03.Rsp=1 -OVENOPSTATE.S.C04.Tx=1 +OVENOPSTATE.S.C00.Rsp=0 +OVENOPSTATE.S.C01.Rsp=0 +OVENOPSTATE.S.C02.Rsp=0 +OVENOPSTATE.S.C03.Rsp=0 +OVENOPSTATE.S.C04.Tx=0 # Server Events OVENOPSTATE.S.E00=1 diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index d029deb2abd51a..4fb816cf757ed9 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -34,18 +34,18 @@ async def read_mod_attribute_expect_success(self, endpoint, attribute): return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) async def read_and_validate_opstate(self, step, expected_state): - self.print_step(step, "Read OvenCavityOperationalState attribute") + self.print_step(step, "Read OperationalState attribute") operational_state = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OvenCavityOperationalState) - logging.info("OvenCavityOperationalState: %s" % (operational_state)) + endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) asserts.assert_equal(operational_state, expected_state, - "OvenCavityOperationalState(%s) should equal %s" % (operational_state, expected_state)) + "OperationalState(%s) should equal %s" % (operational_state, expected_state)) async def read_and_validate_operror(self, step, expected_error): self.print_step(step, "Read OperationalError attribute") operational_error = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OvenCavityOperationalError) - logging.info("OvenCavityOperationalError: %s" % (operational_error)) + endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalError) + logging.info("OperationalError: %s" % (operational_error)) asserts.assert_equal(operational_error.errorStateID, expected_error, "errorStateID(%s) should equal %s" % (operational_error.errorStateID, expected_error)) @@ -98,61 +98,61 @@ async def test_TC_OVENOPSTATE_2_1(self): "CountdownTime(%s) must be between 0 and 259200" % countdown_time) if self.check_pics("OVENOPSTATE.S.A0003"): - self.print_step(5, "Read OvenCavityOperationalStateList attribute") + self.print_step(5, "Read OperationalStateList attribute") operational_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OvenCavityOperationalStateList) + attribute=attributes.OperationalStateList) - logging.info("OvenCavityOperationalStateList: %s" % (operational_state_list)) + logging.info("OperationalStateList: %s" % (operational_state_list)) - defined_states = [state.value for state in Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum - if state is not Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kUnknownEnumValue] + defined_states = [state.value for state in Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum + if state is not Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] for state in operational_state_list: in_range = (0x80 <= state.operationalStateID <= 0xBF) asserts.assert_true(state.operationalStateID in defined_states or in_range, - "Found a OvenCavityOperationalStateList entry with invalid ID value!") + "Found a OperationalStateList entry with invalid ID value!") if in_range: asserts.assert_true(state.operationalStateLabel is not None, - "The OvenCavityOperationalStateLabel should be populated") - if state.operationalStateID == Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kError: + "The OperationalStateLabel should be populated") + if state.operationalStateID == Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kError: error_state_present = True - asserts.assert_true(error_state_present, "The OvenCavityOperationalStateList does not have an ID entry of Error(0x03)") + asserts.assert_true(error_state_present, "The OperationalStateList does not have an ID entry of Error(0x03)") if self.check_pics("OVENOPSTATE.S.A0004"): - self.print_step(6, "Read OvenCavityOperationalState attribute") + self.print_step(6, "Read OperationalState attribute") operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OvenCavityOperationalState) + attribute=attributes.OperationalState) - logging.info("OvenCavityOperationalState: %s" % (operational_state)) + logging.info("OperationalState: %s" % (operational_state)) in_range = (0x80 <= operational_state <= 0xBF) asserts.assert_true(operational_state in defined_states or in_range, - "OvenCavityOperationalState has an invalid ID value!") + "OperationalState has an invalid ID value!") if self.check_pics("OVENOPSTATE.S.M.ST_STOPPED"): self.print_step("6a", "Manually put the device in the stopped state") input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6b", expected_state=Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kStopped) + await self.read_and_validate_opstate(step="6b", expected_state=Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kStopped) if self.check_pics("OVENOPSTATE.S.M.ST_RUNNING"): self.print_step("6c", "Manually put the device in the running state") input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6d", expected_state=Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kRunning) + await self.read_and_validate_opstate(step="6d", expected_state=Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning) if self.check_pics("OVENOPSTATE.S.M.ST_PAUSED"): self.print_step("6e", "Manually put the device in the paused state") input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6f", expected_state=Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kPaused) + await self.read_and_validate_opstate(step="6f", expected_state=Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kPaused) if self.check_pics("OVENOPSTATE.S.M.ST_ERROR"): self.print_step("6g", "Manually put the device in the error state") input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6h", expected_state=Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kError) + await self.read_and_validate_opstate(step="6h", expected_state=Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kError) if self.check_pics("OVENOPSTATE.S.A0005"): - self.print_step(7, "Read OvenCavityOperationalError attribute") + self.print_step(7, "Read OperationalError attribute") operational_error = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OvenCavityOperationalError) + attribute=attributes.OperationalError) - logging.info("OvenCavityOperationalError: %s" % (operational_error)) + logging.info("OperationalError: %s" % (operational_error)) # Defined Errors defined_errors = [error.value for error in Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py index 6ebcd4759b70c9..1d0d94e7a3d69c 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_3.py +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -36,13 +36,13 @@ async def read_mod_attribute_expect_success(self, endpoint, attribute): async def send_pause_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Pause: ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Pause(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OvenCavityOperationalCommandResponse), + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), "Unexpected return type for Pause") return ret async def send_resume_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Resume: ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Resume(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OvenCavityOperationalCommandResponse), + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), "Unexpected return type for Resume") return ret @@ -67,31 +67,31 @@ async def test_TC_OVENOPSTATE_2_3(self): self.print_step(2, "Manually put the device in a state where it can receive a Pause command") input("Press Enter when done.\n") - self.print_step(3, "Read OvenCavityOperationalStateList attribute") + self.print_step(3, "Read OperationalStateList attribute") op_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OvenCavityOperationalStateList) + attribute=attributes.OperationalStateList) - logging.info("OvenCavityOperationalStateList: %s" % (op_state_list)) + logging.info("OperationalStateList: %s" % (op_state_list)) - defined_states = [state.value for state in Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum - if state is not Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kUnknownEnumValue] + defined_states = [state.value for state in Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum + if state is not Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] state_ids = set([s.operationalStateID for s in op_state_list]) asserts.assert_true(all(id in state_ids for id in defined_states), - "OvenCavityOperationalStateList is missing a required entry") + "OperationalStateList is missing a required entry") self.print_step(4, "Send Pause command") ret = await self.send_pause_cmd() asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - self.print_step(5, "Read OvenCavityOperationalState attribute") + self.print_step(5, "Read OperationalState attribute") operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OvenCavityOperationalState) - logging.info("OvenCavityOperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kPaused, - "OvenCavityOperationalState ID should be Paused(0x02)") + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kPaused, + "OperationalState ID should be Paused(0x02)") if self.check_pics("OVENOPSTATE.S.A0002"): self.print_step(6, "Read CountdownTime attribute") @@ -124,11 +124,11 @@ async def test_TC_OVENOPSTATE_2_3(self): asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - self.print_step(11, "Read OvenCavityOperationalState attribute") + self.print_step(11, "Read OperationalState attribute") operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OvenCavityOperationalState) - logging.info("OvenCavityOperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OvenCavityOperationalStateEnum.kRunning, + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, "OperationalState(%s) should be Running(0x01)" % operational_state) self.print_step(12, "Send Resume command") From b057c11a05a2990bf13f2247c0b1b544cf8baed1 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Fri, 19 Jan 2024 14:33:29 -0300 Subject: [PATCH 27/89] zap regen --- ...olClusterAccessControlEntryChangedEvent.kt | 99 +- ...usterAccessControlExtensionChangedEvent.kt | 99 +- .../AccountLoginClusterLoggedOutEvent.kt | 31 +- .../ActionsClusterActionFailedEvent.kt | 21 +- .../ActionsClusterStateChangedEvent.kt | 15 +- .../BasicInformationClusterLeaveEvent.kt | 13 +- ...InformationClusterReachableChangedEvent.kt | 13 +- .../BasicInformationClusterStartUpEvent.kt | 13 +- .../BooleanStateClusterStateChangeEvent.kt | 13 +- ...igurationClusterAlarmsStateChangedEvent.kt | 38 +- ...ateConfigurationClusterSensorFaultEvent.kt | 16 +- ...InformationClusterReachableChangedEvent.kt | 16 +- ...viceBasicInformationClusterStartUpEvent.kt | 16 +- ...lusterLoadControlEventStatusChangeEvent.kt | 281 +- ...rgyManagementClusterPowerAdjustEndEvent.kt | 22 +- ...viceEnergyManagementClusterResumedEvent.kt | 13 +- .../DishwasherAlarmClusterNotifyEvent.kt | 21 +- .../DoorLockClusterDoorLockAlarmEvent.kt | 13 +- .../DoorLockClusterDoorStateChangeEvent.kt | 13 +- .../DoorLockClusterLockOperationErrorEvent.kt | 161 +- .../DoorLockClusterLockOperationEvent.kt | 158 +- .../DoorLockClusterLockUserChangeEvent.kt | 121 +- ...entClusterCumulativeEnergyMeasuredEvent.kt | 74 +- ...ementClusterPeriodicEnergyMeasuredEvent.kt | 74 +- .../EnergyEvseClusterEVConnectedEvent.kt | 13 +- .../EnergyEvseClusterEVNotDetectedEvent.kt | 49 +- ...gyEvseClusterEnergyTransferStartedEvent.kt | 19 +- ...gyEvseClusterEnergyTransferStoppedEvent.kt | 28 +- .../EnergyEvseClusterFaultEvent.kt | 55 +- .../EnergyEvseClusterRFIDEvent.kt | 13 +- ...eneralDiagnosticsClusterBootReasonEvent.kt | 13 +- ...gnosticsClusterHardwareFaultChangeEvent.kt | 49 +- ...agnosticsClusterNetworkFaultChangeEvent.kt | 49 +- ...DiagnosticsClusterRadioFaultChangeEvent.kt | 46 +- .../MediaPlaybackClusterStateChangedEvent.kt | 68 +- ...nalStateClusterOperationCompletionEvent.kt | 99 +- ...tionalStateClusterOperationalErrorEvent.kt | 21 +- ...pdateRequestorClusterDownloadErrorEvent.kt | 73 +- ...ateRequestorClusterStateTransitionEvent.kt | 52 +- ...dateRequestorClusterVersionAppliedEvent.kt | 20 +- ...nalStateClusterOperationCompletionEvent.kt | 99 +- ...tionalStateClusterOperationalErrorEvent.kt | 23 +- ...rSourceClusterBatChargeFaultChangeEvent.kt | 46 +- .../PowerSourceClusterBatFaultChangeEvent.kt | 43 +- ...PowerSourceClusterWiredFaultChangeEvent.kt | 43 +- .../RefrigeratorAlarmClusterNotifyEvent.kt | 21 +- ...nalStateClusterOperationCompletionEvent.kt | 99 +- ...tionalStateClusterOperationalErrorEvent.kt | 24 +- .../SampleMeiClusterPingCountEventEvent.kt | 14 +- .../SmokeCoAlarmClusterCOAlarmEvent.kt | 13 +- ...eCoAlarmClusterInterconnectCOAlarmEvent.kt | 13 +- ...AlarmClusterInterconnectSmokeAlarmEvent.kt | 13 +- .../SmokeCoAlarmClusterLowBatteryEvent.kt | 13 +- .../SmokeCoAlarmClusterSmokeAlarmEvent.kt | 13 +- ...areDiagnosticsClusterSoftwareFaultEvent.kt | 54 +- .../SwitchClusterInitialPressEvent.kt | 13 +- .../SwitchClusterLongPressEvent.kt | 13 +- .../SwitchClusterLongReleaseEvent.kt | 13 +- .../SwitchClusterMultiPressCompleteEvent.kt | 20 +- .../SwitchClusterMultiPressOngoingEvent.kt | 20 +- .../SwitchClusterShortReleaseEvent.kt | 13 +- .../SwitchClusterSwitchLatchedEvent.kt | 13 +- ...argetNavigatorClusterTargetUpdatedEvent.kt | 39 +- ...DiagnosticsClusterConnectionStatusEvent.kt | 16 +- ...agnosticsClusterNetworkFaultChangeEvent.kt | 49 +- ...imeSynchronizationClusterDSTStatusEvent.kt | 13 +- ...nchronizationClusterTimeZoneStatusEvent.kt | 32 +- .../UnitTestingClusterTestEventEvent.kt | 65 +- ...estingClusterTestFabricScopedEventEvent.kt | 13 +- ...urationAndControlClusterValveFaultEvent.kt | 16 +- ...AndControlClusterValveStateChangedEvent.kt | 38 +- ...agnosticsClusterAssociationFailureEvent.kt | 23 +- ...DiagnosticsClusterConnectionStatusEvent.kt | 16 +- ...orkDiagnosticsClusterDisconnectionEvent.kt | 16 +- ...sControlClusterAccessControlEntryStruct.kt | 108 +- ...trolClusterAccessControlExtensionStruct.kt | 17 +- ...ControlClusterAccessControlTargetStruct.kt | 82 +- .../structs/ActionsClusterActionStruct.kt | 34 +- .../ActionsClusterEndpointListStruct.kt | 35 +- ...nitoringClusterReplacementProductStruct.kt | 28 +- ...pplicationBasicClusterApplicationStruct.kt | 17 +- ...ationLauncherClusterApplicationEPStruct.kt | 41 +- ...icationLauncherClusterApplicationStruct.kt | 17 +- .../AudioOutputClusterOutputInfoStruct.kt | 15 +- ...nformationClusterCapabilityMinimaStruct.kt | 28 +- ...formationClusterProductAppearanceStruct.kt | 35 +- .../structs/BindingClusterTargetStruct.kt | 92 +- ...formationClusterProductAppearanceStruct.kt | 41 +- .../ChannelClusterAdditionalInfoStruct.kt | 14 +- .../ChannelClusterChannelInfoStruct.kt | 123 +- .../ChannelClusterChannelPagingStruct.kt | 95 +- .../structs/ChannelClusterLineupInfoStruct.kt | 56 +- .../structs/ChannelClusterPageTokenStruct.kt | 71 +- .../ChannelClusterProgramCastStruct.kt | 14 +- .../ChannelClusterProgramCategoryStruct.kt | 32 +- .../structs/ChannelClusterProgramStruct.kt | 434 +- .../structs/ChannelClusterSeriesInfoStruct.kt | 14 +- .../ContentControlClusterRatingNameStruct.kt | 35 +- ...tentLauncherClusterAdditionalInfoStruct.kt | 14 +- ...auncherClusterBrandingInformationStruct.kt | 148 +- ...ntentLauncherClusterContentSearchStruct.kt | 29 +- .../ContentLauncherClusterDimensionStruct.kt | 19 +- .../ContentLauncherClusterParameterStruct.kt | 56 +- ...auncherClusterPlaybackPreferencesStruct.kt | 71 +- ...ntLauncherClusterStyleInformationStruct.kt | 73 +- ...entLauncherClusterTrackPreferenceStruct.kt | 62 +- ...dControlClusterAverageLoadControlStruct.kt | 16 +- ...oadControlClusterDutyCycleControlStruct.kt | 16 +- ...ontrolClusterHeatingSourceControlStruct.kt | 16 +- ...oadControlClusterLoadControlEventStruct.kt | 122 +- ...ClusterLoadControlEventTransitionStruct.kt | 151 +- ...dControlClusterLoadControlProgramStruct.kt | 97 +- ...ControlClusterPowerSavingsControlStruct.kt | 16 +- ...dControlClusterTemperatureControlStruct.kt | 172 +- .../DescriptorClusterDeviceTypeStruct.kt | 14 +- .../DescriptorClusterSemanticTagStruct.kt | 78 +- ...nergyManagementClusterConstraintsStruct.kt | 83 +- ...DeviceEnergyManagementClusterCostStruct.kt | 39 +- ...ceEnergyManagementClusterForecastStruct.kt | 131 +- ...nergyManagementClusterPowerAdjustStruct.kt | 28 +- ...gyManagementClusterSlotAdjustmentStruct.kt | 22 +- ...DeviceEnergyManagementClusterSlotStruct.kt | 311 +- .../DishwasherModeClusterModeOptionStruct.kt | 33 +- .../DishwasherModeClusterModeTagStruct.kt | 32 +- .../DoorLockClusterCredentialStruct.kt | 14 +- ...asurementClusterEnergyMeasurementStruct.kt | 103 +- ...ntClusterMeasurementAccuracyRangeStruct.kt | 146 +- ...urementClusterMeasurementAccuracyStruct.kt | 53 +- ...EvseClusterChargingTargetScheduleStruct.kt | 31 +- .../EnergyEvseClusterChargingTargetStruct.kt | 63 +- .../EnergyPreferenceClusterBalanceStruct.kt | 32 +- .../structs/FixedLabelClusterLabelStruct.kt | 14 +- ...missioningClusterBasicCommissioningInfo.kt | 31 +- ...neralDiagnosticsClusterNetworkInterface.kt | 117 +- ...pKeyManagementClusterGroupInfoMapStruct.kt | 53 +- ...upKeyManagementClusterGroupKeyMapStruct.kt | 19 +- ...upKeyManagementClusterGroupKeySetStruct.kt | 169 +- ...nitoringClusterReplacementProductStruct.kt | 28 +- ...mentClusterMonitoringRegistrationStruct.kt | 28 +- ...aundryWasherModeClusterModeOptionStruct.kt | 33 +- .../LaundryWasherModeClusterModeTagStruct.kt | 32 +- .../MediaInputClusterInputInfoStruct.kt | 21 +- ...iaPlaybackClusterPlaybackPositionStruct.kt | 35 +- ...diaPlaybackClusterTrackAttributesStruct.kt | 53 +- .../MediaPlaybackClusterTrackStruct.kt | 41 +- ...icrowaveOvenModeClusterModeOptionStruct.kt | 33 +- .../MicrowaveOvenModeClusterModeTagStruct.kt | 32 +- .../ModeSelectClusterModeOptionStruct.kt | 33 +- .../ModeSelectClusterSemanticTagStruct.kt | 14 +- ...rkCommissioningClusterNetworkInfoStruct.kt | 99 +- ...gClusterThreadInterfaceScanResultStruct.kt | 43 +- ...ingClusterWiFiInterfaceScanResultStruct.kt | 37 +- ...redentialsClusterFabricDescriptorStruct.kt | 37 +- .../OperationalCredentialsClusterNOCStruct.kt | 40 +- ...OperationalStateClusterErrorStateStruct.kt | 60 +- ...ionalStateClusterOperationalStateStruct.kt | 40 +- ...eUpdateRequestorClusterProviderLocation.kt | 28 +- ...OperationalStateClusterErrorStateStruct.kt | 63 +- ...ionalStateClusterOperationalStateStruct.kt | 43 +- .../OvenModeClusterModeOptionStruct.kt | 33 +- .../structs/OvenModeClusterModeTagStruct.kt | 32 +- ...erSourceClusterBatChargeFaultChangeType.kt | 46 +- .../PowerSourceClusterBatFaultChangeType.kt | 43 +- .../PowerSourceClusterWiredFaultChangeType.kt | 43 +- ...olledCabinetModeClusterModeOptionStruct.kt | 47 +- ...ntrolledCabinetModeClusterModeTagStruct.kt | 38 +- .../RvcCleanModeClusterModeOptionStruct.kt | 33 +- .../RvcCleanModeClusterModeTagStruct.kt | 32 +- ...OperationalStateClusterErrorStateStruct.kt | 60 +- ...ionalStateClusterOperationalStateStruct.kt | 43 +- .../RvcRunModeClusterModeOptionStruct.kt | 33 +- .../structs/RvcRunModeClusterModeTagStruct.kt | 32 +- ...enesManagementClusterAttributeValuePair.kt | 14 +- ...cenesManagementClusterExtensionFieldSet.kt | 31 +- .../ScenesManagementClusterSceneInfoStruct.kt | 34 +- ...reDiagnosticsClusterThreadMetricsStruct.kt | 100 +- .../TargetNavigatorClusterTargetInfoStruct.kt | 14 +- .../structs/ThermostatClusterPresetStruct.kt | 146 +- .../ThermostatClusterPresetTypeStruct.kt | 19 +- .../ThermostatClusterQueuedPresetStruct.kt | 59 +- .../ThermostatClusterScheduleStruct.kt | 139 +- ...ermostatClusterScheduleTransitionStruct.kt | 103 +- .../ThermostatClusterScheduleTypeStruct.kt | 25 +- ...atClusterWeeklyScheduleTransitionStruct.kt | 70 +- ...rkDiagnosticsClusterNeighborTableStruct.kt | 103 +- ...ticsClusterOperationalDatasetComponents.kt | 70 +- ...tworkDiagnosticsClusterRouteTableStruct.kt | 49 +- ...NetworkDiagnosticsClusterSecurityPolicy.kt | 14 +- ...meSynchronizationClusterDSTOffsetStruct.kt | 40 +- ...sterFabricScopedTrustedTimeSourceStruct.kt | 20 +- ...imeSynchronizationClusterTimeZoneStruct.kt | 37 +- ...onizationClusterTrustedTimeSourceStruct.kt | 22 +- ...nitTestingClusterDoubleNestedStructList.kt | 27 +- .../structs/UnitTestingClusterNestedStruct.kt | 19 +- .../UnitTestingClusterNestedStructList.kt | 86 +- ...stingClusterNullablesAndOptionalsStruct.kt | 412 +- .../structs/UnitTestingClusterSimpleStruct.kt | 29 +- .../UnitTestingClusterTestFabricScoped.kt | 147 +- .../UnitTestingClusterTestListStructOctet.kt | 14 +- .../structs/UserLabelClusterLabelStruct.kt | 14 +- .../cluster/clusters/AccessControlCluster.kt | 1251 +- .../cluster/clusters/AccountLoginCluster.kt | 734 +- .../cluster/clusters/ActionsCluster.kt | 1185 +- .../ActivatedCarbonFilterMonitoringCluster.kt | 1404 +- .../AdministratorCommissioningCluster.kt | 1039 +- .../cluster/clusters/AirQualityCluster.kt | 757 +- .../clusters/ApplicationBasicCluster.kt | 1466 +- .../clusters/ApplicationLauncherCluster.kt | 1130 +- .../cluster/clusters/AudioOutputCluster.kt | 890 +- .../clusters/BallastConfigurationCluster.kt | 2474 +-- .../cluster/clusters/BarrierControlCluster.kt | 1802 +- .../clusters/BasicInformationCluster.kt | 2742 +-- .../clusters/BinaryInputBasicCluster.kt | 1720 +- .../cluster/clusters/BindingCluster.kt | 829 +- .../cluster/clusters/BooleanStateCluster.kt | 762 +- .../BooleanStateConfigurationCluster.kt | 1579 +- .../BridgedDeviceBasicInformationCluster.kt | 2394 +-- ...nDioxideConcentrationMeasurementCluster.kt | 2048 +-- ...MonoxideConcentrationMeasurementCluster.kt | 2048 +-- .../cluster/clusters/ChannelCluster.kt | 1304 +- .../cluster/clusters/ColorControlCluster.kt | 6889 ++++---- .../clusters/ContentAppObserverCluster.kt | 763 +- .../cluster/clusters/ContentControlCluster.kt | 1648 +- .../clusters/ContentLauncherCluster.kt | 1055 +- .../DemandResponseLoadControlCluster.kt | 1548 +- .../cluster/clusters/DescriptorCluster.kt | 1314 +- .../clusters/DeviceEnergyManagementCluster.kt | 1569 +- .../cluster/clusters/DiagnosticLogsCluster.kt | 744 +- .../clusters/DishwasherAlarmCluster.kt | 1036 +- .../cluster/clusters/DishwasherModeCluster.kt | 1271 +- .../cluster/clusters/DoorLockCluster.kt | 6839 ++++---- .../ElectricalEnergyMeasurementCluster.kt | 1372 +- .../clusters/ElectricalMeasurementCluster.kt | 13931 ++++++++-------- .../cluster/clusters/EnergyEvseCluster.kt | 3497 ++-- .../clusters/EnergyPreferenceCluster.kt | 1379 +- .../EthernetNetworkDiagnosticsCluster.kt | 1760 +- .../cluster/clusters/FanControlCluster.kt | 2111 +-- .../cluster/clusters/FaultInjectionCluster.kt | 709 +- .../cluster/clusters/FixedLabelCluster.kt | 802 +- .../clusters/FlowMeasurementCluster.kt | 1171 +- ...aldehydeConcentrationMeasurementCluster.kt | 2048 +-- .../clusters/GeneralCommissioningCluster.kt | 1253 +- .../clusters/GeneralDiagnosticsCluster.kt | 1780 +- .../clusters/GroupKeyManagementCluster.kt | 1199 +- .../cluster/clusters/GroupsCluster.kt | 986 +- .../clusters/HepaFilterMonitoringCluster.kt | 1404 +- .../cluster/clusters/IcdManagementCluster.kt | 1679 +- .../cluster/clusters/IdentifyCluster.kt | 873 +- .../clusters/IlluminanceMeasurementCluster.kt | 1314 +- .../cluster/clusters/KeypadInputCluster.kt | 705 +- .../clusters/LaundryDryerControlsCluster.kt | 952 +- .../clusters/LaundryWasherControlsCluster.kt | 1270 +- .../clusters/LaundryWasherModeCluster.kt | 1271 +- .../cluster/clusters/LevelControlCluster.kt | 2542 +-- .../LocalizationConfigurationCluster.kt | 906 +- .../cluster/clusters/LowPowerCluster.kt | 681 +- .../cluster/clusters/MediaInputCluster.kt | 894 +- .../cluster/clusters/MediaPlaybackCluster.kt | 2644 +-- .../clusters/MicrowaveOvenControlCluster.kt | 1664 +- .../clusters/MicrowaveOvenModeCluster.kt | 883 +- .../cluster/clusters/ModeSelectCluster.kt | 1426 +- .../clusters/NetworkCommissioningCluster.kt | 2582 +-- ...nDioxideConcentrationMeasurementCluster.kt | 2048 +-- .../clusters/OccupancySensingCluster.kt | 2111 +-- .../cluster/clusters/OnOffCluster.kt | 1330 +- .../OnOffSwitchConfigurationCluster.kt | 861 +- .../clusters/OperationalCredentialsCluster.kt | 1709 +- .../clusters/OperationalStateCluster.kt | 1486 +- .../OtaSoftwareUpdateProviderCluster.kt | 918 +- .../OtaSoftwareUpdateRequestorCluster.kt | 1133 +- .../OvenCavityOperationalStateCluster.kt | 1493 +- .../cluster/clusters/OvenModeCluster.kt | 1266 +- .../OzoneConcentrationMeasurementCluster.kt | 2045 +-- .../Pm10ConcentrationMeasurementCluster.kt | 2045 +-- .../Pm1ConcentrationMeasurementCluster.kt | 2045 +-- .../Pm25ConcentrationMeasurementCluster.kt | 2045 +-- .../cluster/clusters/PowerSourceCluster.kt | 4271 ++--- .../PowerSourceConfigurationCluster.kt | 804 +- .../clusters/PressureMeasurementCluster.kt | 1817 +- .../clusters/ProxyConfigurationCluster.kt | 682 +- .../cluster/clusters/ProxyDiscoveryCluster.kt | 682 +- .../cluster/clusters/ProxyValidCluster.kt | 679 +- .../clusters/PulseWidthModulationCluster.kt | 682 +- .../PumpConfigurationAndControlCluster.kt | 3621 ++-- .../RadonConcentrationMeasurementCluster.kt | 2045 +-- .../clusters/RefrigeratorAlarmCluster.kt | 919 +- ...TemperatureControlledCabinetModeCluster.kt | 1280 +- .../RelativeHumidityMeasurementCluster.kt | 1171 +- .../cluster/clusters/RvcCleanModeCluster.kt | 1102 +- .../clusters/RvcOperationalStateCluster.kt | 1509 +- .../cluster/clusters/RvcRunModeCluster.kt | 1097 +- .../cluster/clusters/SampleMeiCluster.kt | 815 +- .../clusters/ScenesManagementCluster.kt | 2219 +-- .../cluster/clusters/SmokeCoAlarmCluster.kt | 1965 +-- .../clusters/SoftwareDiagnosticsCluster.kt | 1155 +- .../cluster/clusters/SwitchCluster.kt | 944 +- .../clusters/TargetNavigatorCluster.kt | 969 +- .../clusters/TemperatureControlCluster.kt | 1376 +- .../clusters/TemperatureMeasurementCluster.kt | 1171 +- .../cluster/clusters/ThermostatCluster.kt | 8673 +++++----- ...mostatUserInterfaceConfigurationCluster.kt | 1022 +- .../ThreadNetworkDiagnosticsCluster.kt | 7529 +++++---- .../clusters/TimeFormatLocalizationCluster.kt | 1062 +- .../clusters/TimeSynchronizationCluster.kt | 2338 +-- .../cluster/clusters/TimerCluster.kt | 931 +- ...ompoundsConcentrationMeasurementCluster.kt | 2050 +-- .../clusters/UnitLocalizationCluster.kt | 811 +- .../cluster/clusters/UnitTestingCluster.kt | 12274 +++++++------- .../cluster/clusters/UserLabelCluster.kt | 829 +- .../ValveConfigurationAndControlCluster.kt | 2131 +-- .../cluster/clusters/WakeOnLanCluster.kt | 897 +- .../clusters/WiFiNetworkDiagnosticsCluster.kt | 2463 +-- .../cluster/clusters/WindowCoveringCluster.kt | 3122 ++-- ...olClusterAccessControlEntryChangedEvent.kt | 59 +- ...usterAccessControlExtensionChangedEvent.kt | 60 +- .../AccountLoginClusterLoggedOutEvent.kt | 20 +- .../ActionsClusterActionFailedEvent.kt | 6 +- .../ActionsClusterStateChangedEvent.kt | 6 +- .../BasicInformationClusterLeaveEvent.kt | 10 +- ...InformationClusterReachableChangedEvent.kt | 10 +- .../BasicInformationClusterStartUpEvent.kt | 10 +- .../BooleanStateClusterStateChangeEvent.kt | 10 +- ...igurationClusterAlarmsStateChangedEvent.kt | 19 +- ...ateConfigurationClusterSensorFaultEvent.kt | 13 +- ...InformationClusterReachableChangedEvent.kt | 13 +- ...viceBasicInformationClusterStartUpEvent.kt | 13 +- ...lusterLoadControlEventStatusChangeEvent.kt | 214 +- ...rgyManagementClusterPowerAdjustEndEvent.kt | 9 +- ...viceEnergyManagementClusterResumedEvent.kt | 10 +- .../DishwasherAlarmClusterNotifyEvent.kt | 6 +- .../DoorLockClusterDoorLockAlarmEvent.kt | 10 +- .../DoorLockClusterDoorStateChangeEvent.kt | 10 +- .../DoorLockClusterLockOperationErrorEvent.kt | 108 +- .../DoorLockClusterLockOperationEvent.kt | 107 +- .../DoorLockClusterLockUserChangeEvent.kt | 68 +- ...entClusterCumulativeEnergyMeasuredEvent.kt | 53 +- ...ementClusterPeriodicEnergyMeasuredEvent.kt | 53 +- .../EnergyEvseClusterEVConnectedEvent.kt | 10 +- .../EnergyEvseClusterEVNotDetectedEvent.kt | 24 +- ...gyEvseClusterEnergyTransferStartedEvent.kt | 6 +- ...gyEvseClusterEnergyTransferStoppedEvent.kt | 13 +- .../EnergyEvseClusterFaultEvent.kt | 32 +- .../EnergyEvseClusterRFIDEvent.kt | 10 +- ...eneralDiagnosticsClusterBootReasonEvent.kt | 10 +- ...gnosticsClusterHardwareFaultChangeEvent.kt | 34 +- ...agnosticsClusterNetworkFaultChangeEvent.kt | 34 +- ...DiagnosticsClusterRadioFaultChangeEvent.kt | 31 +- .../MediaPlaybackClusterStateChangedEvent.kt | 34 +- ...nalStateClusterOperationCompletionEvent.kt | 68 +- ...tionalStateClusterOperationalErrorEvent.kt | 12 +- ...pdateRequestorClusterDownloadErrorEvent.kt | 42 +- ...ateRequestorClusterStateTransitionEvent.kt | 29 +- ...dateRequestorClusterVersionAppliedEvent.kt | 9 +- ...nalStateClusterOperationCompletionEvent.kt | 68 +- ...tionalStateClusterOperationalErrorEvent.kt | 18 +- ...rSourceClusterBatChargeFaultChangeEvent.kt | 31 +- .../PowerSourceClusterBatFaultChangeEvent.kt | 36 +- ...PowerSourceClusterWiredFaultChangeEvent.kt | 36 +- .../RefrigeratorAlarmClusterNotifyEvent.kt | 6 +- ...nalStateClusterOperationCompletionEvent.kt | 68 +- ...tionalStateClusterOperationalErrorEvent.kt | 15 +- .../SampleMeiClusterPingCountEventEvent.kt | 11 +- .../SmokeCoAlarmClusterCOAlarmEvent.kt | 10 +- ...eCoAlarmClusterInterconnectCOAlarmEvent.kt | 10 +- ...AlarmClusterInterconnectSmokeAlarmEvent.kt | 10 +- .../SmokeCoAlarmClusterLowBatteryEvent.kt | 10 +- .../SmokeCoAlarmClusterSmokeAlarmEvent.kt | 10 +- ...areDiagnosticsClusterSoftwareFaultEvent.kt | 27 +- .../SwitchClusterInitialPressEvent.kt | 10 +- .../SwitchClusterLongPressEvent.kt | 10 +- .../SwitchClusterLongReleaseEvent.kt | 10 +- .../SwitchClusterMultiPressCompleteEvent.kt | 9 +- .../SwitchClusterMultiPressOngoingEvent.kt | 9 +- .../SwitchClusterShortReleaseEvent.kt | 10 +- .../SwitchClusterSwitchLatchedEvent.kt | 10 +- ...argetNavigatorClusterTargetUpdatedEvent.kt | 23 +- ...DiagnosticsClusterConnectionStatusEvent.kt | 13 +- ...agnosticsClusterNetworkFaultChangeEvent.kt | 34 +- ...imeSynchronizationClusterDSTStatusEvent.kt | 10 +- ...nchronizationClusterTimeZoneStatusEvent.kt | 21 +- .../UnitTestingClusterTestEventEvent.kt | 42 +- ...estingClusterTestFabricScopedEventEvent.kt | 10 +- ...urationAndControlClusterValveFaultEvent.kt | 13 +- ...AndControlClusterValveStateChangedEvent.kt | 19 +- ...agnosticsClusterAssociationFailureEvent.kt | 12 +- ...DiagnosticsClusterConnectionStatusEvent.kt | 13 +- ...orkDiagnosticsClusterDisconnectionEvent.kt | 13 +- ...sControlClusterAccessControlEntryStruct.kt | 77 +- ...trolClusterAccessControlExtensionStruct.kt | 9 +- ...ControlClusterAccessControlTargetStruct.kt | 43 +- .../structs/ActionsClusterActionStruct.kt | 13 +- .../ActionsClusterEndpointListStruct.kt | 18 +- ...nitoringClusterReplacementProductStruct.kt | 20 +- ...pplicationBasicClusterApplicationStruct.kt | 4 +- ...ationLauncherClusterApplicationEPStruct.kt | 20 +- ...icationLauncherClusterApplicationStruct.kt | 4 +- .../AudioOutputClusterOutputInfoStruct.kt | 4 +- ...nformationClusterCapabilityMinimaStruct.kt | 15 +- ...formationClusterProductAppearanceStruct.kt | 22 +- .../structs/BindingClusterTargetStruct.kt | 47 +- ...formationClusterProductAppearanceStruct.kt | 22 +- .../ChannelClusterAdditionalInfoStruct.kt | 9 +- .../ChannelClusterChannelInfoStruct.kt | 68 +- .../ChannelClusterChannelPagingStruct.kt | 64 +- .../structs/ChannelClusterLineupInfoStruct.kt | 25 +- .../structs/ChannelClusterPageTokenStruct.kt | 36 +- .../ChannelClusterProgramCastStruct.kt | 9 +- .../ChannelClusterProgramCategoryStruct.kt | 19 +- .../structs/ChannelClusterProgramStruct.kt | 309 +- .../structs/ChannelClusterSeriesInfoStruct.kt | 9 +- .../ContentControlClusterRatingNameStruct.kt | 14 +- ...tentLauncherClusterAdditionalInfoStruct.kt | 9 +- ...auncherClusterBrandingInformationStruct.kt | 97 +- ...ntentLauncherClusterContentSearchStruct.kt | 18 +- .../ContentLauncherClusterDimensionStruct.kt | 4 +- .../ContentLauncherClusterParameterStruct.kt | 35 +- ...auncherClusterPlaybackPreferencesStruct.kt | 52 +- ...ntLauncherClusterStyleInformationStruct.kt | 38 +- ...entLauncherClusterTrackPreferenceStruct.kt | 41 +- ...dControlClusterAverageLoadControlStruct.kt | 13 +- ...oadControlClusterDutyCycleControlStruct.kt | 13 +- ...ontrolClusterHeatingSourceControlStruct.kt | 13 +- ...oadControlClusterLoadControlEventStruct.kt | 75 +- ...ClusterLoadControlEventTransitionStruct.kt | 98 +- ...dControlClusterLoadControlProgramStruct.kt | 56 +- ...ControlClusterPowerSavingsControlStruct.kt | 13 +- ...dControlClusterTemperatureControlStruct.kt | 123 +- .../DescriptorClusterDeviceTypeStruct.kt | 9 +- .../DescriptorClusterSemanticTagStruct.kt | 43 +- ...nergyManagementClusterConstraintsStruct.kt | 44 +- ...DeviceEnergyManagementClusterCostStruct.kt | 14 +- ...ceEnergyManagementClusterForecastStruct.kt | 80 +- ...nergyManagementClusterPowerAdjustStruct.kt | 11 +- ...gyManagementClusterSlotAdjustmentStruct.kt | 9 +- ...DeviceEnergyManagementClusterSlotStruct.kt | 188 +- .../DishwasherModeClusterModeOptionStruct.kt | 18 +- .../DishwasherModeClusterModeTagStruct.kt | 19 +- .../DoorLockClusterCredentialStruct.kt | 9 +- ...asurementClusterEnergyMeasurementStruct.kt | 60 +- ...ntClusterMeasurementAccuracyRangeStruct.kt | 85 +- ...urementClusterMeasurementAccuracyStruct.kt | 36 +- ...EvseClusterChargingTargetScheduleStruct.kt | 21 +- .../EnergyEvseClusterChargingTargetStruct.kt | 34 +- .../EnergyPreferenceClusterBalanceStruct.kt | 19 +- .../structs/FixedLabelClusterLabelStruct.kt | 9 +- ...missioningClusterBasicCommissioningInfo.kt | 20 +- ...neralDiagnosticsClusterNetworkInterface.kt | 80 +- ...pKeyManagementClusterGroupInfoMapStruct.kt | 28 +- ...upKeyManagementClusterGroupKeyMapStruct.kt | 4 +- ...upKeyManagementClusterGroupKeySetStruct.kt | 96 +- ...nitoringClusterReplacementProductStruct.kt | 20 +- ...mentClusterMonitoringRegistrationStruct.kt | 15 +- ...aundryWasherModeClusterModeOptionStruct.kt | 18 +- .../LaundryWasherModeClusterModeTagStruct.kt | 19 +- .../MediaInputClusterInputInfoStruct.kt | 4 +- ...iaPlaybackClusterPlaybackPositionStruct.kt | 22 +- ...diaPlaybackClusterTrackAttributesStruct.kt | 30 +- .../MediaPlaybackClusterTrackStruct.kt | 20 +- ...icrowaveOvenModeClusterModeOptionStruct.kt | 18 +- .../MicrowaveOvenModeClusterModeTagStruct.kt | 19 +- .../ModeSelectClusterModeOptionStruct.kt | 18 +- .../ModeSelectClusterSemanticTagStruct.kt | 9 +- ...rkCommissioningClusterNetworkInfoStruct.kt | 64 +- ...gClusterThreadInterfaceScanResultStruct.kt | 20 +- ...ingClusterWiFiInterfaceScanResultStruct.kt | 18 +- ...redentialsClusterFabricDescriptorStruct.kt | 18 +- .../OperationalCredentialsClusterNOCStruct.kt | 17 +- ...OperationalStateClusterErrorStateStruct.kt | 31 +- ...ionalStateClusterOperationalStateStruct.kt | 19 +- ...eUpdateRequestorClusterProviderLocation.kt | 15 +- ...OperationalStateClusterErrorStateStruct.kt | 36 +- ...ionalStateClusterOperationalStateStruct.kt | 24 +- .../OvenModeClusterModeOptionStruct.kt | 18 +- .../structs/OvenModeClusterModeTagStruct.kt | 19 +- ...erSourceClusterBatChargeFaultChangeType.kt | 33 +- .../PowerSourceClusterBatFaultChangeType.kt | 38 +- .../PowerSourceClusterWiredFaultChangeType.kt | 38 +- ...olledCabinetModeClusterModeOptionStruct.kt | 34 +- ...ntrolledCabinetModeClusterModeTagStruct.kt | 19 +- .../RvcCleanModeClusterModeOptionStruct.kt | 18 +- .../RvcCleanModeClusterModeTagStruct.kt | 19 +- ...OperationalStateClusterErrorStateStruct.kt | 31 +- ...ionalStateClusterOperationalStateStruct.kt | 24 +- .../RvcRunModeClusterModeOptionStruct.kt | 18 +- .../structs/RvcRunModeClusterModeTagStruct.kt | 19 +- ...enesManagementClusterAttributeValuePair.kt | 9 +- ...cenesManagementClusterExtensionFieldSet.kt | 18 +- .../ScenesManagementClusterSceneInfoStruct.kt | 13 +- ...reDiagnosticsClusterThreadMetricsStruct.kt | 55 +- .../TargetNavigatorClusterTargetInfoStruct.kt | 9 +- .../structs/ThermostatClusterPresetStruct.kt | 87 +- .../ThermostatClusterPresetTypeStruct.kt | 4 +- .../ThermostatClusterQueuedPresetStruct.kt | 30 +- .../ThermostatClusterScheduleStruct.kt | 88 +- ...ermostatClusterScheduleTransitionStruct.kt | 56 +- .../ThermostatClusterScheduleTypeStruct.kt | 10 +- ...atClusterWeeklyScheduleTransitionStruct.kt | 41 +- ...rkDiagnosticsClusterNeighborTableStruct.kt | 52 +- ...ticsClusterOperationalDatasetComponents.kt | 39 +- ...tworkDiagnosticsClusterRouteTableStruct.kt | 22 +- ...NetworkDiagnosticsClusterSecurityPolicy.kt | 9 +- ...meSynchronizationClusterDSTOffsetStruct.kt | 17 +- ...sterFabricScopedTrustedTimeSourceStruct.kt | 9 +- ...imeSynchronizationClusterTimeZoneStruct.kt | 14 +- ...onizationClusterTrustedTimeSourceStruct.kt | 9 +- ...nitTestingClusterDoubleNestedStructList.kt | 22 +- .../structs/UnitTestingClusterNestedStruct.kt | 4 +- .../UnitTestingClusterNestedStructList.kt | 63 +- ...stingClusterNullablesAndOptionalsStruct.kt | 295 +- .../structs/UnitTestingClusterSimpleStruct.kt | 4 +- .../UnitTestingClusterTestFabricScoped.kt | 100 +- .../UnitTestingClusterTestListStructOctet.kt | 9 +- .../structs/UserLabelClusterLabelStruct.kt | 9 +- .../zap-generated/test/Commands.h | 114 + 514 files changed, 120786 insertions(+), 109667 deletions(-) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt index a206757d729531..75edd8da4997e5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt @@ -17,20 +17,22 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccessControlClusterAccessControlEntryChangedEvent( - val adminNodeID: ULong?, - val adminPasscodeID: UInt?, - val changeType: UInt, - val latestValue: - chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct?, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class AccessControlClusterAccessControlEntryChangedEvent ( + val adminNodeID: ULong?, + val adminPasscodeID: UInt?, + val changeType: UInt, + val latestValue: chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct?, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlEntryChangedEvent {\n") append("\tadminNodeID : $adminNodeID\n") append("\tadminPasscodeID : $adminPasscodeID\n") @@ -44,21 +46,21 @@ class AccessControlClusterAccessControlEntryChangedEvent( tlvWriter.apply { startStructure(tlvTag) if (adminNodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } if (adminPasscodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } put(ContextSpecificTag(TAG_CHANGE_TYPE), changeType) if (latestValue != null) { - latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) - } else { - putNull(ContextSpecificTag(TAG_LATEST_VALUE)) - } + latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) + } else { + putNull(ContextSpecificTag(TAG_LATEST_VALUE)) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -71,45 +73,32 @@ class AccessControlClusterAccessControlEntryChangedEvent( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): AccessControlClusterAccessControlEntryChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlEntryChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUInt(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = - if (!tlvReader.isNull()) { - chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct - .fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = if (!tlvReader.isNull()) { + chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryChangedEvent( - adminNodeID, - adminPasscodeID, - changeType, - latestValue, - fabricIndex - ) + return AccessControlClusterAccessControlEntryChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt index 8377cc96d5f545..31aad754e04833 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt @@ -17,20 +17,22 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccessControlClusterAccessControlExtensionChangedEvent( - val adminNodeID: ULong?, - val adminPasscodeID: UInt?, - val changeType: UInt, - val latestValue: - chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class AccessControlClusterAccessControlExtensionChangedEvent ( + val adminNodeID: ULong?, + val adminPasscodeID: UInt?, + val changeType: UInt, + val latestValue: chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlExtensionChangedEvent {\n") append("\tadminNodeID : $adminNodeID\n") append("\tadminPasscodeID : $adminPasscodeID\n") @@ -44,21 +46,21 @@ class AccessControlClusterAccessControlExtensionChangedEvent( tlvWriter.apply { startStructure(tlvTag) if (adminNodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } if (adminPasscodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } put(ContextSpecificTag(TAG_CHANGE_TYPE), changeType) if (latestValue != null) { - latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) - } else { - putNull(ContextSpecificTag(TAG_LATEST_VALUE)) - } + latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) + } else { + putNull(ContextSpecificTag(TAG_LATEST_VALUE)) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -71,45 +73,32 @@ class AccessControlClusterAccessControlExtensionChangedEvent( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): AccessControlClusterAccessControlExtensionChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlExtensionChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUInt(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = - if (!tlvReader.isNull()) { - chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct - .fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = if (!tlvReader.isNull()) { + chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlExtensionChangedEvent( - adminNodeID, - adminPasscodeID, - changeType, - latestValue, - fabricIndex - ) + return AccessControlClusterAccessControlExtensionChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt index 5c1bf98d9c4f79..b608b8499d5445 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt @@ -17,14 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccountLoginClusterLoggedOutEvent(val node: Optional) { - override fun toString(): String = buildString { +import java.util.Optional + +class AccountLoginClusterLoggedOutEvent ( + val node: Optional) { + override fun toString(): String = buildString { append("AccountLoginClusterLoggedOutEvent {\n") append("\tnode : $node\n") append("}\n") @@ -34,9 +38,9 @@ class AccountLoginClusterLoggedOutEvent(val node: Optional) { tlvWriter.apply { startStructure(tlvTag) if (node.isPresent) { - val optnode = node.get() - put(ContextSpecificTag(TAG_NODE), optnode) - } + val optnode = node.get() + put(ContextSpecificTag(TAG_NODE), optnode) + } endStructure() } } @@ -44,15 +48,14 @@ class AccountLoginClusterLoggedOutEvent(val node: Optional) { companion object { private const val TAG_NODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccountLoginClusterLoggedOutEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccountLoginClusterLoggedOutEvent { tlvReader.enterStructure(tlvTag) - val node = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - + val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return AccountLoginClusterLoggedOutEvent(node) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt index ea2f1931564f35..59405162837cd8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt @@ -17,18 +17,21 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ActionsClusterActionFailedEvent( - val actionID: UInt, - val invokeID: ULong, - val newState: UInt, - val error: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ActionsClusterActionFailedEvent ( + val actionID: UInt, + val invokeID: ULong, + val newState: UInt, + val error: UInt) { + override fun toString(): String = buildString { append("ActionsClusterActionFailedEvent {\n") append("\tactionID : $actionID\n") append("\tinvokeID : $invokeID\n") @@ -54,13 +57,13 @@ class ActionsClusterActionFailedEvent( private const val TAG_NEW_STATE = 2 private const val TAG_ERROR = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterActionFailedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterActionFailedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUInt(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getULong(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) val error = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR)) - + tlvReader.exitContainer() return ActionsClusterActionFailedEvent(actionID, invokeID, newState, error) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt index d95c5e9d66480b..868fbace2ac50e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt @@ -17,13 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ActionsClusterStateChangedEvent(val actionID: UInt, val invokeID: ULong, val newState: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class ActionsClusterStateChangedEvent ( + val actionID: UInt, + val invokeID: ULong, + val newState: UInt) { + override fun toString(): String = buildString { append("ActionsClusterStateChangedEvent {\n") append("\tactionID : $actionID\n") append("\tinvokeID : $invokeID\n") @@ -46,12 +53,12 @@ class ActionsClusterStateChangedEvent(val actionID: UInt, val invokeID: ULong, v private const val TAG_INVOKE_I_D = 1 private const val TAG_NEW_STATE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUInt(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getULong(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) - + tlvReader.exitContainer() return ActionsClusterStateChangedEvent(actionID, invokeID, newState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt index 6d2c068c849afb..8ca5a2a0195e9c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterLeaveEvent(val fabricIndex: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class BasicInformationClusterLeaveEvent ( + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("BasicInformationClusterLeaveEvent {\n") append("\tfabricIndex : $fabricIndex\n") append("}\n") @@ -40,10 +45,10 @@ class BasicInformationClusterLeaveEvent(val fabricIndex: UInt) { companion object { private const val TAG_FABRIC_INDEX = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterLeaveEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterLeaveEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BasicInformationClusterLeaveEvent(fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt index 4e6cb20e13c5e0..4a6bf00b468e48 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { - override fun toString(): String = buildString { +import java.util.Optional + +class BasicInformationClusterReachableChangedEvent ( + val reachableNewValue: Boolean) { + override fun toString(): String = buildString { append("BasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") append("}\n") @@ -40,10 +45,10 @@ class BasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolea companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterReachableChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt index 5ba3a8d3591e9a..b87f7ebee81d72 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterStartUpEvent(val softwareVersion: ULong) { - override fun toString(): String = buildString { +import java.util.Optional + +class BasicInformationClusterStartUpEvent ( + val softwareVersion: ULong) { + override fun toString(): String = buildString { append("BasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("}\n") @@ -40,10 +45,10 @@ class BasicInformationClusterStartUpEvent(val softwareVersion: ULong) { companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterStartUpEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt index f133fd21988180..632226d00db082 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateClusterStateChangeEvent(val stateValue: Boolean) { - override fun toString(): String = buildString { +import java.util.Optional + +class BooleanStateClusterStateChangeEvent ( + val stateValue: Boolean) { + override fun toString(): String = buildString { append("BooleanStateClusterStateChangeEvent {\n") append("\tstateValue : $stateValue\n") append("}\n") @@ -40,10 +45,10 @@ class BooleanStateClusterStateChangeEvent(val stateValue: Boolean) { companion object { private const val TAG_STATE_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BooleanStateClusterStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateClusterStateChangeEvent { tlvReader.enterStructure(tlvTag) val stateValue = tlvReader.getBoolean(ContextSpecificTag(TAG_STATE_VALUE)) - + tlvReader.exitContainer() return BooleanStateClusterStateChangeEvent(stateValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt index 4c7e0fd2bb6110..81fa108828d662 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt @@ -17,17 +17,19 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateConfigurationClusterAlarmsStateChangedEvent( - val alarmsActive: UInt, - val alarmsSuppressed: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class BooleanStateConfigurationClusterAlarmsStateChangedEvent ( + val alarmsActive: UInt, + val alarmsSuppressed: Optional) { + override fun toString(): String = buildString { append("BooleanStateConfigurationClusterAlarmsStateChangedEvent {\n") append("\talarmsActive : $alarmsActive\n") append("\talarmsSuppressed : $alarmsSuppressed\n") @@ -39,9 +41,9 @@ class BooleanStateConfigurationClusterAlarmsStateChangedEvent( startStructure(tlvTag) put(ContextSpecificTag(TAG_ALARMS_ACTIVE), alarmsActive) if (alarmsSuppressed.isPresent) { - val optalarmsSuppressed = alarmsSuppressed.get() - put(ContextSpecificTag(TAG_ALARMS_SUPPRESSED), optalarmsSuppressed) - } + val optalarmsSuppressed = alarmsSuppressed.get() + put(ContextSpecificTag(TAG_ALARMS_SUPPRESSED), optalarmsSuppressed) + } endStructure() } } @@ -50,19 +52,15 @@ class BooleanStateConfigurationClusterAlarmsStateChangedEvent( private const val TAG_ALARMS_ACTIVE = 0 private const val TAG_ALARMS_SUPPRESSED = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): BooleanStateConfigurationClusterAlarmsStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterAlarmsStateChangedEvent { tlvReader.enterStructure(tlvTag) val alarmsActive = tlvReader.getUInt(ContextSpecificTag(TAG_ALARMS_ACTIVE)) - val alarmsSuppressed = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) - } else { - Optional.empty() - } - + val alarmsSuppressed = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return BooleanStateConfigurationClusterAlarmsStateChangedEvent(alarmsActive, alarmsSuppressed) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt index 6232f56300e520..8349bb8fd86151 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateConfigurationClusterSensorFaultEvent(val sensorFault: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class BooleanStateConfigurationClusterSensorFaultEvent ( + val sensorFault: UInt) { + override fun toString(): String = buildString { append("BooleanStateConfigurationClusterSensorFaultEvent {\n") append("\tsensorFault : $sensorFault\n") append("}\n") @@ -40,13 +45,10 @@ class BooleanStateConfigurationClusterSensorFaultEvent(val sensorFault: UInt) { companion object { private const val TAG_SENSOR_FAULT = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): BooleanStateConfigurationClusterSensorFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterSensorFaultEvent { tlvReader.enterStructure(tlvTag) val sensorFault = tlvReader.getUInt(ContextSpecificTag(TAG_SENSOR_FAULT)) - + tlvReader.exitContainer() return BooleanStateConfigurationClusterSensorFaultEvent(sensorFault) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt index 4a66dd930bf954..b5bbae742887b3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { - override fun toString(): String = buildString { +import java.util.Optional + +class BridgedDeviceBasicInformationClusterReachableChangedEvent ( + val reachableNewValue: Boolean) { + override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") append("}\n") @@ -40,13 +45,10 @@ class BridgedDeviceBasicInformationClusterReachableChangedEvent(val reachableNew companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): BridgedDeviceBasicInformationClusterReachableChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt index 33e897ec0dcc9c..ac2c49d2929233 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationClusterStartUpEvent(val softwareVersion: ULong) { - override fun toString(): String = buildString { +import java.util.Optional + +class BridgedDeviceBasicInformationClusterStartUpEvent ( + val softwareVersion: ULong) { + override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("}\n") @@ -40,13 +45,10 @@ class BridgedDeviceBasicInformationClusterStartUpEvent(val softwareVersion: ULon companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): BridgedDeviceBasicInformationClusterStartUpEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt index a4ab48a89bc770..788512180453b2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt @@ -17,40 +17,27 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( - val eventID: ByteArray, - val transitionIndex: UInt?, - val status: UInt, - val criticality: UInt, - val control: UInt, - val temperatureControl: - Optional< - chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct - >?, - val averageLoadControl: - Optional< - chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct - >?, - val dutyCycleControl: - Optional< - chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct - >?, - val powerSavingsControl: - Optional< - chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct - >?, - val heatingSourceControl: - Optional< - chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct - >? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent ( + val eventID: ByteArray, + val transitionIndex: UInt?, + val status: UInt, + val criticality: UInt, + val control: UInt, + val temperatureControl: Optional?, + val averageLoadControl: Optional?, + val dutyCycleControl: Optional?, + val powerSavingsControl: Optional?, + val heatingSourceControl: Optional?) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent {\n") append("\teventID : $eventID\n") append("\ttransitionIndex : $transitionIndex\n") @@ -70,53 +57,53 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( startStructure(tlvTag) put(ContextSpecificTag(TAG_EVENT_I_D), eventID) if (transitionIndex != null) { - put(ContextSpecificTag(TAG_TRANSITION_INDEX), transitionIndex) - } else { - putNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) - } + put(ContextSpecificTag(TAG_TRANSITION_INDEX), transitionIndex) + } else { + putNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) + } put(ContextSpecificTag(TAG_STATUS), status) put(ContextSpecificTag(TAG_CRITICALITY), criticality) put(ContextSpecificTag(TAG_CONTROL), control) if (temperatureControl != null) { - if (temperatureControl.isPresent) { - val opttemperatureControl = temperatureControl.get() - opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) - } + if (temperatureControl.isPresent) { + val opttemperatureControl = temperatureControl.get() + opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) + } if (averageLoadControl != null) { - if (averageLoadControl.isPresent) { - val optaverageLoadControl = averageLoadControl.get() - optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) - } + if (averageLoadControl.isPresent) { + val optaverageLoadControl = averageLoadControl.get() + optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) + } if (dutyCycleControl != null) { - if (dutyCycleControl.isPresent) { - val optdutyCycleControl = dutyCycleControl.get() - optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) - } + if (dutyCycleControl.isPresent) { + val optdutyCycleControl = dutyCycleControl.get() + optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) + } if (powerSavingsControl != null) { - if (powerSavingsControl.isPresent) { - val optpowerSavingsControl = powerSavingsControl.get() - optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) - } + if (powerSavingsControl.isPresent) { + val optpowerSavingsControl = powerSavingsControl.get() + optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) + } if (heatingSourceControl != null) { - if (heatingSourceControl.isPresent) { - val optheatingSourceControl = heatingSourceControl.get() - optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) - } + if (heatingSourceControl.isPresent) { + val optheatingSourceControl = heatingSourceControl.get() + optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) + } endStructure() } } @@ -133,112 +120,72 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( private const val TAG_POWER_SAVINGS_CONTROL = 8 private const val TAG_HEATING_SOURCE_CONTROL = 9 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val transitionIndex = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) - null - } + val transitionIndex = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) + null + } val status = tlvReader.getUInt(ContextSpecificTag(TAG_STATUS)) val criticality = tlvReader.getUInt(ContextSpecificTag(TAG_CRITICALITY)) val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of( - chip.devicecontroller.cluster.structs - .DemandResponseLoadControlClusterTemperatureControlStruct - .fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) - null - } - val averageLoadControl = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of( - chip.devicecontroller.cluster.structs - .DemandResponseLoadControlClusterAverageLoadControlStruct - .fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) - null - } - val dutyCycleControl = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of( - chip.devicecontroller.cluster.structs - .DemandResponseLoadControlClusterDutyCycleControlStruct - .fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) - null - } - val powerSavingsControl = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of( - chip.devicecontroller.cluster.structs - .DemandResponseLoadControlClusterPowerSavingsControlStruct - .fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) - null - } - val heatingSourceControl = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of( - chip.devicecontroller.cluster.structs - .DemandResponseLoadControlClusterHeatingSourceControlStruct - .fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) - null - } - + val temperatureControl = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) + null + } + val averageLoadControl = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) + null + } + val dutyCycleControl = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) + null + } + val powerSavingsControl = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) + null + } + val heatingSourceControl = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( - eventID, - transitionIndex, - status, - criticality, - control, - temperatureControl, - averageLoadControl, - dutyCycleControl, - powerSavingsControl, - heatingSourceControl - ) + return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent(eventID, transitionIndex, status, criticality, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt index 4bb96ee1c6026f..80397f205a2435 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementClusterPowerAdjustEndEvent( - val cause: UInt, - val duration: ULong, - val energyUse: Long -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DeviceEnergyManagementClusterPowerAdjustEndEvent ( + val cause: UInt, + val duration: ULong, + val energyUse: Long) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterPowerAdjustEndEvent {\n") append("\tcause : $cause\n") append("\tduration : $duration\n") @@ -50,15 +53,12 @@ class DeviceEnergyManagementClusterPowerAdjustEndEvent( private const val TAG_DURATION = 1 private const val TAG_ENERGY_USE = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DeviceEnergyManagementClusterPowerAdjustEndEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterPowerAdjustEndEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUInt(ContextSpecificTag(TAG_CAUSE)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) val energyUse = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_USE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterPowerAdjustEndEvent(cause, duration, energyUse) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt index 5b4be5cfc2fd55..9d64e16ea5a9fd 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementClusterResumedEvent(val cause: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class DeviceEnergyManagementClusterResumedEvent ( + val cause: UInt) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterResumedEvent {\n") append("\tcause : $cause\n") append("}\n") @@ -40,10 +45,10 @@ class DeviceEnergyManagementClusterResumedEvent(val cause: UInt) { companion object { private const val TAG_CAUSE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterResumedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterResumedEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUInt(ContextSpecificTag(TAG_CAUSE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterResumedEvent(cause) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt index 233b0d7030c8e5..71bdf0da0ad747 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt @@ -17,18 +17,21 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherAlarmClusterNotifyEvent( - val active: ULong, - val inactive: ULong, - val state: ULong, - val mask: ULong -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DishwasherAlarmClusterNotifyEvent ( + val active: ULong, + val inactive: ULong, + val state: ULong, + val mask: ULong) { + override fun toString(): String = buildString { append("DishwasherAlarmClusterNotifyEvent {\n") append("\tactive : $active\n") append("\tinactive : $inactive\n") @@ -54,13 +57,13 @@ class DishwasherAlarmClusterNotifyEvent( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getULong(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getULong(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getULong(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getULong(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return DishwasherAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt index 918abe443473eb..a64fa042cfcd15 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterDoorLockAlarmEvent(val alarmCode: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class DoorLockClusterDoorLockAlarmEvent ( + val alarmCode: UInt) { + override fun toString(): String = buildString { append("DoorLockClusterDoorLockAlarmEvent {\n") append("\talarmCode : $alarmCode\n") append("}\n") @@ -40,10 +45,10 @@ class DoorLockClusterDoorLockAlarmEvent(val alarmCode: UInt) { companion object { private const val TAG_ALARM_CODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorLockAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorLockAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmCode = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_CODE)) - + tlvReader.exitContainer() return DoorLockClusterDoorLockAlarmEvent(alarmCode) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt index 64b69e7e205eb0..bed611cb8674c0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterDoorStateChangeEvent(val doorState: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class DoorLockClusterDoorStateChangeEvent ( + val doorState: UInt) { + override fun toString(): String = buildString { append("DoorLockClusterDoorStateChangeEvent {\n") append("\tdoorState : $doorState\n") append("}\n") @@ -40,10 +45,10 @@ class DoorLockClusterDoorStateChangeEvent(val doorState: UInt) { companion object { private const val TAG_DOOR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorStateChangeEvent { tlvReader.enterStructure(tlvTag) val doorState = tlvReader.getUInt(ContextSpecificTag(TAG_DOOR_STATE)) - + tlvReader.exitContainer() return DoorLockClusterDoorStateChangeEvent(doorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt index d943e5d8ece7b8..c57900a30d7946 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt @@ -17,24 +17,24 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterLockOperationErrorEvent( - val lockOperationType: UInt, - val operationSource: UInt, - val operationError: UInt, - val userIndex: UInt?, - val fabricIndex: UInt?, - val sourceNode: ULong?, - val credentials: - Optional>? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DoorLockClusterLockOperationErrorEvent ( + val lockOperationType: UInt, + val operationSource: UInt, + val operationError: UInt, + val userIndex: UInt?, + val fabricIndex: UInt?, + val sourceNode: ULong?, + val credentials: Optional>?) { + override fun toString(): String = buildString { append("DoorLockClusterLockOperationErrorEvent {\n") append("\tlockOperationType : $lockOperationType\n") append("\toperationSource : $operationSource\n") @@ -53,32 +53,32 @@ class DoorLockClusterLockOperationErrorEvent( put(ContextSpecificTag(TAG_OPERATION_SOURCE), operationSource) put(ContextSpecificTag(TAG_OPERATION_ERROR), operationError) if (userIndex != null) { - put(ContextSpecificTag(TAG_USER_INDEX), userIndex) - } else { - putNull(ContextSpecificTag(TAG_USER_INDEX)) - } + put(ContextSpecificTag(TAG_USER_INDEX), userIndex) + } else { + putNull(ContextSpecificTag(TAG_USER_INDEX)) + } if (fabricIndex != null) { - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - } else { - putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - } + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + } else { + putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + } if (sourceNode != null) { - put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) - } else { - putNull(ContextSpecificTag(TAG_SOURCE_NODE)) - } + put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) + } else { + putNull(ContextSpecificTag(TAG_SOURCE_NODE)) + } if (credentials != null) { - if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() - } - } else { - putNull(ContextSpecificTag(TAG_CREDENTIALS)) + if (credentials.isPresent) { + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) } + endArray() + } + } else { + putNull(ContextSpecificTag(TAG_CREDENTIALS)) + } endStructure() } } @@ -92,68 +92,49 @@ class DoorLockClusterLockOperationErrorEvent( private const val TAG_SOURCE_NODE = 5 private const val TAG_CREDENTIALS = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationErrorEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) val operationError = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_ERROR)) - val userIndex = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while (!tlvReader.isEndOfContainer()) { - this.add( - chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null - } - + val userIndex = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while(!tlvReader.isEndOfContainer()) { + this.add(chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationErrorEvent( - lockOperationType, - operationSource, - operationError, - userIndex, - fabricIndex, - sourceNode, - credentials - ) + return DoorLockClusterLockOperationErrorEvent(lockOperationType, operationSource, operationError, userIndex, fabricIndex, sourceNode, credentials) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt index 0e7c7e678bac46..e86a8e434ee3ae 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt @@ -17,23 +17,23 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterLockOperationEvent( - val lockOperationType: UInt, - val operationSource: UInt, - val userIndex: UInt?, - val fabricIndex: UInt?, - val sourceNode: ULong?, - val credentials: - Optional>? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DoorLockClusterLockOperationEvent ( + val lockOperationType: UInt, + val operationSource: UInt, + val userIndex: UInt?, + val fabricIndex: UInt?, + val sourceNode: ULong?, + val credentials: Optional>?) { + override fun toString(): String = buildString { append("DoorLockClusterLockOperationEvent {\n") append("\tlockOperationType : $lockOperationType\n") append("\toperationSource : $operationSource\n") @@ -50,32 +50,32 @@ class DoorLockClusterLockOperationEvent( put(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE), lockOperationType) put(ContextSpecificTag(TAG_OPERATION_SOURCE), operationSource) if (userIndex != null) { - put(ContextSpecificTag(TAG_USER_INDEX), userIndex) - } else { - putNull(ContextSpecificTag(TAG_USER_INDEX)) - } + put(ContextSpecificTag(TAG_USER_INDEX), userIndex) + } else { + putNull(ContextSpecificTag(TAG_USER_INDEX)) + } if (fabricIndex != null) { - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - } else { - putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - } + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + } else { + putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + } if (sourceNode != null) { - put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) - } else { - putNull(ContextSpecificTag(TAG_SOURCE_NODE)) - } + put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) + } else { + putNull(ContextSpecificTag(TAG_SOURCE_NODE)) + } if (credentials != null) { - if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() - } - } else { - putNull(ContextSpecificTag(TAG_CREDENTIALS)) + if (credentials.isPresent) { + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) } + endArray() + } + } else { + putNull(ContextSpecificTag(TAG_CREDENTIALS)) + } endStructure() } } @@ -88,66 +88,48 @@ class DoorLockClusterLockOperationEvent( private const val TAG_SOURCE_NODE = 4 private const val TAG_CREDENTIALS = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while (!tlvReader.isEndOfContainer()) { - this.add( - chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null - } - + val userIndex = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while(!tlvReader.isEndOfContainer()) { + this.add(chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationEvent( - lockOperationType, - operationSource, - userIndex, - fabricIndex, - sourceNode, - credentials - ) + return DoorLockClusterLockOperationEvent(lockOperationType, operationSource, userIndex, fabricIndex, sourceNode, credentials) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt index a5fc3f3725485e..7ef7dc4931b846 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt @@ -17,21 +17,24 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterLockUserChangeEvent( - val lockDataType: UInt, - val dataOperationType: UInt, - val operationSource: UInt, - val userIndex: UInt?, - val fabricIndex: UInt?, - val sourceNode: ULong?, - val dataIndex: UInt? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DoorLockClusterLockUserChangeEvent ( + val lockDataType: UInt, + val dataOperationType: UInt, + val operationSource: UInt, + val userIndex: UInt?, + val fabricIndex: UInt?, + val sourceNode: ULong?, + val dataIndex: UInt?) { + override fun toString(): String = buildString { append("DoorLockClusterLockUserChangeEvent {\n") append("\tlockDataType : $lockDataType\n") append("\tdataOperationType : $dataOperationType\n") @@ -50,25 +53,25 @@ class DoorLockClusterLockUserChangeEvent( put(ContextSpecificTag(TAG_DATA_OPERATION_TYPE), dataOperationType) put(ContextSpecificTag(TAG_OPERATION_SOURCE), operationSource) if (userIndex != null) { - put(ContextSpecificTag(TAG_USER_INDEX), userIndex) - } else { - putNull(ContextSpecificTag(TAG_USER_INDEX)) - } + put(ContextSpecificTag(TAG_USER_INDEX), userIndex) + } else { + putNull(ContextSpecificTag(TAG_USER_INDEX)) + } if (fabricIndex != null) { - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - } else { - putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - } + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + } else { + putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + } if (sourceNode != null) { - put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) - } else { - putNull(ContextSpecificTag(TAG_SOURCE_NODE)) - } + put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) + } else { + putNull(ContextSpecificTag(TAG_SOURCE_NODE)) + } if (dataIndex != null) { - put(ContextSpecificTag(TAG_DATA_INDEX), dataIndex) - } else { - putNull(ContextSpecificTag(TAG_DATA_INDEX)) - } + put(ContextSpecificTag(TAG_DATA_INDEX), dataIndex) + } else { + putNull(ContextSpecificTag(TAG_DATA_INDEX)) + } endStructure() } } @@ -82,51 +85,39 @@ class DoorLockClusterLockUserChangeEvent( private const val TAG_SOURCE_NODE = 5 private const val TAG_DATA_INDEX = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockUserChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockUserChangeEvent { tlvReader.enterStructure(tlvTag) val lockDataType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_DATA_TYPE)) val dataOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_DATA_OPERATION_TYPE)) val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val dataIndex = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_DATA_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) - null - } - + val userIndex = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val dataIndex = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_DATA_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockUserChangeEvent( - lockDataType, - dataOperationType, - operationSource, - userIndex, - fabricIndex, - sourceNode, - dataIndex - ) + return DoorLockClusterLockUserChangeEvent(lockDataType, dataOperationType, operationSource, userIndex, fabricIndex, sourceNode, dataIndex) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt index 8e0a4253bbc183..5ffcdf60628cff 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt @@ -17,23 +17,19 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( - val energyImported: - Optional< - chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - >, - val energyExported: - Optional< - chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - > -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent ( + val energyImported: Optional, + val energyExported: Optional) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent {\n") append("\tenergyImported : $energyImported\n") append("\tenergyExported : $energyExported\n") @@ -44,13 +40,13 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( tlvWriter.apply { startStructure(tlvTag) if (energyImported.isPresent) { - val optenergyImported = energyImported.get() - optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) - } + val optenergyImported = energyImported.get() + optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) + } if (energyExported.isPresent) { - val optenergyExported = energyExported.get() - optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) - } + val optenergyExported = energyExported.get() + optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) + } endStructure() } } @@ -59,38 +55,22 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of( - chip.devicecontroller.cluster.structs - .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) - ) - } else { - Optional.empty() - } - val energyExported = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of( - chip.devicecontroller.cluster.structs - .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) - ) - } else { - Optional.empty() - } - + val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) + } else { + Optional.empty() + } + val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( - energyImported, - energyExported - ) + return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent(energyImported, energyExported) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt index a2ffd06d482dc8..b98ed116089884 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt @@ -17,23 +17,19 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( - val energyImported: - Optional< - chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - >, - val energyExported: - Optional< - chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - > -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent ( + val energyImported: Optional, + val energyExported: Optional) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent {\n") append("\tenergyImported : $energyImported\n") append("\tenergyExported : $energyExported\n") @@ -44,13 +40,13 @@ class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( tlvWriter.apply { startStructure(tlvTag) if (energyImported.isPresent) { - val optenergyImported = energyImported.get() - optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) - } + val optenergyImported = energyImported.get() + optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) + } if (energyExported.isPresent) { - val optenergyExported = energyExported.get() - optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) - } + val optenergyExported = energyExported.get() + optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) + } endStructure() } } @@ -59,38 +55,22 @@ class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of( - chip.devicecontroller.cluster.structs - .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) - ) - } else { - Optional.empty() - } - val energyExported = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of( - chip.devicecontroller.cluster.structs - .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) - ) - } else { - Optional.empty() - } - + val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) + } else { + Optional.empty() + } + val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( - energyImported, - energyExported - ) + return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent(energyImported, energyExported) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt index 37d91a3291a9f2..f7cf6196cf4937 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterEVConnectedEvent(val sessionID: ULong) { - override fun toString(): String = buildString { +import java.util.Optional + +class EnergyEvseClusterEVConnectedEvent ( + val sessionID: ULong) { + override fun toString(): String = buildString { append("EnergyEvseClusterEVConnectedEvent {\n") append("\tsessionID : $sessionID\n") append("}\n") @@ -40,10 +45,10 @@ class EnergyEvseClusterEVConnectedEvent(val sessionID: ULong) { companion object { private const val TAG_SESSION_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVConnectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVConnectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) - + tlvReader.exitContainer() return EnergyEvseClusterEVConnectedEvent(sessionID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt index 5720d4469df39c..f3e95efb7fcbfc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt @@ -17,20 +17,22 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterEVNotDetectedEvent( - val sessionID: ULong, - val state: UInt, - val sessionDuration: ULong, - val sessionEnergyCharged: Long, - val sessionEnergyDischarged: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class EnergyEvseClusterEVNotDetectedEvent ( + val sessionID: ULong, + val state: UInt, + val sessionDuration: ULong, + val sessionEnergyCharged: Long, + val sessionEnergyDischarged: Optional) { + override fun toString(): String = buildString { append("EnergyEvseClusterEVNotDetectedEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -48,9 +50,9 @@ class EnergyEvseClusterEVNotDetectedEvent( put(ContextSpecificTag(TAG_SESSION_DURATION), sessionDuration) put(ContextSpecificTag(TAG_SESSION_ENERGY_CHARGED), sessionEnergyCharged) if (sessionEnergyDischarged.isPresent) { - val optsessionEnergyDischarged = sessionEnergyDischarged.get() - put(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED), optsessionEnergyDischarged) - } + val optsessionEnergyDischarged = sessionEnergyDischarged.get() + put(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED), optsessionEnergyDischarged) + } endStructure() } } @@ -62,28 +64,21 @@ class EnergyEvseClusterEVNotDetectedEvent( private const val TAG_SESSION_ENERGY_CHARGED = 3 private const val TAG_SESSION_ENERGY_DISCHARGED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVNotDetectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVNotDetectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val sessionDuration = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_DURATION)) val sessionEnergyCharged = tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_CHARGED)) - val sessionEnergyDischarged = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) - } else { - Optional.empty() - } - + val sessionEnergyDischarged = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterEVNotDetectedEvent( - sessionID, - state, - sessionDuration, - sessionEnergyCharged, - sessionEnergyDischarged - ) + return EnergyEvseClusterEVNotDetectedEvent(sessionID, state, sessionDuration, sessionEnergyCharged, sessionEnergyDischarged) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt index 7843215518c11d..29444bb45ec2c8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterEnergyTransferStartedEvent( - val sessionID: ULong, - val state: UInt, - val maximumCurrent: Long -) { - override fun toString(): String = buildString { +import java.util.Optional + +class EnergyEvseClusterEnergyTransferStartedEvent ( + val sessionID: ULong, + val state: UInt, + val maximumCurrent: Long) { + override fun toString(): String = buildString { append("EnergyEvseClusterEnergyTransferStartedEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -50,12 +53,12 @@ class EnergyEvseClusterEnergyTransferStartedEvent( private const val TAG_STATE = 1 private const val TAG_MAXIMUM_CURRENT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStartedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStartedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val maximumCurrent = tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_CURRENT)) - + tlvReader.exitContainer() return EnergyEvseClusterEnergyTransferStartedEvent(sessionID, state, maximumCurrent) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt index 642bbc9b5e7a04..ab277d74545a32 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt @@ -17,18 +17,21 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterEnergyTransferStoppedEvent( - val sessionID: ULong, - val state: UInt, - val reason: UInt, - val energyTransferred: Long -) { - override fun toString(): String = buildString { +import java.util.Optional + +class EnergyEvseClusterEnergyTransferStoppedEvent ( + val sessionID: ULong, + val state: UInt, + val reason: UInt, + val energyTransferred: Long) { + override fun toString(): String = buildString { append("EnergyEvseClusterEnergyTransferStoppedEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -54,21 +57,16 @@ class EnergyEvseClusterEnergyTransferStoppedEvent( private const val TAG_REASON = 2 private const val TAG_ENERGY_TRANSFERRED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStoppedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStoppedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val reason = tlvReader.getUInt(ContextSpecificTag(TAG_REASON)) val energyTransferred = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_TRANSFERRED)) - + tlvReader.exitContainer() - return EnergyEvseClusterEnergyTransferStoppedEvent( - sessionID, - state, - reason, - energyTransferred - ) + return EnergyEvseClusterEnergyTransferStoppedEvent(sessionID, state, reason, energyTransferred) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt index 53ca88273b038d..d95cc19e30fd92 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt @@ -17,18 +17,21 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterFaultEvent( - val sessionID: ULong?, - val state: UInt, - val faultStatePreviousState: UInt, - val faultStateCurrentState: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class EnergyEvseClusterFaultEvent ( + val sessionID: ULong?, + val state: UInt, + val faultStatePreviousState: UInt, + val faultStateCurrentState: UInt) { + override fun toString(): String = buildString { append("EnergyEvseClusterFaultEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -41,10 +44,10 @@ class EnergyEvseClusterFaultEvent( tlvWriter.apply { startStructure(tlvTag) if (sessionID != null) { - put(ContextSpecificTag(TAG_SESSION_I_D), sessionID) - } else { - putNull(ContextSpecificTag(TAG_SESSION_I_D)) - } + put(ContextSpecificTag(TAG_SESSION_I_D), sessionID) + } else { + putNull(ContextSpecificTag(TAG_SESSION_I_D)) + } put(ContextSpecificTag(TAG_STATE), state) put(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE), faultStatePreviousState) put(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE), faultStateCurrentState) @@ -58,29 +61,21 @@ class EnergyEvseClusterFaultEvent( private const val TAG_FAULT_STATE_PREVIOUS_STATE = 2 private const val TAG_FAULT_STATE_CURRENT_STATE = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterFaultEvent { tlvReader.enterStructure(tlvTag) - val sessionID = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) - null - } + val sessionID = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) + null + } val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) - val faultStatePreviousState = - tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) - val faultStateCurrentState = - tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) - + val faultStatePreviousState = tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) + val faultStateCurrentState = tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) + tlvReader.exitContainer() - return EnergyEvseClusterFaultEvent( - sessionID, - state, - faultStatePreviousState, - faultStateCurrentState - ) + return EnergyEvseClusterFaultEvent(sessionID, state, faultStatePreviousState, faultStateCurrentState) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt index 760bc2cd92b2eb..13834fdaa5eb5b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterRFIDEvent(val uid: ByteArray) { - override fun toString(): String = buildString { +import java.util.Optional + +class EnergyEvseClusterRFIDEvent ( + val uid: ByteArray) { + override fun toString(): String = buildString { append("EnergyEvseClusterRFIDEvent {\n") append("\tuid : $uid\n") append("}\n") @@ -40,10 +45,10 @@ class EnergyEvseClusterRFIDEvent(val uid: ByteArray) { companion object { private const val TAG_UID = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterRFIDEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterRFIDEvent { tlvReader.enterStructure(tlvTag) val uid = tlvReader.getByteArray(ContextSpecificTag(TAG_UID)) - + tlvReader.exitContainer() return EnergyEvseClusterRFIDEvent(uid) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt index ab8a2c3ad964b4..c3100ce31c6f9b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralDiagnosticsClusterBootReasonEvent(val bootReason: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class GeneralDiagnosticsClusterBootReasonEvent ( + val bootReason: UInt) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterBootReasonEvent {\n") append("\tbootReason : $bootReason\n") append("}\n") @@ -40,10 +45,10 @@ class GeneralDiagnosticsClusterBootReasonEvent(val bootReason: UInt) { companion object { private const val TAG_BOOT_REASON = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterBootReasonEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterBootReasonEvent { tlvReader.enterStructure(tlvTag) val bootReason = tlvReader.getUInt(ContextSpecificTag(TAG_BOOT_REASON)) - + tlvReader.exitContainer() return GeneralDiagnosticsClusterBootReasonEvent(bootReason) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt index e09f3961230b34..f93896c837f200 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt @@ -20,14 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralDiagnosticsClusterHardwareFaultChangeEvent( - val current: List, - val previous: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class GeneralDiagnosticsClusterHardwareFaultChangeEvent ( + val current: List, + val previous: List) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterHardwareFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -55,28 +57,23 @@ class GeneralDiagnosticsClusterHardwareFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): GeneralDiagnosticsClusterHardwareFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterHardwareFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterHardwareFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt index 2d17b1773194dc..ebc04643e795f2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -20,14 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralDiagnosticsClusterNetworkFaultChangeEvent( - val current: List, - val previous: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class GeneralDiagnosticsClusterNetworkFaultChangeEvent ( + val current: List, + val previous: List) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterNetworkFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -55,28 +57,23 @@ class GeneralDiagnosticsClusterNetworkFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): GeneralDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt index 3fc425674dde60..238e8657f6984b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt @@ -20,14 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralDiagnosticsClusterRadioFaultChangeEvent( - val current: List, - val previous: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class GeneralDiagnosticsClusterRadioFaultChangeEvent ( + val current: List, + val previous: List) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterRadioFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -55,25 +57,23 @@ class GeneralDiagnosticsClusterRadioFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterRadioFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterRadioFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterRadioFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt index 8626f9daed4e01..c8127f90ae7b9c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt @@ -17,25 +17,26 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaPlaybackClusterStateChangedEvent( - val currentState: UInt, - val startTime: ULong, - val duration: ULong, - val sampledPosition: - chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct, - val playbackSpeed: Float, - val seekRangeEnd: ULong, - val seekRangeStart: ULong, - val data: Optional, - val audioAdvanceUnmuted: Boolean -) { - override fun toString(): String = buildString { +import java.util.Optional + +class MediaPlaybackClusterStateChangedEvent ( + val currentState: UInt, + val startTime: ULong, + val duration: ULong, + val sampledPosition: chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct, + val playbackSpeed: Float, + val seekRangeEnd: ULong, + val seekRangeStart: ULong, + val data: Optional, + val audioAdvanceUnmuted: Boolean) { + override fun toString(): String = buildString { append("MediaPlaybackClusterStateChangedEvent {\n") append("\tcurrentState : $currentState\n") append("\tstartTime : $startTime\n") @@ -60,9 +61,9 @@ class MediaPlaybackClusterStateChangedEvent( put(ContextSpecificTag(TAG_SEEK_RANGE_END), seekRangeEnd) put(ContextSpecificTag(TAG_SEEK_RANGE_START), seekRangeStart) if (data.isPresent) { - val optdata = data.get() - put(ContextSpecificTag(TAG_DATA), optdata) - } + val optdata = data.get() + put(ContextSpecificTag(TAG_DATA), optdata) + } put(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED), audioAdvanceUnmuted) endStructure() } @@ -79,40 +80,25 @@ class MediaPlaybackClusterStateChangedEvent( private const val TAG_DATA = 7 private const val TAG_AUDIO_ADVANCE_UNMUTED = 8 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val currentState = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_STATE)) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - val sampledPosition = - chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv( - ContextSpecificTag(TAG_SAMPLED_POSITION), - tlvReader - ) + val sampledPosition = chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv(ContextSpecificTag(TAG_SAMPLED_POSITION), tlvReader) val playbackSpeed = tlvReader.getFloat(ContextSpecificTag(TAG_PLAYBACK_SPEED)) val seekRangeEnd = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_END)) val seekRangeStart = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_START)) - val data = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) - } else { - Optional.empty() - } + val data = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) + } else { + Optional.empty() + } val audioAdvanceUnmuted = tlvReader.getBoolean(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED)) - + tlvReader.exitContainer() - return MediaPlaybackClusterStateChangedEvent( - currentState, - startTime, - duration, - sampledPosition, - playbackSpeed, - seekRangeEnd, - seekRangeStart, - data, - audioAdvanceUnmuted - ) + return MediaPlaybackClusterStateChangedEvent(currentState, startTime, duration, sampledPosition, playbackSpeed, seekRangeEnd, seekRangeStart, data, audioAdvanceUnmuted) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt index 95cf699d416744..bd2f7895bfd1e2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt @@ -17,18 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalStateClusterOperationCompletionEvent( - val completionErrorCode: UInt, - val totalOperationalTime: Optional?, - val pausedTime: Optional? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OperationalStateClusterOperationCompletionEvent ( + val completionErrorCode: UInt, + val totalOperationalTime: Optional?, + val pausedTime: Optional?) { + override fun toString(): String = buildString { append("OperationalStateClusterOperationCompletionEvent {\n") append("\tcompletionErrorCode : $completionErrorCode\n") append("\ttotalOperationalTime : $totalOperationalTime\n") @@ -41,21 +43,21 @@ class OperationalStateClusterOperationCompletionEvent( startStructure(tlvTag) put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { - if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } - } else { - putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - } + if (totalOperationalTime.isPresent) { + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } + } else { + putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + } if (pausedTime != null) { - if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } - } else { - putNull(ContextSpecificTag(TAG_PAUSED_TIME)) - } + if (pausedTime.isPresent) { + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } + } else { + putNull(ContextSpecificTag(TAG_PAUSED_TIME)) + } endStructure() } } @@ -65,42 +67,33 @@ class OperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OperationalStateClusterOperationCompletionEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OperationalStateClusterOperationCompletionEvent( - completionErrorCode, - totalOperationalTime, - pausedTime - ) + return OperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt index 4ff0719f3d0f3b..f0cd196223d72c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt @@ -17,15 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalStateClusterOperationalErrorEvent( - val errorState: chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OperationalStateClusterOperationalErrorEvent ( + val errorState: chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct) { + override fun toString(): String = buildString { append("OperationalStateClusterOperationalErrorEvent {\n") append("\terrorState : $errorState\n") append("}\n") @@ -42,14 +45,10 @@ class OperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = - chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv( - ContextSpecificTag(TAG_ERROR_STATE), - tlvReader - ) - + val errorState = chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) + tlvReader.exitContainer() return OperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt index 8156c9578afadc..67e9047f0532a4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt @@ -17,18 +17,21 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( - val softwareVersion: ULong, - val bytesDownloaded: ULong, - val progressPercent: UInt?, - val platformCode: Long? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent ( + val softwareVersion: ULong, + val bytesDownloaded: ULong, + val progressPercent: UInt?, + val platformCode: Long?) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterDownloadErrorEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("\tbytesDownloaded : $bytesDownloaded\n") @@ -43,15 +46,15 @@ class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( put(ContextSpecificTag(TAG_SOFTWARE_VERSION), softwareVersion) put(ContextSpecificTag(TAG_BYTES_DOWNLOADED), bytesDownloaded) if (progressPercent != null) { - put(ContextSpecificTag(TAG_PROGRESS_PERCENT), progressPercent) - } else { - putNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - } + put(ContextSpecificTag(TAG_PROGRESS_PERCENT), progressPercent) + } else { + putNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + } if (platformCode != null) { - put(ContextSpecificTag(TAG_PLATFORM_CODE), platformCode) - } else { - putNull(ContextSpecificTag(TAG_PLATFORM_CODE)) - } + put(ContextSpecificTag(TAG_PLATFORM_CODE), platformCode) + } else { + putNull(ContextSpecificTag(TAG_PLATFORM_CODE)) + } endStructure() } } @@ -62,36 +65,26 @@ class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( private const val TAG_PROGRESS_PERCENT = 2 private const val TAG_PLATFORM_CODE = 3 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val bytesDownloaded = tlvReader.getULong(ContextSpecificTag(TAG_BYTES_DOWNLOADED)) - val progressPercent = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - null - } - val platformCode = - if (!tlvReader.isNull()) { - tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) - null - } - + val progressPercent = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + null + } + val platformCode = if (!tlvReader.isNull()) { + tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( - softwareVersion, - bytesDownloaded, - progressPercent, - platformCode - ) + return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent(softwareVersion, bytesDownloaded, progressPercent, platformCode) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt index 3843fe8b3b782a..99acba4d90a2dd 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt @@ -17,18 +17,21 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OtaSoftwareUpdateRequestorClusterStateTransitionEvent( - val previousState: UInt, - val newState: UInt, - val reason: UInt, - val targetSoftwareVersion: ULong? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OtaSoftwareUpdateRequestorClusterStateTransitionEvent ( + val previousState: UInt, + val newState: UInt, + val reason: UInt, + val targetSoftwareVersion: ULong?) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterStateTransitionEvent {\n") append("\tpreviousState : $previousState\n") append("\tnewState : $newState\n") @@ -44,10 +47,10 @@ class OtaSoftwareUpdateRequestorClusterStateTransitionEvent( put(ContextSpecificTag(TAG_NEW_STATE), newState) put(ContextSpecificTag(TAG_REASON), reason) if (targetSoftwareVersion != null) { - put(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION), targetSoftwareVersion) - } else { - putNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - } + put(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION), targetSoftwareVersion) + } else { + putNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + } endStructure() } } @@ -58,30 +61,21 @@ class OtaSoftwareUpdateRequestorClusterStateTransitionEvent( private const val TAG_REASON = 2 private const val TAG_TARGET_SOFTWARE_VERSION = 3 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OtaSoftwareUpdateRequestorClusterStateTransitionEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterStateTransitionEvent { tlvReader.enterStructure(tlvTag) val previousState = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_STATE)) val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) val reason = tlvReader.getUInt(ContextSpecificTag(TAG_REASON)) - val targetSoftwareVersion = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - null - } - + val targetSoftwareVersion = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterStateTransitionEvent( - previousState, - newState, - reason, - targetSoftwareVersion - ) + return OtaSoftwareUpdateRequestorClusterStateTransitionEvent(previousState, newState, reason, targetSoftwareVersion) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt index 43ec6b74bfc442..50dda1eeae85db 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent( - val softwareVersion: ULong, - val productID: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent ( + val softwareVersion: ULong, + val productID: UInt) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterVersionAppliedEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("\tproductID : $productID\n") @@ -46,14 +49,11 @@ class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent( private const val TAG_SOFTWARE_VERSION = 0 private const val TAG_PRODUCT_I_D = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val productID = tlvReader.getUInt(ContextSpecificTag(TAG_PRODUCT_I_D)) - + tlvReader.exitContainer() return OtaSoftwareUpdateRequestorClusterVersionAppliedEvent(softwareVersion, productID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt index b5a235e97841ba..c823fe799eb82b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt @@ -17,18 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenCavityOperationalStateClusterOperationCompletionEvent( - val completionErrorCode: UInt, - val totalOperationalTime: Optional?, - val pausedTime: Optional? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OvenCavityOperationalStateClusterOperationCompletionEvent ( + val completionErrorCode: UInt, + val totalOperationalTime: Optional?, + val pausedTime: Optional?) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationCompletionEvent {\n") append("\tcompletionErrorCode : $completionErrorCode\n") append("\ttotalOperationalTime : $totalOperationalTime\n") @@ -41,21 +43,21 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent( startStructure(tlvTag) put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { - if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } - } else { - putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - } + if (totalOperationalTime.isPresent) { + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } + } else { + putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + } if (pausedTime != null) { - if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } - } else { - putNull(ContextSpecificTag(TAG_PAUSED_TIME)) - } + if (pausedTime.isPresent) { + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } + } else { + putNull(ContextSpecificTag(TAG_PAUSED_TIME)) + } endStructure() } } @@ -65,42 +67,33 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OvenCavityOperationalStateClusterOperationCompletionEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationCompletionEvent( - completionErrorCode, - totalOperationalTime, - pausedTime - ) + return OvenCavityOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt index 8b1b9345a7df0b..9ba1604dedd97a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt @@ -17,16 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenCavityOperationalStateClusterOperationalErrorEvent( - val errorState: - chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OvenCavityOperationalStateClusterOperationalErrorEvent ( + val errorState: chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationalErrorEvent {\n") append("\terrorState : $errorState\n") append("}\n") @@ -43,15 +45,10 @@ class OvenCavityOperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OvenCavityOperationalStateClusterOperationalErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = - chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct - .fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) + tlvReader.exitContainer() return OvenCavityOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt index fdb0b033a7616a..b09829b20efd50 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt @@ -20,14 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatChargeFaultChangeEvent( - val current: List, - val previous: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class PowerSourceClusterBatChargeFaultChangeEvent ( + val current: List, + val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterBatChargeFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -55,25 +57,23 @@ class PowerSourceClusterBatChargeFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatChargeFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt index 7a5d133299cef5..ef4689fff56f84 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt @@ -20,11 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatFaultChangeEvent(val current: List, val previous: List) { - override fun toString(): String = buildString { +import java.util.Optional + +class PowerSourceClusterBatFaultChangeEvent ( + val current: List, + val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -52,25 +57,23 @@ class PowerSourceClusterBatFaultChangeEvent(val current: List, val previou private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt index 1f004191d406f0..5062e14fc47019 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt @@ -20,11 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterWiredFaultChangeEvent(val current: List, val previous: List) { - override fun toString(): String = buildString { +import java.util.Optional + +class PowerSourceClusterWiredFaultChangeEvent ( + val current: List, + val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -52,25 +57,23 @@ class PowerSourceClusterWiredFaultChangeEvent(val current: List, val previ private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterWiredFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt index 2584478cd02e39..0d0ec7f29f122c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt @@ -17,18 +17,21 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RefrigeratorAlarmClusterNotifyEvent( - val active: ULong, - val inactive: ULong, - val state: ULong, - val mask: ULong -) { - override fun toString(): String = buildString { +import java.util.Optional + +class RefrigeratorAlarmClusterNotifyEvent ( + val active: ULong, + val inactive: ULong, + val state: ULong, + val mask: ULong) { + override fun toString(): String = buildString { append("RefrigeratorAlarmClusterNotifyEvent {\n") append("\tactive : $active\n") append("\tinactive : $inactive\n") @@ -54,13 +57,13 @@ class RefrigeratorAlarmClusterNotifyEvent( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getULong(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getULong(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getULong(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getULong(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return RefrigeratorAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt index cfea1b82753b91..a9817567e22677 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt @@ -17,18 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcOperationalStateClusterOperationCompletionEvent( - val completionErrorCode: UInt, - val totalOperationalTime: Optional?, - val pausedTime: Optional? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class RvcOperationalStateClusterOperationCompletionEvent ( + val completionErrorCode: UInt, + val totalOperationalTime: Optional?, + val pausedTime: Optional?) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterOperationCompletionEvent {\n") append("\tcompletionErrorCode : $completionErrorCode\n") append("\ttotalOperationalTime : $totalOperationalTime\n") @@ -41,21 +43,21 @@ class RvcOperationalStateClusterOperationCompletionEvent( startStructure(tlvTag) put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { - if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } - } else { - putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - } + if (totalOperationalTime.isPresent) { + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } + } else { + putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + } if (pausedTime != null) { - if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } - } else { - putNull(ContextSpecificTag(TAG_PAUSED_TIME)) - } + if (pausedTime.isPresent) { + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } + } else { + putNull(ContextSpecificTag(TAG_PAUSED_TIME)) + } endStructure() } } @@ -65,42 +67,33 @@ class RvcOperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): RvcOperationalStateClusterOperationCompletionEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationCompletionEvent( - completionErrorCode, - totalOperationalTime, - pausedTime - ) + return RvcOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt index 6ad8a5e8875408..406ef9431645cd 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt @@ -17,15 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcOperationalStateClusterOperationalErrorEvent( - val errorState: chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct -) { - override fun toString(): String = buildString { +import java.util.Optional + +class RvcOperationalStateClusterOperationalErrorEvent ( + val errorState: chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterOperationalErrorEvent {\n") append("\terrorState : $errorState\n") append("}\n") @@ -42,17 +45,10 @@ class RvcOperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): RvcOperationalStateClusterOperationalErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = - chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv( - ContextSpecificTag(TAG_ERROR_STATE), - tlvReader - ) - + val errorState = chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) + tlvReader.exitContainer() return RvcOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt index a0588f4ad66d56..03b105c427a397 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SampleMeiClusterPingCountEventEvent(val count: ULong, val fabricIndex: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class SampleMeiClusterPingCountEventEvent ( + val count: ULong, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("SampleMeiClusterPingCountEventEvent {\n") append("\tcount : $count\n") append("\tfabricIndex : $fabricIndex\n") @@ -43,11 +49,11 @@ class SampleMeiClusterPingCountEventEvent(val count: ULong, val fabricIndex: UIn private const val TAG_COUNT = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingCountEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SampleMeiClusterPingCountEventEvent { tlvReader.enterStructure(tlvTag) val count = tlvReader.getULong(ContextSpecificTag(TAG_COUNT)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return SampleMeiClusterPingCountEventEvent(count, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt index a34090499ca233..48acd74033fca2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterCOAlarmEvent(val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class SmokeCoAlarmClusterCOAlarmEvent ( + val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -40,10 +45,10 @@ class SmokeCoAlarmClusterCOAlarmEvent(val alarmSeverityLevel: UInt) { companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt index c3ec4fbf491c87..685a6ab5fc1059 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterInterconnectCOAlarmEvent(val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class SmokeCoAlarmClusterInterconnectCOAlarmEvent ( + val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -40,10 +45,10 @@ class SmokeCoAlarmClusterInterconnectCOAlarmEvent(val alarmSeverityLevel: UInt) companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt index 3957d722ade622..1fb60bf24aec59 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent ( + val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -40,10 +45,10 @@ class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(val alarmSeverityLevel: UIn companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt index e855a9391a7491..91345969b757b4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterLowBatteryEvent(val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class SmokeCoAlarmClusterLowBatteryEvent ( + val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterLowBatteryEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -40,10 +45,10 @@ class SmokeCoAlarmClusterLowBatteryEvent(val alarmSeverityLevel: UInt) { companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterLowBatteryEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterLowBatteryEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterLowBatteryEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt index 5e5ff96385c265..3494dffe4f3d5b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterSmokeAlarmEvent(val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class SmokeCoAlarmClusterSmokeAlarmEvent ( + val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -40,10 +45,10 @@ class SmokeCoAlarmClusterSmokeAlarmEvent(val alarmSeverityLevel: UInt) { companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt index d3389bbaf8f367..b0e0d4844fadca 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt @@ -17,18 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SoftwareDiagnosticsClusterSoftwareFaultEvent( - val id: ULong, - val name: Optional, - val faultRecording: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class SoftwareDiagnosticsClusterSoftwareFaultEvent ( + val id: ULong, + val name: Optional, + val faultRecording: Optional) { + override fun toString(): String = buildString { append("SoftwareDiagnosticsClusterSoftwareFaultEvent {\n") append("\tid : $id\n") append("\tname : $name\n") @@ -41,13 +43,13 @@ class SoftwareDiagnosticsClusterSoftwareFaultEvent( startStructure(tlvTag) put(ContextSpecificTag(TAG_ID), id) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (faultRecording.isPresent) { - val optfaultRecording = faultRecording.get() - put(ContextSpecificTag(TAG_FAULT_RECORDING), optfaultRecording) - } + val optfaultRecording = faultRecording.get() + put(ContextSpecificTag(TAG_FAULT_RECORDING), optfaultRecording) + } endStructure() } } @@ -57,22 +59,20 @@ class SoftwareDiagnosticsClusterSoftwareFaultEvent( private const val TAG_NAME = 1 private const val TAG_FAULT_RECORDING = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterSoftwareFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SoftwareDiagnosticsClusterSoftwareFaultEvent { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val faultRecording = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) - } else { - Optional.empty() - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val faultRecording = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return SoftwareDiagnosticsClusterSoftwareFaultEvent(id, name, faultRecording) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt index 965bc1a81af5ac..fa3cf254ebdb96 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterInitialPressEvent(val newPosition: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class SwitchClusterInitialPressEvent ( + val newPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterInitialPressEvent {\n") append("\tnewPosition : $newPosition\n") append("}\n") @@ -40,10 +45,10 @@ class SwitchClusterInitialPressEvent(val newPosition: UInt) { companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterInitialPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterInitialPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterInitialPressEvent(newPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt index e986ef1d8d97fe..2748e8e6a44449 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterLongPressEvent(val newPosition: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class SwitchClusterLongPressEvent ( + val newPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterLongPressEvent {\n") append("\tnewPosition : $newPosition\n") append("}\n") @@ -40,10 +45,10 @@ class SwitchClusterLongPressEvent(val newPosition: UInt) { companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongPressEvent(newPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt index e99b119d906e8b..f4661d48d8e63e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterLongReleaseEvent(val previousPosition: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class SwitchClusterLongReleaseEvent ( + val previousPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterLongReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") append("}\n") @@ -40,10 +45,10 @@ class SwitchClusterLongReleaseEvent(val previousPosition: UInt) { companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt index 381ec17ae29ac5..b5d580a7cf0c55 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterMultiPressCompleteEvent( - val previousPosition: UInt, - val totalNumberOfPressesCounted: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class SwitchClusterMultiPressCompleteEvent ( + val previousPosition: UInt, + val totalNumberOfPressesCounted: UInt) { + override fun toString(): String = buildString { append("SwitchClusterMultiPressCompleteEvent {\n") append("\tpreviousPosition : $previousPosition\n") append("\ttotalNumberOfPressesCounted : $totalNumberOfPressesCounted\n") @@ -46,12 +49,11 @@ class SwitchClusterMultiPressCompleteEvent( private const val TAG_PREVIOUS_POSITION = 0 private const val TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressCompleteEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressCompleteEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - val totalNumberOfPressesCounted = - tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) - + val totalNumberOfPressesCounted = tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressCompleteEvent(previousPosition, totalNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt index dd904f59cb9fdc..fcaf6c0ca5ef5f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterMultiPressOngoingEvent( - val newPosition: UInt, - val currentNumberOfPressesCounted: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class SwitchClusterMultiPressOngoingEvent ( + val newPosition: UInt, + val currentNumberOfPressesCounted: UInt) { + override fun toString(): String = buildString { append("SwitchClusterMultiPressOngoingEvent {\n") append("\tnewPosition : $newPosition\n") append("\tcurrentNumberOfPressesCounted : $currentNumberOfPressesCounted\n") @@ -46,12 +49,11 @@ class SwitchClusterMultiPressOngoingEvent( private const val TAG_NEW_POSITION = 0 private const val TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressOngoingEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressOngoingEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - val currentNumberOfPressesCounted = - tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) - + val currentNumberOfPressesCounted = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressOngoingEvent(newPosition, currentNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt index 477dc53e895a2a..91a786b4f78740 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterShortReleaseEvent(val previousPosition: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class SwitchClusterShortReleaseEvent ( + val previousPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterShortReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") append("}\n") @@ -40,10 +45,10 @@ class SwitchClusterShortReleaseEvent(val previousPosition: UInt) { companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterShortReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterShortReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterShortReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt index 6a2ea4883e4f6f..f6537ab66e931a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterSwitchLatchedEvent(val newPosition: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class SwitchClusterSwitchLatchedEvent ( + val newPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterSwitchLatchedEvent {\n") append("\tnewPosition : $newPosition\n") append("}\n") @@ -40,10 +45,10 @@ class SwitchClusterSwitchLatchedEvent(val newPosition: UInt) { companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterSwitchLatchedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterSwitchLatchedEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterSwitchLatchedEvent(newPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt index ce5bbb1df841c9..e49f93ead0165f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt @@ -20,16 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TargetNavigatorClusterTargetUpdatedEvent( - val targetList: - List, - val currentTarget: UInt, - val data: ByteArray -) { - override fun toString(): String = buildString { +import java.util.Optional + +class TargetNavigatorClusterTargetUpdatedEvent ( + val targetList: List, + val currentTarget: UInt, + val data: ByteArray) { + override fun toString(): String = buildString { append("TargetNavigatorClusterTargetUpdatedEvent {\n") append("\ttargetList : $targetList\n") append("\tcurrentTarget : $currentTarget\n") @@ -56,24 +57,18 @@ class TargetNavigatorClusterTargetUpdatedEvent( private const val TAG_CURRENT_TARGET = 1 private const val TAG_DATA = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TargetNavigatorClusterTargetUpdatedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TargetNavigatorClusterTargetUpdatedEvent { tlvReader.enterStructure(tlvTag) - val targetList = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) - while (!tlvReader.isEndOfContainer()) { - this.add( - chip.devicecontroller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } + val targetList = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) + while(!tlvReader.isEndOfContainer()) { + this.add(chip.devicecontroller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } val currentTarget = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_TARGET)) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetUpdatedEvent(targetList, currentTarget, data) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt index dc55e372090536..7a9290a163f25e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThreadNetworkDiagnosticsClusterConnectionStatusEvent ( + val connectionStatus: UInt) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") append("}\n") @@ -40,13 +45,10 @@ class ThreadNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThreadNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUInt(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt index f2ce60e4c710ba..384675b471a0d6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -20,14 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent( - val current: List, - val previous: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent ( + val current: List, + val previous: List) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -55,28 +57,23 @@ class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt index 7564293e97be61..d4162a1dd3f5ae 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterDSTStatusEvent(val DSTOffsetActive: Boolean) { - override fun toString(): String = buildString { +import java.util.Optional + +class TimeSynchronizationClusterDSTStatusEvent ( + val DSTOffsetActive: Boolean) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterDSTStatusEvent {\n") append("\tDSTOffsetActive : $DSTOffsetActive\n") append("}\n") @@ -40,10 +45,10 @@ class TimeSynchronizationClusterDSTStatusEvent(val DSTOffsetActive: Boolean) { companion object { private const val TAG_D_S_T_OFFSET_ACTIVE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterDSTStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterDSTStatusEvent { tlvReader.enterStructure(tlvTag) val DSTOffsetActive = tlvReader.getBoolean(ContextSpecificTag(TAG_D_S_T_OFFSET_ACTIVE)) - + tlvReader.exitContainer() return TimeSynchronizationClusterDSTStatusEvent(DSTOffsetActive) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt index 9e9d5ef9f1355f..52b2b4fd1e1dfa 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt @@ -17,14 +17,19 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterTimeZoneStatusEvent(val offset: Long, val name: Optional) { - override fun toString(): String = buildString { +import java.util.Optional + +class TimeSynchronizationClusterTimeZoneStatusEvent ( + val offset: Long, + val name: Optional) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterTimeZoneStatusEvent {\n") append("\toffset : $offset\n") append("\tname : $name\n") @@ -36,9 +41,9 @@ class TimeSynchronizationClusterTimeZoneStatusEvent(val offset: Long, val name: startStructure(tlvTag) put(ContextSpecificTag(TAG_OFFSET), offset) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } endStructure() } } @@ -47,16 +52,15 @@ class TimeSynchronizationClusterTimeZoneStatusEvent(val offset: Long, val name: private const val TAG_OFFSET = 0 private const val TAG_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTimeZoneStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTimeZoneStatusEvent { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getLong(ContextSpecificTag(TAG_OFFSET)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStatusEvent(offset, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt index d92c0b6b531a6b..89dbdc9593b84e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt @@ -20,18 +20,20 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterTestEventEvent( - val arg1: UInt, - val arg2: UInt, - val arg3: Boolean, - val arg4: chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct, - val arg5: List, - val arg6: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class UnitTestingClusterTestEventEvent ( + val arg1: UInt, + val arg2: UInt, + val arg3: Boolean, + val arg4: chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct, + val arg5: List, + val arg6: List) { + override fun toString(): String = buildString { append("UnitTestingClusterTestEventEvent {\n") append("\targ1 : $arg1\n") append("\targ2 : $arg2\n") @@ -71,38 +73,27 @@ class UnitTestingClusterTestEventEvent( private const val TAG_ARG5 = 5 private const val TAG_ARG6 = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestEventEvent { tlvReader.enterStructure(tlvTag) val arg1 = tlvReader.getUInt(ContextSpecificTag(TAG_ARG1)) val arg2 = tlvReader.getUInt(ContextSpecificTag(TAG_ARG2)) val arg3 = tlvReader.getBoolean(ContextSpecificTag(TAG_ARG3)) - val arg4 = - chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( - ContextSpecificTag(TAG_ARG4), - tlvReader - ) - val arg5 = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) - while (!tlvReader.isEndOfContainer()) { - this.add( - chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - val arg6 = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val arg4 = chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_ARG4), tlvReader) + val arg5 = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) + while(!tlvReader.isEndOfContainer()) { + this.add(chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val arg6 = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterTestEventEvent(arg1, arg2, arg3, arg4, arg5, arg6) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt index b6cc1c77125923..b71c9c788a3a76 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterTestFabricScopedEventEvent(val fabricIndex: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class UnitTestingClusterTestFabricScopedEventEvent ( + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("UnitTestingClusterTestFabricScopedEventEvent {\n") append("\tfabricIndex : $fabricIndex\n") append("}\n") @@ -40,10 +45,10 @@ class UnitTestingClusterTestFabricScopedEventEvent(val fabricIndex: UInt) { companion object { private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScopedEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestFabricScopedEventEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return UnitTestingClusterTestFabricScopedEventEvent(fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt index cb432d975e1275..cead9f186377e2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ValveConfigurationAndControlClusterValveFaultEvent(val valveFault: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class ValveConfigurationAndControlClusterValveFaultEvent ( + val valveFault: UInt) { + override fun toString(): String = buildString { append("ValveConfigurationAndControlClusterValveFaultEvent {\n") append("\tvalveFault : $valveFault\n") append("}\n") @@ -40,13 +45,10 @@ class ValveConfigurationAndControlClusterValveFaultEvent(val valveFault: UInt) { companion object { private const val TAG_VALVE_FAULT = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ValveConfigurationAndControlClusterValveFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveFaultEvent { tlvReader.enterStructure(tlvTag) val valveFault = tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_FAULT)) - + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveFaultEvent(valveFault) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt index e34e14aee60c7d..d8714935057610 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt @@ -17,17 +17,19 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ValveConfigurationAndControlClusterValveStateChangedEvent( - val valveState: UInt, - val valveLevel: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ValveConfigurationAndControlClusterValveStateChangedEvent ( + val valveState: UInt, + val valveLevel: Optional) { + override fun toString(): String = buildString { append("ValveConfigurationAndControlClusterValveStateChangedEvent {\n") append("\tvalveState : $valveState\n") append("\tvalveLevel : $valveLevel\n") @@ -39,9 +41,9 @@ class ValveConfigurationAndControlClusterValveStateChangedEvent( startStructure(tlvTag) put(ContextSpecificTag(TAG_VALVE_STATE), valveState) if (valveLevel.isPresent) { - val optvalveLevel = valveLevel.get() - put(ContextSpecificTag(TAG_VALVE_LEVEL), optvalveLevel) - } + val optvalveLevel = valveLevel.get() + put(ContextSpecificTag(TAG_VALVE_LEVEL), optvalveLevel) + } endStructure() } } @@ -50,19 +52,15 @@ class ValveConfigurationAndControlClusterValveStateChangedEvent( private const val TAG_VALVE_STATE = 0 private const val TAG_VALVE_LEVEL = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ValveConfigurationAndControlClusterValveStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveStateChangedEvent { tlvReader.enterStructure(tlvTag) val valveState = tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_STATE)) - val valveLevel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_LEVEL))) - } else { - Optional.empty() - } - + val valveLevel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_LEVEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveStateChangedEvent(valveState, valveLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt index 2f94dc8e6b1c58..353230c4664dc5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsClusterAssociationFailureEvent( - val associationFailureCause: UInt, - val status: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class WiFiNetworkDiagnosticsClusterAssociationFailureEvent ( + val associationFailureCause: UInt, + val status: UInt) { + override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterAssociationFailureEvent {\n") append("\tassociationFailureCause : $associationFailureCause\n") append("\tstatus : $status\n") @@ -46,15 +49,11 @@ class WiFiNetworkDiagnosticsClusterAssociationFailureEvent( private const val TAG_ASSOCIATION_FAILURE_CAUSE = 0 private const val TAG_STATUS = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): WiFiNetworkDiagnosticsClusterAssociationFailureEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterAssociationFailureEvent { tlvReader.enterStructure(tlvTag) - val associationFailureCause = - tlvReader.getUInt(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) + val associationFailureCause = tlvReader.getUInt(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) val status = tlvReader.getUInt(ContextSpecificTag(TAG_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterAssociationFailureEvent(associationFailureCause, status) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt index 34b126059fffd2..e106ddd9b7498d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class WiFiNetworkDiagnosticsClusterConnectionStatusEvent ( + val connectionStatus: UInt) { + override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") append("}\n") @@ -40,13 +45,10 @@ class WiFiNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: U companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): WiFiNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUInt(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt index 9c0875da20a177..33cb99c03f48a2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsClusterDisconnectionEvent(val reasonCode: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class WiFiNetworkDiagnosticsClusterDisconnectionEvent ( + val reasonCode: UInt) { + override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterDisconnectionEvent {\n") append("\treasonCode : $reasonCode\n") append("}\n") @@ -40,13 +45,10 @@ class WiFiNetworkDiagnosticsClusterDisconnectionEvent(val reasonCode: UInt) { companion object { private const val TAG_REASON_CODE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): WiFiNetworkDiagnosticsClusterDisconnectionEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterDisconnectionEvent { tlvReader.enterStructure(tlvTag) val reasonCode = tlvReader.getUInt(ContextSpecificTag(TAG_REASON_CODE)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterDisconnectionEvent(reasonCode) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt index ad7257cc39f901..d228ef19fb8e79 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt @@ -20,17 +20,19 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccessControlClusterAccessControlEntryStruct( - val privilege: UInt, - val authMode: UInt, - val subjects: List?, - val targets: List?, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class AccessControlClusterAccessControlEntryStruct ( + val privilege: UInt, + val authMode: UInt, + val subjects: List?, + val targets: List?, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlEntryStruct {\n") append("\tprivilege : $privilege\n") append("\tauthMode : $authMode\n") @@ -46,23 +48,23 @@ class AccessControlClusterAccessControlEntryStruct( put(ContextSpecificTag(TAG_PRIVILEGE), privilege) put(ContextSpecificTag(TAG_AUTH_MODE), authMode) if (subjects != null) { - startArray(ContextSpecificTag(TAG_SUBJECTS)) - for (item in subjects.iterator()) { - put(AnonymousTag, item) - } - endArray() - } else { - putNull(ContextSpecificTag(TAG_SUBJECTS)) + startArray(ContextSpecificTag(TAG_SUBJECTS)) + for (item in subjects.iterator()) { + put(AnonymousTag, item) } + endArray() + } else { + putNull(ContextSpecificTag(TAG_SUBJECTS)) + } if (targets != null) { - startArray(ContextSpecificTag(TAG_TARGETS)) - for (item in targets.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() - } else { - putNull(ContextSpecificTag(TAG_TARGETS)) + startArray(ContextSpecificTag(TAG_TARGETS)) + for (item in targets.iterator()) { + item.toTlv(AnonymousTag, this) } + endArray() + } else { + putNull(ContextSpecificTag(TAG_TARGETS)) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -75,47 +77,39 @@ class AccessControlClusterAccessControlEntryStruct( private const val TAG_TARGETS = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlEntryStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlEntryStruct { tlvReader.enterStructure(tlvTag) val privilege = tlvReader.getUInt(ContextSpecificTag(TAG_PRIVILEGE)) val authMode = tlvReader.getUInt(ContextSpecificTag(TAG_AUTH_MODE)) - val subjects = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getULong(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) - null - } - val targets = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) - while (!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) - null - } + val subjects = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getULong(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) + null + } + val targets = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) + while(!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryStruct( - privilege, - authMode, - subjects, - targets, - fabricIndex - ) + return AccessControlClusterAccessControlEntryStruct(privilege, authMode, subjects, targets, fabricIndex) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt index c75c7632f06be3..b41ebafd9de72a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccessControlClusterAccessControlExtensionStruct(val data: ByteArray, val fabricIndex: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class AccessControlClusterAccessControlExtensionStruct ( + val data: ByteArray, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlExtensionStruct {\n") append("\tdata : $data\n") append("\tfabricIndex : $fabricIndex\n") @@ -43,14 +49,11 @@ class AccessControlClusterAccessControlExtensionStruct(val data: ByteArray, val private const val TAG_DATA = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): AccessControlClusterAccessControlExtensionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlExtensionStruct { tlvReader.enterStructure(tlvTag) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return AccessControlClusterAccessControlExtensionStruct(data, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt index 5fb4de109d6c6a..1eab00f450d8f0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccessControlClusterAccessControlTargetStruct( - val cluster: ULong?, - val endpoint: UInt?, - val deviceType: ULong? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class AccessControlClusterAccessControlTargetStruct ( + val cluster: ULong?, + val endpoint: UInt?, + val deviceType: ULong?) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlTargetStruct {\n") append("\tcluster : $cluster\n") append("\tendpoint : $endpoint\n") @@ -39,20 +42,20 @@ class AccessControlClusterAccessControlTargetStruct( tlvWriter.apply { startStructure(tlvTag) if (cluster != null) { - put(ContextSpecificTag(TAG_CLUSTER), cluster) - } else { - putNull(ContextSpecificTag(TAG_CLUSTER)) - } + put(ContextSpecificTag(TAG_CLUSTER), cluster) + } else { + putNull(ContextSpecificTag(TAG_CLUSTER)) + } if (endpoint != null) { - put(ContextSpecificTag(TAG_ENDPOINT), endpoint) - } else { - putNull(ContextSpecificTag(TAG_ENDPOINT)) - } + put(ContextSpecificTag(TAG_ENDPOINT), endpoint) + } else { + putNull(ContextSpecificTag(TAG_ENDPOINT)) + } if (deviceType != null) { - put(ContextSpecificTag(TAG_DEVICE_TYPE), deviceType) - } else { - putNull(ContextSpecificTag(TAG_DEVICE_TYPE)) - } + put(ContextSpecificTag(TAG_DEVICE_TYPE), deviceType) + } else { + putNull(ContextSpecificTag(TAG_DEVICE_TYPE)) + } endStructure() } } @@ -62,30 +65,27 @@ class AccessControlClusterAccessControlTargetStruct( private const val TAG_ENDPOINT = 1 private const val TAG_DEVICE_TYPE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlTargetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlTargetStruct { tlvReader.enterStructure(tlvTag) - val cluster = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) - null - } - val endpoint = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) - null - } - val deviceType = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_TYPE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) - null - } - + val cluster = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) + null + } + val endpoint = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) + null + } + val deviceType = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_TYPE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) + null + } + tlvReader.exitContainer() return AccessControlClusterAccessControlTargetStruct(cluster, endpoint, deviceType) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt index 5d5c21a6906968..8ae474f8e727db 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt @@ -17,20 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ActionsClusterActionStruct( - val actionID: UInt, - val name: String, - val type: UInt, - val endpointListID: UInt, - val supportedCommands: UInt, - val state: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ActionsClusterActionStruct ( + val actionID: UInt, + val name: String, + val type: UInt, + val endpointListID: UInt, + val supportedCommands: UInt, + val state: UInt) { + override fun toString(): String = buildString { append("ActionsClusterActionStruct {\n") append("\tactionID : $actionID\n") append("\tname : $name\n") @@ -62,7 +65,7 @@ class ActionsClusterActionStruct( private const val TAG_SUPPORTED_COMMANDS = 4 private const val TAG_STATE = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterActionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterActionStruct { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUInt(ContextSpecificTag(TAG_ACTION_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) @@ -70,17 +73,10 @@ class ActionsClusterActionStruct( val endpointListID = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val supportedCommands = tlvReader.getUInt(ContextSpecificTag(TAG_SUPPORTED_COMMANDS)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) - + tlvReader.exitContainer() - return ActionsClusterActionStruct( - actionID, - name, - type, - endpointListID, - supportedCommands, - state - ) + return ActionsClusterActionStruct(actionID, name, type, endpointListID, supportedCommands, state) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt index d5716531a18c99..a8f078a4ba75c6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt @@ -20,16 +20,18 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ActionsClusterEndpointListStruct( - val endpointListID: UInt, - val name: String, - val type: UInt, - val endpoints: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ActionsClusterEndpointListStruct ( + val endpointListID: UInt, + val name: String, + val type: UInt, + val endpoints: List) { + override fun toString(): String = buildString { append("ActionsClusterEndpointListStruct {\n") append("\tendpointListID : $endpointListID\n") append("\tname : $name\n") @@ -59,20 +61,19 @@ class ActionsClusterEndpointListStruct( private const val TAG_TYPE = 2 private const val TAG_ENDPOINTS = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterEndpointListStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterEndpointListStruct { tlvReader.enterStructure(tlvTag) val endpointListID = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) - val endpoints = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val endpoints = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ActionsClusterEndpointListStruct(endpointListID, name, type, endpoints) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt index 138571f0342bb8..fa41e784da11de 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( - val productIdentifierType: UInt, - val productIdentifierValue: String -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct ( + val productIdentifierType: UInt, + val productIdentifierValue: String) { + override fun toString(): String = buildString { append("ActivatedCarbonFilterMonitoringClusterReplacementProductStruct {\n") append("\tproductIdentifierType : $productIdentifierType\n") append("\tproductIdentifierValue : $productIdentifierValue\n") @@ -46,21 +49,14 @@ class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) val productIdentifierType = tlvReader.getUInt(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = - tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( - productIdentifierType, - productIdentifierValue - ) + return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt index 1fb108656c7973..f052c51f03c144 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ApplicationBasicClusterApplicationStruct( - val catalogVendorID: UInt, - val applicationID: String -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ApplicationBasicClusterApplicationStruct ( + val catalogVendorID: UInt, + val applicationID: String) { + override fun toString(): String = buildString { append("ApplicationBasicClusterApplicationStruct {\n") append("\tcatalogVendorID : $catalogVendorID\n") append("\tapplicationID : $applicationID\n") @@ -46,11 +49,11 @@ class ApplicationBasicClusterApplicationStruct( private const val TAG_CATALOG_VENDOR_I_D = 0 private const val TAG_APPLICATION_I_D = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationBasicClusterApplicationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ApplicationBasicClusterApplicationStruct { tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUInt(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationBasicClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt index ea33f81faaf3e0..89f372803fe317 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt @@ -17,17 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ApplicationLauncherClusterApplicationEPStruct( - val application: ApplicationLauncherClusterApplicationStruct, - val endpoint: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ApplicationLauncherClusterApplicationEPStruct ( + val application: ApplicationLauncherClusterApplicationStruct, + val endpoint: Optional) { + override fun toString(): String = buildString { append("ApplicationLauncherClusterApplicationEPStruct {\n") append("\tapplication : $application\n") append("\tendpoint : $endpoint\n") @@ -39,9 +41,9 @@ class ApplicationLauncherClusterApplicationEPStruct( startStructure(tlvTag) application.toTlv(ContextSpecificTag(TAG_APPLICATION), this) if (endpoint.isPresent) { - val optendpoint = endpoint.get() - put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) - } + val optendpoint = endpoint.get() + put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) + } endStructure() } } @@ -50,20 +52,15 @@ class ApplicationLauncherClusterApplicationEPStruct( private const val TAG_APPLICATION = 0 private const val TAG_ENDPOINT = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationLauncherClusterApplicationEPStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ApplicationLauncherClusterApplicationEPStruct { tlvReader.enterStructure(tlvTag) - val application = - ApplicationLauncherClusterApplicationStruct.fromTlv( - ContextSpecificTag(TAG_APPLICATION), - tlvReader - ) - val endpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - + val application = ApplicationLauncherClusterApplicationStruct.fromTlv(ContextSpecificTag(TAG_APPLICATION), tlvReader) + val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationEPStruct(application, endpoint) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt index c7ec51b47dfb4b..b306cbca62125a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ApplicationLauncherClusterApplicationStruct( - val catalogVendorID: UInt, - val applicationID: String -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ApplicationLauncherClusterApplicationStruct ( + val catalogVendorID: UInt, + val applicationID: String) { + override fun toString(): String = buildString { append("ApplicationLauncherClusterApplicationStruct {\n") append("\tcatalogVendorID : $catalogVendorID\n") append("\tapplicationID : $applicationID\n") @@ -46,11 +49,11 @@ class ApplicationLauncherClusterApplicationStruct( private const val TAG_CATALOG_VENDOR_I_D = 0 private const val TAG_APPLICATION_I_D = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationLauncherClusterApplicationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ApplicationLauncherClusterApplicationStruct { tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUInt(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt index 6336549e45a0bc..60726ce82d5c56 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt @@ -17,13 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AudioOutputClusterOutputInfoStruct(val index: UInt, val outputType: UInt, val name: String) { - override fun toString(): String = buildString { +import java.util.Optional + +class AudioOutputClusterOutputInfoStruct ( + val index: UInt, + val outputType: UInt, + val name: String) { + override fun toString(): String = buildString { append("AudioOutputClusterOutputInfoStruct {\n") append("\tindex : $index\n") append("\toutputType : $outputType\n") @@ -46,12 +53,12 @@ class AudioOutputClusterOutputInfoStruct(val index: UInt, val outputType: UInt, private const val TAG_OUTPUT_TYPE = 1 private const val TAG_NAME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AudioOutputClusterOutputInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AudioOutputClusterOutputInfoStruct { tlvReader.enterStructure(tlvTag) val index = tlvReader.getUInt(ContextSpecificTag(TAG_INDEX)) val outputType = tlvReader.getUInt(ContextSpecificTag(TAG_OUTPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return AudioOutputClusterOutputInfoStruct(index, outputType, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt index d79225dd61468e..494c946f40b998 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterCapabilityMinimaStruct( - val caseSessionsPerFabric: UInt, - val subscriptionsPerFabric: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class BasicInformationClusterCapabilityMinimaStruct ( + val caseSessionsPerFabric: UInt, + val subscriptionsPerFabric: UInt) { + override fun toString(): String = buildString { append("BasicInformationClusterCapabilityMinimaStruct {\n") append("\tcaseSessionsPerFabric : $caseSessionsPerFabric\n") append("\tsubscriptionsPerFabric : $subscriptionsPerFabric\n") @@ -46,19 +49,14 @@ class BasicInformationClusterCapabilityMinimaStruct( private const val TAG_CASE_SESSIONS_PER_FABRIC = 0 private const val TAG_SUBSCRIPTIONS_PER_FABRIC = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterCapabilityMinimaStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterCapabilityMinimaStruct { tlvReader.enterStructure(tlvTag) - val caseSessionsPerFabric = - tlvReader.getUInt(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) - val subscriptionsPerFabric = - tlvReader.getUInt(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) - + val caseSessionsPerFabric = tlvReader.getUInt(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) + val subscriptionsPerFabric = tlvReader.getUInt(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) + tlvReader.exitContainer() - return BasicInformationClusterCapabilityMinimaStruct( - caseSessionsPerFabric, - subscriptionsPerFabric - ) + return BasicInformationClusterCapabilityMinimaStruct(caseSessionsPerFabric, subscriptionsPerFabric) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt index 5a0eb3ace2ef7b..44f42edb6adf2d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterProductAppearanceStruct(val finish: UInt, val primaryColor: UInt?) { - override fun toString(): String = buildString { +import java.util.Optional + +class BasicInformationClusterProductAppearanceStruct ( + val finish: UInt, + val primaryColor: UInt?) { + override fun toString(): String = buildString { append("BasicInformationClusterProductAppearanceStruct {\n") append("\tfinish : $finish\n") append("\tprimaryColor : $primaryColor\n") @@ -35,10 +41,10 @@ class BasicInformationClusterProductAppearanceStruct(val finish: UInt, val prima startStructure(tlvTag) put(ContextSpecificTag(TAG_FINISH), finish) if (primaryColor != null) { - put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) - } else { - putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } + put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) + } else { + putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } endStructure() } } @@ -47,17 +53,16 @@ class BasicInformationClusterProductAppearanceStruct(val finish: UInt, val prima private const val TAG_FINISH = 0 private const val TAG_PRIMARY_COLOR = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterProductAppearanceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUInt(ContextSpecificTag(TAG_FINISH)) - val primaryColor = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt index 70c8deedaaaf6a..9454790cb7ac05 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt @@ -17,20 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BindingClusterTargetStruct( - val node: Optional, - val group: Optional, - val endpoint: Optional, - val cluster: Optional, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class BindingClusterTargetStruct ( + val node: Optional, + val group: Optional, + val endpoint: Optional, + val cluster: Optional, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("BindingClusterTargetStruct {\n") append("\tnode : $node\n") append("\tgroup : $group\n") @@ -44,21 +46,21 @@ class BindingClusterTargetStruct( tlvWriter.apply { startStructure(tlvTag) if (node.isPresent) { - val optnode = node.get() - put(ContextSpecificTag(TAG_NODE), optnode) - } + val optnode = node.get() + put(ContextSpecificTag(TAG_NODE), optnode) + } if (group.isPresent) { - val optgroup = group.get() - put(ContextSpecificTag(TAG_GROUP), optgroup) - } + val optgroup = group.get() + put(ContextSpecificTag(TAG_GROUP), optgroup) + } if (endpoint.isPresent) { - val optendpoint = endpoint.get() - put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) - } + val optendpoint = endpoint.get() + put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) + } if (cluster.isPresent) { - val optcluster = cluster.get() - put(ContextSpecificTag(TAG_CLUSTER), optcluster) - } + val optcluster = cluster.get() + put(ContextSpecificTag(TAG_CLUSTER), optcluster) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -71,34 +73,30 @@ class BindingClusterTargetStruct( private const val TAG_CLUSTER = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BindingClusterTargetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BindingClusterTargetStruct { tlvReader.enterStructure(tlvTag) - val node = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - val group = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_GROUP))) - } else { - Optional.empty() - } - val endpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - val cluster = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER))) - } else { - Optional.empty() - } + val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + val group = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_GROUP))) + } else { + Optional.empty() + } + val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + val cluster = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BindingClusterTargetStruct(node, group, endpoint, cluster, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt index ec2d58aa588cea..6f548b1a015b9c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationClusterProductAppearanceStruct( - val finish: UInt, - val primaryColor: UInt? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class BridgedDeviceBasicInformationClusterProductAppearanceStruct ( + val finish: UInt, + val primaryColor: UInt?) { + override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterProductAppearanceStruct {\n") append("\tfinish : $finish\n") append("\tprimaryColor : $primaryColor\n") @@ -38,10 +41,10 @@ class BridgedDeviceBasicInformationClusterProductAppearanceStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_FINISH), finish) if (primaryColor != null) { - put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) - } else { - putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } + put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) + } else { + putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } endStructure() } } @@ -50,20 +53,16 @@ class BridgedDeviceBasicInformationClusterProductAppearanceStruct( private const val TAG_FINISH = 0 private const val TAG_PRIMARY_COLOR = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): BridgedDeviceBasicInformationClusterProductAppearanceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUInt(ContextSpecificTag(TAG_FINISH)) - val primaryColor = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt index 082ea9c5debbbc..9fe7d172bf4551 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterAdditionalInfoStruct(val name: String, val value: String) { - override fun toString(): String = buildString { +import java.util.Optional + +class ChannelClusterAdditionalInfoStruct ( + val name: String, + val value: String) { + override fun toString(): String = buildString { append("ChannelClusterAdditionalInfoStruct {\n") append("\tname : $name\n") append("\tvalue : $value\n") @@ -43,11 +49,11 @@ class ChannelClusterAdditionalInfoStruct(val name: String, val value: String) { private const val TAG_NAME = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterAdditionalInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterAdditionalInfoStruct { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ChannelClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt index deb76c4fb0791c..a72550236ad007 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt @@ -17,22 +17,24 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterChannelInfoStruct( - val majorNumber: UInt, - val minorNumber: UInt, - val name: Optional, - val callSign: Optional, - val affiliateCallSign: Optional, - val identifier: Optional, - val type: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ChannelClusterChannelInfoStruct ( + val majorNumber: UInt, + val minorNumber: UInt, + val name: Optional, + val callSign: Optional, + val affiliateCallSign: Optional, + val identifier: Optional, + val type: Optional) { + override fun toString(): String = buildString { append("ChannelClusterChannelInfoStruct {\n") append("\tmajorNumber : $majorNumber\n") append("\tminorNumber : $minorNumber\n") @@ -50,25 +52,25 @@ class ChannelClusterChannelInfoStruct( put(ContextSpecificTag(TAG_MAJOR_NUMBER), majorNumber) put(ContextSpecificTag(TAG_MINOR_NUMBER), minorNumber) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (callSign.isPresent) { - val optcallSign = callSign.get() - put(ContextSpecificTag(TAG_CALL_SIGN), optcallSign) - } + val optcallSign = callSign.get() + put(ContextSpecificTag(TAG_CALL_SIGN), optcallSign) + } if (affiliateCallSign.isPresent) { - val optaffiliateCallSign = affiliateCallSign.get() - put(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN), optaffiliateCallSign) - } + val optaffiliateCallSign = affiliateCallSign.get() + put(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN), optaffiliateCallSign) + } if (identifier.isPresent) { - val optidentifier = identifier.get() - put(ContextSpecificTag(TAG_IDENTIFIER), optidentifier) - } + val optidentifier = identifier.get() + put(ContextSpecificTag(TAG_IDENTIFIER), optidentifier) + } if (type.isPresent) { - val opttype = type.get() - put(ContextSpecificTag(TAG_TYPE), opttype) - } + val opttype = type.get() + put(ContextSpecificTag(TAG_TYPE), opttype) + } endStructure() } } @@ -82,52 +84,39 @@ class ChannelClusterChannelInfoStruct( private const val TAG_IDENTIFIER = 5 private const val TAG_TYPE = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterChannelInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterChannelInfoStruct { tlvReader.enterStructure(tlvTag) val majorNumber = tlvReader.getUInt(ContextSpecificTag(TAG_MAJOR_NUMBER)) val minorNumber = tlvReader.getUInt(ContextSpecificTag(TAG_MINOR_NUMBER)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val callSign = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) - } else { - Optional.empty() - } - val affiliateCallSign = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) - } else { - Optional.empty() - } - val identifier = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) - } else { - Optional.empty() - } - val type = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TYPE))) - } else { - Optional.empty() - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val callSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) + } else { + Optional.empty() + } + val affiliateCallSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) + } else { + Optional.empty() + } + val identifier = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) + } else { + Optional.empty() + } + val type = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TYPE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterChannelInfoStruct( - majorNumber, - minorNumber, - name, - callSign, - affiliateCallSign, - identifier, - type - ) + return ChannelClusterChannelInfoStruct(majorNumber, minorNumber, name, callSign, affiliateCallSign, identifier, type) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt index 64b035d2b02583..936bdfd02a603b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt @@ -17,17 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterChannelPagingStruct( - val previousToken: Optional?, - val nextToken: Optional? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ChannelClusterChannelPagingStruct ( + val previousToken: Optional?, + val nextToken: Optional?) { + override fun toString(): String = buildString { append("ChannelClusterChannelPagingStruct {\n") append("\tpreviousToken : $previousToken\n") append("\tnextToken : $nextToken\n") @@ -38,21 +40,21 @@ class ChannelClusterChannelPagingStruct( tlvWriter.apply { startStructure(tlvTag) if (previousToken != null) { - if (previousToken.isPresent) { - val optpreviousToken = previousToken.get() - optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) - } - } else { - putNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) - } + if (previousToken.isPresent) { + val optpreviousToken = previousToken.get() + optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) + } + } else { + putNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) + } if (nextToken != null) { - if (nextToken.isPresent) { - val optnextToken = nextToken.get() - optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) - } - } else { - putNull(ContextSpecificTag(TAG_NEXT_TOKEN)) - } + if (nextToken.isPresent) { + val optnextToken = nextToken.get() + optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) + } + } else { + putNull(ContextSpecificTag(TAG_NEXT_TOKEN)) + } endStructure() } } @@ -61,38 +63,29 @@ class ChannelClusterChannelPagingStruct( private const val TAG_PREVIOUS_TOKEN = 0 private const val TAG_NEXT_TOKEN = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterChannelPagingStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterChannelPagingStruct { tlvReader.enterStructure(tlvTag) - val previousToken = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { - Optional.of( - ChannelClusterPageTokenStruct.fromTlv( - ContextSpecificTag(TAG_PREVIOUS_TOKEN), - tlvReader - ) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) - null - } - val nextToken = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { - Optional.of( - ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) - null - } - + val previousToken = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { + Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) + null + } + val nextToken = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { + Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) + null + } + tlvReader.exitContainer() return ChannelClusterChannelPagingStruct(previousToken, nextToken) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt index d205e89f966bae..357509b7e3eb70 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt @@ -17,19 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterLineupInfoStruct( - val operatorName: String, - val lineupName: Optional, - val postalCode: Optional, - val lineupInfoType: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ChannelClusterLineupInfoStruct ( + val operatorName: String, + val lineupName: Optional, + val postalCode: Optional, + val lineupInfoType: UInt) { + override fun toString(): String = buildString { append("ChannelClusterLineupInfoStruct {\n") append("\toperatorName : $operatorName\n") append("\tlineupName : $lineupName\n") @@ -43,13 +45,13 @@ class ChannelClusterLineupInfoStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATOR_NAME), operatorName) if (lineupName.isPresent) { - val optlineupName = lineupName.get() - put(ContextSpecificTag(TAG_LINEUP_NAME), optlineupName) - } + val optlineupName = lineupName.get() + put(ContextSpecificTag(TAG_LINEUP_NAME), optlineupName) + } if (postalCode.isPresent) { - val optpostalCode = postalCode.get() - put(ContextSpecificTag(TAG_POSTAL_CODE), optpostalCode) - } + val optpostalCode = postalCode.get() + put(ContextSpecificTag(TAG_POSTAL_CODE), optpostalCode) + } put(ContextSpecificTag(TAG_LINEUP_INFO_TYPE), lineupInfoType) endStructure() } @@ -61,23 +63,21 @@ class ChannelClusterLineupInfoStruct( private const val TAG_POSTAL_CODE = 2 private const val TAG_LINEUP_INFO_TYPE = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterLineupInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterLineupInfoStruct { tlvReader.enterStructure(tlvTag) val operatorName = tlvReader.getString(ContextSpecificTag(TAG_OPERATOR_NAME)) - val lineupName = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) - } else { - Optional.empty() - } - val postalCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) - } else { - Optional.empty() - } + val lineupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) + } else { + Optional.empty() + } + val postalCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) + } else { + Optional.empty() + } val lineupInfoType = tlvReader.getUInt(ContextSpecificTag(TAG_LINEUP_INFO_TYPE)) - + tlvReader.exitContainer() return ChannelClusterLineupInfoStruct(operatorName, lineupName, postalCode, lineupInfoType) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt index 18e92f157a24d4..73639a9681a7b3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt @@ -17,18 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterPageTokenStruct( - val limit: Optional, - val after: Optional, - val before: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ChannelClusterPageTokenStruct ( + val limit: Optional, + val after: Optional, + val before: Optional) { + override fun toString(): String = buildString { append("ChannelClusterPageTokenStruct {\n") append("\tlimit : $limit\n") append("\tafter : $after\n") @@ -40,17 +42,17 @@ class ChannelClusterPageTokenStruct( tlvWriter.apply { startStructure(tlvTag) if (limit.isPresent) { - val optlimit = limit.get() - put(ContextSpecificTag(TAG_LIMIT), optlimit) - } + val optlimit = limit.get() + put(ContextSpecificTag(TAG_LIMIT), optlimit) + } if (after.isPresent) { - val optafter = after.get() - put(ContextSpecificTag(TAG_AFTER), optafter) - } + val optafter = after.get() + put(ContextSpecificTag(TAG_AFTER), optafter) + } if (before.isPresent) { - val optbefore = before.get() - put(ContextSpecificTag(TAG_BEFORE), optbefore) - } + val optbefore = before.get() + put(ContextSpecificTag(TAG_BEFORE), optbefore) + } endStructure() } } @@ -60,27 +62,24 @@ class ChannelClusterPageTokenStruct( private const val TAG_AFTER = 1 private const val TAG_BEFORE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterPageTokenStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterPageTokenStruct { tlvReader.enterStructure(tlvTag) - val limit = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LIMIT))) - } else { - Optional.empty() - } - val after = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) - } else { - Optional.empty() - } - val before = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) - } else { - Optional.empty() - } - + val limit = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LIMIT))) + } else { + Optional.empty() + } + val after = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) + } else { + Optional.empty() + } + val before = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterPageTokenStruct(limit, after, before) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt index b11edabf62f0b0..5d03551b82d852 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterProgramCastStruct(val name: String, val role: String) { - override fun toString(): String = buildString { +import java.util.Optional + +class ChannelClusterProgramCastStruct ( + val name: String, + val role: String) { + override fun toString(): String = buildString { append("ChannelClusterProgramCastStruct {\n") append("\tname : $name\n") append("\trole : $role\n") @@ -43,11 +49,11 @@ class ChannelClusterProgramCastStruct(val name: String, val role: String) { private const val TAG_NAME = 0 private const val TAG_ROLE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramCastStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterProgramCastStruct { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val role = tlvReader.getString(ContextSpecificTag(TAG_ROLE)) - + tlvReader.exitContainer() return ChannelClusterProgramCastStruct(name, role) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt index d22742f8be42c5..66800400ce15bb 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt @@ -17,14 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterProgramCategoryStruct(val category: String, val subCategory: Optional) { - override fun toString(): String = buildString { +import java.util.Optional + +class ChannelClusterProgramCategoryStruct ( + val category: String, + val subCategory: Optional) { + override fun toString(): String = buildString { append("ChannelClusterProgramCategoryStruct {\n") append("\tcategory : $category\n") append("\tsubCategory : $subCategory\n") @@ -36,9 +41,9 @@ class ChannelClusterProgramCategoryStruct(val category: String, val subCategory: startStructure(tlvTag) put(ContextSpecificTag(TAG_CATEGORY), category) if (subCategory.isPresent) { - val optsubCategory = subCategory.get() - put(ContextSpecificTag(TAG_SUB_CATEGORY), optsubCategory) - } + val optsubCategory = subCategory.get() + put(ContextSpecificTag(TAG_SUB_CATEGORY), optsubCategory) + } endStructure() } } @@ -47,16 +52,15 @@ class ChannelClusterProgramCategoryStruct(val category: String, val subCategory: private const val TAG_CATEGORY = 0 private const val TAG_SUB_CATEGORY = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramCategoryStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterProgramCategoryStruct { tlvReader.enterStructure(tlvTag) val category = tlvReader.getString(ContextSpecificTag(TAG_CATEGORY)) - val subCategory = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) - } else { - Optional.empty() - } - + val subCategory = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterProgramCategoryStruct(category, subCategory) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt index 5f5a7e48d1b8dc..82c4ab33b445ed 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt @@ -17,35 +17,36 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterProgramStruct( - val identifier: String, - val channel: ChannelClusterChannelInfoStruct, - val startTime: ULong, - val endTime: ULong, - val title: String, - val subtitle: Optional, - val description: Optional, - val audioLanguages: Optional>, - val ratings: Optional>, - val thumbnailUrl: Optional, - val posterArtUrl: Optional, - val dvbiUrl: Optional, - val releaseDate: Optional, - val parentalGuidanceText: Optional, - val recordingFlag: Optional, - val seriesInfo: Optional?, - val categoryList: Optional>, - val castList: Optional>, - val externalIDList: Optional> -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ChannelClusterProgramStruct ( + val identifier: String, + val channel: ChannelClusterChannelInfoStruct, + val startTime: ULong, + val endTime: ULong, + val title: String, + val subtitle: Optional, + val description: Optional, + val audioLanguages: Optional>, + val ratings: Optional>, + val thumbnailUrl: Optional, + val posterArtUrl: Optional, + val dvbiUrl: Optional, + val releaseDate: Optional, + val parentalGuidanceText: Optional, + val recordingFlag: Optional, + val seriesInfo: Optional?, + val categoryList: Optional>, + val castList: Optional>, + val externalIDList: Optional>) { + override fun toString(): String = buildString { append("ChannelClusterProgramStruct {\n") append("\tidentifier : $identifier\n") append("\tchannel : $channel\n") @@ -78,85 +79,85 @@ class ChannelClusterProgramStruct( put(ContextSpecificTag(TAG_END_TIME), endTime) put(ContextSpecificTag(TAG_TITLE), title) if (subtitle.isPresent) { - val optsubtitle = subtitle.get() - put(ContextSpecificTag(TAG_SUBTITLE), optsubtitle) - } + val optsubtitle = subtitle.get() + put(ContextSpecificTag(TAG_SUBTITLE), optsubtitle) + } if (description.isPresent) { - val optdescription = description.get() - put(ContextSpecificTag(TAG_DESCRIPTION), optdescription) - } + val optdescription = description.get() + put(ContextSpecificTag(TAG_DESCRIPTION), optdescription) + } if (audioLanguages.isPresent) { - val optaudioLanguages = audioLanguages.get() - startArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - for (item in optaudioLanguages.iterator()) { - put(AnonymousTag, item) - } - endArray() + val optaudioLanguages = audioLanguages.get() + startArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) + for (item in optaudioLanguages.iterator()) { + put(AnonymousTag, item) } + endArray() + } if (ratings.isPresent) { - val optratings = ratings.get() - startArray(ContextSpecificTag(TAG_RATINGS)) - for (item in optratings.iterator()) { - put(AnonymousTag, item) - } - endArray() + val optratings = ratings.get() + startArray(ContextSpecificTag(TAG_RATINGS)) + for (item in optratings.iterator()) { + put(AnonymousTag, item) } + endArray() + } if (thumbnailUrl.isPresent) { - val optthumbnailUrl = thumbnailUrl.get() - put(ContextSpecificTag(TAG_THUMBNAIL_URL), optthumbnailUrl) - } + val optthumbnailUrl = thumbnailUrl.get() + put(ContextSpecificTag(TAG_THUMBNAIL_URL), optthumbnailUrl) + } if (posterArtUrl.isPresent) { - val optposterArtUrl = posterArtUrl.get() - put(ContextSpecificTag(TAG_POSTER_ART_URL), optposterArtUrl) - } + val optposterArtUrl = posterArtUrl.get() + put(ContextSpecificTag(TAG_POSTER_ART_URL), optposterArtUrl) + } if (dvbiUrl.isPresent) { - val optdvbiUrl = dvbiUrl.get() - put(ContextSpecificTag(TAG_DVBI_URL), optdvbiUrl) - } + val optdvbiUrl = dvbiUrl.get() + put(ContextSpecificTag(TAG_DVBI_URL), optdvbiUrl) + } if (releaseDate.isPresent) { - val optreleaseDate = releaseDate.get() - put(ContextSpecificTag(TAG_RELEASE_DATE), optreleaseDate) - } + val optreleaseDate = releaseDate.get() + put(ContextSpecificTag(TAG_RELEASE_DATE), optreleaseDate) + } if (parentalGuidanceText.isPresent) { - val optparentalGuidanceText = parentalGuidanceText.get() - put(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT), optparentalGuidanceText) - } + val optparentalGuidanceText = parentalGuidanceText.get() + put(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT), optparentalGuidanceText) + } if (recordingFlag.isPresent) { - val optrecordingFlag = recordingFlag.get() - put(ContextSpecificTag(TAG_RECORDING_FLAG), optrecordingFlag) - } + val optrecordingFlag = recordingFlag.get() + put(ContextSpecificTag(TAG_RECORDING_FLAG), optrecordingFlag) + } if (seriesInfo != null) { - if (seriesInfo.isPresent) { - val optseriesInfo = seriesInfo.get() - optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) - } - } else { - putNull(ContextSpecificTag(TAG_SERIES_INFO)) - } + if (seriesInfo.isPresent) { + val optseriesInfo = seriesInfo.get() + optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) + } + } else { + putNull(ContextSpecificTag(TAG_SERIES_INFO)) + } if (categoryList.isPresent) { - val optcategoryList = categoryList.get() - startArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - for (item in optcategoryList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + val optcategoryList = categoryList.get() + startArray(ContextSpecificTag(TAG_CATEGORY_LIST)) + for (item in optcategoryList.iterator()) { + item.toTlv(AnonymousTag, this) } + endArray() + } if (castList.isPresent) { - val optcastList = castList.get() - startArray(ContextSpecificTag(TAG_CAST_LIST)) - for (item in optcastList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + val optcastList = castList.get() + startArray(ContextSpecificTag(TAG_CAST_LIST)) + for (item in optcastList.iterator()) { + item.toTlv(AnonymousTag, this) } + endArray() + } if (externalIDList.isPresent) { - val optexternalIDList = externalIDList.get() - startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + val optexternalIDList = externalIDList.get() + startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) } + endArray() + } endStructure() } } @@ -182,169 +183,122 @@ class ChannelClusterProgramStruct( private const val TAG_CAST_LIST = 17 private const val TAG_EXTERNAL_I_D_LIST = 18 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterProgramStruct { tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER)) - val channel = - ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) + val channel = ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getULong(ContextSpecificTag(TAG_END_TIME)) val title = tlvReader.getString(ContextSpecificTag(TAG_TITLE)) - val subtitle = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) - } else { - Optional.empty() - } - val description = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) - } else { - Optional.empty() - } - val audioLanguages = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val ratings = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val thumbnailUrl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) - } else { - Optional.empty() - } - val posterArtUrl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) - } else { - Optional.empty() - } - val dvbiUrl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) - } else { - Optional.empty() - } - val releaseDate = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) - } else { - Optional.empty() - } - val parentalGuidanceText = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) - } else { - Optional.empty() - } - val recordingFlag = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_RECORDING_FLAG))) - } else { - Optional.empty() - } - val seriesInfo = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { - Optional.of( - ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) - null - } - val categoryList = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val castList = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val externalIDList = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - + val subtitle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) + } else { + Optional.empty() + } + val description = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) + } else { + Optional.empty() + } + val audioLanguages = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val ratings = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val thumbnailUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) + } else { + Optional.empty() + } + val posterArtUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) + } else { + Optional.empty() + } + val dvbiUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) + } else { + Optional.empty() + } + val releaseDate = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) + } else { + Optional.empty() + } + val parentalGuidanceText = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) + } else { + Optional.empty() + } + val recordingFlag = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_RECORDING_FLAG))) + } else { + Optional.empty() + } + val seriesInfo = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { + Optional.of(ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) + null + } + val categoryList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val castList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterProgramStruct( - identifier, - channel, - startTime, - endTime, - title, - subtitle, - description, - audioLanguages, - ratings, - thumbnailUrl, - posterArtUrl, - dvbiUrl, - releaseDate, - parentalGuidanceText, - recordingFlag, - seriesInfo, - categoryList, - castList, - externalIDList - ) + return ChannelClusterProgramStruct(identifier, channel, startTime, endTime, title, subtitle, description, audioLanguages, ratings, thumbnailUrl, posterArtUrl, dvbiUrl, releaseDate, parentalGuidanceText, recordingFlag, seriesInfo, categoryList, castList, externalIDList) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt index eb06e3fe6dac2a..93e49be4ae9eb0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterSeriesInfoStruct(val season: String, val episode: String) { - override fun toString(): String = buildString { +import java.util.Optional + +class ChannelClusterSeriesInfoStruct ( + val season: String, + val episode: String) { + override fun toString(): String = buildString { append("ChannelClusterSeriesInfoStruct {\n") append("\tseason : $season\n") append("\tepisode : $episode\n") @@ -43,11 +49,11 @@ class ChannelClusterSeriesInfoStruct(val season: String, val episode: String) { private const val TAG_SEASON = 0 private const val TAG_EPISODE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterSeriesInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterSeriesInfoStruct { tlvReader.enterStructure(tlvTag) val season = tlvReader.getString(ContextSpecificTag(TAG_SEASON)) val episode = tlvReader.getString(ContextSpecificTag(TAG_EPISODE)) - + tlvReader.exitContainer() return ChannelClusterSeriesInfoStruct(season, episode) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt index c22158cb36c3bd..c1aab30b53c51f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt @@ -17,17 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentControlClusterRatingNameStruct( - val ratingName: String, - val ratingNameDesc: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ContentControlClusterRatingNameStruct ( + val ratingName: String, + val ratingNameDesc: Optional) { + override fun toString(): String = buildString { append("ContentControlClusterRatingNameStruct {\n") append("\tratingName : $ratingName\n") append("\tratingNameDesc : $ratingNameDesc\n") @@ -39,9 +41,9 @@ class ContentControlClusterRatingNameStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_RATING_NAME), ratingName) if (ratingNameDesc.isPresent) { - val optratingNameDesc = ratingNameDesc.get() - put(ContextSpecificTag(TAG_RATING_NAME_DESC), optratingNameDesc) - } + val optratingNameDesc = ratingNameDesc.get() + put(ContextSpecificTag(TAG_RATING_NAME_DESC), optratingNameDesc) + } endStructure() } } @@ -50,16 +52,15 @@ class ContentControlClusterRatingNameStruct( private const val TAG_RATING_NAME = 0 private const val TAG_RATING_NAME_DESC = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentControlClusterRatingNameStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentControlClusterRatingNameStruct { tlvReader.enterStructure(tlvTag) val ratingName = tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME)) - val ratingNameDesc = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) - } else { - Optional.empty() - } - + val ratingNameDesc = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentControlClusterRatingNameStruct(ratingName, ratingNameDesc) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt index c9df652a2ca5a8..cdc41e36467d57 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherClusterAdditionalInfoStruct(val name: String, val value: String) { - override fun toString(): String = buildString { +import java.util.Optional + +class ContentLauncherClusterAdditionalInfoStruct ( + val name: String, + val value: String) { + override fun toString(): String = buildString { append("ContentLauncherClusterAdditionalInfoStruct {\n") append("\tname : $name\n") append("\tvalue : $value\n") @@ -43,11 +49,11 @@ class ContentLauncherClusterAdditionalInfoStruct(val name: String, val value: St private const val TAG_NAME = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterAdditionalInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterAdditionalInfoStruct { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ContentLauncherClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt index 5508763757c036..56028fc4d11e93 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt @@ -17,21 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherClusterBrandingInformationStruct( - val providerName: String, - val background: Optional, - val logo: Optional, - val progressBar: Optional, - val splash: Optional, - val waterMark: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ContentLauncherClusterBrandingInformationStruct ( + val providerName: String, + val background: Optional, + val logo: Optional, + val progressBar: Optional, + val splash: Optional, + val waterMark: Optional) { + override fun toString(): String = buildString { append("ContentLauncherClusterBrandingInformationStruct {\n") append("\tproviderName : $providerName\n") append("\tbackground : $background\n") @@ -47,25 +49,25 @@ class ContentLauncherClusterBrandingInformationStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_PROVIDER_NAME), providerName) if (background.isPresent) { - val optbackground = background.get() - optbackground.toTlv(ContextSpecificTag(TAG_BACKGROUND), this) - } + val optbackground = background.get() + optbackground.toTlv(ContextSpecificTag(TAG_BACKGROUND), this) + } if (logo.isPresent) { - val optlogo = logo.get() - optlogo.toTlv(ContextSpecificTag(TAG_LOGO), this) - } + val optlogo = logo.get() + optlogo.toTlv(ContextSpecificTag(TAG_LOGO), this) + } if (progressBar.isPresent) { - val optprogressBar = progressBar.get() - optprogressBar.toTlv(ContextSpecificTag(TAG_PROGRESS_BAR), this) - } + val optprogressBar = progressBar.get() + optprogressBar.toTlv(ContextSpecificTag(TAG_PROGRESS_BAR), this) + } if (splash.isPresent) { - val optsplash = splash.get() - optsplash.toTlv(ContextSpecificTag(TAG_SPLASH), this) - } + val optsplash = splash.get() + optsplash.toTlv(ContextSpecificTag(TAG_SPLASH), this) + } if (waterMark.isPresent) { - val optwaterMark = waterMark.get() - optwaterMark.toTlv(ContextSpecificTag(TAG_WATER_MARK), this) - } + val optwaterMark = waterMark.get() + optwaterMark.toTlv(ContextSpecificTag(TAG_WATER_MARK), this) + } endStructure() } } @@ -78,78 +80,38 @@ class ContentLauncherClusterBrandingInformationStruct( private const val TAG_SPLASH = 4 private const val TAG_WATER_MARK = 5 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ContentLauncherClusterBrandingInformationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterBrandingInformationStruct { tlvReader.enterStructure(tlvTag) val providerName = tlvReader.getString(ContextSpecificTag(TAG_PROVIDER_NAME)) - val background = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { - Optional.of( - ContentLauncherClusterStyleInformationStruct.fromTlv( - ContextSpecificTag(TAG_BACKGROUND), - tlvReader - ) - ) - } else { - Optional.empty() - } - val logo = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { - Optional.of( - ContentLauncherClusterStyleInformationStruct.fromTlv( - ContextSpecificTag(TAG_LOGO), - tlvReader - ) - ) - } else { - Optional.empty() - } - val progressBar = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { - Optional.of( - ContentLauncherClusterStyleInformationStruct.fromTlv( - ContextSpecificTag(TAG_PROGRESS_BAR), - tlvReader - ) - ) - } else { - Optional.empty() - } - val splash = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { - Optional.of( - ContentLauncherClusterStyleInformationStruct.fromTlv( - ContextSpecificTag(TAG_SPLASH), - tlvReader - ) - ) - } else { - Optional.empty() - } - val waterMark = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { - Optional.of( - ContentLauncherClusterStyleInformationStruct.fromTlv( - ContextSpecificTag(TAG_WATER_MARK), - tlvReader - ) - ) - } else { - Optional.empty() - } - + val background = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { + Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_BACKGROUND), tlvReader)) + } else { + Optional.empty() + } + val logo = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { + Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_LOGO), tlvReader)) + } else { + Optional.empty() + } + val progressBar = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { + Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_PROGRESS_BAR), tlvReader)) + } else { + Optional.empty() + } + val splash = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { + Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_SPLASH), tlvReader)) + } else { + Optional.empty() + } + val waterMark = if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { + Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_WATER_MARK), tlvReader)) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterBrandingInformationStruct( - providerName, - background, - logo, - progressBar, - splash, - waterMark - ) + return ContentLauncherClusterBrandingInformationStruct(providerName, background, logo, progressBar, splash, waterMark) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt index fc1cfc5de7b014..9f100e058c4305 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt @@ -20,13 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherClusterContentSearchStruct( - val parameterList: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ContentLauncherClusterContentSearchStruct ( + val parameterList: List) { + override fun toString(): String = buildString { append("ContentLauncherClusterContentSearchStruct {\n") append("\tparameterList : $parameterList\n") append("}\n") @@ -47,17 +49,16 @@ class ContentLauncherClusterContentSearchStruct( companion object { private const val TAG_PARAMETER_LIST = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterContentSearchStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterContentSearchStruct { tlvReader.enterStructure(tlvTag) - val parameterList = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val parameterList = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ContentLauncherClusterContentSearchStruct(parameterList) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt index f00027d639958c..8c6fd83e614072 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherClusterDimensionStruct( - val width: Double, - val height: Double, - val metric: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ContentLauncherClusterDimensionStruct ( + val width: Double, + val height: Double, + val metric: UInt) { + override fun toString(): String = buildString { append("ContentLauncherClusterDimensionStruct {\n") append("\twidth : $width\n") append("\theight : $height\n") @@ -50,12 +53,12 @@ class ContentLauncherClusterDimensionStruct( private const val TAG_HEIGHT = 1 private const val TAG_METRIC = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterDimensionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterDimensionStruct { tlvReader.enterStructure(tlvTag) val width = tlvReader.getDouble(ContextSpecificTag(TAG_WIDTH)) val height = tlvReader.getDouble(ContextSpecificTag(TAG_HEIGHT)) val metric = tlvReader.getUInt(ContextSpecificTag(TAG_METRIC)) - + tlvReader.exitContainer() return ContentLauncherClusterDimensionStruct(width, height, metric) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt index 458fb5e7b29d9c..0a547a665e8609 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt @@ -17,19 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherClusterParameterStruct( - val type: UInt, - val value: String, - val externalIDList: Optional> -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ContentLauncherClusterParameterStruct ( + val type: UInt, + val value: String, + val externalIDList: Optional>) { + override fun toString(): String = buildString { append("ContentLauncherClusterParameterStruct {\n") append("\ttype : $type\n") append("\tvalue : $value\n") @@ -43,13 +44,13 @@ class ContentLauncherClusterParameterStruct( put(ContextSpecificTag(TAG_TYPE), type) put(ContextSpecificTag(TAG_VALUE), value) if (externalIDList.isPresent) { - val optexternalIDList = externalIDList.get() - startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + val optexternalIDList = externalIDList.get() + startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) } + endArray() + } endStructure() } } @@ -59,25 +60,22 @@ class ContentLauncherClusterParameterStruct( private const val TAG_VALUE = 1 private const val TAG_EXTERNAL_I_D_LIST = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterParameterStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterParameterStruct { tlvReader.enterStructure(tlvTag) val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - val externalIDList = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - + val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterParameterStruct(type, value, externalIDList) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt index 4199602517911f..6ca30cceaac011 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt @@ -17,19 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherClusterPlaybackPreferencesStruct( - val playbackPosition: ULong, - val textTrack: ContentLauncherClusterTrackPreferenceStruct, - val audioTracks: Optional> -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ContentLauncherClusterPlaybackPreferencesStruct ( + val playbackPosition: ULong, + val textTrack: ContentLauncherClusterTrackPreferenceStruct, + val audioTracks: Optional>) { + override fun toString(): String = buildString { append("ContentLauncherClusterPlaybackPreferencesStruct {\n") append("\tplaybackPosition : $playbackPosition\n") append("\ttextTrack : $textTrack\n") @@ -43,13 +44,13 @@ class ContentLauncherClusterPlaybackPreferencesStruct( put(ContextSpecificTag(TAG_PLAYBACK_POSITION), playbackPosition) textTrack.toTlv(ContextSpecificTag(TAG_TEXT_TRACK), this) if (audioTracks.isPresent) { - val optaudioTracks = audioTracks.get() - startArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - for (item in optaudioTracks.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + val optaudioTracks = audioTracks.get() + startArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) + for (item in optaudioTracks.iterator()) { + item.toTlv(AnonymousTag, this) } + endArray() + } endStructure() } } @@ -59,39 +60,25 @@ class ContentLauncherClusterPlaybackPreferencesStruct( private const val TAG_TEXT_TRACK = 1 private const val TAG_AUDIO_TRACKS = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ContentLauncherClusterPlaybackPreferencesStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterPlaybackPreferencesStruct { tlvReader.enterStructure(tlvTag) val playbackPosition = tlvReader.getULong(ContextSpecificTag(TAG_PLAYBACK_POSITION)) - val textTrack = - ContentLauncherClusterTrackPreferenceStruct.fromTlv( - ContextSpecificTag(TAG_TEXT_TRACK), - tlvReader - ) - val audioTracks = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - while (!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - + val textTrack = ContentLauncherClusterTrackPreferenceStruct.fromTlv(ContextSpecificTag(TAG_TEXT_TRACK), tlvReader) + val audioTracks = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) + while(!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterPlaybackPreferencesStruct( - playbackPosition, - textTrack, - audioTracks - ) + return ContentLauncherClusterPlaybackPreferencesStruct(playbackPosition, textTrack, audioTracks) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt index 9b34f59f3eefa6..c5de0e5706eaea 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt @@ -17,18 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherClusterStyleInformationStruct( - val imageURL: Optional, - val color: Optional, - val size: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ContentLauncherClusterStyleInformationStruct ( + val imageURL: Optional, + val color: Optional, + val size: Optional) { + override fun toString(): String = buildString { append("ContentLauncherClusterStyleInformationStruct {\n") append("\timageURL : $imageURL\n") append("\tcolor : $color\n") @@ -40,17 +42,17 @@ class ContentLauncherClusterStyleInformationStruct( tlvWriter.apply { startStructure(tlvTag) if (imageURL.isPresent) { - val optimageURL = imageURL.get() - put(ContextSpecificTag(TAG_IMAGE_U_R_L), optimageURL) - } + val optimageURL = imageURL.get() + put(ContextSpecificTag(TAG_IMAGE_U_R_L), optimageURL) + } if (color.isPresent) { - val optcolor = color.get() - put(ContextSpecificTag(TAG_COLOR), optcolor) - } + val optcolor = color.get() + put(ContextSpecificTag(TAG_COLOR), optcolor) + } if (size.isPresent) { - val optsize = size.get() - optsize.toTlv(ContextSpecificTag(TAG_SIZE), this) - } + val optsize = size.get() + optsize.toTlv(ContextSpecificTag(TAG_SIZE), this) + } endStructure() } } @@ -60,29 +62,24 @@ class ContentLauncherClusterStyleInformationStruct( private const val TAG_COLOR = 1 private const val TAG_SIZE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterStyleInformationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterStyleInformationStruct { tlvReader.enterStructure(tlvTag) - val imageURL = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) - } else { - Optional.empty() - } - val color = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) - } else { - Optional.empty() - } - val size = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { - Optional.of( - ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader) - ) - } else { - Optional.empty() - } - + val imageURL = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) + } else { + Optional.empty() + } + val color = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) + } else { + Optional.empty() + } + val size = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { + Optional.of(ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader)) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterStyleInformationStruct(imageURL, color, size) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt index d5a3e09a859f73..a1f60ee83fe421 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt @@ -17,19 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherClusterTrackPreferenceStruct( - val languageCode: String, - val characteristics: Optional>, - val audioOutputIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ContentLauncherClusterTrackPreferenceStruct ( + val languageCode: String, + val characteristics: Optional>, + val audioOutputIndex: UInt) { + override fun toString(): String = buildString { append("ContentLauncherClusterTrackPreferenceStruct {\n") append("\tlanguageCode : $languageCode\n") append("\tcharacteristics : $characteristics\n") @@ -42,13 +43,13 @@ class ContentLauncherClusterTrackPreferenceStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_LANGUAGE_CODE), languageCode) if (characteristics.isPresent) { - val optcharacteristics = characteristics.get() - startArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - for (item in optcharacteristics.iterator()) { - put(AnonymousTag, item) - } - endArray() + val optcharacteristics = characteristics.get() + startArray(ContextSpecificTag(TAG_CHARACTERISTICS)) + for (item in optcharacteristics.iterator()) { + put(AnonymousTag, item) } + endArray() + } put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX), audioOutputIndex) endStructure() } @@ -59,32 +60,25 @@ class ContentLauncherClusterTrackPreferenceStruct( private const val TAG_CHARACTERISTICS = 1 private const val TAG_AUDIO_OUTPUT_INDEX = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterTrackPreferenceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterTrackPreferenceStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val characteristics = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } + val characteristics = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } val audioOutputIndex = tlvReader.getUInt(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX)) - + tlvReader.exitContainer() - return ContentLauncherClusterTrackPreferenceStruct( - languageCode, - characteristics, - audioOutputIndex - ) + return ContentLauncherClusterTrackPreferenceStruct(languageCode, characteristics, audioOutputIndex) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt index a4dd7c659efb22..4357cf625ca244 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterAverageLoadControlStruct(val loadAdjustment: Int) { - override fun toString(): String = buildString { +import java.util.Optional + +class DemandResponseLoadControlClusterAverageLoadControlStruct ( + val loadAdjustment: Int) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterAverageLoadControlStruct {\n") append("\tloadAdjustment : $loadAdjustment\n") append("}\n") @@ -40,13 +45,10 @@ class DemandResponseLoadControlClusterAverageLoadControlStruct(val loadAdjustmen companion object { private const val TAG_LOAD_ADJUSTMENT = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterAverageLoadControlStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterAverageLoadControlStruct { tlvReader.enterStructure(tlvTag) val loadAdjustment = tlvReader.getInt(ContextSpecificTag(TAG_LOAD_ADJUSTMENT)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterAverageLoadControlStruct(loadAdjustment) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt index af1ad8026cc11b..ce5980bf12eab7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterDutyCycleControlStruct(val dutyCycle: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class DemandResponseLoadControlClusterDutyCycleControlStruct ( + val dutyCycle: UInt) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterDutyCycleControlStruct {\n") append("\tdutyCycle : $dutyCycle\n") append("}\n") @@ -40,13 +45,10 @@ class DemandResponseLoadControlClusterDutyCycleControlStruct(val dutyCycle: UInt companion object { private const val TAG_DUTY_CYCLE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterDutyCycleControlStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterDutyCycleControlStruct { tlvReader.enterStructure(tlvTag) val dutyCycle = tlvReader.getUInt(ContextSpecificTag(TAG_DUTY_CYCLE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterDutyCycleControlStruct(dutyCycle) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt index 049c061b9966e1..c957612bd8942e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterHeatingSourceControlStruct(val heatingSource: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class DemandResponseLoadControlClusterHeatingSourceControlStruct ( + val heatingSource: UInt) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterHeatingSourceControlStruct {\n") append("\theatingSource : $heatingSource\n") append("}\n") @@ -40,13 +45,10 @@ class DemandResponseLoadControlClusterHeatingSourceControlStruct(val heatingSour companion object { private const val TAG_HEATING_SOURCE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterHeatingSourceControlStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterHeatingSourceControlStruct { tlvReader.enterStructure(tlvTag) val heatingSource = tlvReader.getUInt(ContextSpecificTag(TAG_HEATING_SOURCE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterHeatingSourceControlStruct(heatingSource) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt index f714af6d7b8fbd..150b4bc952bad3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt @@ -17,24 +17,25 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterLoadControlEventStruct( - val eventID: ByteArray, - val programID: ByteArray?, - val control: UInt, - val deviceClass: ULong, - val enrollmentGroup: Optional, - val criticality: UInt, - val startTime: ULong?, - val transitions: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DemandResponseLoadControlClusterLoadControlEventStruct ( + val eventID: ByteArray, + val programID: ByteArray?, + val control: UInt, + val deviceClass: ULong, + val enrollmentGroup: Optional, + val criticality: UInt, + val startTime: ULong?, + val transitions: List) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventStruct {\n") append("\teventID : $eventID\n") append("\tprogramID : $programID\n") @@ -52,22 +53,22 @@ class DemandResponseLoadControlClusterLoadControlEventStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_EVENT_I_D), eventID) if (programID != null) { - put(ContextSpecificTag(TAG_PROGRAM_I_D), programID) - } else { - putNull(ContextSpecificTag(TAG_PROGRAM_I_D)) - } + put(ContextSpecificTag(TAG_PROGRAM_I_D), programID) + } else { + putNull(ContextSpecificTag(TAG_PROGRAM_I_D)) + } put(ContextSpecificTag(TAG_CONTROL), control) put(ContextSpecificTag(TAG_DEVICE_CLASS), deviceClass) if (enrollmentGroup.isPresent) { - val optenrollmentGroup = enrollmentGroup.get() - put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), optenrollmentGroup) - } + val optenrollmentGroup = enrollmentGroup.get() + put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), optenrollmentGroup) + } put(ContextSpecificTag(TAG_CRITICALITY), criticality) if (startTime != null) { - put(ContextSpecificTag(TAG_START_TIME), startTime) - } else { - putNull(ContextSpecificTag(TAG_START_TIME)) - } + put(ContextSpecificTag(TAG_START_TIME), startTime) + } else { + putNull(ContextSpecificTag(TAG_START_TIME)) + } startArray(ContextSpecificTag(TAG_TRANSITIONS)) for (item in transitions.iterator()) { item.toTlv(AnonymousTag, this) @@ -87,61 +88,40 @@ class DemandResponseLoadControlClusterLoadControlEventStruct( private const val TAG_START_TIME = 6 private const val TAG_TRANSITIONS = 7 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterLoadControlEventStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventStruct { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val programID = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) - null - } + val programID = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) + null + } val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) val deviceClass = tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_CLASS)) - val enrollmentGroup = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) - } else { - Optional.empty() - } + val enrollmentGroup = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) + } else { + Optional.empty() + } val criticality = tlvReader.getUInt(ContextSpecificTag(TAG_CRITICALITY)) - val startTime = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) - null - } - val transitions = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while (!tlvReader.isEndOfContainer()) { - add( - DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - + val startTime = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) + null + } + val transitions = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while(!tlvReader.isEndOfContainer()) { + add(DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStruct( - eventID, - programID, - control, - deviceClass, - enrollmentGroup, - criticality, - startTime, - transitions - ) + return DemandResponseLoadControlClusterLoadControlEventStruct(eventID, programID, control, deviceClass, enrollmentGroup, criticality, startTime, transitions) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt index 6d44b1e020d180..c1643805f9a6bf 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt @@ -17,22 +17,24 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterLoadControlEventTransitionStruct( - val duration: UInt, - val control: UInt, - val temperatureControl: Optional, - val averageLoadControl: Optional, - val dutyCycleControl: Optional, - val powerSavingsControl: Optional, - val heatingSourceControl: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DemandResponseLoadControlClusterLoadControlEventTransitionStruct ( + val duration: UInt, + val control: UInt, + val temperatureControl: Optional, + val averageLoadControl: Optional, + val dutyCycleControl: Optional, + val powerSavingsControl: Optional, + val heatingSourceControl: Optional) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventTransitionStruct {\n") append("\tduration : $duration\n") append("\tcontrol : $control\n") @@ -50,25 +52,25 @@ class DemandResponseLoadControlClusterLoadControlEventTransitionStruct( put(ContextSpecificTag(TAG_DURATION), duration) put(ContextSpecificTag(TAG_CONTROL), control) if (temperatureControl.isPresent) { - val opttemperatureControl = temperatureControl.get() - opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) - } + val opttemperatureControl = temperatureControl.get() + opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) + } if (averageLoadControl.isPresent) { - val optaverageLoadControl = averageLoadControl.get() - optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) - } + val optaverageLoadControl = averageLoadControl.get() + optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) + } if (dutyCycleControl.isPresent) { - val optdutyCycleControl = dutyCycleControl.get() - optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) - } + val optdutyCycleControl = dutyCycleControl.get() + optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) + } if (powerSavingsControl.isPresent) { - val optpowerSavingsControl = powerSavingsControl.get() - optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) - } + val optpowerSavingsControl = powerSavingsControl.get() + optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) + } if (heatingSourceControl.isPresent) { - val optheatingSourceControl = heatingSourceControl.get() - optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) - } + val optheatingSourceControl = heatingSourceControl.get() + optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) + } endStructure() } } @@ -82,80 +84,39 @@ class DemandResponseLoadControlClusterLoadControlEventTransitionStruct( private const val TAG_POWER_SAVINGS_CONTROL = 5 private const val TAG_HEATING_SOURCE_CONTROL = 6 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterLoadControlEventTransitionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventTransitionStruct { tlvReader.enterStructure(tlvTag) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of( - DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv( - ContextSpecificTag(TAG_TEMPERATURE_CONTROL), - tlvReader - ) - ) - } else { - Optional.empty() - } - val averageLoadControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of( - DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv( - ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), - tlvReader - ) - ) - } else { - Optional.empty() - } - val dutyCycleControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of( - DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv( - ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), - tlvReader - ) - ) - } else { - Optional.empty() - } - val powerSavingsControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of( - DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv( - ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), - tlvReader - ) - ) - } else { - Optional.empty() - } - val heatingSourceControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of( - DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv( - ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), - tlvReader - ) - ) - } else { - Optional.empty() - } - + val temperatureControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of(DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + val averageLoadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of(DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) + } else { + Optional.empty() + } + val dutyCycleControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of(DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + val powerSavingsControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of(DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) + } else { + Optional.empty() + } + val heatingSourceControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of(DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventTransitionStruct( - duration, - control, - temperatureControl, - averageLoadControl, - dutyCycleControl, - powerSavingsControl, - heatingSourceControl - ) + return DemandResponseLoadControlClusterLoadControlEventTransitionStruct(duration, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt index 289e4b0a1dbebf..70787ef931f659 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt @@ -17,19 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterLoadControlProgramStruct( - val programID: ByteArray, - val name: String, - val enrollmentGroup: UInt?, - val randomStartMinutes: UInt?, - val randomDurationMinutes: UInt? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DemandResponseLoadControlClusterLoadControlProgramStruct ( + val programID: ByteArray, + val name: String, + val enrollmentGroup: UInt?, + val randomStartMinutes: UInt?, + val randomDurationMinutes: UInt?) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlProgramStruct {\n") append("\tprogramID : $programID\n") append("\tname : $name\n") @@ -45,20 +48,20 @@ class DemandResponseLoadControlClusterLoadControlProgramStruct( put(ContextSpecificTag(TAG_PROGRAM_I_D), programID) put(ContextSpecificTag(TAG_NAME), name) if (enrollmentGroup != null) { - put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), enrollmentGroup) - } else { - putNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } + put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), enrollmentGroup) + } else { + putNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + } if (randomStartMinutes != null) { - put(ContextSpecificTag(TAG_RANDOM_START_MINUTES), randomStartMinutes) - } else { - putNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - } + put(ContextSpecificTag(TAG_RANDOM_START_MINUTES), randomStartMinutes) + } else { + putNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + } if (randomDurationMinutes != null) { - put(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES), randomDurationMinutes) - } else { - putNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - } + put(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES), randomDurationMinutes) + } else { + putNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + } endStructure() } } @@ -70,44 +73,32 @@ class DemandResponseLoadControlClusterLoadControlProgramStruct( private const val TAG_RANDOM_START_MINUTES = 3 private const val TAG_RANDOM_DURATION_MINUTES = 4 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterLoadControlProgramStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlProgramStruct { tlvReader.enterStructure(tlvTag) val programID = tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - val enrollmentGroup = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - null - } - val randomStartMinutes = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - null - } - val randomDurationMinutes = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - null - } - + val enrollmentGroup = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + null + } + val randomStartMinutes = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + null + } + val randomDurationMinutes = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlProgramStruct( - programID, - name, - enrollmentGroup, - randomStartMinutes, - randomDurationMinutes - ) + return DemandResponseLoadControlClusterLoadControlProgramStruct(programID, name, enrollmentGroup, randomStartMinutes, randomDurationMinutes) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt index 30ed601d4ac156..a06b0011af0b89 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt @@ -17,13 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterPowerSavingsControlStruct(val powerSavings: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class DemandResponseLoadControlClusterPowerSavingsControlStruct ( + val powerSavings: UInt) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterPowerSavingsControlStruct {\n") append("\tpowerSavings : $powerSavings\n") append("}\n") @@ -40,13 +45,10 @@ class DemandResponseLoadControlClusterPowerSavingsControlStruct(val powerSavings companion object { private const val TAG_POWER_SAVINGS = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterPowerSavingsControlStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterPowerSavingsControlStruct { tlvReader.enterStructure(tlvTag) val powerSavings = tlvReader.getUInt(ContextSpecificTag(TAG_POWER_SAVINGS)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterPowerSavingsControlStruct(powerSavings) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt index 925c1db888410a..70524b6e349fca 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt @@ -17,19 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterTemperatureControlStruct( - val coolingTempOffset: Optional?, - val heatingtTempOffset: Optional?, - val coolingTempSetpoint: Optional?, - val heatingTempSetpoint: Optional? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DemandResponseLoadControlClusterTemperatureControlStruct ( + val coolingTempOffset: Optional?, + val heatingtTempOffset: Optional?, + val coolingTempSetpoint: Optional?, + val heatingTempSetpoint: Optional?) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterTemperatureControlStruct {\n") append("\tcoolingTempOffset : $coolingTempOffset\n") append("\theatingtTempOffset : $heatingtTempOffset\n") @@ -42,37 +44,37 @@ class DemandResponseLoadControlClusterTemperatureControlStruct( tlvWriter.apply { startStructure(tlvTag) if (coolingTempOffset != null) { - if (coolingTempOffset.isPresent) { - val optcoolingTempOffset = coolingTempOffset.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) - } - } else { - putNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) - } + if (coolingTempOffset.isPresent) { + val optcoolingTempOffset = coolingTempOffset.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) + } + } else { + putNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) + } if (heatingtTempOffset != null) { - if (heatingtTempOffset.isPresent) { - val optheatingtTempOffset = heatingtTempOffset.get() - put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) - } - } else { - putNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) - } + if (heatingtTempOffset.isPresent) { + val optheatingtTempOffset = heatingtTempOffset.get() + put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) + } + } else { + putNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) + } if (coolingTempSetpoint != null) { - if (coolingTempSetpoint.isPresent) { - val optcoolingTempSetpoint = coolingTempSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) - } - } else { - putNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) - } + if (coolingTempSetpoint.isPresent) { + val optcoolingTempSetpoint = coolingTempSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) + } + } else { + putNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) + } if (heatingTempSetpoint != null) { - if (heatingTempSetpoint.isPresent) { - val optheatingTempSetpoint = heatingTempSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) - } - } else { - putNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) - } + if (heatingTempSetpoint.isPresent) { + val optheatingTempSetpoint = heatingTempSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) + } + } else { + putNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) + } endStructure() } } @@ -83,64 +85,52 @@ class DemandResponseLoadControlClusterTemperatureControlStruct( private const val TAG_COOLING_TEMP_SETPOINT = 2 private const val TAG_HEATING_TEMP_SETPOINT = 3 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterTemperatureControlStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterTemperatureControlStruct { tlvReader.enterStructure(tlvTag) - val coolingTempOffset = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) - null - } - val heatingtTempOffset = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) - null - } - val coolingTempSetpoint = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) - null - } - val heatingTempSetpoint = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) - null - } - + val coolingTempOffset = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) + null + } + val heatingtTempOffset = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) + null + } + val coolingTempSetpoint = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) + null + } + val heatingTempSetpoint = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterTemperatureControlStruct( - coolingTempOffset, - heatingtTempOffset, - coolingTempSetpoint, - heatingTempSetpoint - ) + return DemandResponseLoadControlClusterTemperatureControlStruct(coolingTempOffset, heatingtTempOffset, coolingTempSetpoint, heatingTempSetpoint) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt index 0a867ba2296515..c5529da5072ea8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DescriptorClusterDeviceTypeStruct(val deviceType: ULong, val revision: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class DescriptorClusterDeviceTypeStruct ( + val deviceType: ULong, + val revision: UInt) { + override fun toString(): String = buildString { append("DescriptorClusterDeviceTypeStruct {\n") append("\tdeviceType : $deviceType\n") append("\trevision : $revision\n") @@ -43,11 +49,11 @@ class DescriptorClusterDeviceTypeStruct(val deviceType: ULong, val revision: UIn private const val TAG_DEVICE_TYPE = 0 private const val TAG_REVISION = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DescriptorClusterDeviceTypeStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DescriptorClusterDeviceTypeStruct { tlvReader.enterStructure(tlvTag) val deviceType = tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_TYPE)) val revision = tlvReader.getUInt(ContextSpecificTag(TAG_REVISION)) - + tlvReader.exitContainer() return DescriptorClusterDeviceTypeStruct(deviceType, revision) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt index 91d33d5c0fe2e5..89967a1445d75d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt @@ -17,19 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DescriptorClusterSemanticTagStruct( - val mfgCode: UInt?, - val namespaceID: UInt, - val tag: UInt, - val label: Optional? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DescriptorClusterSemanticTagStruct ( + val mfgCode: UInt?, + val namespaceID: UInt, + val tag: UInt, + val label: Optional?) { + override fun toString(): String = buildString { append("DescriptorClusterSemanticTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tnamespaceID : $namespaceID\n") @@ -42,20 +44,20 @@ class DescriptorClusterSemanticTagStruct( tlvWriter.apply { startStructure(tlvTag) if (mfgCode != null) { - put(ContextSpecificTag(TAG_MFG_CODE), mfgCode) - } else { - putNull(ContextSpecificTag(TAG_MFG_CODE)) - } + put(ContextSpecificTag(TAG_MFG_CODE), mfgCode) + } else { + putNull(ContextSpecificTag(TAG_MFG_CODE)) + } put(ContextSpecificTag(TAG_NAMESPACE_I_D), namespaceID) put(ContextSpecificTag(TAG_TAG), tag) if (label != null) { - if (label.isPresent) { - val optlabel = label.get() - put(ContextSpecificTag(TAG_LABEL), optlabel) - } - } else { - putNull(ContextSpecificTag(TAG_LABEL)) - } + if (label.isPresent) { + val optlabel = label.get() + put(ContextSpecificTag(TAG_LABEL), optlabel) + } + } else { + putNull(ContextSpecificTag(TAG_LABEL)) + } endStructure() } } @@ -66,29 +68,27 @@ class DescriptorClusterSemanticTagStruct( private const val TAG_TAG = 2 private const val TAG_LABEL = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DescriptorClusterSemanticTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DescriptorClusterSemanticTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) - null - } + val mfgCode = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) + null + } val namespaceID = tlvReader.getUInt(ContextSpecificTag(TAG_NAMESPACE_I_D)) val tag = tlvReader.getUInt(ContextSpecificTag(TAG_TAG)) - val label = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) - null - } - + val label = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) + null + } + tlvReader.exitContainer() return DescriptorClusterSemanticTagStruct(mfgCode, namespaceID, tag, label) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt index 8389173d80aca7..b473bdd6ebe7c3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt @@ -17,20 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementClusterConstraintsStruct( - val startTime: ULong, - val duration: ULong, - val nominalPower: Optional, - val maximumEnergy: Optional, - val loadControl: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DeviceEnergyManagementClusterConstraintsStruct ( + val startTime: ULong, + val duration: ULong, + val nominalPower: Optional, + val maximumEnergy: Optional, + val loadControl: Optional) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterConstraintsStruct {\n") append("\tstartTime : $startTime\n") append("\tduration : $duration\n") @@ -46,17 +48,17 @@ class DeviceEnergyManagementClusterConstraintsStruct( put(ContextSpecificTag(TAG_START_TIME), startTime) put(ContextSpecificTag(TAG_DURATION), duration) if (nominalPower.isPresent) { - val optnominalPower = nominalPower.get() - put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) - } + val optnominalPower = nominalPower.get() + put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) + } if (maximumEnergy.isPresent) { - val optmaximumEnergy = maximumEnergy.get() - put(ContextSpecificTag(TAG_MAXIMUM_ENERGY), optmaximumEnergy) - } + val optmaximumEnergy = maximumEnergy.get() + put(ContextSpecificTag(TAG_MAXIMUM_ENERGY), optmaximumEnergy) + } if (loadControl.isPresent) { - val optloadControl = loadControl.get() - put(ContextSpecificTag(TAG_LOAD_CONTROL), optloadControl) - } + val optloadControl = loadControl.get() + put(ContextSpecificTag(TAG_LOAD_CONTROL), optloadControl) + } endStructure() } } @@ -68,38 +70,29 @@ class DeviceEnergyManagementClusterConstraintsStruct( private const val TAG_MAXIMUM_ENERGY = 3 private const val TAG_LOAD_CONTROL = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterConstraintsStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterConstraintsStruct { tlvReader.enterStructure(tlvTag) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - val nominalPower = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val maximumEnergy = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) - } else { - Optional.empty() - } - val loadControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_LOAD_CONTROL))) - } else { - Optional.empty() - } - + val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val maximumEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) + } else { + Optional.empty() + } + val loadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_LOAD_CONTROL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterConstraintsStruct( - startTime, - duration, - nominalPower, - maximumEnergy, - loadControl - ) + return DeviceEnergyManagementClusterConstraintsStruct(startTime, duration, nominalPower, maximumEnergy, loadControl) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt index 1d74d861c90b76..d996e8c0c944d0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt @@ -17,19 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementClusterCostStruct( - val costType: UInt, - val value: Long, - val decimalPoints: UInt, - val currency: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DeviceEnergyManagementClusterCostStruct ( + val costType: UInt, + val value: Long, + val decimalPoints: UInt, + val currency: Optional) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterCostStruct {\n") append("\tcostType : $costType\n") append("\tvalue : $value\n") @@ -45,9 +47,9 @@ class DeviceEnergyManagementClusterCostStruct( put(ContextSpecificTag(TAG_VALUE), value) put(ContextSpecificTag(TAG_DECIMAL_POINTS), decimalPoints) if (currency.isPresent) { - val optcurrency = currency.get() - put(ContextSpecificTag(TAG_CURRENCY), optcurrency) - } + val optcurrency = currency.get() + put(ContextSpecificTag(TAG_CURRENCY), optcurrency) + } endStructure() } } @@ -58,18 +60,17 @@ class DeviceEnergyManagementClusterCostStruct( private const val TAG_DECIMAL_POINTS = 2 private const val TAG_CURRENCY = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterCostStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterCostStruct { tlvReader.enterStructure(tlvTag) val costType = tlvReader.getUInt(ContextSpecificTag(TAG_COST_TYPE)) val value = tlvReader.getLong(ContextSpecificTag(TAG_VALUE)) val decimalPoints = tlvReader.getUInt(ContextSpecificTag(TAG_DECIMAL_POINTS)) - val currency = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CURRENCY))) - } else { - Optional.empty() - } - + val currency = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CURRENCY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return DeviceEnergyManagementClusterCostStruct(costType, value, decimalPoints, currency) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt index 17e45fa732ea47..a037d3ad1c7b8f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt @@ -17,25 +17,26 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementClusterForecastStruct( - val forecastId: UInt, - val activeSlotNumber: UInt?, - val startTime: ULong, - val endTime: ULong, - val earliestStartTime: Optional?, - val latestEndTime: Optional, - val isPauseable: Boolean, - val slots: List, - val forecastUpdateReason: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DeviceEnergyManagementClusterForecastStruct ( + val forecastId: UInt, + val activeSlotNumber: UInt?, + val startTime: ULong, + val endTime: ULong, + val earliestStartTime: Optional?, + val latestEndTime: Optional, + val isPauseable: Boolean, + val slots: List, + val forecastUpdateReason: UInt) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterForecastStruct {\n") append("\tforecastId : $forecastId\n") append("\tactiveSlotNumber : $activeSlotNumber\n") @@ -54,24 +55,24 @@ class DeviceEnergyManagementClusterForecastStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_FORECAST_ID), forecastId) if (activeSlotNumber != null) { - put(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER), activeSlotNumber) - } else { - putNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - } + put(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER), activeSlotNumber) + } else { + putNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + } put(ContextSpecificTag(TAG_START_TIME), startTime) put(ContextSpecificTag(TAG_END_TIME), endTime) if (earliestStartTime != null) { - if (earliestStartTime.isPresent) { - val optearliestStartTime = earliestStartTime.get() - put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) - } - } else { - putNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) - } + if (earliestStartTime.isPresent) { + val optearliestStartTime = earliestStartTime.get() + put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) + } + } else { + putNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) + } if (latestEndTime.isPresent) { - val optlatestEndTime = latestEndTime.get() - put(ContextSpecificTag(TAG_LATEST_END_TIME), optlatestEndTime) - } + val optlatestEndTime = latestEndTime.get() + put(ContextSpecificTag(TAG_LATEST_END_TIME), optlatestEndTime) + } put(ContextSpecificTag(TAG_IS_PAUSEABLE), isPauseable) startArray(ContextSpecificTag(TAG_SLOTS)) for (item in slots.iterator()) { @@ -94,59 +95,45 @@ class DeviceEnergyManagementClusterForecastStruct( private const val TAG_SLOTS = 7 private const val TAG_FORECAST_UPDATE_REASON = 8 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterForecastStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterForecastStruct { tlvReader.enterStructure(tlvTag) val forecastId = tlvReader.getUInt(ContextSpecificTag(TAG_FORECAST_ID)) - val activeSlotNumber = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - null - } + val activeSlotNumber = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + null + } val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getULong(ContextSpecificTag(TAG_END_TIME)) - val earliestStartTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EARLIEST_START_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) - null - } - val latestEndTime = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_LATEST_END_TIME))) - } else { - Optional.empty() - } + val earliestStartTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EARLIEST_START_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) + null + } + val latestEndTime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_LATEST_END_TIME))) + } else { + Optional.empty() + } val isPauseable = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_PAUSEABLE)) - val slots = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) - while (!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val slots = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) + while(!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } val forecastUpdateReason = tlvReader.getUInt(ContextSpecificTag(TAG_FORECAST_UPDATE_REASON)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterForecastStruct( - forecastId, - activeSlotNumber, - startTime, - endTime, - earliestStartTime, - latestEndTime, - isPauseable, - slots, - forecastUpdateReason - ) + return DeviceEnergyManagementClusterForecastStruct(forecastId, activeSlotNumber, startTime, endTime, earliestStartTime, latestEndTime, isPauseable, slots, forecastUpdateReason) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt index 7021aa2720949e..20385dd1ca78e2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt @@ -17,18 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementClusterPowerAdjustStruct( - val minPower: Long, - val maxPower: Long, - val minDuration: ULong, - val maxDuration: ULong -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DeviceEnergyManagementClusterPowerAdjustStruct ( + val minPower: Long, + val maxPower: Long, + val minDuration: ULong, + val maxDuration: ULong) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterPowerAdjustStruct {\n") append("\tminPower : $minPower\n") append("\tmaxPower : $maxPower\n") @@ -54,21 +57,16 @@ class DeviceEnergyManagementClusterPowerAdjustStruct( private const val TAG_MIN_DURATION = 2 private const val TAG_MAX_DURATION = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterPowerAdjustStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterPowerAdjustStruct { tlvReader.enterStructure(tlvTag) val minPower = tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER)) val maxPower = tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER)) val minDuration = tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION)) val maxDuration = tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterPowerAdjustStruct( - minPower, - maxPower, - minDuration, - maxDuration - ) + return DeviceEnergyManagementClusterPowerAdjustStruct(minPower, maxPower, minDuration, maxDuration) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt index 11fcf975e99039..6b6209aed1166b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementClusterSlotAdjustmentStruct( - val slotIndex: UInt, - val nominalPower: Long, - val duration: ULong -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DeviceEnergyManagementClusterSlotAdjustmentStruct ( + val slotIndex: UInt, + val nominalPower: Long, + val duration: ULong) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterSlotAdjustmentStruct {\n") append("\tslotIndex : $slotIndex\n") append("\tnominalPower : $nominalPower\n") @@ -50,15 +53,12 @@ class DeviceEnergyManagementClusterSlotAdjustmentStruct( private const val TAG_NOMINAL_POWER = 1 private const val TAG_DURATION = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DeviceEnergyManagementClusterSlotAdjustmentStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterSlotAdjustmentStruct { tlvReader.enterStructure(tlvTag) val slotIndex = tlvReader.getUInt(ContextSpecificTag(TAG_SLOT_INDEX)) val nominalPower = tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterSlotAdjustmentStruct(slotIndex, nominalPower, duration) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt index 18759432dc2ce4..63e8b90eba0cac 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt @@ -17,34 +17,35 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementClusterSlotStruct( - val minDuration: ULong, - val maxDuration: ULong, - val defaultDuration: ULong, - val elapsedSlotTime: ULong, - val remainingSlotTime: ULong, - val slotIsPauseable: Optional, - val minPauseDuration: Optional, - val maxPauseDuration: Optional, - val manufacturerESAState: Optional, - val nominalPower: Optional, - val minPower: Optional, - val maxPower: Optional, - val nominalEnergy: Optional, - val costs: Optional>, - val minPowerAdjustment: Optional, - val maxPowerAdjustment: Optional, - val minDurationAdjustment: Optional, - val maxDurationAdjustment: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DeviceEnergyManagementClusterSlotStruct ( + val minDuration: ULong, + val maxDuration: ULong, + val defaultDuration: ULong, + val elapsedSlotTime: ULong, + val remainingSlotTime: ULong, + val slotIsPauseable: Optional, + val minPauseDuration: Optional, + val maxPauseDuration: Optional, + val manufacturerESAState: Optional, + val nominalPower: Optional, + val minPower: Optional, + val maxPower: Optional, + val nominalEnergy: Optional, + val costs: Optional>, + val minPowerAdjustment: Optional, + val maxPowerAdjustment: Optional, + val minDurationAdjustment: Optional, + val maxDurationAdjustment: Optional) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterSlotStruct {\n") append("\tminDuration : $minDuration\n") append("\tmaxDuration : $maxDuration\n") @@ -76,61 +77,61 @@ class DeviceEnergyManagementClusterSlotStruct( put(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME), elapsedSlotTime) put(ContextSpecificTag(TAG_REMAINING_SLOT_TIME), remainingSlotTime) if (slotIsPauseable.isPresent) { - val optslotIsPauseable = slotIsPauseable.get() - put(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE), optslotIsPauseable) - } + val optslotIsPauseable = slotIsPauseable.get() + put(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE), optslotIsPauseable) + } if (minPauseDuration.isPresent) { - val optminPauseDuration = minPauseDuration.get() - put(ContextSpecificTag(TAG_MIN_PAUSE_DURATION), optminPauseDuration) - } + val optminPauseDuration = minPauseDuration.get() + put(ContextSpecificTag(TAG_MIN_PAUSE_DURATION), optminPauseDuration) + } if (maxPauseDuration.isPresent) { - val optmaxPauseDuration = maxPauseDuration.get() - put(ContextSpecificTag(TAG_MAX_PAUSE_DURATION), optmaxPauseDuration) - } + val optmaxPauseDuration = maxPauseDuration.get() + put(ContextSpecificTag(TAG_MAX_PAUSE_DURATION), optmaxPauseDuration) + } if (manufacturerESAState.isPresent) { - val optmanufacturerESAState = manufacturerESAState.get() - put(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE), optmanufacturerESAState) - } + val optmanufacturerESAState = manufacturerESAState.get() + put(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE), optmanufacturerESAState) + } if (nominalPower.isPresent) { - val optnominalPower = nominalPower.get() - put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) - } + val optnominalPower = nominalPower.get() + put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) + } if (minPower.isPresent) { - val optminPower = minPower.get() - put(ContextSpecificTag(TAG_MIN_POWER), optminPower) - } + val optminPower = minPower.get() + put(ContextSpecificTag(TAG_MIN_POWER), optminPower) + } if (maxPower.isPresent) { - val optmaxPower = maxPower.get() - put(ContextSpecificTag(TAG_MAX_POWER), optmaxPower) - } + val optmaxPower = maxPower.get() + put(ContextSpecificTag(TAG_MAX_POWER), optmaxPower) + } if (nominalEnergy.isPresent) { - val optnominalEnergy = nominalEnergy.get() - put(ContextSpecificTag(TAG_NOMINAL_ENERGY), optnominalEnergy) - } + val optnominalEnergy = nominalEnergy.get() + put(ContextSpecificTag(TAG_NOMINAL_ENERGY), optnominalEnergy) + } if (costs.isPresent) { - val optcosts = costs.get() - startArray(ContextSpecificTag(TAG_COSTS)) - for (item in optcosts.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + val optcosts = costs.get() + startArray(ContextSpecificTag(TAG_COSTS)) + for (item in optcosts.iterator()) { + item.toTlv(AnonymousTag, this) } + endArray() + } if (minPowerAdjustment.isPresent) { - val optminPowerAdjustment = minPowerAdjustment.get() - put(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT), optminPowerAdjustment) - } + val optminPowerAdjustment = minPowerAdjustment.get() + put(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT), optminPowerAdjustment) + } if (maxPowerAdjustment.isPresent) { - val optmaxPowerAdjustment = maxPowerAdjustment.get() - put(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT), optmaxPowerAdjustment) - } + val optmaxPowerAdjustment = maxPowerAdjustment.get() + put(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT), optmaxPowerAdjustment) + } if (minDurationAdjustment.isPresent) { - val optminDurationAdjustment = minDurationAdjustment.get() - put(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT), optminDurationAdjustment) - } + val optminDurationAdjustment = minDurationAdjustment.get() + put(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT), optminDurationAdjustment) + } if (maxDurationAdjustment.isPresent) { - val optmaxDurationAdjustment = maxDurationAdjustment.get() - put(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT), optmaxDurationAdjustment) - } + val optmaxDurationAdjustment = maxDurationAdjustment.get() + put(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT), optmaxDurationAdjustment) + } endStructure() } } @@ -155,122 +156,88 @@ class DeviceEnergyManagementClusterSlotStruct( private const val TAG_MIN_DURATION_ADJUSTMENT = 16 private const val TAG_MAX_DURATION_ADJUSTMENT = 17 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterSlotStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterSlotStruct { tlvReader.enterStructure(tlvTag) val minDuration = tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION)) val maxDuration = tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION)) val defaultDuration = tlvReader.getULong(ContextSpecificTag(TAG_DEFAULT_DURATION)) val elapsedSlotTime = tlvReader.getULong(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME)) val remainingSlotTime = tlvReader.getULong(ContextSpecificTag(TAG_REMAINING_SLOT_TIME)) - val slotIsPauseable = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) - } else { - Optional.empty() - } - val minPauseDuration = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) - } else { - Optional.empty() - } - val maxPauseDuration = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) - } else { - Optional.empty() - } - val manufacturerESAState = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) - } else { - Optional.empty() - } - val nominalPower = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val minPower = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) - } else { - Optional.empty() - } - val maxPower = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) - } else { - Optional.empty() - } - val nominalEnergy = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) - } else { - Optional.empty() - } - val costs = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) - while (!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val minPowerAdjustment = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxPowerAdjustment = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val minDurationAdjustment = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxDurationAdjustment = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - + val slotIsPauseable = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) + } else { + Optional.empty() + } + val minPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) + } else { + Optional.empty() + } + val maxPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) + } else { + Optional.empty() + } + val manufacturerESAState = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) + } else { + Optional.empty() + } + val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val minPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) + } else { + Optional.empty() + } + val maxPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) + } else { + Optional.empty() + } + val nominalEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) + } else { + Optional.empty() + } + val costs = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) + while(!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val minPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val minDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterSlotStruct( - minDuration, - maxDuration, - defaultDuration, - elapsedSlotTime, - remainingSlotTime, - slotIsPauseable, - minPauseDuration, - maxPauseDuration, - manufacturerESAState, - nominalPower, - minPower, - maxPower, - nominalEnergy, - costs, - minPowerAdjustment, - maxPowerAdjustment, - minDurationAdjustment, - maxDurationAdjustment - ) + return DeviceEnergyManagementClusterSlotStruct(minDuration, maxDuration, defaultDuration, elapsedSlotTime, remainingSlotTime, slotIsPauseable, minPauseDuration, maxPauseDuration, manufacturerESAState, nominalPower, minPower, maxPower, nominalEnergy, costs, minPowerAdjustment, maxPowerAdjustment, minDurationAdjustment, maxDurationAdjustment) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt index 0cbbf8fb8c37eb..04305789265487 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt @@ -20,15 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherModeClusterModeOptionStruct( - val label: String, - val mode: UInt, - val modeTags: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class DishwasherModeClusterModeOptionStruct ( + val label: String, + val mode: UInt, + val modeTags: List) { + override fun toString(): String = buildString { append("DishwasherModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -55,19 +57,18 @@ class DishwasherModeClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return DishwasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt index 916f58bdab72e6..f2615f2ddeb01e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt @@ -17,14 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class DishwasherModeClusterModeTagStruct ( + val mfgCode: Optional, + val value: UInt) { + override fun toString(): String = buildString { append("DishwasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -35,9 +40,9 @@ class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val value: tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -47,16 +52,15 @@ class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val value: private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return DishwasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt index 5ee8045b4d17ed..108dd2b0efe922 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterCredentialStruct(val credentialType: UInt, val credentialIndex: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class DoorLockClusterCredentialStruct ( + val credentialType: UInt, + val credentialIndex: UInt) { + override fun toString(): String = buildString { append("DoorLockClusterCredentialStruct {\n") append("\tcredentialType : $credentialType\n") append("\tcredentialIndex : $credentialIndex\n") @@ -43,11 +49,11 @@ class DoorLockClusterCredentialStruct(val credentialType: UInt, val credentialIn private const val TAG_CREDENTIAL_TYPE = 0 private const val TAG_CREDENTIAL_INDEX = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterCredentialStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterCredentialStruct { tlvReader.enterStructure(tlvTag) val credentialType = tlvReader.getUInt(ContextSpecificTag(TAG_CREDENTIAL_TYPE)) val credentialIndex = tlvReader.getUInt(ContextSpecificTag(TAG_CREDENTIAL_INDEX)) - + tlvReader.exitContainer() return DoorLockClusterCredentialStruct(credentialType, credentialIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt index bbce3fc7d16ff7..498c715482bd90 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt @@ -17,20 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( - val energy: Long, - val startTimestamp: Optional, - val endTimestamp: Optional, - val startSystime: Optional, - val endSystime: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct ( + val energy: Long, + val startTimestamp: Optional, + val endTimestamp: Optional, + val startSystime: Optional, + val endSystime: Optional) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterEnergyMeasurementStruct {\n") append("\tenergy : $energy\n") append("\tstartTimestamp : $startTimestamp\n") @@ -45,21 +47,21 @@ class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_ENERGY), energy) if (startTimestamp.isPresent) { - val optstartTimestamp = startTimestamp.get() - put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) - } + val optstartTimestamp = startTimestamp.get() + put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) + } if (endTimestamp.isPresent) { - val optendTimestamp = endTimestamp.get() - put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) - } + val optendTimestamp = endTimestamp.get() + put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) + } if (startSystime.isPresent) { - val optstartSystime = startSystime.get() - put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) - } + val optstartSystime = startSystime.get() + put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) + } if (endSystime.isPresent) { - val optendSystime = endSystime.get() - put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) - } + val optendSystime = endSystime.get() + put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) + } endStructure() } } @@ -71,46 +73,33 @@ class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( private const val TAG_START_SYSTIME = 3 private const val TAG_END_SYSTIME = 4 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { tlvReader.enterStructure(tlvTag) val energy = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY)) - val startTimestamp = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_TIMESTAMP))) - } else { - Optional.empty() - } - val endTimestamp = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_TIMESTAMP))) - } else { - Optional.empty() - } - val startSystime = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) - } else { - Optional.empty() - } - val endSystime = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) - } else { - Optional.empty() - } - + val startTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( - energy, - startTimestamp, - endTimestamp, - startSystime, - endSystime - ) + return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct(energy, startTimestamp, endTimestamp, startSystime, endSystime) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt index 8ce0529f9cd457..53795eacfd0bda 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -17,23 +17,25 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( - val rangeMin: Long, - val rangeMax: Long, - val percentMax: Optional, - val percentMin: Optional, - val percentTypical: Optional, - val fixedMax: Optional, - val fixedMin: Optional, - val fixedTypical: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct ( + val rangeMin: Long, + val rangeMax: Long, + val percentMax: Optional, + val percentMin: Optional, + val percentTypical: Optional, + val fixedMax: Optional, + val fixedMin: Optional, + val fixedTypical: Optional) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct {\n") append("\trangeMin : $rangeMin\n") append("\trangeMax : $rangeMax\n") @@ -52,29 +54,29 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( put(ContextSpecificTag(TAG_RANGE_MIN), rangeMin) put(ContextSpecificTag(TAG_RANGE_MAX), rangeMax) if (percentMax.isPresent) { - val optpercentMax = percentMax.get() - put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) - } + val optpercentMax = percentMax.get() + put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) + } if (percentMin.isPresent) { - val optpercentMin = percentMin.get() - put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) - } + val optpercentMin = percentMin.get() + put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) + } if (percentTypical.isPresent) { - val optpercentTypical = percentTypical.get() - put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) - } + val optpercentTypical = percentTypical.get() + put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) + } if (fixedMax.isPresent) { - val optfixedMax = fixedMax.get() - put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) - } + val optfixedMax = fixedMax.get() + put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) + } if (fixedMin.isPresent) { - val optfixedMin = fixedMin.get() - put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) - } + val optfixedMin = fixedMin.get() + put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) + } if (fixedTypical.isPresent) { - val optfixedTypical = fixedTypical.get() - put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) - } + val optfixedTypical = fixedTypical.get() + put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) + } endStructure() } } @@ -89,62 +91,44 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( private const val TAG_FIXED_MIN = 6 private const val TAG_FIXED_TYPICAL = 7 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { tlvReader.enterStructure(tlvTag) val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) - val percentMax = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MAX))) - } else { - Optional.empty() - } - val percentMin = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MIN))) - } else { - Optional.empty() - } - val percentTypical = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_TYPICAL))) - } else { - Optional.empty() - } - val fixedMax = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) - } else { - Optional.empty() - } - val fixedMin = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) - } else { - Optional.empty() - } - val fixedTypical = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) - } else { - Optional.empty() - } - + val percentMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( - rangeMin, - rangeMax, - percentMax, - percentMin, - percentTypical, - fixedMax, - fixedMin, - fixedTypical - ) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct(rangeMin, rangeMax, percentMax, percentMin, percentTypical, fixedMax, fixedMin, fixedTypical) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt index 3c33b23cb9e505..25bd74a73e38b7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt @@ -20,17 +20,19 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( - val measurementType: UInt, - val measured: Boolean, - val minMeasuredValue: Long, - val maxMeasuredValue: Long, - val accuracyRanges: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct ( + val measurementType: UInt, + val measured: Boolean, + val minMeasuredValue: Long, + val maxMeasuredValue: Long, + val accuracyRanges: List) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct {\n") append("\tmeasurementType : $measurementType\n") append("\tmeasured : $measured\n") @@ -63,38 +65,23 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( private const val TAG_MAX_MEASURED_VALUE = 3 private const val TAG_ACCURACY_RANGES = 4 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { tlvReader.enterStructure(tlvTag) val measurementType = tlvReader.getUInt(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) - val accuracyRanges = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) - while (!tlvReader.isEndOfContainer()) { - add( - ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - + val accuracyRanges = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while(!tlvReader.isEndOfContainer()) { + add(ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( - measurementType, - measured, - minMeasuredValue, - maxMeasuredValue, - accuracyRanges - ) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct(measurementType, measured, minMeasuredValue, maxMeasuredValue, accuracyRanges) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt index bddc2563640620..1fe6ccedd3ae38 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt @@ -20,14 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterChargingTargetScheduleStruct( - val dayOfWeekForSequence: UInt, - val chargingTargets: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class EnergyEvseClusterChargingTargetScheduleStruct ( + val dayOfWeekForSequence: UInt, + val chargingTargets: List) { + override fun toString(): String = buildString { append("EnergyEvseClusterChargingTargetScheduleStruct {\n") append("\tdayOfWeekForSequence : $dayOfWeekForSequence\n") append("\tchargingTargets : $chargingTargets\n") @@ -51,18 +53,17 @@ class EnergyEvseClusterChargingTargetScheduleStruct( private const val TAG_DAY_OF_WEEK_FOR_SEQUENCE = 0 private const val TAG_CHARGING_TARGETS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetScheduleStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterChargingTargetScheduleStruct { tlvReader.enterStructure(tlvTag) val dayOfWeekForSequence = tlvReader.getUInt(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) - val chargingTargets = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) - while (!tlvReader.isEndOfContainer()) { - add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val chargingTargets = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) + while(!tlvReader.isEndOfContainer()) { + add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return EnergyEvseClusterChargingTargetScheduleStruct(dayOfWeekForSequence, chargingTargets) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt index 9e859dbdf40e53..1f87d383888f87 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt @@ -17,18 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterChargingTargetStruct( - val targetTimeMinutesPastMidnight: UInt, - val targetSoC: Optional, - val addedEnergy: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class EnergyEvseClusterChargingTargetStruct ( + val targetTimeMinutesPastMidnight: UInt, + val targetSoC: Optional, + val addedEnergy: Optional) { + override fun toString(): String = buildString { append("EnergyEvseClusterChargingTargetStruct {\n") append("\ttargetTimeMinutesPastMidnight : $targetTimeMinutesPastMidnight\n") append("\ttargetSoC : $targetSoC\n") @@ -41,13 +43,13 @@ class EnergyEvseClusterChargingTargetStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT), targetTimeMinutesPastMidnight) if (targetSoC.isPresent) { - val opttargetSoC = targetSoC.get() - put(ContextSpecificTag(TAG_TARGET_SO_C), opttargetSoC) - } + val opttargetSoC = targetSoC.get() + put(ContextSpecificTag(TAG_TARGET_SO_C), opttargetSoC) + } if (addedEnergy.isPresent) { - val optaddedEnergy = addedEnergy.get() - put(ContextSpecificTag(TAG_ADDED_ENERGY), optaddedEnergy) - } + val optaddedEnergy = addedEnergy.get() + put(ContextSpecificTag(TAG_ADDED_ENERGY), optaddedEnergy) + } endStructure() } } @@ -57,30 +59,23 @@ class EnergyEvseClusterChargingTargetStruct( private const val TAG_TARGET_SO_C = 1 private const val TAG_ADDED_ENERGY = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterChargingTargetStruct { tlvReader.enterStructure(tlvTag) - val targetTimeMinutesPastMidnight = - tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) - val targetSoC = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SO_C))) - } else { - Optional.empty() - } - val addedEnergy = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) - } else { - Optional.empty() - } - + val targetTimeMinutesPastMidnight = tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) + val targetSoC = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SO_C))) + } else { + Optional.empty() + } + val addedEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterChargingTargetStruct( - targetTimeMinutesPastMidnight, - targetSoC, - addedEnergy - ) + return EnergyEvseClusterChargingTargetStruct(targetTimeMinutesPastMidnight, targetSoC, addedEnergy) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt index 75f77558f0e982..677ef98e62f19c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt @@ -17,14 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyPreferenceClusterBalanceStruct(val step: UInt, val label: Optional) { - override fun toString(): String = buildString { +import java.util.Optional + +class EnergyPreferenceClusterBalanceStruct ( + val step: UInt, + val label: Optional) { + override fun toString(): String = buildString { append("EnergyPreferenceClusterBalanceStruct {\n") append("\tstep : $step\n") append("\tlabel : $label\n") @@ -36,9 +41,9 @@ class EnergyPreferenceClusterBalanceStruct(val step: UInt, val label: Optional, - val IPv6Addresses: List, - val type: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class GeneralDiagnosticsClusterNetworkInterface ( + val name: String, + val isOperational: Boolean, + val offPremiseServicesReachableIPv4: Boolean?, + val offPremiseServicesReachableIPv6: Boolean?, + val hardwareAddress: ByteArray, + val IPv4Addresses: List, + val IPv6Addresses: List, + val type: UInt) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterNetworkInterface {\n") append("\tname : $name\n") append("\tisOperational : $isOperational\n") @@ -52,21 +54,15 @@ class GeneralDiagnosticsClusterNetworkInterface( put(ContextSpecificTag(TAG_NAME), name) put(ContextSpecificTag(TAG_IS_OPERATIONAL), isOperational) if (offPremiseServicesReachableIPv4 != null) { - put( - ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), - offPremiseServicesReachableIPv4 - ) - } else { - putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - } + put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), offPremiseServicesReachableIPv4) + } else { + putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + } if (offPremiseServicesReachableIPv6 != null) { - put( - ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), - offPremiseServicesReachableIPv6 - ) - } else { - putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - } + put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), offPremiseServicesReachableIPv6) + } else { + putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + } put(ContextSpecificTag(TAG_HARDWARE_ADDRESS), hardwareAddress) startArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) for (item in IPv4Addresses.iterator()) { @@ -93,55 +89,42 @@ class GeneralDiagnosticsClusterNetworkInterface( private const val TAG_I_PV6_ADDRESSES = 6 private const val TAG_TYPE = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterNetworkInterface { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterNetworkInterface { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val isOperational = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_OPERATIONAL)) - val offPremiseServicesReachableIPv4 = - if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - null - } - val offPremiseServicesReachableIPv6 = - if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - null - } + val offPremiseServicesReachableIPv4 = if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + null + } + val offPremiseServicesReachableIPv6 = if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + null + } val hardwareAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_HARDWARE_ADDRESS)) - val IPv4Addresses = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val IPv6Addresses = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val IPv4Addresses = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val IPv6Addresses = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) - + tlvReader.exitContainer() - return GeneralDiagnosticsClusterNetworkInterface( - name, - isOperational, - offPremiseServicesReachableIPv4, - offPremiseServicesReachableIPv6, - hardwareAddress, - IPv4Addresses, - IPv6Addresses, - type - ) + return GeneralDiagnosticsClusterNetworkInterface(name, isOperational, offPremiseServicesReachableIPv4, offPremiseServicesReachableIPv6, hardwareAddress, IPv4Addresses, IPv6Addresses, type) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt index 1549a376b4542a..72cf67168df8e4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt @@ -17,20 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GroupKeyManagementClusterGroupInfoMapStruct( - val groupId: UInt, - val endpoints: List, - val groupName: Optional, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class GroupKeyManagementClusterGroupInfoMapStruct ( + val groupId: UInt, + val endpoints: List, + val groupName: Optional, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("GroupKeyManagementClusterGroupInfoMapStruct {\n") append("\tgroupId : $groupId\n") append("\tendpoints : $endpoints\n") @@ -49,9 +50,9 @@ class GroupKeyManagementClusterGroupInfoMapStruct( } endArray() if (groupName.isPresent) { - val optgroupName = groupName.get() - put(ContextSpecificTag(TAG_GROUP_NAME), optgroupName) - } + val optgroupName = groupName.get() + put(ContextSpecificTag(TAG_GROUP_NAME), optgroupName) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -63,25 +64,23 @@ class GroupKeyManagementClusterGroupInfoMapStruct( private const val TAG_GROUP_NAME = 3 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupInfoMapStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GroupKeyManagementClusterGroupInfoMapStruct { tlvReader.enterStructure(tlvTag) val groupId = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_ID)) - val endpoints = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val groupName = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) - } else { - Optional.empty() - } + val endpoints = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val groupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupInfoMapStruct(groupId, endpoints, groupName, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt index 46f4656366bbc8..71d7c3ca4cb959 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GroupKeyManagementClusterGroupKeyMapStruct( - val groupId: UInt, - val groupKeySetID: UInt, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class GroupKeyManagementClusterGroupKeyMapStruct ( + val groupId: UInt, + val groupKeySetID: UInt, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("GroupKeyManagementClusterGroupKeyMapStruct {\n") append("\tgroupId : $groupId\n") append("\tgroupKeySetID : $groupKeySetID\n") @@ -50,12 +53,12 @@ class GroupKeyManagementClusterGroupKeyMapStruct( private const val TAG_GROUP_KEY_SET_I_D = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupKeyMapStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GroupKeyManagementClusterGroupKeyMapStruct { tlvReader.enterStructure(tlvTag) val groupId = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_ID)) val groupKeySetID = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupKeyMapStruct(groupId, groupKeySetID, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt index 4d995ac2974023..2eee6ef47d3353 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt @@ -17,22 +17,25 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GroupKeyManagementClusterGroupKeySetStruct( - val groupKeySetID: UInt, - val groupKeySecurityPolicy: UInt, - val epochKey0: ByteArray?, - val epochStartTime0: ULong?, - val epochKey1: ByteArray?, - val epochStartTime1: ULong?, - val epochKey2: ByteArray?, - val epochStartTime2: ULong? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class GroupKeyManagementClusterGroupKeySetStruct ( + val groupKeySetID: UInt, + val groupKeySecurityPolicy: UInt, + val epochKey0: ByteArray?, + val epochStartTime0: ULong?, + val epochKey1: ByteArray?, + val epochStartTime1: ULong?, + val epochKey2: ByteArray?, + val epochStartTime2: ULong?) { + override fun toString(): String = buildString { append("GroupKeyManagementClusterGroupKeySetStruct {\n") append("\tgroupKeySetID : $groupKeySetID\n") append("\tgroupKeySecurityPolicy : $groupKeySecurityPolicy\n") @@ -51,35 +54,35 @@ class GroupKeyManagementClusterGroupKeySetStruct( put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D), groupKeySetID) put(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY), groupKeySecurityPolicy) if (epochKey0 != null) { - put(ContextSpecificTag(TAG_EPOCH_KEY0), epochKey0) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_KEY0)) - } + put(ContextSpecificTag(TAG_EPOCH_KEY0), epochKey0) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_KEY0)) + } if (epochStartTime0 != null) { - put(ContextSpecificTag(TAG_EPOCH_START_TIME0), epochStartTime0) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - } + put(ContextSpecificTag(TAG_EPOCH_START_TIME0), epochStartTime0) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + } if (epochKey1 != null) { - put(ContextSpecificTag(TAG_EPOCH_KEY1), epochKey1) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_KEY1)) - } + put(ContextSpecificTag(TAG_EPOCH_KEY1), epochKey1) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_KEY1)) + } if (epochStartTime1 != null) { - put(ContextSpecificTag(TAG_EPOCH_START_TIME1), epochStartTime1) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - } + put(ContextSpecificTag(TAG_EPOCH_START_TIME1), epochStartTime1) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + } if (epochKey2 != null) { - put(ContextSpecificTag(TAG_EPOCH_KEY2), epochKey2) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_KEY2)) - } + put(ContextSpecificTag(TAG_EPOCH_KEY2), epochKey2) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_KEY2)) + } if (epochStartTime2 != null) { - put(ContextSpecificTag(TAG_EPOCH_START_TIME2), epochStartTime2) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - } + put(ContextSpecificTag(TAG_EPOCH_START_TIME2), epochStartTime2) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + } endStructure() } } @@ -94,66 +97,50 @@ class GroupKeyManagementClusterGroupKeySetStruct( private const val TAG_EPOCH_KEY2 = 6 private const val TAG_EPOCH_START_TIME2 = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupKeySetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GroupKeyManagementClusterGroupKeySetStruct { tlvReader.enterStructure(tlvTag) val groupKeySetID = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) - val groupKeySecurityPolicy = - tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) - val epochKey0 = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) - null - } - val epochStartTime0 = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - null - } - val epochKey1 = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) - null - } - val epochStartTime1 = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - null - } - val epochKey2 = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) - null - } - val epochStartTime2 = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - null - } - + val groupKeySecurityPolicy = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) + val epochKey0 = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) + null + } + val epochStartTime0 = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + null + } + val epochKey1 = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) + null + } + val epochStartTime1 = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + null + } + val epochKey2 = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) + null + } + val epochStartTime2 = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + null + } + tlvReader.exitContainer() - return GroupKeyManagementClusterGroupKeySetStruct( - groupKeySetID, - groupKeySecurityPolicy, - epochKey0, - epochStartTime0, - epochKey1, - epochStartTime1, - epochKey2, - epochStartTime2 - ) + return GroupKeyManagementClusterGroupKeySetStruct(groupKeySetID, groupKeySecurityPolicy, epochKey0, epochStartTime0, epochKey1, epochStartTime1, epochKey2, epochStartTime2) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt index b36468116ac1dd..a5e79f7e076234 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class HepaFilterMonitoringClusterReplacementProductStruct( - val productIdentifierType: UInt, - val productIdentifierValue: String -) { - override fun toString(): String = buildString { +import java.util.Optional + +class HepaFilterMonitoringClusterReplacementProductStruct ( + val productIdentifierType: UInt, + val productIdentifierValue: String) { + override fun toString(): String = buildString { append("HepaFilterMonitoringClusterReplacementProductStruct {\n") append("\tproductIdentifierType : $productIdentifierType\n") append("\tproductIdentifierValue : $productIdentifierValue\n") @@ -46,21 +49,14 @@ class HepaFilterMonitoringClusterReplacementProductStruct( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): HepaFilterMonitoringClusterReplacementProductStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : HepaFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) val productIdentifierType = tlvReader.getUInt(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = - tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return HepaFilterMonitoringClusterReplacementProductStruct( - productIdentifierType, - productIdentifierValue - ) + return HepaFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt index 87927430232e4e..73b5b688af77c2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class IcdManagementClusterMonitoringRegistrationStruct( - val checkInNodeID: ULong, - val monitoredSubject: ULong, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class IcdManagementClusterMonitoringRegistrationStruct ( + val checkInNodeID: ULong, + val monitoredSubject: ULong, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("IcdManagementClusterMonitoringRegistrationStruct {\n") append("\tcheckInNodeID : $checkInNodeID\n") append("\tmonitoredSubject : $monitoredSubject\n") @@ -50,22 +53,15 @@ class IcdManagementClusterMonitoringRegistrationStruct( private const val TAG_MONITORED_SUBJECT = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): IcdManagementClusterMonitoringRegistrationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : IcdManagementClusterMonitoringRegistrationStruct { tlvReader.enterStructure(tlvTag) val checkInNodeID = tlvReader.getULong(ContextSpecificTag(TAG_CHECK_IN_NODE_I_D)) val monitoredSubject = tlvReader.getULong(ContextSpecificTag(TAG_MONITORED_SUBJECT)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return IcdManagementClusterMonitoringRegistrationStruct( - checkInNodeID, - monitoredSubject, - fabricIndex - ) + return IcdManagementClusterMonitoringRegistrationStruct(checkInNodeID, monitoredSubject, fabricIndex) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt index f6ca291e0bb46e..539ddd1fe657ec 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt @@ -20,15 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherModeClusterModeOptionStruct( - val label: String, - val mode: UInt, - val modeTags: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class LaundryWasherModeClusterModeOptionStruct ( + val label: String, + val mode: UInt, + val modeTags: List) { + override fun toString(): String = buildString { append("LaundryWasherModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -55,19 +57,18 @@ class LaundryWasherModeClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): LaundryWasherModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : LaundryWasherModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return LaundryWasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt index 09c2915126efd6..f5e971f19259ee 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt @@ -17,14 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class LaundryWasherModeClusterModeTagStruct ( + val mfgCode: Optional, + val value: UInt) { + override fun toString(): String = buildString { append("LaundryWasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -35,9 +40,9 @@ class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val val tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -47,16 +52,15 @@ class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val val private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): LaundryWasherModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : LaundryWasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return LaundryWasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt index b2b26104143da8..a1e171a4805248 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt @@ -17,18 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaInputClusterInputInfoStruct( - val index: UInt, - val inputType: UInt, - val name: String, - val description: String -) { - override fun toString(): String = buildString { +import java.util.Optional + +class MediaInputClusterInputInfoStruct ( + val index: UInt, + val inputType: UInt, + val name: String, + val description: String) { + override fun toString(): String = buildString { append("MediaInputClusterInputInfoStruct {\n") append("\tindex : $index\n") append("\tinputType : $inputType\n") @@ -54,13 +57,13 @@ class MediaInputClusterInputInfoStruct( private const val TAG_NAME = 2 private const val TAG_DESCRIPTION = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaInputClusterInputInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaInputClusterInputInfoStruct { tlvReader.enterStructure(tlvTag) val index = tlvReader.getUInt(ContextSpecificTag(TAG_INDEX)) val inputType = tlvReader.getUInt(ContextSpecificTag(TAG_INPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val description = tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION)) - + tlvReader.exitContainer() return MediaInputClusterInputInfoStruct(index, inputType, name, description) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt index c58c381f8d6e14..a41c94eb25f23b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaPlaybackClusterPlaybackPositionStruct(val updatedAt: ULong, val position: ULong?) { - override fun toString(): String = buildString { +import java.util.Optional + +class MediaPlaybackClusterPlaybackPositionStruct ( + val updatedAt: ULong, + val position: ULong?) { + override fun toString(): String = buildString { append("MediaPlaybackClusterPlaybackPositionStruct {\n") append("\tupdatedAt : $updatedAt\n") append("\tposition : $position\n") @@ -35,10 +41,10 @@ class MediaPlaybackClusterPlaybackPositionStruct(val updatedAt: ULong, val posit startStructure(tlvTag) put(ContextSpecificTag(TAG_UPDATED_AT), updatedAt) if (position != null) { - put(ContextSpecificTag(TAG_POSITION), position) - } else { - putNull(ContextSpecificTag(TAG_POSITION)) - } + put(ContextSpecificTag(TAG_POSITION), position) + } else { + putNull(ContextSpecificTag(TAG_POSITION)) + } endStructure() } } @@ -47,17 +53,16 @@ class MediaPlaybackClusterPlaybackPositionStruct(val updatedAt: ULong, val posit private const val TAG_UPDATED_AT = 0 private const val TAG_POSITION = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterPlaybackPositionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterPlaybackPositionStruct { tlvReader.enterStructure(tlvTag) val updatedAt = tlvReader.getULong(ContextSpecificTag(TAG_UPDATED_AT)) - val position = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) - null - } - + val position = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterPlaybackPositionStruct(updatedAt, position) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt index 1b991a4a051864..85afda84daca8d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt @@ -17,17 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaPlaybackClusterTrackAttributesStruct( - val languageCode: String, - val displayName: Optional? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class MediaPlaybackClusterTrackAttributesStruct ( + val languageCode: String, + val displayName: Optional?) { + override fun toString(): String = buildString { append("MediaPlaybackClusterTrackAttributesStruct {\n") append("\tlanguageCode : $languageCode\n") append("\tdisplayName : $displayName\n") @@ -39,13 +41,13 @@ class MediaPlaybackClusterTrackAttributesStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_LANGUAGE_CODE), languageCode) if (displayName != null) { - if (displayName.isPresent) { - val optdisplayName = displayName.get() - put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) - } - } else { - putNull(ContextSpecificTag(TAG_DISPLAY_NAME)) - } + if (displayName.isPresent) { + val optdisplayName = displayName.get() + put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) + } + } else { + putNull(ContextSpecificTag(TAG_DISPLAY_NAME)) + } endStructure() } } @@ -54,21 +56,20 @@ class MediaPlaybackClusterTrackAttributesStruct( private const val TAG_LANGUAGE_CODE = 0 private const val TAG_DISPLAY_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackAttributesStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterTrackAttributesStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val displayName = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) - null - } - + val displayName = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackAttributesStruct(languageCode, displayName) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt index 087bc437a2a754..cca4fa751f8d8d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaPlaybackClusterTrackStruct( - val id: String, - val trackAttributes: MediaPlaybackClusterTrackAttributesStruct? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class MediaPlaybackClusterTrackStruct ( + val id: String, + val trackAttributes: MediaPlaybackClusterTrackAttributesStruct?) { + override fun toString(): String = buildString { append("MediaPlaybackClusterTrackStruct {\n") append("\tid : $id\n") append("\ttrackAttributes : $trackAttributes\n") @@ -38,10 +41,10 @@ class MediaPlaybackClusterTrackStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_ID), id) if (trackAttributes != null) { - trackAttributes.toTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), this) - } else { - putNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) - } + trackAttributes.toTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), this) + } else { + putNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) + } endStructure() } } @@ -50,20 +53,16 @@ class MediaPlaybackClusterTrackStruct( private const val TAG_ID = 0 private const val TAG_TRACK_ATTRIBUTES = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterTrackStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getString(ContextSpecificTag(TAG_ID)) - val trackAttributes = - if (!tlvReader.isNull()) { - MediaPlaybackClusterTrackAttributesStruct.fromTlv( - ContextSpecificTag(TAG_TRACK_ATTRIBUTES), - tlvReader - ) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) - null - } - + val trackAttributes = if (!tlvReader.isNull()) { + MediaPlaybackClusterTrackAttributesStruct.fromTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackStruct(id, trackAttributes) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt index 69caf35509d049..504a72e24e3598 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt @@ -20,15 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MicrowaveOvenModeClusterModeOptionStruct( - val label: String, - val mode: UInt, - val modeTags: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class MicrowaveOvenModeClusterModeOptionStruct ( + val label: String, + val mode: UInt, + val modeTags: List) { + override fun toString(): String = buildString { append("MicrowaveOvenModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -55,19 +57,18 @@ class MicrowaveOvenModeClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MicrowaveOvenModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MicrowaveOvenModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt index bf9800a012de5f..4459562dcadcf3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt @@ -17,14 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class MicrowaveOvenModeClusterModeTagStruct ( + val mfgCode: Optional, + val value: UInt) { + override fun toString(): String = buildString { append("MicrowaveOvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -35,9 +40,9 @@ class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val val tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -47,16 +52,15 @@ class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val val private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MicrowaveOvenModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MicrowaveOvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt index fb74943fcd20b0..6613c8f6988cc6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt @@ -20,15 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ModeSelectClusterModeOptionStruct( - val label: String, - val mode: UInt, - val semanticTags: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ModeSelectClusterModeOptionStruct ( + val label: String, + val mode: UInt, + val semanticTags: List) { + override fun toString(): String = buildString { append("ModeSelectClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -55,19 +57,18 @@ class ModeSelectClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_SEMANTIC_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ModeSelectClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ModeSelectClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val semanticTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val semanticTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ModeSelectClusterModeOptionStruct(label, mode, semanticTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt index ca14c2ebd4d8dc..2b501b089a5d8e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ModeSelectClusterSemanticTagStruct(val mfgCode: UInt, val value: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class ModeSelectClusterSemanticTagStruct ( + val mfgCode: UInt, + val value: UInt) { + override fun toString(): String = buildString { append("ModeSelectClusterSemanticTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -43,11 +49,11 @@ class ModeSelectClusterSemanticTagStruct(val mfgCode: UInt, val value: UInt) { private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ModeSelectClusterSemanticTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ModeSelectClusterSemanticTagStruct { tlvReader.enterStructure(tlvTag) val mfgCode = tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE)) val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ModeSelectClusterSemanticTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt index 82f98aeb677204..78e54129ba293a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt @@ -17,19 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class NetworkCommissioningClusterNetworkInfoStruct( - val networkID: ByteArray, - val connected: Boolean, - val networkIdentifier: Optional?, - val clientIdentifier: Optional? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class NetworkCommissioningClusterNetworkInfoStruct ( + val networkID: ByteArray, + val connected: Boolean, + val networkIdentifier: Optional?, + val clientIdentifier: Optional?) { + override fun toString(): String = buildString { append("NetworkCommissioningClusterNetworkInfoStruct {\n") append("\tnetworkID : $networkID\n") append("\tconnected : $connected\n") @@ -44,21 +46,21 @@ class NetworkCommissioningClusterNetworkInfoStruct( put(ContextSpecificTag(TAG_NETWORK_I_D), networkID) put(ContextSpecificTag(TAG_CONNECTED), connected) if (networkIdentifier != null) { - if (networkIdentifier.isPresent) { - val optnetworkIdentifier = networkIdentifier.get() - put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) - } - } else { - putNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) - } + if (networkIdentifier.isPresent) { + val optnetworkIdentifier = networkIdentifier.get() + put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) + } + } else { + putNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) + } if (clientIdentifier != null) { - if (clientIdentifier.isPresent) { - val optclientIdentifier = clientIdentifier.get() - put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) - } - } else { - putNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) - } + if (clientIdentifier.isPresent) { + val optclientIdentifier = clientIdentifier.get() + put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) + } + } else { + putNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) + } endStructure() } } @@ -69,41 +71,34 @@ class NetworkCommissioningClusterNetworkInfoStruct( private const val TAG_NETWORK_IDENTIFIER = 2 private const val TAG_CLIENT_IDENTIFIER = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): NetworkCommissioningClusterNetworkInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : NetworkCommissioningClusterNetworkInfoStruct { tlvReader.enterStructure(tlvTag) val networkID = tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_I_D)) val connected = tlvReader.getBoolean(ContextSpecificTag(TAG_CONNECTED)) - val networkIdentifier = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) - null - } - val clientIdentifier = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) - null - } - + val networkIdentifier = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) + null + } + val clientIdentifier = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) + null + } + tlvReader.exitContainer() - return NetworkCommissioningClusterNetworkInfoStruct( - networkID, - connected, - networkIdentifier, - clientIdentifier - ) + return NetworkCommissioningClusterNetworkInfoStruct(networkID, connected, networkIdentifier, clientIdentifier) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt index c72319998ba002..01d987d0125f0f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt @@ -17,22 +17,25 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class NetworkCommissioningClusterThreadInterfaceScanResultStruct( - val panId: UInt, - val extendedPanId: ULong, - val networkName: String, - val channel: UInt, - val version: UInt, - val extendedAddress: ByteArray, - val rssi: Int, - val lqi: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class NetworkCommissioningClusterThreadInterfaceScanResultStruct ( + val panId: UInt, + val extendedPanId: ULong, + val networkName: String, + val channel: UInt, + val version: UInt, + val extendedAddress: ByteArray, + val rssi: Int, + val lqi: UInt) { + override fun toString(): String = buildString { append("NetworkCommissioningClusterThreadInterfaceScanResultStruct {\n") append("\tpanId : $panId\n") append("\textendedPanId : $extendedPanId\n") @@ -70,10 +73,7 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct( private const val TAG_RSSI = 6 private const val TAG_LQI = 7 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): NetworkCommissioningClusterThreadInterfaceScanResultStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : NetworkCommissioningClusterThreadInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val panId = tlvReader.getUInt(ContextSpecificTag(TAG_PAN_ID)) val extendedPanId = tlvReader.getULong(ContextSpecificTag(TAG_EXTENDED_PAN_ID)) @@ -83,19 +83,10 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct( val extendedAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_EXTENDED_ADDRESS)) val rssi = tlvReader.getInt(ContextSpecificTag(TAG_RSSI)) val lqi = tlvReader.getUInt(ContextSpecificTag(TAG_LQI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterThreadInterfaceScanResultStruct( - panId, - extendedPanId, - networkName, - channel, - version, - extendedAddress, - rssi, - lqi - ) + return NetworkCommissioningClusterThreadInterfaceScanResultStruct(panId, extendedPanId, networkName, channel, version, extendedAddress, rssi, lqi) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt index e3e4ef10cbce76..8bdbd11bbc322c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt @@ -17,20 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( - val security: UInt, - val ssid: ByteArray, - val bssid: ByteArray, - val channel: UInt, - val wiFiBand: UInt, - val rssi: Int -) { - override fun toString(): String = buildString { +import java.util.Optional + +class NetworkCommissioningClusterWiFiInterfaceScanResultStruct ( + val security: UInt, + val ssid: ByteArray, + val bssid: ByteArray, + val channel: UInt, + val wiFiBand: UInt, + val rssi: Int) { + override fun toString(): String = buildString { append("NetworkCommissioningClusterWiFiInterfaceScanResultStruct {\n") append("\tsecurity : $security\n") append("\tssid : $ssid\n") @@ -62,10 +65,7 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( private const val TAG_WI_FI_BAND = 4 private const val TAG_RSSI = 5 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): NetworkCommissioningClusterWiFiInterfaceScanResultStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : NetworkCommissioningClusterWiFiInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val security = tlvReader.getUInt(ContextSpecificTag(TAG_SECURITY)) val ssid = tlvReader.getByteArray(ContextSpecificTag(TAG_SSID)) @@ -73,17 +73,10 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( val channel = tlvReader.getUInt(ContextSpecificTag(TAG_CHANNEL)) val wiFiBand = tlvReader.getUInt(ContextSpecificTag(TAG_WI_FI_BAND)) val rssi = tlvReader.getInt(ContextSpecificTag(TAG_RSSI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterWiFiInterfaceScanResultStruct( - security, - ssid, - bssid, - channel, - wiFiBand, - rssi - ) + return NetworkCommissioningClusterWiFiInterfaceScanResultStruct(security, ssid, bssid, channel, wiFiBand, rssi) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt index a1e736d1b0407c..de9d80b7482140 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt @@ -17,20 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalCredentialsClusterFabricDescriptorStruct( - val rootPublicKey: ByteArray, - val vendorID: UInt, - val fabricID: ULong, - val nodeID: ULong, - val label: String, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OperationalCredentialsClusterFabricDescriptorStruct ( + val rootPublicKey: ByteArray, + val vendorID: UInt, + val fabricID: ULong, + val nodeID: ULong, + val label: String, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("OperationalCredentialsClusterFabricDescriptorStruct {\n") append("\trootPublicKey : $rootPublicKey\n") append("\tvendorID : $vendorID\n") @@ -62,10 +65,7 @@ class OperationalCredentialsClusterFabricDescriptorStruct( private const val TAG_LABEL = 5 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OperationalCredentialsClusterFabricDescriptorStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalCredentialsClusterFabricDescriptorStruct { tlvReader.enterStructure(tlvTag) val rootPublicKey = tlvReader.getByteArray(ContextSpecificTag(TAG_ROOT_PUBLIC_KEY)) val vendorID = tlvReader.getUInt(ContextSpecificTag(TAG_VENDOR_I_D)) @@ -73,17 +73,10 @@ class OperationalCredentialsClusterFabricDescriptorStruct( val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OperationalCredentialsClusterFabricDescriptorStruct( - rootPublicKey, - vendorID, - fabricID, - nodeID, - label, - fabricIndex - ) + return OperationalCredentialsClusterFabricDescriptorStruct(rootPublicKey, vendorID, fabricID, nodeID, label, fabricIndex) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt index a45a68e28cf2f8..2013bec14e74b5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalCredentialsClusterNOCStruct( - val noc: ByteArray, - val icac: ByteArray?, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OperationalCredentialsClusterNOCStruct ( + val noc: ByteArray, + val icac: ByteArray?, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("OperationalCredentialsClusterNOCStruct {\n") append("\tnoc : $noc\n") append("\ticac : $icac\n") @@ -40,10 +43,10 @@ class OperationalCredentialsClusterNOCStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_NOC), noc) if (icac != null) { - put(ContextSpecificTag(TAG_ICAC), icac) - } else { - putNull(ContextSpecificTag(TAG_ICAC)) - } + put(ContextSpecificTag(TAG_ICAC), icac) + } else { + putNull(ContextSpecificTag(TAG_ICAC)) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -54,18 +57,17 @@ class OperationalCredentialsClusterNOCStruct( private const val TAG_ICAC = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalCredentialsClusterNOCStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalCredentialsClusterNOCStruct { tlvReader.enterStructure(tlvTag) val noc = tlvReader.getByteArray(ContextSpecificTag(TAG_NOC)) - val icac = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) - null - } + val icac = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return OperationalCredentialsClusterNOCStruct(noc, icac, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt index c41c0205d88d84..6078c84c862ae8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt @@ -17,18 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalStateClusterErrorStateStruct( - val errorStateID: UInt, - val errorStateLabel: Optional, - val errorStateDetails: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OperationalStateClusterErrorStateStruct ( + val errorStateID: UInt, + val errorStateLabel: Optional, + val errorStateDetails: Optional) { + override fun toString(): String = buildString { append("OperationalStateClusterErrorStateStruct {\n") append("\terrorStateID : $errorStateID\n") append("\terrorStateLabel : $errorStateLabel\n") @@ -41,13 +43,13 @@ class OperationalStateClusterErrorStateStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_ERROR_STATE_I_D), errorStateID) if (errorStateLabel.isPresent) { - val opterrorStateLabel = errorStateLabel.get() - put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) - } + val opterrorStateLabel = errorStateLabel.get() + put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) + } if (errorStateDetails.isPresent) { - val opterrorStateDetails = errorStateDetails.get() - put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) - } + val opterrorStateDetails = errorStateDetails.get() + put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) + } endStructure() } } @@ -57,29 +59,23 @@ class OperationalStateClusterErrorStateStruct( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterErrorStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterErrorStateStruct( - errorStateID, - errorStateLabel, - errorStateDetails - ) + return OperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt index 3157b9c4b7dec2..e464504d71b4f1 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt @@ -17,17 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalStateClusterOperationalStateStruct( - val operationalStateID: UInt, - val operationalStateLabel: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OperationalStateClusterOperationalStateStruct ( + val operationalStateID: UInt, + val operationalStateLabel: Optional) { + override fun toString(): String = buildString { append("OperationalStateClusterOperationalStateStruct {\n") append("\toperationalStateID : $operationalStateID\n") append("\toperationalStateLabel : $operationalStateLabel\n") @@ -39,9 +41,9 @@ class OperationalStateClusterOperationalStateStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D), operationalStateID) if (operationalStateLabel.isPresent) { - val optoperationalStateLabel = operationalStateLabel.get() - put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) - } + val optoperationalStateLabel = operationalStateLabel.get() + put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) + } endStructure() } } @@ -50,22 +52,18 @@ class OperationalStateClusterOperationalStateStruct( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterOperationalStateStruct( - operationalStateID, - operationalStateLabel - ) + return OperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt index abb8f952cfce50..7f80ca90ed8c9f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OtaSoftwareUpdateRequestorClusterProviderLocation( - val providerNodeID: ULong, - val endpoint: UInt, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OtaSoftwareUpdateRequestorClusterProviderLocation ( + val providerNodeID: ULong, + val endpoint: UInt, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterProviderLocation {\n") append("\tproviderNodeID : $providerNodeID\n") append("\tendpoint : $endpoint\n") @@ -50,22 +53,15 @@ class OtaSoftwareUpdateRequestorClusterProviderLocation( private const val TAG_ENDPOINT = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OtaSoftwareUpdateRequestorClusterProviderLocation { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterProviderLocation { tlvReader.enterStructure(tlvTag) val providerNodeID = tlvReader.getULong(ContextSpecificTag(TAG_PROVIDER_NODE_I_D)) val endpoint = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterProviderLocation( - providerNodeID, - endpoint, - fabricIndex - ) + return OtaSoftwareUpdateRequestorClusterProviderLocation(providerNodeID, endpoint, fabricIndex) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt index dff5c0684a1501..8844263c96a1ce 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt @@ -17,18 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenCavityOperationalStateClusterErrorStateStruct( - val errorStateID: UInt, - val errorStateLabel: Optional, - val errorStateDetails: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OvenCavityOperationalStateClusterErrorStateStruct ( + val errorStateID: UInt, + val errorStateLabel: Optional, + val errorStateDetails: Optional) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterErrorStateStruct {\n") append("\terrorStateID : $errorStateID\n") append("\terrorStateLabel : $errorStateLabel\n") @@ -41,13 +43,13 @@ class OvenCavityOperationalStateClusterErrorStateStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_ERROR_STATE_I_D), errorStateID) if (errorStateLabel.isPresent) { - val opterrorStateLabel = errorStateLabel.get() - put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) - } + val opterrorStateLabel = errorStateLabel.get() + put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) + } if (errorStateDetails.isPresent) { - val opterrorStateDetails = errorStateDetails.get() - put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) - } + val opterrorStateDetails = errorStateDetails.get() + put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) + } endStructure() } } @@ -57,32 +59,23 @@ class OvenCavityOperationalStateClusterErrorStateStruct( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OvenCavityOperationalStateClusterErrorStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterErrorStateStruct( - errorStateID, - errorStateLabel, - errorStateDetails - ) + return OvenCavityOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt index 1d32c7fe4a6af2..6d815321e7cb46 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt @@ -17,17 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenCavityOperationalStateClusterOperationalStateStruct( - val operationalStateID: UInt, - val operationalStateLabel: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OvenCavityOperationalStateClusterOperationalStateStruct ( + val operationalStateID: UInt, + val operationalStateLabel: Optional) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationalStateStruct {\n") append("\toperationalStateID : $operationalStateID\n") append("\toperationalStateLabel : $operationalStateLabel\n") @@ -39,9 +41,9 @@ class OvenCavityOperationalStateClusterOperationalStateStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D), operationalStateID) if (operationalStateLabel.isPresent) { - val optoperationalStateLabel = operationalStateLabel.get() - put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) - } + val optoperationalStateLabel = operationalStateLabel.get() + put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) + } endStructure() } } @@ -50,25 +52,18 @@ class OvenCavityOperationalStateClusterOperationalStateStruct( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OvenCavityOperationalStateClusterOperationalStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationalStateStruct( - operationalStateID, - operationalStateLabel - ) + return OvenCavityOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt index 0df558d3935e26..4698441672eae2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt @@ -20,15 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenModeClusterModeOptionStruct( - val label: String, - val mode: UInt, - val modeTags: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class OvenModeClusterModeOptionStruct ( + val label: String, + val mode: UInt, + val modeTags: List) { + override fun toString(): String = buildString { append("OvenModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -55,19 +57,18 @@ class OvenModeClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return OvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt index df0465b2c3055d..9c204fa8ecb2ea 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt @@ -17,14 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class OvenModeClusterModeTagStruct ( + val mfgCode: Optional, + val value: UInt) { + override fun toString(): String = buildString { append("OvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -35,9 +40,9 @@ class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -47,16 +52,15 @@ class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return OvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt index 1d260017a0b722..c24d47fe4b23ee 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt @@ -20,14 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatChargeFaultChangeType( - val current: List, - val previous: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class PowerSourceClusterBatChargeFaultChangeType ( + val current: List, + val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterBatChargeFaultChangeType {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -55,25 +57,23 @@ class PowerSourceClusterBatChargeFaultChangeType( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeType { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatChargeFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt index 07ed4351bcd3a1..789a1f0a36c47c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt @@ -20,11 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatFaultChangeType(val current: List, val previous: List) { - override fun toString(): String = buildString { +import java.util.Optional + +class PowerSourceClusterBatFaultChangeType ( + val current: List, + val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeType {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -52,25 +57,23 @@ class PowerSourceClusterBatFaultChangeType(val current: List, val previous private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeType { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt index f0c80ef26ff5ad..849c0b2edfc454 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt @@ -20,11 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterWiredFaultChangeType(val current: List, val previous: List) { - override fun toString(): String = buildString { +import java.util.Optional + +class PowerSourceClusterWiredFaultChangeType ( + val current: List, + val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeType {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -52,25 +57,23 @@ class PowerSourceClusterWiredFaultChangeType(val current: List, val previo private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeType { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterWiredFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt index 85b1d995d2fd76..74809e3ae5215c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt @@ -20,15 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( - val label: String, - val mode: UInt, - val modeTags: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct ( + val label: String, + val mode: UInt, + val modeTags: List) { + override fun toString(): String = buildString { append("RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -55,34 +57,21 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add( - RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( - label, - mode, - modeTags - ) + return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct(label, mode, modeTags) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt index db10b1db8bab30..0831587768d6a3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt @@ -17,17 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct ( + val mfgCode: Optional, + val value: UInt) { + override fun toString(): String = buildString { append("RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -38,9 +40,9 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -50,19 +52,15 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt index 31f7b8adb6ac63..d4cf5dd09a6214 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt @@ -20,15 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcCleanModeClusterModeOptionStruct( - val label: String, - val mode: UInt, - val modeTags: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class RvcCleanModeClusterModeOptionStruct ( + val label: String, + val mode: UInt, + val modeTags: List) { + override fun toString(): String = buildString { append("RvcCleanModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -55,19 +57,18 @@ class RvcCleanModeClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcCleanModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcCleanModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcCleanModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt index a06d26774dacc6..7c293c839acb4f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt @@ -17,14 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class RvcCleanModeClusterModeTagStruct ( + val mfgCode: Optional, + val value: UInt) { + override fun toString(): String = buildString { append("RvcCleanModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -35,9 +40,9 @@ class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: U tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -47,16 +52,15 @@ class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: U private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcCleanModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcCleanModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcCleanModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt index 0f8daddb5212c3..15f9250edbe478 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt @@ -17,18 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcOperationalStateClusterErrorStateStruct( - val errorStateID: UInt, - val errorStateLabel: Optional, - val errorStateDetails: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class RvcOperationalStateClusterErrorStateStruct ( + val errorStateID: UInt, + val errorStateLabel: Optional, + val errorStateDetails: Optional) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterErrorStateStruct {\n") append("\terrorStateID : $errorStateID\n") append("\terrorStateLabel : $errorStateLabel\n") @@ -41,13 +43,13 @@ class RvcOperationalStateClusterErrorStateStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_ERROR_STATE_I_D), errorStateID) if (errorStateLabel.isPresent) { - val opterrorStateLabel = errorStateLabel.get() - put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) - } + val opterrorStateLabel = errorStateLabel.get() + put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) + } if (errorStateDetails.isPresent) { - val opterrorStateDetails = errorStateDetails.get() - put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) - } + val opterrorStateDetails = errorStateDetails.get() + put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) + } endStructure() } } @@ -57,29 +59,23 @@ class RvcOperationalStateClusterErrorStateStruct( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcOperationalStateClusterErrorStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterErrorStateStruct( - errorStateID, - errorStateLabel, - errorStateDetails - ) + return RvcOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt index cc01c472f7f71b..930daff7a6d833 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt @@ -17,17 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcOperationalStateClusterOperationalStateStruct( - val operationalStateID: UInt, - val operationalStateLabel: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class RvcOperationalStateClusterOperationalStateStruct ( + val operationalStateID: UInt, + val operationalStateLabel: Optional) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterOperationalStateStruct {\n") append("\toperationalStateID : $operationalStateID\n") append("\toperationalStateLabel : $operationalStateLabel\n") @@ -39,9 +41,9 @@ class RvcOperationalStateClusterOperationalStateStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D), operationalStateID) if (operationalStateLabel.isPresent) { - val optoperationalStateLabel = operationalStateLabel.get() - put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) - } + val optoperationalStateLabel = operationalStateLabel.get() + put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) + } endStructure() } } @@ -50,25 +52,18 @@ class RvcOperationalStateClusterOperationalStateStruct( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): RvcOperationalStateClusterOperationalStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationalStateStruct( - operationalStateID, - operationalStateLabel - ) + return RvcOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt index c20f7b3f626474..519546666e3b33 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt @@ -20,15 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcRunModeClusterModeOptionStruct( - val label: String, - val mode: UInt, - val modeTags: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class RvcRunModeClusterModeOptionStruct ( + val label: String, + val mode: UInt, + val modeTags: List) { + override fun toString(): String = buildString { append("RvcRunModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -55,19 +57,18 @@ class RvcRunModeClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcRunModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcRunModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcRunModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt index 4c32d28ee6ad67..c6183c3e89c585 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt @@ -17,14 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class RvcRunModeClusterModeTagStruct ( + val mfgCode: Optional, + val value: UInt) { + override fun toString(): String = buildString { append("RvcRunModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -35,9 +40,9 @@ class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: UIn tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -47,16 +52,15 @@ class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: UIn private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcRunModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcRunModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcRunModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt index 3cf9c98d53e6d1..58f02b50feda16 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ScenesManagementClusterAttributeValuePair(val attributeID: ULong, val attributeValue: ULong) { - override fun toString(): String = buildString { +import java.util.Optional + +class ScenesManagementClusterAttributeValuePair ( + val attributeID: ULong, + val attributeValue: ULong) { + override fun toString(): String = buildString { append("ScenesManagementClusterAttributeValuePair {\n") append("\tattributeID : $attributeID\n") append("\tattributeValue : $attributeValue\n") @@ -43,11 +49,11 @@ class ScenesManagementClusterAttributeValuePair(val attributeID: ULong, val attr private const val TAG_ATTRIBUTE_I_D = 0 private const val TAG_ATTRIBUTE_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterAttributeValuePair { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ScenesManagementClusterAttributeValuePair { tlvReader.enterStructure(tlvTag) val attributeID = tlvReader.getULong(ContextSpecificTag(TAG_ATTRIBUTE_I_D)) val attributeValue = tlvReader.getULong(ContextSpecificTag(TAG_ATTRIBUTE_VALUE)) - + tlvReader.exitContainer() return ScenesManagementClusterAttributeValuePair(attributeID, attributeValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt index 3ef60f519e09c2..6d4411c76baead 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt @@ -20,14 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ScenesManagementClusterExtensionFieldSet( - val clusterID: ULong, - val attributeValueList: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ScenesManagementClusterExtensionFieldSet ( + val clusterID: ULong, + val attributeValueList: List) { + override fun toString(): String = buildString { append("ScenesManagementClusterExtensionFieldSet {\n") append("\tclusterID : $clusterID\n") append("\tattributeValueList : $attributeValueList\n") @@ -51,18 +53,17 @@ class ScenesManagementClusterExtensionFieldSet( private const val TAG_CLUSTER_I_D = 0 private const val TAG_ATTRIBUTE_VALUE_LIST = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterExtensionFieldSet { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ScenesManagementClusterExtensionFieldSet { tlvReader.enterStructure(tlvTag) val clusterID = tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER_I_D)) - val attributeValueList = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val attributeValueList = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ScenesManagementClusterExtensionFieldSet(clusterID, attributeValueList) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt index 74979432fbc571..3ac060b092b76a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt @@ -17,20 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ScenesManagementClusterSceneInfoStruct( - val sceneCount: UInt, - val currentScene: UInt, - val currentGroup: UInt, - val sceneValid: Boolean, - val remainingCapacity: UInt, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ScenesManagementClusterSceneInfoStruct ( + val sceneCount: UInt, + val currentScene: UInt, + val currentGroup: UInt, + val sceneValid: Boolean, + val remainingCapacity: UInt, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("ScenesManagementClusterSceneInfoStruct {\n") append("\tsceneCount : $sceneCount\n") append("\tcurrentScene : $currentScene\n") @@ -62,7 +65,7 @@ class ScenesManagementClusterSceneInfoStruct( private const val TAG_REMAINING_CAPACITY = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterSceneInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ScenesManagementClusterSceneInfoStruct { tlvReader.enterStructure(tlvTag) val sceneCount = tlvReader.getUInt(ContextSpecificTag(TAG_SCENE_COUNT)) val currentScene = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_SCENE)) @@ -70,17 +73,10 @@ class ScenesManagementClusterSceneInfoStruct( val sceneValid = tlvReader.getBoolean(ContextSpecificTag(TAG_SCENE_VALID)) val remainingCapacity = tlvReader.getUInt(ContextSpecificTag(TAG_REMAINING_CAPACITY)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return ScenesManagementClusterSceneInfoStruct( - sceneCount, - currentScene, - currentGroup, - sceneValid, - remainingCapacity, - fabricIndex - ) + return ScenesManagementClusterSceneInfoStruct(sceneCount, currentScene, currentGroup, sceneValid, remainingCapacity, fabricIndex) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt index f606a46f9fd057..3ef4fc6b3bbfa6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt @@ -17,20 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SoftwareDiagnosticsClusterThreadMetricsStruct( - val id: ULong, - val name: Optional, - val stackFreeCurrent: Optional, - val stackFreeMinimum: Optional, - val stackSize: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class SoftwareDiagnosticsClusterThreadMetricsStruct ( + val id: ULong, + val name: Optional, + val stackFreeCurrent: Optional, + val stackFreeMinimum: Optional, + val stackSize: Optional) { + override fun toString(): String = buildString { append("SoftwareDiagnosticsClusterThreadMetricsStruct {\n") append("\tid : $id\n") append("\tname : $name\n") @@ -45,21 +47,21 @@ class SoftwareDiagnosticsClusterThreadMetricsStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_ID), id) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (stackFreeCurrent.isPresent) { - val optstackFreeCurrent = stackFreeCurrent.get() - put(ContextSpecificTag(TAG_STACK_FREE_CURRENT), optstackFreeCurrent) - } + val optstackFreeCurrent = stackFreeCurrent.get() + put(ContextSpecificTag(TAG_STACK_FREE_CURRENT), optstackFreeCurrent) + } if (stackFreeMinimum.isPresent) { - val optstackFreeMinimum = stackFreeMinimum.get() - put(ContextSpecificTag(TAG_STACK_FREE_MINIMUM), optstackFreeMinimum) - } + val optstackFreeMinimum = stackFreeMinimum.get() + put(ContextSpecificTag(TAG_STACK_FREE_MINIMUM), optstackFreeMinimum) + } if (stackSize.isPresent) { - val optstackSize = stackSize.get() - put(ContextSpecificTag(TAG_STACK_SIZE), optstackSize) - } + val optstackSize = stackSize.get() + put(ContextSpecificTag(TAG_STACK_SIZE), optstackSize) + } endStructure() } } @@ -71,43 +73,33 @@ class SoftwareDiagnosticsClusterThreadMetricsStruct( private const val TAG_STACK_FREE_MINIMUM = 3 private const val TAG_STACK_SIZE = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterThreadMetricsStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SoftwareDiagnosticsClusterThreadMetricsStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val stackFreeCurrent = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) - } else { - Optional.empty() - } - val stackFreeMinimum = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) - } else { - Optional.empty() - } - val stackSize = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_SIZE))) - } else { - Optional.empty() - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val stackFreeCurrent = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) + } else { + Optional.empty() + } + val stackFreeMinimum = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) + } else { + Optional.empty() + } + val stackSize = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_SIZE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return SoftwareDiagnosticsClusterThreadMetricsStruct( - id, - name, - stackFreeCurrent, - stackFreeMinimum, - stackSize - ) + return SoftwareDiagnosticsClusterThreadMetricsStruct(id, name, stackFreeCurrent, stackFreeMinimum, stackSize) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt index 8d667ba0f94cfa..49ebd8e74713c8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TargetNavigatorClusterTargetInfoStruct(val identifier: UInt, val name: String) { - override fun toString(): String = buildString { +import java.util.Optional + +class TargetNavigatorClusterTargetInfoStruct ( + val identifier: UInt, + val name: String) { + override fun toString(): String = buildString { append("TargetNavigatorClusterTargetInfoStruct {\n") append("\tidentifier : $identifier\n") append("\tname : $name\n") @@ -43,11 +49,11 @@ class TargetNavigatorClusterTargetInfoStruct(val identifier: UInt, val name: Str private const val TAG_IDENTIFIER = 0 private const val TAG_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TargetNavigatorClusterTargetInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TargetNavigatorClusterTargetInfoStruct { tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getUInt(ContextSpecificTag(TAG_IDENTIFIER)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetInfoStruct(identifier, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt index cb91c04d920b9c..5b426e8234fc4d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt @@ -17,21 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThermostatClusterPresetStruct( - val presetHandle: ByteArray?, - val presetScenario: UInt, - val name: Optional?, - val coolingSetpoint: Optional, - val heatingSetpoint: Optional, - val builtIn: Boolean? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThermostatClusterPresetStruct ( + val presetHandle: ByteArray?, + val presetScenario: UInt, + val name: Optional?, + val coolingSetpoint: Optional, + val heatingSetpoint: Optional, + val builtIn: Boolean?) { + override fun toString(): String = buildString { append("ThermostatClusterPresetStruct {\n") append("\tpresetHandle : $presetHandle\n") append("\tpresetScenario : $presetScenario\n") @@ -46,32 +48,32 @@ class ThermostatClusterPresetStruct( tlvWriter.apply { startStructure(tlvTag) if (presetHandle != null) { - put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) - } else { - putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - } + put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) + } else { + putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + } put(ContextSpecificTag(TAG_PRESET_SCENARIO), presetScenario) if (name != null) { - if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } - } else { - putNull(ContextSpecificTag(TAG_NAME)) - } + if (name.isPresent) { + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } + } else { + putNull(ContextSpecificTag(TAG_NAME)) + } if (coolingSetpoint.isPresent) { - val optcoolingSetpoint = coolingSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) - } + val optcoolingSetpoint = coolingSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) + } if (heatingSetpoint.isPresent) { - val optheatingSetpoint = heatingSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) - } + val optheatingSetpoint = heatingSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) + } if (builtIn != null) { - put(ContextSpecificTag(TAG_BUILT_IN), builtIn) - } else { - putNull(ContextSpecificTag(TAG_BUILT_IN)) - } + put(ContextSpecificTag(TAG_BUILT_IN), builtIn) + } else { + putNull(ContextSpecificTag(TAG_BUILT_IN)) + } endStructure() } } @@ -84,57 +86,45 @@ class ThermostatClusterPresetStruct( private const val TAG_HEATING_SETPOINT = 4 private const val TAG_BUILT_IN = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterPresetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } + val presetHandle = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } val presetScenario = tlvReader.getUInt(ContextSpecificTag(TAG_PRESET_SCENARIO)) - val name = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NAME)) - null - } - val coolingSetpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - val builtIn = - if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NAME)) + null + } + val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + val builtIn = if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterPresetStruct( - presetHandle, - presetScenario, - name, - coolingSetpoint, - heatingSetpoint, - builtIn - ) + return ThermostatClusterPresetStruct(presetHandle, presetScenario, name, coolingSetpoint, heatingSetpoint, builtIn) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt index 386af8f682e665..26a9bab02f91e6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThermostatClusterPresetTypeStruct( - val presetScenario: UInt, - val numberOfPresets: UInt, - val presetTypeFeatures: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThermostatClusterPresetTypeStruct ( + val presetScenario: UInt, + val numberOfPresets: UInt, + val presetTypeFeatures: UInt) { + override fun toString(): String = buildString { append("ThermostatClusterPresetTypeStruct {\n") append("\tpresetScenario : $presetScenario\n") append("\tnumberOfPresets : $numberOfPresets\n") @@ -50,12 +53,12 @@ class ThermostatClusterPresetTypeStruct( private const val TAG_NUMBER_OF_PRESETS = 1 private const val TAG_PRESET_TYPE_FEATURES = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterPresetTypeStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterPresetTypeStruct { tlvReader.enterStructure(tlvTag) val presetScenario = tlvReader.getUInt(ContextSpecificTag(TAG_PRESET_SCENARIO)) val numberOfPresets = tlvReader.getUInt(ContextSpecificTag(TAG_NUMBER_OF_PRESETS)) val presetTypeFeatures = tlvReader.getUInt(ContextSpecificTag(TAG_PRESET_TYPE_FEATURES)) - + tlvReader.exitContainer() return ThermostatClusterPresetTypeStruct(presetScenario, numberOfPresets, presetTypeFeatures) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt index 4ecaecf98901dc..92e30614970dd2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThermostatClusterQueuedPresetStruct( - val presetHandle: ByteArray?, - val transitionTimestamp: ULong? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThermostatClusterQueuedPresetStruct ( + val presetHandle: ByteArray?, + val transitionTimestamp: ULong?) { + override fun toString(): String = buildString { append("ThermostatClusterQueuedPresetStruct {\n") append("\tpresetHandle : $presetHandle\n") append("\ttransitionTimestamp : $transitionTimestamp\n") @@ -37,15 +40,15 @@ class ThermostatClusterQueuedPresetStruct( tlvWriter.apply { startStructure(tlvTag) if (presetHandle != null) { - put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) - } else { - putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - } + put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) + } else { + putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + } if (transitionTimestamp != null) { - put(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP), transitionTimestamp) - } else { - putNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - } + put(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP), transitionTimestamp) + } else { + putNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + } endStructure() } } @@ -54,23 +57,21 @@ class ThermostatClusterQueuedPresetStruct( private const val TAG_PRESET_HANDLE = 0 private const val TAG_TRANSITION_TIMESTAMP = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterQueuedPresetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterQueuedPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } - val transitionTimestamp = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - null - } - + val presetHandle = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } + val transitionTimestamp = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + null + } + tlvReader.exitContainer() return ThermostatClusterQueuedPresetStruct(presetHandle, transitionTimestamp) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt index ac1ffbde1caca9..f07278bc4b607a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt @@ -17,22 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThermostatClusterScheduleStruct( - val scheduleHandle: ByteArray?, - val systemMode: UInt, - val name: Optional, - val presetHandle: Optional, - val transitions: List, - val builtIn: Optional? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThermostatClusterScheduleStruct ( + val scheduleHandle: ByteArray?, + val systemMode: UInt, + val name: Optional, + val presetHandle: Optional, + val transitions: List, + val builtIn: Optional?) { + override fun toString(): String = buildString { append("ThermostatClusterScheduleStruct {\n") append("\tscheduleHandle : $scheduleHandle\n") append("\tsystemMode : $systemMode\n") @@ -47,32 +48,32 @@ class ThermostatClusterScheduleStruct( tlvWriter.apply { startStructure(tlvTag) if (scheduleHandle != null) { - put(ContextSpecificTag(TAG_SCHEDULE_HANDLE), scheduleHandle) - } else { - putNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - } + put(ContextSpecificTag(TAG_SCHEDULE_HANDLE), scheduleHandle) + } else { + putNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + } put(ContextSpecificTag(TAG_SYSTEM_MODE), systemMode) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (presetHandle.isPresent) { - val optpresetHandle = presetHandle.get() - put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) - } + val optpresetHandle = presetHandle.get() + put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) + } startArray(ContextSpecificTag(TAG_TRANSITIONS)) for (item in transitions.iterator()) { item.toTlv(AnonymousTag, this) } endArray() if (builtIn != null) { - if (builtIn.isPresent) { - val optbuiltIn = builtIn.get() - put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) - } - } else { - putNull(ContextSpecificTag(TAG_BUILT_IN)) - } + if (builtIn.isPresent) { + val optbuiltIn = builtIn.get() + put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) + } + } else { + putNull(ContextSpecificTag(TAG_BUILT_IN)) + } endStructure() } } @@ -85,58 +86,46 @@ class ThermostatClusterScheduleStruct( private const val TAG_TRANSITIONS = 4 private const val TAG_BUILT_IN = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterScheduleStruct { tlvReader.enterStructure(tlvTag) - val scheduleHandle = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - null - } + val scheduleHandle = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + null + } val systemMode = tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val presetHandle = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val transitions = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while (!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val builtIn = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val transitions = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while(!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val builtIn = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterScheduleStruct( - scheduleHandle, - systemMode, - name, - presetHandle, - transitions, - builtIn - ) + return ThermostatClusterScheduleStruct(scheduleHandle, systemMode, name, presetHandle, transitions, builtIn) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt index aabb3b6418da7b..e429994e90d20a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt @@ -17,21 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThermostatClusterScheduleTransitionStruct( - val dayOfWeek: UInt, - val transitionTime: UInt, - val presetHandle: Optional, - val systemMode: Optional, - val coolingSetpoint: Optional, - val heatingSetpoint: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThermostatClusterScheduleTransitionStruct ( + val dayOfWeek: UInt, + val transitionTime: UInt, + val presetHandle: Optional, + val systemMode: Optional, + val coolingSetpoint: Optional, + val heatingSetpoint: Optional) { + override fun toString(): String = buildString { append("ThermostatClusterScheduleTransitionStruct {\n") append("\tdayOfWeek : $dayOfWeek\n") append("\ttransitionTime : $transitionTime\n") @@ -48,21 +50,21 @@ class ThermostatClusterScheduleTransitionStruct( put(ContextSpecificTag(TAG_DAY_OF_WEEK), dayOfWeek) put(ContextSpecificTag(TAG_TRANSITION_TIME), transitionTime) if (presetHandle.isPresent) { - val optpresetHandle = presetHandle.get() - put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) - } + val optpresetHandle = presetHandle.get() + put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) + } if (systemMode.isPresent) { - val optsystemMode = systemMode.get() - put(ContextSpecificTag(TAG_SYSTEM_MODE), optsystemMode) - } + val optsystemMode = systemMode.get() + put(ContextSpecificTag(TAG_SYSTEM_MODE), optsystemMode) + } if (coolingSetpoint.isPresent) { - val optcoolingSetpoint = coolingSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) - } + val optcoolingSetpoint = coolingSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) + } if (heatingSetpoint.isPresent) { - val optheatingSetpoint = heatingSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) - } + val optheatingSetpoint = heatingSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) + } endStructure() } } @@ -75,45 +77,34 @@ class ThermostatClusterScheduleTransitionStruct( private const val TAG_COOLING_SETPOINT = 4 private const val TAG_HEATING_SETPOINT = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleTransitionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterScheduleTransitionStruct { tlvReader.enterStructure(tlvTag) val dayOfWeek = tlvReader.getUInt(ContextSpecificTag(TAG_DAY_OF_WEEK)) val transitionTime = tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIME)) - val presetHandle = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val systemMode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE))) - } else { - Optional.empty() - } - val coolingSetpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - + val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val systemMode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE))) + } else { + Optional.empty() + } + val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ThermostatClusterScheduleTransitionStruct( - dayOfWeek, - transitionTime, - presetHandle, - systemMode, - coolingSetpoint, - heatingSetpoint - ) + return ThermostatClusterScheduleTransitionStruct(dayOfWeek, transitionTime, presetHandle, systemMode, coolingSetpoint, heatingSetpoint) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt index eb62cbf32b28a4..02b2c88e6c9d01 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThermostatClusterScheduleTypeStruct( - val systemMode: UInt, - val numberOfSchedules: UInt, - val scheduleTypeFeatures: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThermostatClusterScheduleTypeStruct ( + val systemMode: UInt, + val numberOfSchedules: UInt, + val scheduleTypeFeatures: UInt) { + override fun toString(): String = buildString { append("ThermostatClusterScheduleTypeStruct {\n") append("\tsystemMode : $systemMode\n") append("\tnumberOfSchedules : $numberOfSchedules\n") @@ -50,19 +53,15 @@ class ThermostatClusterScheduleTypeStruct( private const val TAG_NUMBER_OF_SCHEDULES = 1 private const val TAG_SCHEDULE_TYPE_FEATURES = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleTypeStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterScheduleTypeStruct { tlvReader.enterStructure(tlvTag) val systemMode = tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE)) val numberOfSchedules = tlvReader.getUInt(ContextSpecificTag(TAG_NUMBER_OF_SCHEDULES)) val scheduleTypeFeatures = tlvReader.getUInt(ContextSpecificTag(TAG_SCHEDULE_TYPE_FEATURES)) - + tlvReader.exitContainer() - return ThermostatClusterScheduleTypeStruct( - systemMode, - numberOfSchedules, - scheduleTypeFeatures - ) + return ThermostatClusterScheduleTypeStruct(systemMode, numberOfSchedules, scheduleTypeFeatures) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt index 343952b9a54a79..b033662cbf23b2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThermostatClusterWeeklyScheduleTransitionStruct( - val transitionTime: UInt, - val heatSetpoint: Int?, - val coolSetpoint: Int? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThermostatClusterWeeklyScheduleTransitionStruct ( + val transitionTime: UInt, + val heatSetpoint: Int?, + val coolSetpoint: Int?) { + override fun toString(): String = buildString { append("ThermostatClusterWeeklyScheduleTransitionStruct {\n") append("\ttransitionTime : $transitionTime\n") append("\theatSetpoint : $heatSetpoint\n") @@ -40,15 +43,15 @@ class ThermostatClusterWeeklyScheduleTransitionStruct( startStructure(tlvTag) put(ContextSpecificTag(TAG_TRANSITION_TIME), transitionTime) if (heatSetpoint != null) { - put(ContextSpecificTag(TAG_HEAT_SETPOINT), heatSetpoint) - } else { - putNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } + put(ContextSpecificTag(TAG_HEAT_SETPOINT), heatSetpoint) + } else { + putNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) + } if (coolSetpoint != null) { - put(ContextSpecificTag(TAG_COOL_SETPOINT), coolSetpoint) - } else { - putNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - } + put(ContextSpecificTag(TAG_COOL_SETPOINT), coolSetpoint) + } else { + putNull(ContextSpecificTag(TAG_COOL_SETPOINT)) + } endStructure() } } @@ -58,34 +61,25 @@ class ThermostatClusterWeeklyScheduleTransitionStruct( private const val TAG_HEAT_SETPOINT = 1 private const val TAG_COOL_SETPOINT = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThermostatClusterWeeklyScheduleTransitionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterWeeklyScheduleTransitionStruct { tlvReader.enterStructure(tlvTag) val transitionTime = tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIME)) - val heatSetpoint = - if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - null - } - val coolSetpoint = - if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_COOL_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - null - } - + val heatSetpoint = if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_HEAT_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) + null + } + val coolSetpoint = if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_COOL_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) + null + } + tlvReader.exitContainer() - return ThermostatClusterWeeklyScheduleTransitionStruct( - transitionTime, - heatSetpoint, - coolSetpoint - ) + return ThermostatClusterWeeklyScheduleTransitionStruct(transitionTime, heatSetpoint, coolSetpoint) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt index 84733d5bd9d5fc..40156c06651284 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt @@ -17,28 +17,31 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterNeighborTableStruct( - val extAddress: ULong, - val age: ULong, - val rloc16: UInt, - val linkFrameCounter: ULong, - val mleFrameCounter: ULong, - val lqi: UInt, - val averageRssi: Int?, - val lastRssi: Int?, - val frameErrorRate: UInt, - val messageErrorRate: UInt, - val rxOnWhenIdle: Boolean, - val fullThreadDevice: Boolean, - val fullNetworkData: Boolean, - val isChild: Boolean -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThreadNetworkDiagnosticsClusterNeighborTableStruct ( + val extAddress: ULong, + val age: ULong, + val rloc16: UInt, + val linkFrameCounter: ULong, + val mleFrameCounter: ULong, + val lqi: UInt, + val averageRssi: Int?, + val lastRssi: Int?, + val frameErrorRate: UInt, + val messageErrorRate: UInt, + val rxOnWhenIdle: Boolean, + val fullThreadDevice: Boolean, + val fullNetworkData: Boolean, + val isChild: Boolean) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterNeighborTableStruct {\n") append("\textAddress : $extAddress\n") append("\tage : $age\n") @@ -67,15 +70,15 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct( put(ContextSpecificTag(TAG_MLE_FRAME_COUNTER), mleFrameCounter) put(ContextSpecificTag(TAG_LQI), lqi) if (averageRssi != null) { - put(ContextSpecificTag(TAG_AVERAGE_RSSI), averageRssi) - } else { - putNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) - } + put(ContextSpecificTag(TAG_AVERAGE_RSSI), averageRssi) + } else { + putNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) + } if (lastRssi != null) { - put(ContextSpecificTag(TAG_LAST_RSSI), lastRssi) - } else { - putNull(ContextSpecificTag(TAG_LAST_RSSI)) - } + put(ContextSpecificTag(TAG_LAST_RSSI), lastRssi) + } else { + putNull(ContextSpecificTag(TAG_LAST_RSSI)) + } put(ContextSpecificTag(TAG_FRAME_ERROR_RATE), frameErrorRate) put(ContextSpecificTag(TAG_MESSAGE_ERROR_RATE), messageErrorRate) put(ContextSpecificTag(TAG_RX_ON_WHEN_IDLE), rxOnWhenIdle) @@ -102,10 +105,7 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct( private const val TAG_FULL_NETWORK_DATA = 12 private const val TAG_IS_CHILD = 13 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThreadNetworkDiagnosticsClusterNeighborTableStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterNeighborTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val age = tlvReader.getULong(ContextSpecificTag(TAG_AGE)) @@ -113,45 +113,28 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct( val linkFrameCounter = tlvReader.getULong(ContextSpecificTag(TAG_LINK_FRAME_COUNTER)) val mleFrameCounter = tlvReader.getULong(ContextSpecificTag(TAG_MLE_FRAME_COUNTER)) val lqi = tlvReader.getUInt(ContextSpecificTag(TAG_LQI)) - val averageRssi = - if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_AVERAGE_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) - null - } - val lastRssi = - if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_LAST_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) - null - } + val averageRssi = if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_AVERAGE_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) + null + } + val lastRssi = if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_LAST_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) + null + } val frameErrorRate = tlvReader.getUInt(ContextSpecificTag(TAG_FRAME_ERROR_RATE)) val messageErrorRate = tlvReader.getUInt(ContextSpecificTag(TAG_MESSAGE_ERROR_RATE)) val rxOnWhenIdle = tlvReader.getBoolean(ContextSpecificTag(TAG_RX_ON_WHEN_IDLE)) val fullThreadDevice = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_THREAD_DEVICE)) val fullNetworkData = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_NETWORK_DATA)) val isChild = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_CHILD)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterNeighborTableStruct( - extAddress, - age, - rloc16, - linkFrameCounter, - mleFrameCounter, - lqi, - averageRssi, - lastRssi, - frameErrorRate, - messageErrorRate, - rxOnWhenIdle, - fullThreadDevice, - fullNetworkData, - isChild - ) + return ThreadNetworkDiagnosticsClusterNeighborTableStruct(extAddress, age, rloc16, linkFrameCounter, mleFrameCounter, lqi, averageRssi, lastRssi, frameErrorRate, messageErrorRate, rxOnWhenIdle, fullThreadDevice, fullNetworkData, isChild) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt index 39938fd1ee6403..b236dab6cb1906 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt @@ -17,26 +17,29 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( - val activeTimestampPresent: Boolean, - val pendingTimestampPresent: Boolean, - val masterKeyPresent: Boolean, - val networkNamePresent: Boolean, - val extendedPanIdPresent: Boolean, - val meshLocalPrefixPresent: Boolean, - val delayPresent: Boolean, - val panIdPresent: Boolean, - val channelPresent: Boolean, - val pskcPresent: Boolean, - val securityPolicyPresent: Boolean, - val channelMaskPresent: Boolean -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents ( + val activeTimestampPresent: Boolean, + val pendingTimestampPresent: Boolean, + val masterKeyPresent: Boolean, + val networkNamePresent: Boolean, + val extendedPanIdPresent: Boolean, + val meshLocalPrefixPresent: Boolean, + val delayPresent: Boolean, + val panIdPresent: Boolean, + val channelPresent: Boolean, + val pskcPresent: Boolean, + val securityPolicyPresent: Boolean, + val channelMaskPresent: Boolean) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterOperationalDatasetComponents {\n") append("\tactiveTimestampPresent : $activeTimestampPresent\n") append("\tpendingTimestampPresent : $pendingTimestampPresent\n") @@ -86,45 +89,24 @@ class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( private const val TAG_SECURITY_POLICY_PRESENT = 10 private const val TAG_CHANNEL_MASK_PRESENT = 11 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { tlvReader.enterStructure(tlvTag) - val activeTimestampPresent = - tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) - val pendingTimestampPresent = - tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) + val activeTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) + val pendingTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) val masterKeyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MASTER_KEY_PRESENT)) val networkNamePresent = tlvReader.getBoolean(ContextSpecificTag(TAG_NETWORK_NAME_PRESENT)) - val extendedPanIdPresent = - tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) - val meshLocalPrefixPresent = - tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) + val extendedPanIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) + val meshLocalPrefixPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) val delayPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_DELAY_PRESENT)) val panIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PAN_ID_PRESENT)) val channelPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_PRESENT)) val pskcPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PSKC_PRESENT)) - val securityPolicyPresent = - tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) + val securityPolicyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) val channelMaskPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_MASK_PRESENT)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( - activeTimestampPresent, - pendingTimestampPresent, - masterKeyPresent, - networkNamePresent, - extendedPanIdPresent, - meshLocalPrefixPresent, - delayPresent, - panIdPresent, - channelPresent, - pskcPresent, - securityPolicyPresent, - channelMaskPresent - ) + return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents(activeTimestampPresent, pendingTimestampPresent, masterKeyPresent, networkNamePresent, extendedPanIdPresent, meshLocalPrefixPresent, delayPresent, panIdPresent, channelPresent, pskcPresent, securityPolicyPresent, channelMaskPresent) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt index d1bbbec7592462..3d5edad134669d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt @@ -17,24 +17,27 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterRouteTableStruct( - val extAddress: ULong, - val rloc16: UInt, - val routerId: UInt, - val nextHop: UInt, - val pathCost: UInt, - val LQIIn: UInt, - val LQIOut: UInt, - val age: UInt, - val allocated: Boolean, - val linkEstablished: Boolean -) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThreadNetworkDiagnosticsClusterRouteTableStruct ( + val extAddress: ULong, + val rloc16: UInt, + val routerId: UInt, + val nextHop: UInt, + val pathCost: UInt, + val LQIIn: UInt, + val LQIOut: UInt, + val age: UInt, + val allocated: Boolean, + val linkEstablished: Boolean) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterRouteTableStruct {\n") append("\textAddress : $extAddress\n") append("\trloc16 : $rloc16\n") @@ -78,10 +81,7 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct( private const val TAG_ALLOCATED = 8 private const val TAG_LINK_ESTABLISHED = 9 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThreadNetworkDiagnosticsClusterRouteTableStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterRouteTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val rloc16 = tlvReader.getUInt(ContextSpecificTag(TAG_RLOC16)) @@ -93,21 +93,10 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct( val age = tlvReader.getUInt(ContextSpecificTag(TAG_AGE)) val allocated = tlvReader.getBoolean(ContextSpecificTag(TAG_ALLOCATED)) val linkEstablished = tlvReader.getBoolean(ContextSpecificTag(TAG_LINK_ESTABLISHED)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterRouteTableStruct( - extAddress, - rloc16, - routerId, - nextHop, - pathCost, - LQIIn, - LQIOut, - age, - allocated, - linkEstablished - ) + return ThreadNetworkDiagnosticsClusterRouteTableStruct(extAddress, rloc16, routerId, nextHop, pathCost, LQIIn, LQIOut, age, allocated, linkEstablished) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt index c0d8b857424511..44eec2ff64ab26 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterSecurityPolicy(val rotationTime: UInt, val flags: UInt) { - override fun toString(): String = buildString { +import java.util.Optional + +class ThreadNetworkDiagnosticsClusterSecurityPolicy ( + val rotationTime: UInt, + val flags: UInt) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterSecurityPolicy {\n") append("\trotationTime : $rotationTime\n") append("\tflags : $flags\n") @@ -43,11 +49,11 @@ class ThreadNetworkDiagnosticsClusterSecurityPolicy(val rotationTime: UInt, val private const val TAG_ROTATION_TIME = 0 private const val TAG_FLAGS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterSecurityPolicy { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterSecurityPolicy { tlvReader.enterStructure(tlvTag) val rotationTime = tlvReader.getUInt(ContextSpecificTag(TAG_ROTATION_TIME)) val flags = tlvReader.getUInt(ContextSpecificTag(TAG_FLAGS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterSecurityPolicy(rotationTime, flags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt index 6df9767939dcef..c960f8a3d1e069 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterDSTOffsetStruct( - val offset: Long, - val validStarting: ULong, - val validUntil: ULong? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class TimeSynchronizationClusterDSTOffsetStruct ( + val offset: Long, + val validStarting: ULong, + val validUntil: ULong?) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterDSTOffsetStruct {\n") append("\toffset : $offset\n") append("\tvalidStarting : $validStarting\n") @@ -41,10 +44,10 @@ class TimeSynchronizationClusterDSTOffsetStruct( put(ContextSpecificTag(TAG_OFFSET), offset) put(ContextSpecificTag(TAG_VALID_STARTING), validStarting) if (validUntil != null) { - put(ContextSpecificTag(TAG_VALID_UNTIL), validUntil) - } else { - putNull(ContextSpecificTag(TAG_VALID_UNTIL)) - } + put(ContextSpecificTag(TAG_VALID_UNTIL), validUntil) + } else { + putNull(ContextSpecificTag(TAG_VALID_UNTIL)) + } endStructure() } } @@ -54,18 +57,17 @@ class TimeSynchronizationClusterDSTOffsetStruct( private const val TAG_VALID_STARTING = 1 private const val TAG_VALID_UNTIL = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterDSTOffsetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterDSTOffsetStruct { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getLong(ContextSpecificTag(TAG_OFFSET)) val validStarting = tlvReader.getULong(ContextSpecificTag(TAG_VALID_STARTING)) - val validUntil = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) - null - } - + val validUntil = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) + null + } + tlvReader.exitContainer() return TimeSynchronizationClusterDSTOffsetStruct(offset, validStarting, validUntil) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt index cca59a20972c7b..956908c9cd381d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt @@ -17,16 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct( - val nodeID: ULong, - val endpoint: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct ( + val nodeID: ULong, + val endpoint: UInt) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct {\n") append("\tnodeID : $nodeID\n") append("\tendpoint : $endpoint\n") @@ -46,14 +49,11 @@ class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct( private const val TAG_NODE_I_D = 0 private const val TAG_ENDPOINT = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct(nodeID, endpoint) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt index 0d870bb1aa4b11..d972f05dbd528a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt @@ -17,18 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterTimeZoneStruct( - val offset: Long, - val validAt: ULong, - val name: Optional -) { - override fun toString(): String = buildString { +import java.util.Optional + +class TimeSynchronizationClusterTimeZoneStruct ( + val offset: Long, + val validAt: ULong, + val name: Optional) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterTimeZoneStruct {\n") append("\toffset : $offset\n") append("\tvalidAt : $validAt\n") @@ -42,9 +44,9 @@ class TimeSynchronizationClusterTimeZoneStruct( put(ContextSpecificTag(TAG_OFFSET), offset) put(ContextSpecificTag(TAG_VALID_AT), validAt) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } endStructure() } } @@ -54,17 +56,16 @@ class TimeSynchronizationClusterTimeZoneStruct( private const val TAG_VALID_AT = 1 private const val TAG_NAME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTimeZoneStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTimeZoneStruct { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getLong(ContextSpecificTag(TAG_OFFSET)) val validAt = tlvReader.getULong(ContextSpecificTag(TAG_VALID_AT)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStruct(offset, validAt, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt index db6786d49ee802..16685608686cb7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterTrustedTimeSourceStruct( - val fabricIndex: UInt, - val nodeID: ULong, - val endpoint: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class TimeSynchronizationClusterTrustedTimeSourceStruct ( + val fabricIndex: UInt, + val nodeID: ULong, + val endpoint: UInt) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterTrustedTimeSourceStruct {\n") append("\tfabricIndex : $fabricIndex\n") append("\tnodeID : $nodeID\n") @@ -50,15 +53,12 @@ class TimeSynchronizationClusterTrustedTimeSourceStruct( private const val TAG_NODE_I_D = 1 private const val TAG_ENDPOINT = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): TimeSynchronizationClusterTrustedTimeSourceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterTrustedTimeSourceStruct(fabricIndex, nodeID, endpoint) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt index 46ebbe20eb1528..4ae6ee1b7692ff 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt @@ -20,11 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterDoubleNestedStructList(val a: List) { - override fun toString(): String = buildString { +import java.util.Optional + +class UnitTestingClusterDoubleNestedStructList ( + val a: List) { + override fun toString(): String = buildString { append("UnitTestingClusterDoubleNestedStructList {\n") append("\ta : $a\n") append("}\n") @@ -45,17 +49,16 @@ class UnitTestingClusterDoubleNestedStructList(val a: List { - tlvReader.enterArray(ContextSpecificTag(TAG_A)) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val a = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_A)) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterDoubleNestedStructList(a) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt index cd2c6a5d251fe9..0a3799929a49c6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt @@ -17,17 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterNestedStruct( - val a: UInt, - val b: Boolean, - val c: UnitTestingClusterSimpleStruct -) { - override fun toString(): String = buildString { +import java.util.Optional + +class UnitTestingClusterNestedStruct ( + val a: UInt, + val b: Boolean, + val c: UnitTestingClusterSimpleStruct) { + override fun toString(): String = buildString { append("UnitTestingClusterNestedStruct {\n") append("\ta : $a\n") append("\tb : $b\n") @@ -50,12 +53,12 @@ class UnitTestingClusterNestedStruct( private const val TAG_B = 1 private const val TAG_C = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNestedStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterNestedStruct { tlvReader.enterStructure(tlvTag) val a = tlvReader.getUInt(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - + tlvReader.exitContainer() return UnitTestingClusterNestedStruct(a, b, c) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt index 9b32b5343204c5..425b1753d17039 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt @@ -20,19 +20,21 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterNestedStructList( - val a: UInt, - val b: Boolean, - val c: UnitTestingClusterSimpleStruct, - val d: List, - val e: List, - val f: List, - val g: List -) { - override fun toString(): String = buildString { +import java.util.Optional + +class UnitTestingClusterNestedStructList ( + val a: UInt, + val b: Boolean, + val c: UnitTestingClusterSimpleStruct, + val d: List, + val e: List, + val f: List, + val g: List) { + override fun toString(): String = buildString { append("UnitTestingClusterNestedStructList {\n") append("\ta : $a\n") append("\tb : $b\n") @@ -83,44 +85,40 @@ class UnitTestingClusterNestedStructList( private const val TAG_F = 5 private const val TAG_G = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNestedStructList { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterNestedStructList { tlvReader.enterStructure(tlvTag) val a = tlvReader.getUInt(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - val d = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_D)) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val e = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_E)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getULong(AnonymousTag)) - } - tlvReader.exitContainer() - } - val f = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_F)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val g = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_G)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val d = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_D)) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val e = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_E)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getULong(AnonymousTag)) + } + tlvReader.exitContainer() + } + val f = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_F)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val g = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_G)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterNestedStructList(a, b, c, d, e, f, g) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt index e8f12057027054..4758e679ca22cb 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt @@ -17,28 +17,29 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterNullablesAndOptionalsStruct( - val nullableInt: UInt?, - val optionalInt: Optional, - val nullableOptionalInt: Optional?, - val nullableString: String?, - val optionalString: Optional, - val nullableOptionalString: Optional?, - val nullableStruct: UnitTestingClusterSimpleStruct?, - val optionalStruct: Optional, - val nullableOptionalStruct: Optional?, - val nullableList: List?, - val optionalList: Optional>, - val nullableOptionalList: Optional>? -) { - override fun toString(): String = buildString { +import java.util.Optional + +class UnitTestingClusterNullablesAndOptionalsStruct ( + val nullableInt: UInt?, + val optionalInt: Optional, + val nullableOptionalInt: Optional?, + val nullableString: String?, + val optionalString: Optional, + val nullableOptionalString: Optional?, + val nullableStruct: UnitTestingClusterSimpleStruct?, + val optionalStruct: Optional, + val nullableOptionalStruct: Optional?, + val nullableList: List?, + val optionalList: Optional>, + val nullableOptionalList: Optional>?) { + override fun toString(): String = buildString { append("UnitTestingClusterNullablesAndOptionalsStruct {\n") append("\tnullableInt : $nullableInt\n") append("\toptionalInt : $optionalInt\n") @@ -59,85 +60,85 @@ class UnitTestingClusterNullablesAndOptionalsStruct( tlvWriter.apply { startStructure(tlvTag) if (nullableInt != null) { - put(ContextSpecificTag(TAG_NULLABLE_INT), nullableInt) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_INT)) - } + put(ContextSpecificTag(TAG_NULLABLE_INT), nullableInt) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_INT)) + } if (optionalInt.isPresent) { - val optoptionalInt = optionalInt.get() - put(ContextSpecificTag(TAG_OPTIONAL_INT), optoptionalInt) - } + val optoptionalInt = optionalInt.get() + put(ContextSpecificTag(TAG_OPTIONAL_INT), optoptionalInt) + } if (nullableOptionalInt != null) { - if (nullableOptionalInt.isPresent) { - val optnullableOptionalInt = nullableOptionalInt.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) - } + if (nullableOptionalInt.isPresent) { + val optnullableOptionalInt = nullableOptionalInt.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) + } if (nullableString != null) { - put(ContextSpecificTag(TAG_NULLABLE_STRING), nullableString) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_STRING)) - } + put(ContextSpecificTag(TAG_NULLABLE_STRING), nullableString) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_STRING)) + } if (optionalString.isPresent) { - val optoptionalString = optionalString.get() - put(ContextSpecificTag(TAG_OPTIONAL_STRING), optoptionalString) - } + val optoptionalString = optionalString.get() + put(ContextSpecificTag(TAG_OPTIONAL_STRING), optoptionalString) + } if (nullableOptionalString != null) { - if (nullableOptionalString.isPresent) { - val optnullableOptionalString = nullableOptionalString.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) - } + if (nullableOptionalString.isPresent) { + val optnullableOptionalString = nullableOptionalString.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) + } if (nullableStruct != null) { - nullableStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), this) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) - } + nullableStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), this) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) + } if (optionalStruct.isPresent) { - val optoptionalStruct = optionalStruct.get() - optoptionalStruct.toTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), this) - } + val optoptionalStruct = optionalStruct.get() + optoptionalStruct.toTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), this) + } if (nullableOptionalStruct != null) { - if (nullableOptionalStruct.isPresent) { - val optnullableOptionalStruct = nullableOptionalStruct.get() - optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) - } + if (nullableOptionalStruct.isPresent) { + val optnullableOptionalStruct = nullableOptionalStruct.get() + optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) + } if (nullableList != null) { - startArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - for (item in nullableList.iterator()) { - put(AnonymousTag, item) - } - endArray() - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_LIST)) + startArray(ContextSpecificTag(TAG_NULLABLE_LIST)) + for (item in nullableList.iterator()) { + put(AnonymousTag, item) } + endArray() + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_LIST)) + } if (optionalList.isPresent) { - val optoptionalList = optionalList.get() - startArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - for (item in optoptionalList.iterator()) { - put(AnonymousTag, item) - } - endArray() + val optoptionalList = optionalList.get() + startArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) + for (item in optoptionalList.iterator()) { + put(AnonymousTag, item) } + endArray() + } if (nullableOptionalList != null) { - if (nullableOptionalList.isPresent) { - val optnullableOptionalList = nullableOptionalList.get() - startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - for (item in optnullableOptionalList.iterator()) { - put(AnonymousTag, item) - } - endArray() - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + if (nullableOptionalList.isPresent) { + val optnullableOptionalList = nullableOptionalList.get() + startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + for (item in optnullableOptionalList.iterator()) { + put(AnonymousTag, item) } + endArray() + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + } endStructure() } } @@ -156,153 +157,114 @@ class UnitTestingClusterNullablesAndOptionalsStruct( private const val TAG_OPTIONAL_LIST = 10 private const val TAG_NULLABLE_OPTIONAL_LIST = 11 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNullablesAndOptionalsStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterNullablesAndOptionalsStruct { tlvReader.enterStructure(tlvTag) - val nullableInt = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_INT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) - null - } - val optionalInt = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_INT))) - } else { - Optional.empty() - } - val nullableOptionalInt = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) - null - } - val nullableString = - if (!tlvReader.isNull()) { - tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) - null - } - val optionalString = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) - } else { - Optional.empty() - } - val nullableOptionalString = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) - null - } - val nullableStruct = - if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) - null - } - val optionalStruct = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { - Optional.of( - UnitTestingClusterSimpleStruct.fromTlv( - ContextSpecificTag(TAG_OPTIONAL_STRUCT), - tlvReader - ) - ) - } else { - Optional.empty() - } - val nullableOptionalStruct = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { - Optional.of( - UnitTestingClusterSimpleStruct.fromTlv( - ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), - tlvReader - ) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) - null - } - val nullableList = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) - null - } - val optionalList = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val nullableOptionalList = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - null - } - + val nullableInt = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_INT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) + null + } + val optionalInt = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_INT))) + } else { + Optional.empty() + } + val nullableOptionalInt = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) + null + } + val nullableString = if (!tlvReader.isNull()) { + tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) + null + } + val optionalString = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) + } else { + Optional.empty() + } + val nullableOptionalString = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) + null + } + val nullableStruct = if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) + null + } + val optionalStruct = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { + Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), tlvReader)) + } else { + Optional.empty() + } + val nullableOptionalStruct = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { + Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) + null + } + val nullableList = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) + null + } + val optionalList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val nullableOptionalList = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + null + } + tlvReader.exitContainer() - return UnitTestingClusterNullablesAndOptionalsStruct( - nullableInt, - optionalInt, - nullableOptionalInt, - nullableString, - optionalString, - nullableOptionalString, - nullableStruct, - optionalStruct, - nullableOptionalStruct, - nullableList, - optionalList, - nullableOptionalList - ) + return UnitTestingClusterNullablesAndOptionalsStruct(nullableInt, optionalInt, nullableOptionalInt, nullableString, optionalString, nullableOptionalString, nullableStruct, optionalStruct, nullableOptionalStruct, nullableList, optionalList, nullableOptionalList) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt index 217991a38b634a..3026a55dc4380c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt @@ -17,22 +17,25 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterSimpleStruct( - val a: UInt, - val b: Boolean, - val c: UInt, - val d: ByteArray, - val e: String, - val f: UInt, - val g: Float, - val h: Double -) { - override fun toString(): String = buildString { +import java.util.Optional + +class UnitTestingClusterSimpleStruct ( + val a: UInt, + val b: Boolean, + val c: UInt, + val d: ByteArray, + val e: String, + val f: UInt, + val g: Float, + val h: Double) { + override fun toString(): String = buildString { append("UnitTestingClusterSimpleStruct {\n") append("\ta : $a\n") append("\tb : $b\n") @@ -70,7 +73,7 @@ class UnitTestingClusterSimpleStruct( private const val TAG_G = 6 private const val TAG_H = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterSimpleStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterSimpleStruct { tlvReader.enterStructure(tlvTag) val a = tlvReader.getUInt(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) @@ -80,7 +83,7 @@ class UnitTestingClusterSimpleStruct( val f = tlvReader.getUInt(ContextSpecificTag(TAG_F)) val g = tlvReader.getFloat(ContextSpecificTag(TAG_G)) val h = tlvReader.getDouble(ContextSpecificTag(TAG_H)) - + tlvReader.exitContainer() return UnitTestingClusterSimpleStruct(a, b, c, d, e, f, g, h) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt index 36da8ea1549865..22970640c5eb3c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt @@ -17,24 +17,25 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterTestFabricScoped( - val fabricSensitiveInt8u: UInt, - val optionalFabricSensitiveInt8u: Optional, - val nullableFabricSensitiveInt8u: UInt?, - val nullableOptionalFabricSensitiveInt8u: Optional?, - val fabricSensitiveCharString: String, - val fabricSensitiveStruct: UnitTestingClusterSimpleStruct, - val fabricSensitiveInt8uList: List, - val fabricIndex: UInt -) { - override fun toString(): String = buildString { +import java.util.Optional + +class UnitTestingClusterTestFabricScoped ( + val fabricSensitiveInt8u: UInt, + val optionalFabricSensitiveInt8u: Optional, + val nullableFabricSensitiveInt8u: UInt?, + val nullableOptionalFabricSensitiveInt8u: Optional?, + val fabricSensitiveCharString: String, + val fabricSensitiveStruct: UnitTestingClusterSimpleStruct, + val fabricSensitiveInt8uList: List, + val fabricIndex: UInt) { + override fun toString(): String = buildString { append("UnitTestingClusterTestFabricScoped {\n") append("\tfabricSensitiveInt8u : $fabricSensitiveInt8u\n") append("\toptionalFabricSensitiveInt8u : $optionalFabricSensitiveInt8u\n") @@ -52,28 +53,22 @@ class UnitTestingClusterTestFabricScoped( startStructure(tlvTag) put(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U), fabricSensitiveInt8u) if (optionalFabricSensitiveInt8u.isPresent) { - val optoptionalFabricSensitiveInt8u = optionalFabricSensitiveInt8u.get() - put( - ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), - optoptionalFabricSensitiveInt8u - ) - } + val optoptionalFabricSensitiveInt8u = optionalFabricSensitiveInt8u.get() + put(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), optoptionalFabricSensitiveInt8u) + } if (nullableFabricSensitiveInt8u != null) { - put(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U), nullableFabricSensitiveInt8u) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - } + put(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U), nullableFabricSensitiveInt8u) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + } if (nullableOptionalFabricSensitiveInt8u != null) { - if (nullableOptionalFabricSensitiveInt8u.isPresent) { - val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() - put( - ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), - optnullableOptionalFabricSensitiveInt8u - ) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - } + if (nullableOptionalFabricSensitiveInt8u.isPresent) { + val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), optnullableOptionalFabricSensitiveInt8u) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + } put(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING), fabricSensitiveCharString) fabricSensitiveStruct.toTlv(ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), this) startArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) @@ -96,66 +91,44 @@ class UnitTestingClusterTestFabricScoped( private const val TAG_FABRIC_SENSITIVE_INT8U_LIST = 7 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScoped { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestFabricScoped { tlvReader.enterStructure(tlvTag) val fabricSensitiveInt8u = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U)) - val optionalFabricSensitiveInt8u = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) - } else { - Optional.empty() - } - val nullableFabricSensitiveInt8u = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - null - } - val nullableOptionalFabricSensitiveInt8u = - if (!tlvReader.isNull()) { - if ( - tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - ) { - Optional.of( - tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - null - } - val fabricSensitiveCharString = - tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) - val fabricSensitiveStruct = - UnitTestingClusterSimpleStruct.fromTlv( - ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), - tlvReader - ) - val fabricSensitiveInt8uList = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val optionalFabricSensitiveInt8u = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) + } else { + Optional.empty() + } + val nullableFabricSensitiveInt8u = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + null + } + val nullableOptionalFabricSensitiveInt8u = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + null + } + val fabricSensitiveCharString = tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) + val fabricSensitiveStruct = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), tlvReader) + val fabricSensitiveInt8uList = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return UnitTestingClusterTestFabricScoped( - fabricSensitiveInt8u, - optionalFabricSensitiveInt8u, - nullableFabricSensitiveInt8u, - nullableOptionalFabricSensitiveInt8u, - fabricSensitiveCharString, - fabricSensitiveStruct, - fabricSensitiveInt8uList, - fabricIndex - ) + return UnitTestingClusterTestFabricScoped(fabricSensitiveInt8u, optionalFabricSensitiveInt8u, nullableFabricSensitiveInt8u, nullableOptionalFabricSensitiveInt8u, fabricSensitiveCharString, fabricSensitiveStruct, fabricSensitiveInt8uList, fabricIndex) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt index 91afedb93a404f..1f823ba5cb92f9 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterTestListStructOctet(val member1: ULong, val member2: ByteArray) { - override fun toString(): String = buildString { +import java.util.Optional + +class UnitTestingClusterTestListStructOctet ( + val member1: ULong, + val member2: ByteArray) { + override fun toString(): String = buildString { append("UnitTestingClusterTestListStructOctet {\n") append("\tmember1 : $member1\n") append("\tmember2 : $member2\n") @@ -43,11 +49,11 @@ class UnitTestingClusterTestListStructOctet(val member1: ULong, val member2: Byt private const val TAG_MEMBER1 = 0 private const val TAG_MEMBER2 = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestListStructOctet { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestListStructOctet { tlvReader.enterStructure(tlvTag) val member1 = tlvReader.getULong(ContextSpecificTag(TAG_MEMBER1)) val member2 = tlvReader.getByteArray(ContextSpecificTag(TAG_MEMBER2)) - + tlvReader.exitContainer() return UnitTestingClusterTestListStructOctet(member1, member2) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt index 1cfbb532f5abaf..02509a81a9dbbc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt @@ -17,13 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UserLabelClusterLabelStruct(val label: String, val value: String) { - override fun toString(): String = buildString { +import java.util.Optional + +class UserLabelClusterLabelStruct ( + val label: String, + val value: String) { + override fun toString(): String = buildString { append("UserLabelClusterLabelStruct {\n") append("\tlabel : $label\n") append("\tvalue : $value\n") @@ -43,11 +49,11 @@ class UserLabelClusterLabelStruct(val label: String, val value: String) { private const val TAG_LABEL = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UserLabelClusterLabelStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UserLabelClusterLabelStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return UserLabelClusterLabelStruct(label, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt index c42cda3ef21f13..6c02e602d0f2cf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt @@ -17,154 +17,195 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccessControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class AclAttribute(val value: List) +class AccessControlCluster(private val controller: MatterController, private val endpointId: UShort) {class AclAttribute( + val value: List + ) sealed class AclAttributeSubscriptionState { - data class Success(val value: List) : - AclAttributeSubscriptionState() - + data class Success( + val value: List + ) : AclAttributeSubscriptionState() + data class Error(val exception: Exception) : AclAttributeSubscriptionState() - object SubscriptionEstablished : AclAttributeSubscriptionState() - } - - class ExtensionAttribute(val value: List?) + object SubscriptionEstablished : AclAttributeSubscriptionState() + } +class ExtensionAttribute( + val value: List? + ) sealed class ExtensionAttributeSubscriptionState { - data class Success(val value: List?) : - ExtensionAttributeSubscriptionState() - + data class Success( + val value: List? + ) : ExtensionAttributeSubscriptionState() + data class Error(val exception: Exception) : ExtensionAttributeSubscriptionState() - object SubscriptionEstablished : ExtensionAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : ExtensionAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readAclAttribute(): AclAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readAclAttribute(): AclAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acl attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acl attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return AclAttribute(decodedValue) } suspend fun writeAclAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -186,7 +227,7 @@ class AccessControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAclAttribute( @@ -194,48 +235,45 @@ class AccessControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AclAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AclAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Acl attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acl attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(AclAttributeSubscriptionState.Success(decodedValue)) } @@ -243,74 +281,81 @@ class AccessControlCluster( emit(AclAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readExtensionAttribute(): ExtensionAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readExtensionAttribute(): ExtensionAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Extension attribute not found in response" } + } + + requireNotNull(attributeData) { + "Extension attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlExtensionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlExtensionStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return ExtensionAttribute(decodedValue) } suspend fun writeExtensionAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -332,7 +377,7 @@ class AccessControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeExtensionAttribute( @@ -340,97 +385,97 @@ class AccessControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ExtensionAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ExtensionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Extension attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Extension attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - AccessControlClusterAccessControlExtensionStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ExtensionAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlExtensionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ExtensionAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ExtensionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Subjectsperaccesscontrolentry attribute not found in response" + } + + requireNotNull(attributeData) { + "Subjectsperaccesscontrolentry attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -439,38 +484,34 @@ class AccessControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Subjectsperaccesscontrolentry attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Subjectsperaccesscontrolentry attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -483,37 +524,44 @@ class AccessControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTargetsPerAccessControlEntryAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTargetsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Targetsperaccesscontrolentry attribute not found in response" } + } + + requireNotNull(attributeData) { + "Targetsperaccesscontrolentry attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -522,38 +570,34 @@ class AccessControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Targetsperaccesscontrolentry attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Targetsperaccesscontrolentry attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -566,39 +610,44 @@ class AccessControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAccessControlEntriesPerFabricAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAccessControlEntriesPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accesscontrolentriesperfabric attribute not found in response" + } + + requireNotNull(attributeData) { + "Accesscontrolentriesperfabric attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -607,38 +656,34 @@ class AccessControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Accesscontrolentriesperfabric attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Accesscontrolentriesperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -651,43 +696,49 @@ class AccessControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -697,50 +748,45 @@ class AccessControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -748,43 +794,49 @@ class AccessControlCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -794,50 +846,45 @@ class AccessControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -845,43 +892,49 @@ class AccessControlCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -891,48 +944,45 @@ class AccessControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -940,43 +990,49 @@ class AccessControlCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -986,48 +1042,45 @@ class AccessControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1035,37 +1088,44 @@ class AccessControlCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1074,37 +1134,35 @@ class AccessControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1116,37 +1174,44 @@ class AccessControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1155,38 +1220,34 @@ class AccessControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1199,7 +1260,7 @@ class AccessControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt index d7dcb095c61498..8bd65be952b931 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt @@ -17,85 +17,114 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccountLoginCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GetSetupPINResponse(val setupPIN: String) - - class GeneratedCommandListAttribute(val value: List) +class AccountLoginCluster(private val controller: MatterController, private val endpointId: UShort) { + class GetSetupPINResponse( + val setupPIN: String + ) +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun getSetupPIN( - tempAccountIdentifier: String, - timedInvokeTimeout: Duration - ): GetSetupPINResponse { + suspend fun getSetupPIN(tempAccountIdentifier: String + ,timedInvokeTimeout: Duration): GetSetupPINResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TEMP_ACCOUNT_IDENTIFIER_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TEMP_ACCOUNT_IDENTIFIER_REQ), tempAccountIdentifier) + tlvWriter.put(ContextSpecificTag(TAG_TEMP_ACCOUNT_IDENTIFIER_REQ), tempAccountIdentifier) tlvWriter.endStructure() val request: InvokeRequest = @@ -112,32 +141,38 @@ class AccountLoginCluster( tlvReader.enterStructure(AnonymousTag) val TAG_SETUP_P_I_N: Int = 0 var setupPIN_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_SETUP_P_I_N)) { - setupPIN_decoded = tlvReader.getString(tag) - } else { + + if (tag == ContextSpecificTag(TAG_SETUP_P_I_N)) {setupPIN_decoded = tlvReader.getString(tag)} + + + else { tlvReader.skipElement() } } + + if (setupPIN_decoded == null) { - throw IllegalStateException("setupPIN not found in TLV") + throw IllegalStateException("setupPIN not found in TLV") } + tlvReader.exitContainer() - return GetSetupPINResponse(setupPIN_decoded) + return GetSetupPINResponse( + setupPIN_decoded + ) } - suspend fun login( - tempAccountIdentifier: String, - setupPIN: String, - node: ULong?, - timedInvokeTimeout: Duration - ) { + suspend fun login(tempAccountIdentifier: String + ,setupPIN: String + ,node: ULong? + ,timedInvokeTimeout: Duration) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -150,7 +185,9 @@ class AccountLoginCluster( tlvWriter.put(ContextSpecificTag(TAG_SETUP_P_I_N_REQ), setupPIN) val TAG_NODE_REQ: Int = 2 - node?.let { tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) } + node?.let { + tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -164,14 +201,17 @@ class AccountLoginCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun logout(node: ULong?, timedInvokeTimeout: Duration) { + suspend fun logout(node: ULong? + ,timedInvokeTimeout: Duration) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NODE_REQ: Int = 0 - node?.let { tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) } + node?.let { + tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -184,41 +224,47 @@ class AccountLoginCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -228,50 +274,45 @@ class AccountLoginCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -279,43 +320,49 @@ class AccountLoginCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -325,50 +372,45 @@ class AccountLoginCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -376,43 +418,49 @@ class AccountLoginCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -422,48 +470,45 @@ class AccountLoginCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -471,43 +516,49 @@ class AccountLoginCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -517,48 +568,45 @@ class AccountLoginCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -566,37 +614,44 @@ class AccountLoginCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -605,37 +660,35 @@ class AccountLoginCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -647,37 +700,44 @@ class AccountLoginCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -686,38 +746,34 @@ class AccountLoginCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -730,7 +786,7 @@ class AccountLoginCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt index 5f44f5c6a99747..77cb5b4c8feca0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt @@ -17,97 +17,130 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ActionsCluster(private val controller: MatterController, private val endpointId: UShort) { - class ActionListAttribute(val value: List) +class ActionsCluster(private val controller: MatterController, private val endpointId: UShort) {class ActionListAttribute( + val value: List + ) sealed class ActionListAttributeSubscriptionState { - data class Success(val value: List) : - ActionListAttributeSubscriptionState() - + data class Success( + val value: List + ) : ActionListAttributeSubscriptionState() + data class Error(val exception: Exception) : ActionListAttributeSubscriptionState() - object SubscriptionEstablished : ActionListAttributeSubscriptionState() - } - - class EndpointListsAttribute(val value: List) + object SubscriptionEstablished : ActionListAttributeSubscriptionState() + } +class EndpointListsAttribute( + val value: List + ) sealed class EndpointListsAttributeSubscriptionState { - data class Success(val value: List) : - EndpointListsAttributeSubscriptionState() - + data class Success( + val value: List + ) : EndpointListsAttributeSubscriptionState() + data class Error(val exception: Exception) : EndpointListsAttributeSubscriptionState() - object SubscriptionEstablished : EndpointListsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : EndpointListsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun instantAction( - actionID: UShort, - invokeID: UInt?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun instantAction(actionID: UShort + ,invokeID: UInt? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -117,7 +150,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -131,12 +166,10 @@ class ActionsCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun instantActionWithTransition( - actionID: UShort, - invokeID: UInt?, - transitionTime: UShort, - timedInvokeTimeout: Duration? = null - ) { + suspend fun instantActionWithTransition(actionID: UShort + ,invokeID: UInt? + ,transitionTime: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -146,10 +179,12 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } val TAG_TRANSITION_TIME_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -163,7 +198,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeout: Duration? = null) { + suspend fun startAction(actionID: UShort + ,invokeID: UInt? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -173,7 +210,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -187,12 +226,10 @@ class ActionsCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startActionWithDuration( - actionID: UShort, - invokeID: UInt?, - duration: UInt, - timedInvokeTimeout: Duration? = null - ) { + suspend fun startActionWithDuration(actionID: UShort + ,invokeID: UInt? + ,duration: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -202,10 +239,12 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -219,7 +258,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stopAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeout: Duration? = null) { + suspend fun stopAction(actionID: UShort + ,invokeID: UInt? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -229,7 +270,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -243,7 +286,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun pauseAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeout: Duration? = null) { + suspend fun pauseAction(actionID: UShort + ,invokeID: UInt? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -253,7 +298,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -267,12 +314,10 @@ class ActionsCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun pauseActionWithDuration( - actionID: UShort, - invokeID: UInt?, - duration: UInt, - timedInvokeTimeout: Duration? = null - ) { + suspend fun pauseActionWithDuration(actionID: UShort + ,invokeID: UInt? + ,duration: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -282,10 +327,12 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -299,11 +346,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun resumeAction( - actionID: UShort, - invokeID: UInt?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun resumeAction(actionID: UShort + ,invokeID: UInt? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -313,7 +358,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -327,11 +374,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableAction( - actionID: UShort, - invokeID: UInt?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun enableAction(actionID: UShort + ,invokeID: UInt? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 8u val tlvWriter = TlvWriter() @@ -341,7 +386,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -355,12 +402,10 @@ class ActionsCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableActionWithDuration( - actionID: UShort, - invokeID: UInt?, - duration: UInt, - timedInvokeTimeout: Duration? = null - ) { + suspend fun enableActionWithDuration(actionID: UShort + ,invokeID: UInt? + ,duration: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -370,10 +415,12 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -387,11 +434,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun disableAction( - actionID: UShort, - invokeID: UInt?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun disableAction(actionID: UShort + ,invokeID: UInt? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 10u val tlvWriter = TlvWriter() @@ -401,7 +446,9 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -415,12 +462,10 @@ class ActionsCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun disableActionWithDuration( - actionID: UShort, - invokeID: UInt?, - duration: UInt, - timedInvokeTimeout: Duration? = null - ) { + suspend fun disableActionWithDuration(actionID: UShort + ,invokeID: UInt? + ,duration: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 11u val tlvWriter = TlvWriter() @@ -430,10 +475,12 @@ class ActionsCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } + invokeID?.let { + tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) + } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -446,41 +493,47 @@ class ActionsCluster(private val controller: MatterController, private val endpo val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readActionListAttribute(): ActionListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readActionListAttribute(): ActionListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Actionlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Actionlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return ActionListAttribute(decodedValue) } @@ -490,48 +543,45 @@ class ActionsCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActionListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActionListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Actionlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Actionlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ActionListAttributeSubscriptionState.Success(decodedValue)) } @@ -539,43 +589,49 @@ class ActionsCluster(private val controller: MatterController, private val endpo emit(ActionListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEndpointListsAttribute(): EndpointListsAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEndpointListsAttribute(): EndpointListsAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Endpointlists attribute not found in response" } + } + + requireNotNull(attributeData) { + "Endpointlists attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return EndpointListsAttribute(decodedValue) } @@ -585,48 +641,45 @@ class ActionsCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EndpointListsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EndpointListsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Endpointlists attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Endpointlists attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(EndpointListsAttributeSubscriptionState.Success(decodedValue)) } @@ -634,41 +687,47 @@ class ActionsCluster(private val controller: MatterController, private val endpo emit(EndpointListsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSetupURLAttribute(): String? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSetupURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Setupurl attribute not found in response" } + } + + requireNotNull(attributeData) { + "Setupurl attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -678,90 +737,96 @@ class ActionsCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Setupurl attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Setupurl attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -771,50 +836,45 @@ class ActionsCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -822,43 +882,49 @@ class ActionsCluster(private val controller: MatterController, private val endpo emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -868,50 +934,45 @@ class ActionsCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -919,43 +980,49 @@ class ActionsCluster(private val controller: MatterController, private val endpo emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -965,48 +1032,45 @@ class ActionsCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1014,43 +1078,49 @@ class ActionsCluster(private val controller: MatterController, private val endpo emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1060,48 +1130,45 @@ class ActionsCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1109,37 +1176,44 @@ class ActionsCluster(private val controller: MatterController, private val endpo emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1148,37 +1222,35 @@ class ActionsCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1190,37 +1262,44 @@ class ActionsCluster(private val controller: MatterController, private val endpo emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1229,38 +1308,34 @@ class ActionsCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1273,7 +1348,7 @@ class ActionsCluster(private val controller: MatterController, private val endpo emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt index daa2d6a7bdf0f6..73fbba68b06ac4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt @@ -17,105 +17,132 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ActivatedCarbonFilterMonitoringCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class LastChangedTimeAttribute(val value: UInt?) +class ActivatedCarbonFilterMonitoringCluster(private val controller: MatterController, private val endpointId: UShort) {class LastChangedTimeAttribute( + val value: UInt? + ) sealed class LastChangedTimeAttributeSubscriptionState { - data class Success(val value: UInt?) : LastChangedTimeAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : LastChangedTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : LastChangedTimeAttributeSubscriptionState() - object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() - } - - class ReplacementProductListAttribute( + object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() + } +class ReplacementProductListAttribute( val value: List? ) sealed class ReplacementProductListAttributeSubscriptionState { data class Success( - val value: List? + val value: List? ) : ReplacementProductListAttributeSubscriptionState() - + data class Error(val exception: Exception) : ReplacementProductListAttributeSubscriptionState() - object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCondition(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -128,39 +155,45 @@ class ActivatedCarbonFilterMonitoringCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readConditionAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readConditionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Condition attribute not found in response" } + } + + requireNotNull(attributeData) { + "Condition attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -170,88 +203,94 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Condition attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Condition attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDegradationDirectionAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDegradationDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Degradationdirection attribute not found in response" } + } + + requireNotNull(attributeData) { + "Degradationdirection attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -261,86 +300,91 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Degradationdirection attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Degradationdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readChangeIndicationAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Changeindication attribute not found in response" } + } + + requireNotNull(attributeData) { + "Changeindication attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -349,38 +393,34 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Changeindication attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Changeindication attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -393,41 +433,47 @@ class ActivatedCarbonFilterMonitoringCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readInPlaceIndicatorAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readInPlaceIndicatorAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Inplaceindicator attribute not found in response" } + } + + requireNotNull(attributeData) { + "Inplaceindicator attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -437,115 +483,123 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Inplaceindicator attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Inplaceindicator attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lastchangedtime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lastchangedtime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LastChangedTimeAttribute(decodedValue) } - suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeLastChangedTimeAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -567,7 +621,7 @@ class ActivatedCarbonFilterMonitoringCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLastChangedTimeAttribute( @@ -575,106 +629,105 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LastChangedTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LastChangedTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lastchangedtime attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lastchangedtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(LastChangedTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(LastChangedTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LastChangedTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Replacementproductlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Replacementproductlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return ReplacementProductListAttribute(decodedValue) } @@ -684,103 +737,102 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ReplacementProductListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ReplacementProductListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Replacementproductlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Replacementproductlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ReplacementProductListAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ReplacementProductListAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ReplacementProductListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -790,50 +842,45 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -841,43 +888,49 @@ class ActivatedCarbonFilterMonitoringCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -887,50 +940,45 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -938,43 +986,49 @@ class ActivatedCarbonFilterMonitoringCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -984,48 +1038,45 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1033,43 +1084,49 @@ class ActivatedCarbonFilterMonitoringCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1079,48 +1136,45 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1128,37 +1182,44 @@ class ActivatedCarbonFilterMonitoringCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1167,37 +1228,35 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1209,37 +1268,44 @@ class ActivatedCarbonFilterMonitoringCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1248,38 +1314,34 @@ class ActivatedCarbonFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1292,7 +1354,7 @@ class ActivatedCarbonFilterMonitoringCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt index 4fd1bd91dacbe3..0d51abdb78e597 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt @@ -17,101 +17,133 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AdministratorCommissioningCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class AdminFabricIndexAttribute(val value: UByte?) +class AdministratorCommissioningCluster(private val controller: MatterController, private val endpointId: UShort) {class AdminFabricIndexAttribute( + val value: UByte? + ) sealed class AdminFabricIndexAttributeSubscriptionState { - data class Success(val value: UByte?) : AdminFabricIndexAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : AdminFabricIndexAttributeSubscriptionState() + data class Error(val exception: Exception) : AdminFabricIndexAttributeSubscriptionState() - object SubscriptionEstablished : AdminFabricIndexAttributeSubscriptionState() - } - - class AdminVendorIdAttribute(val value: UShort?) + object SubscriptionEstablished : AdminFabricIndexAttributeSubscriptionState() + } +class AdminVendorIdAttribute( + val value: UShort? + ) sealed class AdminVendorIdAttributeSubscriptionState { - data class Success(val value: UShort?) : AdminVendorIdAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : AdminVendorIdAttributeSubscriptionState() + data class Error(val exception: Exception) : AdminVendorIdAttributeSubscriptionState() - object SubscriptionEstablished : AdminVendorIdAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AdminVendorIdAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun openCommissioningWindow( - commissioningTimeout: UShort, - PAKEPasscodeVerifier: ByteArray, - discriminator: UShort, - iterations: UInt, - salt: ByteArray, - timedInvokeTimeout: Duration - ) { + suspend fun openCommissioningWindow(commissioningTimeout: UShort + ,PAKEPasscodeVerifier: ByteArray + ,discriminator: UShort + ,iterations: UInt + ,salt: ByteArray + ,timedInvokeTimeout: Duration) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -130,7 +162,7 @@ class AdministratorCommissioningCluster( tlvWriter.put(ContextSpecificTag(TAG_ITERATIONS_REQ), iterations) val TAG_SALT_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_SALT_REQ), salt) + tlvWriter.put(ContextSpecificTag(TAG_SALT_REQ), salt) tlvWriter.endStructure() val request: InvokeRequest = @@ -144,17 +176,15 @@ class AdministratorCommissioningCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun openBasicCommissioningWindow( - commissioningTimeout: UShort, - timedInvokeTimeout: Duration - ) { + suspend fun openBasicCommissioningWindow(commissioningTimeout: UShort + ,timedInvokeTimeout: Duration) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_COMMISSIONING_TIMEOUT_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_COMMISSIONING_TIMEOUT_REQ), commissioningTimeout) + tlvWriter.put(ContextSpecificTag(TAG_COMMISSIONING_TIMEOUT_REQ), commissioningTimeout) tlvWriter.endStructure() val request: InvokeRequest = @@ -172,7 +202,7 @@ class AdministratorCommissioningCluster( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -185,35 +215,42 @@ class AdministratorCommissioningCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readWindowStatusAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readWindowStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Windowstatus attribute not found in response" } + } + + requireNotNull(attributeData) { + "Windowstatus attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -222,37 +259,35 @@ class AdministratorCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Windowstatus attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Windowstatus attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -264,42 +299,48 @@ class AdministratorCommissioningCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAdminFabricIndexAttribute(): AdminFabricIndexAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAdminFabricIndexAttribute(): AdminFabricIndexAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Adminfabricindex attribute not found in response" } + } + + requireNotNull(attributeData) { + "Adminfabricindex attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AdminFabricIndexAttribute(decodedValue) } @@ -309,92 +350,96 @@ class AdministratorCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AdminFabricIndexAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AdminFabricIndexAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Adminfabricindex attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Adminfabricindex attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AdminFabricIndexAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AdminFabricIndexAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AdminFabricIndexAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAdminVendorIdAttribute(): AdminVendorIdAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAdminVendorIdAttribute(): AdminVendorIdAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Adminvendorid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Adminvendorid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AdminVendorIdAttribute(decodedValue) } @@ -404,91 +449,97 @@ class AdministratorCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AdminVendorIdAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AdminVendorIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Adminvendorid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Adminvendorid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AdminVendorIdAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AdminVendorIdAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AdminVendorIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -498,50 +549,45 @@ class AdministratorCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -549,43 +595,49 @@ class AdministratorCommissioningCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -595,50 +647,45 @@ class AdministratorCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -646,43 +693,49 @@ class AdministratorCommissioningCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -692,48 +745,45 @@ class AdministratorCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -741,43 +791,49 @@ class AdministratorCommissioningCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -787,48 +843,45 @@ class AdministratorCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -836,37 +889,44 @@ class AdministratorCommissioningCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -875,37 +935,35 @@ class AdministratorCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -917,37 +975,44 @@ class AdministratorCommissioningCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -956,38 +1021,34 @@ class AdministratorCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1000,7 +1061,7 @@ class AdministratorCommissioningCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt index b2c558f45df037..7622ac8f893d32 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt @@ -17,93 +17,136 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class AirQualityCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) +class AirQualityCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readAirQualityAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readAirQualityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Airquality attribute not found in response" } + } + + requireNotNull(attributeData) { + "Airquality attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -112,37 +155,35 @@ class AirQualityCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Airquality attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Airquality attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -154,43 +195,49 @@ class AirQualityCluster(private val controller: MatterController, private val en emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -200,50 +247,45 @@ class AirQualityCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -251,43 +293,49 @@ class AirQualityCluster(private val controller: MatterController, private val en emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -297,50 +345,45 @@ class AirQualityCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -348,43 +391,49 @@ class AirQualityCluster(private val controller: MatterController, private val en emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -394,48 +443,45 @@ class AirQualityCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -443,43 +489,49 @@ class AirQualityCluster(private val controller: MatterController, private val en emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -489,48 +541,45 @@ class AirQualityCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -538,37 +587,44 @@ class AirQualityCluster(private val controller: MatterController, private val en emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -577,37 +633,35 @@ class AirQualityCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -619,37 +673,44 @@ class AirQualityCluster(private val controller: MatterController, private val en emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -658,38 +719,34 @@ class AirQualityCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -702,7 +759,7 @@ class AirQualityCluster(private val controller: MatterController, private val en emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt index ed62272114e72a..880e6385833234 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt @@ -17,122 +17,165 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class ApplicationBasicCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ApplicationAttribute(val value: ApplicationBasicClusterApplicationStruct) +class ApplicationBasicCluster(private val controller: MatterController, private val endpointId: UShort) {class ApplicationAttribute( + val value: ApplicationBasicClusterApplicationStruct + ) sealed class ApplicationAttributeSubscriptionState { - data class Success(val value: ApplicationBasicClusterApplicationStruct) : - ApplicationAttributeSubscriptionState() - + data class Success( + val value: ApplicationBasicClusterApplicationStruct + ) : ApplicationAttributeSubscriptionState() + data class Error(val exception: Exception) : ApplicationAttributeSubscriptionState() - object SubscriptionEstablished : ApplicationAttributeSubscriptionState() - } - - class AllowedVendorListAttribute(val value: List) + object SubscriptionEstablished : ApplicationAttributeSubscriptionState() + } +class AllowedVendorListAttribute( + val value: List + ) sealed class AllowedVendorListAttributeSubscriptionState { - data class Success(val value: List) : AllowedVendorListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AllowedVendorListAttributeSubscriptionState() + data class Error(val exception: Exception) : AllowedVendorListAttributeSubscriptionState() - object SubscriptionEstablished : AllowedVendorListAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AllowedVendorListAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readVendorNameAttribute(): String? { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readVendorNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Vendorname attribute not found in response" } + } + + requireNotNull(attributeData) { + "Vendorname attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -142,88 +185,94 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Vendorname attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Vendorname attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readVendorIDAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readVendorIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Vendorid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Vendorid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -233,84 +282,91 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Vendorid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readApplicationNameAttribute(): String { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readApplicationNameAttribute(): String {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Applicationname attribute not found in response" } + } + + requireNotNull(attributeData) { + "Applicationname attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } @@ -319,38 +375,34 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Applicationname attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Applicationname attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -363,41 +415,47 @@ class ApplicationBasicCluster( emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readProductIDAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readProductIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Productid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Productid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -407,84 +465,90 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Productid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Productid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readApplicationAttribute(): ApplicationAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readApplicationAttribute(): ApplicationAttribute {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Application attribute not found in response" } + } + + requireNotNull(attributeData) { + "Application attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationBasicClusterApplicationStruct = - ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: ApplicationBasicClusterApplicationStruct = ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) + return ApplicationAttribute(decodedValue) } @@ -494,42 +558,39 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ApplicationAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ApplicationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Application attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Application attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationBasicClusterApplicationStruct = - ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: ApplicationBasicClusterApplicationStruct = ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) emit(ApplicationAttributeSubscriptionState.Success(decodedValue)) } @@ -537,37 +598,44 @@ class ApplicationBasicCluster( emit(ApplicationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStatusAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Status attribute not found in response" } + } + + requireNotNull(attributeData) { + "Status attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -576,37 +644,35 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Status attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Status attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -618,37 +684,44 @@ class ApplicationBasicCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readApplicationVersionAttribute(): String { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readApplicationVersionAttribute(): String {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Applicationversion attribute not found in response" } + } + + requireNotNull(attributeData) { + "Applicationversion attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } @@ -657,38 +730,34 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Applicationversion attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Applicationversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -701,43 +770,49 @@ class ApplicationBasicCluster( emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Allowedvendorlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Allowedvendorlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) } + tlvReader.exitContainer() + } + return AllowedVendorListAttribute(decodedValue) } @@ -747,50 +822,45 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AllowedVendorListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AllowedVendorListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Allowedvendorlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Allowedvendorlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AllowedVendorListAttributeSubscriptionState.Success(decodedValue)) } @@ -798,43 +868,49 @@ class ApplicationBasicCluster( emit(AllowedVendorListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -844,50 +920,45 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -895,43 +966,49 @@ class ApplicationBasicCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -941,50 +1018,45 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -992,43 +1064,49 @@ class ApplicationBasicCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1038,48 +1116,45 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1087,43 +1162,49 @@ class ApplicationBasicCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1133,48 +1214,45 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1182,37 +1260,44 @@ class ApplicationBasicCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1221,37 +1306,35 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1263,37 +1346,44 @@ class ApplicationBasicCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1302,38 +1392,34 @@ class ApplicationBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1346,7 +1432,7 @@ class ApplicationBasicCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt index 7d9f650c50480b..5045bf8de2e5ee 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt @@ -17,110 +17,149 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ApplicationLauncherCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class LauncherResponse(val status: UByte, val data: ByteArray?) - - class CatalogListAttribute(val value: List?) +class ApplicationLauncherCluster(private val controller: MatterController, private val endpointId: UShort) { + class LauncherResponse( + val status: UByte, + val data: ByteArray? + ) +class CatalogListAttribute( + val value: List? + ) sealed class CatalogListAttributeSubscriptionState { - data class Success(val value: List?) : CatalogListAttributeSubscriptionState() - + data class Success( + val value: List? + ) : CatalogListAttributeSubscriptionState() + data class Error(val exception: Exception) : CatalogListAttributeSubscriptionState() - object SubscriptionEstablished : CatalogListAttributeSubscriptionState() - } - - class CurrentAppAttribute(val value: ApplicationLauncherClusterApplicationEPStruct?) + object SubscriptionEstablished : CatalogListAttributeSubscriptionState() + } +class CurrentAppAttribute( + val value: ApplicationLauncherClusterApplicationEPStruct? + ) sealed class CurrentAppAttributeSubscriptionState { - data class Success(val value: ApplicationLauncherClusterApplicationEPStruct?) : - CurrentAppAttributeSubscriptionState() - + data class Success( + val value: ApplicationLauncherClusterApplicationEPStruct? + ) : CurrentAppAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentAppAttributeSubscriptionState() - object SubscriptionEstablished : CurrentAppAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : CurrentAppAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun launchApp( - application: ApplicationLauncherClusterApplicationStruct?, - data: ByteArray?, - timedInvokeTimeout: Duration? = null - ): LauncherResponse { + suspend fun launchApp(application: ApplicationLauncherClusterApplicationStruct? + ,data: ByteArray? + ,timedInvokeTimeout: Duration? = null): LauncherResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_APPLICATION_REQ: Int = 0 - application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } + application?.let { + application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) + } val TAG_DATA_REQ: Int = 1 - data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } + data?.let { + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -137,54 +176,63 @@ class ApplicationLauncherCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } else { + tlvReader.getByteArray(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return LauncherResponse(status_decoded, data_decoded) + return LauncherResponse( + status_decoded, + data_decoded + ) } - suspend fun stopApp( - application: ApplicationLauncherClusterApplicationStruct?, - timedInvokeTimeout: Duration? = null - ): LauncherResponse { + suspend fun stopApp(application: ApplicationLauncherClusterApplicationStruct? + ,timedInvokeTimeout: Duration? = null): LauncherResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_APPLICATION_REQ: Int = 0 - application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } + application?.let { + application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -201,54 +249,63 @@ class ApplicationLauncherCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } else { + tlvReader.getByteArray(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return LauncherResponse(status_decoded, data_decoded) + return LauncherResponse( + status_decoded, + data_decoded + ) } - suspend fun hideApp( - application: ApplicationLauncherClusterApplicationStruct?, - timedInvokeTimeout: Duration? = null - ): LauncherResponse { + suspend fun hideApp(application: ApplicationLauncherClusterApplicationStruct? + ,timedInvokeTimeout: Duration? = null): LauncherResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_APPLICATION_REQ: Int = 0 - application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } + application?.let { + application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -265,81 +322,96 @@ class ApplicationLauncherCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } else { + tlvReader.getByteArray(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return LauncherResponse(status_decoded, data_decoded) + return LauncherResponse( + status_decoded, + data_decoded + ) } - - suspend fun readCatalogListAttribute(): CatalogListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCatalogListAttribute(): CatalogListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Cataloglist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Cataloglist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return CatalogListAttribute(decodedValue) } @@ -349,99 +421,105 @@ class ApplicationLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CatalogListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CatalogListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Cataloglist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Cataloglist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(CatalogListAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(CatalogListAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CatalogListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentAppAttribute(): CurrentAppAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentAppAttribute(): CurrentAppAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentapp attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentapp attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentAppAttribute(decodedValue) } @@ -451,95 +529,101 @@ class ApplicationLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentAppAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentAppAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentapp attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentapp attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CurrentAppAttributeSubscriptionState.Success(it)) } + val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CurrentAppAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentAppAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -549,50 +633,45 @@ class ApplicationLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -600,43 +679,49 @@ class ApplicationLauncherCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -646,50 +731,45 @@ class ApplicationLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -697,43 +777,49 @@ class ApplicationLauncherCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -743,48 +829,45 @@ class ApplicationLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -792,43 +875,49 @@ class ApplicationLauncherCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -838,48 +927,45 @@ class ApplicationLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -887,37 +973,44 @@ class ApplicationLauncherCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -926,37 +1019,35 @@ class ApplicationLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -968,37 +1059,44 @@ class ApplicationLauncherCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1007,38 +1105,34 @@ class ApplicationLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1051,7 +1145,7 @@ class ApplicationLauncherCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt index d5a58d5c07ca1f..c038970d786898 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt @@ -17,89 +17,123 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AudioOutputCluster(private val controller: MatterController, private val endpointId: UShort) { - class OutputListAttribute(val value: List) +class AudioOutputCluster(private val controller: MatterController, private val endpointId: UShort) {class OutputListAttribute( + val value: List + ) sealed class OutputListAttributeSubscriptionState { - data class Success(val value: List) : - OutputListAttributeSubscriptionState() - + data class Success( + val value: List + ) : OutputListAttributeSubscriptionState() + data class Error(val exception: Exception) : OutputListAttributeSubscriptionState() - object SubscriptionEstablished : OutputListAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OutputListAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun selectOutput(index: UByte, timedInvokeTimeout: Duration? = null) { + suspend fun selectOutput(index: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) + tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) tlvWriter.endStructure() val request: InvokeRequest = @@ -113,7 +147,9 @@ class AudioOutputCluster(private val controller: MatterController, private val e logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun renameOutput(index: UByte, name: String, timedInvokeTimeout: Duration? = null) { + suspend fun renameOutput(index: UByte + ,name: String + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -123,7 +159,7 @@ class AudioOutputCluster(private val controller: MatterController, private val e tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) val TAG_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) + tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) tlvWriter.endStructure() val request: InvokeRequest = @@ -136,41 +172,47 @@ class AudioOutputCluster(private val controller: MatterController, private val e val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readOutputListAttribute(): OutputListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOutputListAttribute(): OutputListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Outputlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Outputlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return OutputListAttribute(decodedValue) } @@ -180,48 +222,45 @@ class AudioOutputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OutputListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OutputListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Outputlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Outputlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(OutputListAttributeSubscriptionState.Success(decodedValue)) } @@ -229,37 +268,44 @@ class AudioOutputCluster(private val controller: MatterController, private val e emit(OutputListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentOutputAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentOutputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentoutput attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentoutput attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -268,37 +314,35 @@ class AudioOutputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentoutput attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentoutput attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -310,43 +354,49 @@ class AudioOutputCluster(private val controller: MatterController, private val e emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -356,50 +406,45 @@ class AudioOutputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -407,43 +452,49 @@ class AudioOutputCluster(private val controller: MatterController, private val e emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -453,50 +504,45 @@ class AudioOutputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -504,43 +550,49 @@ class AudioOutputCluster(private val controller: MatterController, private val e emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -550,48 +602,45 @@ class AudioOutputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -599,43 +648,49 @@ class AudioOutputCluster(private val controller: MatterController, private val e emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -645,48 +700,45 @@ class AudioOutputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -694,37 +746,44 @@ class AudioOutputCluster(private val controller: MatterController, private val e emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -733,37 +792,35 @@ class AudioOutputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -775,37 +832,44 @@ class AudioOutputCluster(private val controller: MatterController, private val e emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -814,38 +878,34 @@ class AudioOutputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -858,7 +918,7 @@ class AudioOutputCluster(private val controller: MatterController, private val e emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt index a0b361cdbb2400..e733a38744d421 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt @@ -17,152 +17,201 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BallastConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class IntrinsicBallastFactorAttribute(val value: UByte?) +class BallastConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class IntrinsicBallastFactorAttribute( + val value: UByte? + ) sealed class IntrinsicBallastFactorAttributeSubscriptionState { - data class Success(val value: UByte?) : IntrinsicBallastFactorAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : IntrinsicBallastFactorAttributeSubscriptionState() + data class Error(val exception: Exception) : IntrinsicBallastFactorAttributeSubscriptionState() - object SubscriptionEstablished : IntrinsicBallastFactorAttributeSubscriptionState() - } - - class BallastFactorAdjustmentAttribute(val value: UByte?) + object SubscriptionEstablished : IntrinsicBallastFactorAttributeSubscriptionState() + } +class BallastFactorAdjustmentAttribute( + val value: UByte? + ) sealed class BallastFactorAdjustmentAttributeSubscriptionState { - data class Success(val value: UByte?) : BallastFactorAdjustmentAttributeSubscriptionState() - - data class Error(val exception: Exception) : - BallastFactorAdjustmentAttributeSubscriptionState() - - object SubscriptionEstablished : BallastFactorAdjustmentAttributeSubscriptionState() - } - - class LampRatedHoursAttribute(val value: UInt?) + data class Success( + val value: UByte? + ) : BallastFactorAdjustmentAttributeSubscriptionState() + + data class Error(val exception: Exception) : BallastFactorAdjustmentAttributeSubscriptionState() + + object SubscriptionEstablished : BallastFactorAdjustmentAttributeSubscriptionState() + } +class LampRatedHoursAttribute( + val value: UInt? + ) sealed class LampRatedHoursAttributeSubscriptionState { - data class Success(val value: UInt?) : LampRatedHoursAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : LampRatedHoursAttributeSubscriptionState() + data class Error(val exception: Exception) : LampRatedHoursAttributeSubscriptionState() - object SubscriptionEstablished : LampRatedHoursAttributeSubscriptionState() - } - - class LampBurnHoursAttribute(val value: UInt?) + object SubscriptionEstablished : LampRatedHoursAttributeSubscriptionState() + } +class LampBurnHoursAttribute( + val value: UInt? + ) sealed class LampBurnHoursAttributeSubscriptionState { - data class Success(val value: UInt?) : LampBurnHoursAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : LampBurnHoursAttributeSubscriptionState() + data class Error(val exception: Exception) : LampBurnHoursAttributeSubscriptionState() - object SubscriptionEstablished : LampBurnHoursAttributeSubscriptionState() - } - - class LampBurnHoursTripPointAttribute(val value: UInt?) + object SubscriptionEstablished : LampBurnHoursAttributeSubscriptionState() + } +class LampBurnHoursTripPointAttribute( + val value: UInt? + ) sealed class LampBurnHoursTripPointAttributeSubscriptionState { - data class Success(val value: UInt?) : LampBurnHoursTripPointAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : LampBurnHoursTripPointAttributeSubscriptionState() + data class Error(val exception: Exception) : LampBurnHoursTripPointAttributeSubscriptionState() - object SubscriptionEstablished : LampBurnHoursTripPointAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : LampBurnHoursTripPointAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readPhysicalMinLevelAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readPhysicalMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Physicalminlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Physicalminlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -171,38 +220,34 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Physicalminlevel attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Physicalminlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -215,37 +260,44 @@ class BallastConfigurationCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPhysicalMaxLevelAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPhysicalMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Physicalmaxlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Physicalmaxlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -254,38 +306,34 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Physicalmaxlevel attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Physicalmaxlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -298,41 +346,47 @@ class BallastConfigurationCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBallastStatusAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBallastStatusAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Ballaststatus attribute not found in response" } + } + + requireNotNull(attributeData) { + "Ballaststatus attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -342,103 +396,114 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Ballaststatus attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ballaststatus attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinLevelAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeMinLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeMinLevelAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -460,7 +525,7 @@ class BallastConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinLevelAttribute( @@ -468,37 +533,35 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Minlevel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minlevel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -510,56 +573,67 @@ class BallastConfigurationCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxLevelAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeMaxLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeMaxLevelAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -581,7 +655,7 @@ class BallastConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMaxLevelAttribute( @@ -589,37 +663,35 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxlevel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxlevel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -631,69 +703,76 @@ class BallastConfigurationCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribute { - val ATTRIBUTE_ID: UInt = 20u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribute {val ATTRIBUTE_ID: UInt = 20u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Intrinsicballastfactor attribute not found in response" } + } + + requireNotNull(attributeData) { + "Intrinsicballastfactor attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return IntrinsicBallastFactorAttribute(decodedValue) } suspend fun writeIntrinsicBallastFactorAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -715,7 +794,7 @@ class BallastConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeIntrinsicBallastFactorAttribute( @@ -723,123 +802,128 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - IntrinsicBallastFactorAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(IntrinsicBallastFactorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Intrinsicballastfactor attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Intrinsicballastfactor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(IntrinsicBallastFactorAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(IntrinsicBallastFactorAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(IntrinsicBallastFactorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttribute { - val ATTRIBUTE_ID: UInt = 21u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttribute {val ATTRIBUTE_ID: UInt = 21u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Ballastfactoradjustment attribute not found in response" } + } + + requireNotNull(attributeData) { + "Ballastfactoradjustment attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return BallastFactorAdjustmentAttribute(decodedValue) } suspend fun writeBallastFactorAdjustmentAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -861,7 +945,7 @@ class BallastConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBallastFactorAdjustmentAttribute( @@ -869,91 +953,96 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BallastFactorAdjustmentAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BallastFactorAdjustmentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Ballastfactoradjustment attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ballastfactoradjustment attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(BallastFactorAdjustmentAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(BallastFactorAdjustmentAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BallastFactorAdjustmentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLampQuantityAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 32u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLampQuantityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lampquantity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lampquantity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -962,37 +1051,35 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Lampquantity attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lampquantity attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1004,61 +1091,71 @@ class BallastConfigurationCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLampTypeAttribute(): String? { - val ATTRIBUTE_ID: UInt = 48u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLampTypeAttribute(): String? {val ATTRIBUTE_ID: UInt = 48u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lamptype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lamptype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeLampTypeAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeLampTypeAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1080,7 +1177,7 @@ class BallastConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampTypeAttribute( @@ -1088,108 +1185,118 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Lamptype attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lamptype attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLampManufacturerAttribute(): String? { - val ATTRIBUTE_ID: UInt = 49u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLampManufacturerAttribute(): String? {val ATTRIBUTE_ID: UInt = 49u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lampmanufacturer attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lampmanufacturer attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeLampManufacturerAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeLampManufacturerAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1211,7 +1318,7 @@ class BallastConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampManufacturerAttribute( @@ -1219,115 +1326,123 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lampmanufacturer attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lampmanufacturer attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute { - val ATTRIBUTE_ID: UInt = 50u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute {val ATTRIBUTE_ID: UInt = 50u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lampratedhours attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lampratedhours attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LampRatedHoursAttribute(decodedValue) } - suspend fun writeLampRatedHoursAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeLampRatedHoursAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1349,7 +1464,7 @@ class BallastConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampRatedHoursAttribute( @@ -1357,120 +1472,128 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LampRatedHoursAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LampRatedHoursAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lampratedhours attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lampratedhours attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(LampRatedHoursAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(LampRatedHoursAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LampRatedHoursAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute { - val ATTRIBUTE_ID: UInt = 51u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute {val ATTRIBUTE_ID: UInt = 51u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lampburnhours attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lampburnhours attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LampBurnHoursAttribute(decodedValue) } - suspend fun writeLampBurnHoursAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeLampBurnHoursAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 51u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1492,7 +1615,7 @@ class BallastConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampBurnHoursAttribute( @@ -1500,113 +1623,123 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LampBurnHoursAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LampBurnHoursAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Lampburnhours attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lampburnhours attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(LampBurnHoursAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(LampBurnHoursAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LampBurnHoursAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLampAlarmModeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 52u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLampAlarmModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 52u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lampalarmmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lampalarmmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeLampAlarmModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeLampAlarmModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 52u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1628,7 +1761,7 @@ class BallastConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampAlarmModeAttribute( @@ -1636,116 +1769,123 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Lampalarmmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lampalarmmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribute { - val ATTRIBUTE_ID: UInt = 53u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribute {val ATTRIBUTE_ID: UInt = 53u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lampburnhourstrippoint attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lampburnhourstrippoint attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LampBurnHoursTripPointAttribute(decodedValue) } suspend fun writeLampBurnHoursTripPointAttribute( value: UInt, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 53u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1767,7 +1907,7 @@ class BallastConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampBurnHoursTripPointAttribute( @@ -1775,97 +1915,101 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LampBurnHoursTripPointAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LampBurnHoursTripPointAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lampburnhourstrippoint attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lampburnhourstrippoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(LampBurnHoursTripPointAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(LampBurnHoursTripPointAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LampBurnHoursTripPointAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1875,50 +2019,45 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1926,43 +2065,49 @@ class BallastConfigurationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1972,50 +2117,45 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2023,43 +2163,49 @@ class BallastConfigurationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -2069,48 +2215,45 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2118,43 +2261,49 @@ class BallastConfigurationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -2164,48 +2313,45 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2213,37 +2359,44 @@ class BallastConfigurationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -2252,37 +2405,35 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2294,37 +2445,44 @@ class BallastConfigurationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2333,38 +2491,34 @@ class BallastConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2377,7 +2531,7 @@ class BallastConfigurationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt index baddce34338c61..01b8f509d4f7af 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt @@ -17,84 +17,110 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BarrierControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class BarrierControlCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun barrierControlGoToPercent(percentOpen: UByte, timedInvokeTimeout: Duration? = null) { + suspend fun barrierControlGoToPercent(percentOpen: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_PERCENT_OPEN_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_PERCENT_OPEN_REQ), percentOpen) + tlvWriter.put(ContextSpecificTag(TAG_PERCENT_OPEN_REQ), percentOpen) tlvWriter.endStructure() val request: InvokeRequest = @@ -112,7 +138,7 @@ class BarrierControlCluster( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -125,35 +151,42 @@ class BarrierControlCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readBarrierMovingStateAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBarrierMovingStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Barriermovingstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Barriermovingstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -162,38 +195,34 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Barriermovingstate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Barriermovingstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -206,37 +235,44 @@ class BarrierControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBarrierSafetyStatusAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBarrierSafetyStatusAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Barriersafetystatus attribute not found in response" } + } + + requireNotNull(attributeData) { + "Barriersafetystatus attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -245,38 +281,34 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Barriersafetystatus attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Barriersafetystatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -289,37 +321,44 @@ class BarrierControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBarrierCapabilitiesAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBarrierCapabilitiesAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Barriercapabilities attribute not found in response" } + } + + requireNotNull(attributeData) { + "Barriercapabilities attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -328,38 +367,34 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Barriercapabilities attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Barriercapabilities attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -372,61 +407,71 @@ class BarrierControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBarrierOpenEventsAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBarrierOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Barrieropenevents attribute not found in response" } + } + + requireNotNull(attributeData) { + "Barrieropenevents attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeBarrierOpenEventsAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierOpenEventsAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -448,7 +493,7 @@ class BarrierControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierOpenEventsAttribute( @@ -456,110 +501,118 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Barrieropenevents attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Barrieropenevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBarrierCloseEventsAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBarrierCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Barriercloseevents attribute not found in response" } + } + + requireNotNull(attributeData) { + "Barriercloseevents attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeBarrierCloseEventsAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierCloseEventsAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -581,7 +634,7 @@ class BarrierControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierCloseEventsAttribute( @@ -589,113 +642,118 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Barriercloseevents attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Barriercloseevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBarrierCommandOpenEventsAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBarrierCommandOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Barriercommandopenevents attribute not found in response" } + } + + requireNotNull(attributeData) { + "Barriercommandopenevents attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeBarrierCommandOpenEventsAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -717,7 +775,7 @@ class BarrierControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierCommandOpenEventsAttribute( @@ -725,113 +783,118 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Barriercommandopenevents attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Barriercommandopenevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBarrierCommandCloseEventsAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBarrierCommandCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Barriercommandcloseevents attribute not found in response" } + } + + requireNotNull(attributeData) { + "Barriercommandcloseevents attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeBarrierCommandCloseEventsAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -853,7 +916,7 @@ class BarrierControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierCommandCloseEventsAttribute( @@ -861,110 +924,118 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Barriercommandcloseevents attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Barriercommandcloseevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBarrierOpenPeriodAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBarrierOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Barrieropenperiod attribute not found in response" } + } + + requireNotNull(attributeData) { + "Barrieropenperiod attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeBarrierOpenPeriodAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierOpenPeriodAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -986,7 +1057,7 @@ class BarrierControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierOpenPeriodAttribute( @@ -994,110 +1065,118 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Barrieropenperiod attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Barrieropenperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBarrierClosePeriodAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBarrierClosePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Barriercloseperiod attribute not found in response" } + } + + requireNotNull(attributeData) { + "Barriercloseperiod attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeBarrierClosePeriodAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierClosePeriodAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1119,7 +1198,7 @@ class BarrierControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierClosePeriodAttribute( @@ -1127,86 +1206,91 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Barriercloseperiod attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Barriercloseperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBarrierPositionAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBarrierPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Barrierposition attribute not found in response" } + } + + requireNotNull(attributeData) { + "Barrierposition attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -1215,38 +1299,34 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Barrierposition attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Barrierposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1259,43 +1339,49 @@ class BarrierControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1305,50 +1391,45 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1356,43 +1437,49 @@ class BarrierControlCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1402,50 +1489,45 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1453,43 +1535,49 @@ class BarrierControlCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1499,48 +1587,45 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1548,43 +1633,49 @@ class BarrierControlCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1594,48 +1685,45 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1643,37 +1731,44 @@ class BarrierControlCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1682,37 +1777,35 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1724,37 +1817,44 @@ class BarrierControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1763,38 +1863,34 @@ class BarrierControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1807,7 +1903,7 @@ class BarrierControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt index 0a669f0fddd221..02d2f9bea9084e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt @@ -17,103 +17,132 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class CapabilityMinimaAttribute(val value: BasicInformationClusterCapabilityMinimaStruct) +class BasicInformationCluster(private val controller: MatterController, private val endpointId: UShort) {class CapabilityMinimaAttribute( + val value: BasicInformationClusterCapabilityMinimaStruct + ) sealed class CapabilityMinimaAttributeSubscriptionState { - data class Success(val value: BasicInformationClusterCapabilityMinimaStruct) : - CapabilityMinimaAttributeSubscriptionState() - + data class Success( + val value: BasicInformationClusterCapabilityMinimaStruct + ) : CapabilityMinimaAttributeSubscriptionState() + data class Error(val exception: Exception) : CapabilityMinimaAttributeSubscriptionState() - object SubscriptionEstablished : CapabilityMinimaAttributeSubscriptionState() - } - - class ProductAppearanceAttribute(val value: BasicInformationClusterProductAppearanceStruct?) + object SubscriptionEstablished : CapabilityMinimaAttributeSubscriptionState() + } +class ProductAppearanceAttribute( + val value: BasicInformationClusterProductAppearanceStruct? + ) sealed class ProductAppearanceAttributeSubscriptionState { - data class Success(val value: BasicInformationClusterProductAppearanceStruct?) : - ProductAppearanceAttributeSubscriptionState() - + data class Success( + val value: BasicInformationClusterProductAppearanceStruct? + ) : ProductAppearanceAttributeSubscriptionState() + data class Error(val exception: Exception) : ProductAppearanceAttributeSubscriptionState() - object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun mfgSpecificPing(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -126,35 +155,42 @@ class BasicInformationCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } +suspend fun readDataModelRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u - suspend fun readDataModelRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Datamodelrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Datamodelrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -163,38 +199,34 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Datamodelrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Datamodelrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -207,37 +239,44 @@ class BasicInformationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readVendorNameAttribute(): String {val ATTRIBUTE_ID: UInt = 1u - suspend fun readVendorNameAttribute(): String { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Vendorname attribute not found in response" } + } + + requireNotNull(attributeData) { + "Vendorname attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } @@ -246,37 +285,35 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Vendorname attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Vendorname attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -288,37 +325,44 @@ class BasicInformationCluster( emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readVendorIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - suspend fun readVendorIDAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Vendorid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Vendorid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -327,37 +371,35 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Vendorid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -369,37 +411,44 @@ class BasicInformationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readProductNameAttribute(): String {val ATTRIBUTE_ID: UInt = 3u - suspend fun readProductNameAttribute(): String { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Productname attribute not found in response" } + } + + requireNotNull(attributeData) { + "Productname attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } @@ -408,37 +457,35 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Productname attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Productname attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -450,37 +497,44 @@ class BasicInformationCluster( emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readProductIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 4u - suspend fun readProductIDAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Productid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Productid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -489,37 +543,35 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Productid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Productid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -531,56 +583,67 @@ class BasicInformationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNodeLabelAttribute(): String {val ATTRIBUTE_ID: UInt = 5u - suspend fun readNodeLabelAttribute(): String { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nodelabel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nodelabel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } - suspend fun writeNodeLabelAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeNodeLabelAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -602,7 +665,7 @@ class BasicInformationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNodeLabelAttribute( @@ -610,37 +673,35 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Nodelabel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nodelabel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -652,56 +713,67 @@ class BasicInformationCluster( emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLocationAttribute(): String {val ATTRIBUTE_ID: UInt = 6u - suspend fun readLocationAttribute(): String { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Location attribute not found in response" } + } + + requireNotNull(attributeData) { + "Location attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } - suspend fun writeLocationAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeLocationAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -723,7 +795,7 @@ class BasicInformationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocationAttribute( @@ -731,37 +803,35 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Location attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Location attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -773,37 +843,44 @@ class BasicInformationCluster( emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readHardwareVersionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 7u - suspend fun readHardwareVersionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Hardwareversion attribute not found in response" } + } + + requireNotNull(attributeData) { + "Hardwareversion attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -812,38 +889,34 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Hardwareversion attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Hardwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -856,37 +929,44 @@ class BasicInformationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readHardwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt = 8u - suspend fun readHardwareVersionStringAttribute(): String { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Hardwareversionstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Hardwareversionstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } @@ -895,38 +975,34 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Hardwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Hardwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -939,37 +1015,44 @@ class BasicInformationCluster( emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSoftwareVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = 9u - suspend fun readSoftwareVersionAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Softwareversion attribute not found in response" } + } + + requireNotNull(attributeData) { + "Softwareversion attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -978,38 +1061,34 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Softwareversion attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Softwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1022,37 +1101,44 @@ class BasicInformationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSoftwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt = 10u - suspend fun readSoftwareVersionStringAttribute(): String { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Softwareversionstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Softwareversionstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } @@ -1061,38 +1147,34 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Softwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Softwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1105,41 +1187,47 @@ class BasicInformationCluster( emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readManufacturingDateAttribute(): String? {val ATTRIBUTE_ID: UInt = 11u - suspend fun readManufacturingDateAttribute(): String? { - val ATTRIBUTE_ID: UInt = 11u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Manufacturingdate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Manufacturingdate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1149,90 +1237,94 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Manufacturingdate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Manufacturingdate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPartNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 12u - suspend fun readPartNumberAttribute(): String? { - val ATTRIBUTE_ID: UInt = 12u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Partnumber attribute not found in response" } + } + + requireNotNull(attributeData) { + "Partnumber attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1242,88 +1334,94 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Partnumber attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Partnumber attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readProductURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 13u - suspend fun readProductURLAttribute(): String? { - val ATTRIBUTE_ID: UInt = 13u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Producturl attribute not found in response" } + } + + requireNotNull(attributeData) { + "Producturl attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1333,88 +1431,94 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Producturl attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Producturl attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readProductLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 14u - suspend fun readProductLabelAttribute(): String? { - val ATTRIBUTE_ID: UInt = 14u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Productlabel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Productlabel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1424,88 +1528,94 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Productlabel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Productlabel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSerialNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 15u - suspend fun readSerialNumberAttribute(): String? { - val ATTRIBUTE_ID: UInt = 15u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Serialnumber attribute not found in response" } + } + + requireNotNull(attributeData) { + "Serialnumber attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1515,111 +1625,118 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Serialnumber attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Serialnumber attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLocalConfigDisabledAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 16u - suspend fun readLocalConfigDisabledAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Localconfigdisabled attribute not found in response" } + } + + requireNotNull(attributeData) { + "Localconfigdisabled attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeLocalConfigDisabledAttribute( value: Boolean, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1641,7 +1758,7 @@ class BasicInformationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocalConfigDisabledAttribute( @@ -1649,90 +1766,94 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Localconfigdisabled attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Localconfigdisabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readReachableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 17u - suspend fun readReachableAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Reachable attribute not found in response" } + } + + requireNotNull(attributeData) { + "Reachable attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1742,88 +1863,94 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Reachable attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Reachable attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readUniqueIDAttribute(): String? {val ATTRIBUTE_ID: UInt = 18u - suspend fun readUniqueIDAttribute(): String? { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uniqueid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uniqueid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1833,84 +1960,90 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uniqueid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uniqueid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute {val ATTRIBUTE_ID: UInt = 19u - suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute { - val ATTRIBUTE_ID: UInt = 19u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Capabilityminima attribute not found in response" } + } + + requireNotNull(attributeData) { + "Capabilityminima attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterCapabilityMinimaStruct = - BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: BasicInformationClusterCapabilityMinimaStruct = BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) + return CapabilityMinimaAttribute(decodedValue) } @@ -1920,44 +2053,39 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CapabilityMinimaAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CapabilityMinimaAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Capabilityminima attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Capabilityminima attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterCapabilityMinimaStruct = - BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: BasicInformationClusterCapabilityMinimaStruct = BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) emit(CapabilityMinimaAttributeSubscriptionState.Success(decodedValue)) } @@ -1965,41 +2093,47 @@ class BasicInformationCluster( emit(CapabilityMinimaAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute {val ATTRIBUTE_ID: UInt = 20u - suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute { - val ATTRIBUTE_ID: UInt = 20u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Productappearance attribute not found in response" } + } + + requireNotNull(attributeData) { + "Productappearance attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterProductAppearanceStruct? = - if (tlvReader.isNextTag(AnonymousTag)) { - BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } + val decodedValue: BasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { + BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + return ProductAppearanceAttribute(decodedValue) } @@ -2009,86 +2143,91 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ProductAppearanceAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ProductAppearanceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Productappearance attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Productappearance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterProductAppearanceStruct? = - if (tlvReader.isNextTag(AnonymousTag)) { - BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } + val decodedValue: BasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { + BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } - decodedValue?.let { emit(ProductAppearanceAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ProductAppearanceAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ProductAppearanceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSpecificationVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = 21u - suspend fun readSpecificationVersionAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 21u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Specificationversion attribute not found in response" } + } + + requireNotNull(attributeData) { + "Specificationversion attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -2097,38 +2236,34 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Specificationversion attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Specificationversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2141,37 +2276,44 @@ class BasicInformationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxPathsPerInvokeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 22u - suspend fun readMaxPathsPerInvokeAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 22u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxpathsperinvoke attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxpathsperinvoke attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2180,38 +2322,34 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxpathsperinvoke attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxpathsperinvoke attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2224,43 +2362,49 @@ class BasicInformationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -2270,50 +2414,45 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2321,43 +2460,49 @@ class BasicInformationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -2367,50 +2512,45 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2418,43 +2558,49 @@ class BasicInformationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -2464,48 +2610,45 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2513,43 +2656,49 @@ class BasicInformationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -2559,48 +2708,45 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2608,37 +2754,44 @@ class BasicInformationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -2647,37 +2800,35 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2689,37 +2840,44 @@ class BasicInformationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2728,38 +2886,34 @@ class BasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2772,7 +2926,7 @@ class BasicInformationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt index 89769881291daf..6573eb5ba275c1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt @@ -17,126 +17,163 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BinaryInputBasicCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class BinaryInputBasicCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readActiveTextAttribute(): String? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readActiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activetext attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activetext attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeActiveTextAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeActiveTextAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -158,7 +195,7 @@ class BinaryInputBasicCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeActiveTextAttribute( @@ -166,108 +203,118 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Activetext attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activetext attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDescriptionAttribute(): String? { - val ATTRIBUTE_ID: UInt = 28u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDescriptionAttribute(): String? {val ATTRIBUTE_ID: UInt = 28u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Description attribute not found in response" } + } + + requireNotNull(attributeData) { + "Description attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeDescriptionAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeDescriptionAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 28u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -289,7 +336,7 @@ class BinaryInputBasicCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDescriptionAttribute( @@ -297,108 +344,118 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Description attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Description attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readInactiveTextAttribute(): String? { - val ATTRIBUTE_ID: UInt = 46u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readInactiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 46u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Inactivetext attribute not found in response" } + } + + requireNotNull(attributeData) { + "Inactivetext attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeInactiveTextAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeInactiveTextAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 46u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -420,7 +477,7 @@ class BinaryInputBasicCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInactiveTextAttribute( @@ -428,103 +485,114 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 46u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Inactivetext attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Inactivetext attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOutOfServiceAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 81u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOutOfServiceAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 81u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Outofservice attribute not found in response" } + } + + requireNotNull(attributeData) { + "Outofservice attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } - suspend fun writeOutOfServiceAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { + suspend fun writeOutOfServiceAttribute( + value: Boolean, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 81u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -546,7 +614,7 @@ class BinaryInputBasicCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOutOfServiceAttribute( @@ -554,37 +622,35 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 81u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Outofservice attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Outofservice attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -596,41 +662,47 @@ class BinaryInputBasicCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPolarityAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 84u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPolarityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 84u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Polarity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Polarity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -640,103 +712,114 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 84u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Polarity attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Polarity attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPresentValueAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 85u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPresentValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 85u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Presentvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Presentvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } - suspend fun writePresentValueAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { + suspend fun writePresentValueAttribute( + value: Boolean, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 85u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -758,7 +841,7 @@ class BinaryInputBasicCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePresentValueAttribute( @@ -766,37 +849,35 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 85u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Presentvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Presentvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -808,61 +889,71 @@ class BinaryInputBasicCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readReliabilityAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 103u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readReliabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 103u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Reliability attribute not found in response" } + } + + requireNotNull(attributeData) { + "Reliability attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeReliabilityAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeReliabilityAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 103u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -884,7 +975,7 @@ class BinaryInputBasicCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeReliabilityAttribute( @@ -892,84 +983,91 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 103u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Reliability attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Reliability attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStatusFlagsAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 111u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStatusFlagsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 111u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Statusflags attribute not found in response" } + } + + requireNotNull(attributeData) { + "Statusflags attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -978,37 +1076,35 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 111u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Statusflags attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Statusflags attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1020,41 +1116,47 @@ class BinaryInputBasicCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readApplicationTypeAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 256u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readApplicationTypeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 256u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Applicationtype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Applicationtype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1064,92 +1166,96 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 256u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Applicationtype attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Applicationtype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1159,50 +1265,45 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1210,43 +1311,49 @@ class BinaryInputBasicCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1256,50 +1363,45 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1307,43 +1409,49 @@ class BinaryInputBasicCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1353,48 +1461,45 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1402,43 +1507,49 @@ class BinaryInputBasicCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1448,48 +1559,45 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1497,37 +1605,44 @@ class BinaryInputBasicCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1536,37 +1651,35 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1578,37 +1691,44 @@ class BinaryInputBasicCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1617,38 +1737,34 @@ class BinaryInputBasicCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1661,7 +1777,7 @@ class BinaryInputBasicCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt index a5cb5193c9c37d..a29864051af0d1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt @@ -17,140 +17,182 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BindingCluster(private val controller: MatterController, private val endpointId: UShort) { - class BindingAttribute(val value: List) +class BindingCluster(private val controller: MatterController, private val endpointId: UShort) {class BindingAttribute( + val value: List + ) sealed class BindingAttributeSubscriptionState { - data class Success(val value: List) : - BindingAttributeSubscriptionState() - + data class Success( + val value: List + ) : BindingAttributeSubscriptionState() + data class Error(val exception: Exception) : BindingAttributeSubscriptionState() - object SubscriptionEstablished : BindingAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : BindingAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readBindingAttribute(): BindingAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readBindingAttribute(): BindingAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Binding attribute not found in response" } + } + + requireNotNull(attributeData) { + "Binding attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return BindingAttribute(decodedValue) } suspend fun writeBindingAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -172,7 +214,7 @@ class BindingCluster(private val controller: MatterController, private val endpo throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBindingAttribute( @@ -180,48 +222,45 @@ class BindingCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BindingAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BindingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Binding attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Binding attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(BindingAttributeSubscriptionState.Success(decodedValue)) } @@ -229,43 +268,49 @@ class BindingCluster(private val controller: MatterController, private val endpo emit(BindingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -275,50 +320,45 @@ class BindingCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -326,43 +366,49 @@ class BindingCluster(private val controller: MatterController, private val endpo emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -372,50 +418,45 @@ class BindingCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -423,43 +464,49 @@ class BindingCluster(private val controller: MatterController, private val endpo emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -469,48 +516,45 @@ class BindingCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -518,43 +562,49 @@ class BindingCluster(private val controller: MatterController, private val endpo emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -564,48 +614,45 @@ class BindingCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -613,37 +660,44 @@ class BindingCluster(private val controller: MatterController, private val endpo emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -652,37 +706,35 @@ class BindingCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -694,37 +746,44 @@ class BindingCluster(private val controller: MatterController, private val endpo emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -733,38 +792,34 @@ class BindingCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -777,7 +832,7 @@ class BindingCluster(private val controller: MatterController, private val endpo emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt index 7530f3afc9c7cb..0c44c4bb081d4a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt @@ -17,96 +17,136 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class BooleanStateCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class BooleanStateCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readStateValueAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readStateValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Statevalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Statevalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -115,37 +155,35 @@ class BooleanStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Statevalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Statevalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -157,43 +195,49 @@ class BooleanStateCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -203,50 +247,45 @@ class BooleanStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -254,43 +293,49 @@ class BooleanStateCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -300,50 +345,45 @@ class BooleanStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -351,43 +391,49 @@ class BooleanStateCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -397,48 +443,45 @@ class BooleanStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -446,43 +489,49 @@ class BooleanStateCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -492,48 +541,45 @@ class BooleanStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -541,37 +587,44 @@ class BooleanStateCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -580,37 +633,35 @@ class BooleanStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -622,37 +673,44 @@ class BooleanStateCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -661,38 +719,34 @@ class BooleanStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -705,7 +759,7 @@ class BooleanStateCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt index 3cbd118dac1c2e..a92edf5556e383 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt @@ -17,84 +17,110 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class BooleanStateConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun suppressAlarm(alarmsToSuppress: UByte, timedInvokeTimeout: Duration? = null) { + suspend fun suppressAlarm(alarmsToSuppress: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ALARMS_TO_SUPPRESS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_SUPPRESS_REQ), alarmsToSuppress) + tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_SUPPRESS_REQ), alarmsToSuppress) tlvWriter.endStructure() val request: InvokeRequest = @@ -108,17 +134,15 @@ class BooleanStateConfigurationCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableDisableAlarm( - alarmsToEnableDisable: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun enableDisableAlarm(alarmsToEnableDisable: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ALARMS_TO_ENABLE_DISABLE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_ENABLE_DISABLE_REQ), alarmsToEnableDisable) + tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_ENABLE_DISABLE_REQ), alarmsToEnableDisable) tlvWriter.endStructure() val request: InvokeRequest = @@ -131,62 +155,69 @@ class BooleanStateConfigurationCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readCurrentSensitivityLevelAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentsensitivitylevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentsensitivitylevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeCurrentSensitivityLevelAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -208,7 +239,7 @@ class BooleanStateConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCurrentSensitivityLevelAttribute( @@ -216,90 +247,94 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentsensitivitylevel attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentsensitivitylevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportedSensitivityLevelsAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedSensitivityLevelsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedsensitivitylevels attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedsensitivitylevels attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -309,90 +344,94 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedsensitivitylevels attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedsensitivitylevels attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDefaultSensitivityLevelAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDefaultSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Defaultsensitivitylevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Defaultsensitivitylevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -402,90 +441,94 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Defaultsensitivitylevel attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Defaultsensitivitylevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAlarmsActiveAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAlarmsActiveAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Alarmsactive attribute not found in response" } + } + + requireNotNull(attributeData) { + "Alarmsactive attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -495,88 +538,94 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Alarmsactive attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Alarmsactive attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAlarmsSuppressedAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAlarmsSuppressedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Alarmssuppressed attribute not found in response" } + } + + requireNotNull(attributeData) { + "Alarmssuppressed attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -586,90 +635,94 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Alarmssuppressed attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Alarmssuppressed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAlarmsEnabledAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAlarmsEnabledAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Alarmsenabled attribute not found in response" } + } + + requireNotNull(attributeData) { + "Alarmsenabled attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -679,88 +732,94 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Alarmsenabled attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Alarmsenabled attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAlarmsSupportedAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAlarmsSupportedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Alarmssupported attribute not found in response" } + } + + requireNotNull(attributeData) { + "Alarmssupported attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -770,90 +829,94 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Alarmssupported attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Alarmssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSensorFaultAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSensorFaultAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Sensorfault attribute not found in response" } + } + + requireNotNull(attributeData) { + "Sensorfault attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -863,90 +926,96 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Sensorfault attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Sensorfault attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -956,50 +1025,45 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1007,43 +1071,49 @@ class BooleanStateConfigurationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1053,50 +1123,45 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1104,43 +1169,49 @@ class BooleanStateConfigurationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1150,48 +1221,45 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1199,43 +1267,49 @@ class BooleanStateConfigurationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1245,48 +1319,45 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1294,37 +1365,44 @@ class BooleanStateConfigurationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1333,37 +1411,35 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1375,37 +1451,44 @@ class BooleanStateConfigurationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1414,38 +1497,34 @@ class BooleanStateConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1458,7 +1537,7 @@ class BooleanStateConfigurationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt index e867b53a3b8e24..463def619140dc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt @@ -17,118 +17,152 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ProductAppearanceAttribute( +class BridgedDeviceBasicInformationCluster(private val controller: MatterController, private val endpointId: UShort) {class ProductAppearanceAttribute( val value: BridgedDeviceBasicInformationClusterProductAppearanceStruct? ) sealed class ProductAppearanceAttributeSubscriptionState { - data class Success(val value: BridgedDeviceBasicInformationClusterProductAppearanceStruct?) : - ProductAppearanceAttributeSubscriptionState() - + data class Success( + val value: BridgedDeviceBasicInformationClusterProductAppearanceStruct? + ) : ProductAppearanceAttributeSubscriptionState() + data class Error(val exception: Exception) : ProductAppearanceAttributeSubscriptionState() - object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readVendorNameAttribute(): String? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readVendorNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Vendorname attribute not found in response" } + } + + requireNotNull(attributeData) { + "Vendorname attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -138,88 +172,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Vendorname attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Vendorname attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readVendorIDAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readVendorIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Vendorid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Vendorid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -229,88 +269,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Vendorid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readProductNameAttribute(): String? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readProductNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Productname attribute not found in response" } + } + + requireNotNull(attributeData) { + "Productname attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -320,108 +366,118 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Productname attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Productname attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readNodeLabelAttribute(): String? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readNodeLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nodelabel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nodelabel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeNodeLabelAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeNodeLabelAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -443,7 +499,7 @@ class BridgedDeviceBasicInformationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNodeLabelAttribute( @@ -451,88 +507,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Nodelabel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nodelabel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readHardwareVersionAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readHardwareVersionAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Hardwareversion attribute not found in response" } + } + + requireNotNull(attributeData) { + "Hardwareversion attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -542,90 +604,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Hardwareversion attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Hardwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readHardwareVersionStringAttribute(): String? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readHardwareVersionStringAttribute(): String? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Hardwareversionstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Hardwareversionstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -635,90 +701,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Hardwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Hardwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSoftwareVersionAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSoftwareVersionAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Softwareversion attribute not found in response" } + } + + requireNotNull(attributeData) { + "Softwareversion attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -728,90 +798,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Softwareversion attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Softwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSoftwareVersionStringAttribute(): String? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSoftwareVersionStringAttribute(): String? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Softwareversionstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Softwareversionstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -821,90 +895,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Softwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Softwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readManufacturingDateAttribute(): String? { - val ATTRIBUTE_ID: UInt = 11u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readManufacturingDateAttribute(): String? {val ATTRIBUTE_ID: UInt = 11u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Manufacturingdate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Manufacturingdate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -914,90 +992,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Manufacturingdate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Manufacturingdate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPartNumberAttribute(): String? { - val ATTRIBUTE_ID: UInt = 12u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPartNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 12u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Partnumber attribute not found in response" } + } + + requireNotNull(attributeData) { + "Partnumber attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1007,88 +1089,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Partnumber attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Partnumber attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readProductURLAttribute(): String? { - val ATTRIBUTE_ID: UInt = 13u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readProductURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 13u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Producturl attribute not found in response" } + } + + requireNotNull(attributeData) { + "Producturl attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1098,88 +1186,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Producturl attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Producturl attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readProductLabelAttribute(): String? { - val ATTRIBUTE_ID: UInt = 14u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readProductLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 14u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Productlabel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Productlabel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1189,88 +1283,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Productlabel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Productlabel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSerialNumberAttribute(): String? { - val ATTRIBUTE_ID: UInt = 15u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSerialNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 15u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Serialnumber attribute not found in response" } + } + + requireNotNull(attributeData) { + "Serialnumber attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1280,84 +1380,91 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Serialnumber attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Serialnumber attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readReachableAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readReachableAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 17u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Reachable attribute not found in response" } + } + + requireNotNull(attributeData) { + "Reachable attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -1366,37 +1473,35 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Reachable attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Reachable attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1408,41 +1513,47 @@ class BridgedDeviceBasicInformationCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUniqueIDAttribute(): String? { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUniqueIDAttribute(): String? {val ATTRIBUTE_ID: UInt = 18u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uniqueid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uniqueid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1452,88 +1563,94 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uniqueid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uniqueid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute { - val ATTRIBUTE_ID: UInt = 20u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute {val ATTRIBUTE_ID: UInt = 20u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Productappearance attribute not found in response" } + } + + requireNotNull(attributeData) { + "Productappearance attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = - if (tlvReader.isNextTag(AnonymousTag)) { - BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } + val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { + BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + return ProductAppearanceAttribute(decodedValue) } @@ -1543,95 +1660,96 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ProductAppearanceAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ProductAppearanceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Productappearance attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Productappearance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = - if (tlvReader.isNextTag(AnonymousTag)) { - BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv( - AnonymousTag, - tlvReader - ) - } else { - null - } - - decodedValue?.let { emit(ProductAppearanceAttributeSubscriptionState.Success(it)) } + val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { + BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + + decodedValue?.let { + emit(ProductAppearanceAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ProductAppearanceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1641,50 +1759,45 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1692,43 +1805,49 @@ class BridgedDeviceBasicInformationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1738,50 +1857,45 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1789,43 +1903,49 @@ class BridgedDeviceBasicInformationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1835,48 +1955,45 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1884,43 +2001,49 @@ class BridgedDeviceBasicInformationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1930,48 +2053,45 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1979,37 +2099,44 @@ class BridgedDeviceBasicInformationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -2018,37 +2145,35 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2060,37 +2185,44 @@ class BridgedDeviceBasicInformationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2099,38 +2231,34 @@ class BridgedDeviceBasicInformationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2143,7 +2271,7 @@ class BridgedDeviceBasicInformationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt index d2f974c4550a9b..32fbbb01553d32 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt @@ -17,156 +17,209 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class CarbonDioxideConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) +class CarbonDioxideConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Float? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Float? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Float? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class PeakMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class PeakMeasuredValueAttribute( + val value: Float? + ) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } - - class AverageMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } +class AverageMeasuredValueAttribute( + val value: Float? + ) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -176,98 +229,104 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -277,100 +336,104 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -380,100 +443,104 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeakMeasuredValueAttribute(decodedValue) } @@ -483,95 +550,99 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeakMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -581,95 +652,99 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AverageMeasuredValueAttribute(decodedValue) } @@ -679,95 +754,99 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AverageMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -777,90 +856,94 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUncertaintyAttribute(): Float? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + return decodedValue } @@ -870,88 +953,94 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(FloatSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementUnitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -961,90 +1050,94 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementMediumAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1054,90 +1147,94 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLevelValueAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1147,90 +1244,96 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1240,50 +1343,45 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1291,43 +1389,49 @@ class CarbonDioxideConcentrationMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1337,50 +1441,45 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1388,43 +1487,49 @@ class CarbonDioxideConcentrationMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1434,48 +1539,45 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1483,43 +1585,49 @@ class CarbonDioxideConcentrationMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1529,48 +1637,45 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1578,37 +1683,44 @@ class CarbonDioxideConcentrationMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1617,37 +1729,35 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1659,37 +1769,44 @@ class CarbonDioxideConcentrationMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1698,38 +1815,34 @@ class CarbonDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1742,12 +1855,11 @@ class CarbonDioxideConcentrationMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = - Logger.getLogger(CarbonDioxideConcentrationMeasurementCluster::class.java.name) + private val logger = Logger.getLogger(CarbonDioxideConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1037u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt index 93341731a25b70..c97c2f69df0087 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt @@ -17,156 +17,209 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class CarbonMonoxideConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) +class CarbonMonoxideConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Float? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Float? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Float? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class PeakMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class PeakMeasuredValueAttribute( + val value: Float? + ) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } - - class AverageMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } +class AverageMeasuredValueAttribute( + val value: Float? + ) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -176,98 +229,104 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -277,100 +336,104 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -380,100 +443,104 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeakMeasuredValueAttribute(decodedValue) } @@ -483,95 +550,99 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeakMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -581,95 +652,99 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AverageMeasuredValueAttribute(decodedValue) } @@ -679,95 +754,99 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AverageMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -777,90 +856,94 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUncertaintyAttribute(): Float? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + return decodedValue } @@ -870,88 +953,94 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(FloatSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementUnitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -961,90 +1050,94 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementMediumAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1054,90 +1147,94 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLevelValueAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1147,90 +1244,96 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1240,50 +1343,45 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1291,43 +1389,49 @@ class CarbonMonoxideConcentrationMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1337,50 +1441,45 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1388,43 +1487,49 @@ class CarbonMonoxideConcentrationMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1434,48 +1539,45 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1483,43 +1585,49 @@ class CarbonMonoxideConcentrationMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1529,48 +1637,45 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1578,37 +1683,44 @@ class CarbonMonoxideConcentrationMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1617,37 +1729,35 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1659,37 +1769,44 @@ class CarbonMonoxideConcentrationMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1698,38 +1815,34 @@ class CarbonMonoxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1742,12 +1855,11 @@ class CarbonMonoxideConcentrationMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = - Logger.getLogger(CarbonMonoxideConcentrationMeasurementCluster::class.java.name) + private val logger = Logger.getLogger(CarbonMonoxideConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1036u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt index 653f118fc66440..ce6d28c380c36b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt @@ -17,120 +17,159 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class ChannelCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeChannelResponse(val status: UByte, val data: String?) + class ChangeChannelResponse( + val status: UByte, + val data: String? + ) class ProgramGuideResponse( - val paging: ChannelClusterChannelPagingStruct, + val paging: ChannelClusterChannelPagingStruct, val programList: List ) - - class ChannelListAttribute(val value: List?) +class ChannelListAttribute( + val value: List? + ) sealed class ChannelListAttributeSubscriptionState { - data class Success(val value: List?) : - ChannelListAttributeSubscriptionState() - + data class Success( + val value: List? + ) : ChannelListAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelListAttributeSubscriptionState() - object SubscriptionEstablished : ChannelListAttributeSubscriptionState() - } - - class LineupAttribute(val value: ChannelClusterLineupInfoStruct?) + object SubscriptionEstablished : ChannelListAttributeSubscriptionState() + } +class LineupAttribute( + val value: ChannelClusterLineupInfoStruct? + ) sealed class LineupAttributeSubscriptionState { - data class Success(val value: ChannelClusterLineupInfoStruct?) : - LineupAttributeSubscriptionState() - + data class Success( + val value: ChannelClusterLineupInfoStruct? + ) : LineupAttributeSubscriptionState() + data class Error(val exception: Exception) : LineupAttributeSubscriptionState() - object SubscriptionEstablished : LineupAttributeSubscriptionState() - } - - class CurrentChannelAttribute(val value: ChannelClusterChannelInfoStruct?) + object SubscriptionEstablished : LineupAttributeSubscriptionState() + } +class CurrentChannelAttribute( + val value: ChannelClusterChannelInfoStruct? + ) sealed class CurrentChannelAttributeSubscriptionState { - data class Success(val value: ChannelClusterChannelInfoStruct?) : - CurrentChannelAttributeSubscriptionState() - + data class Success( + val value: ChannelClusterChannelInfoStruct? + ) : CurrentChannelAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentChannelAttributeSubscriptionState() - object SubscriptionEstablished : CurrentChannelAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : CurrentChannelAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeChannel( - match: String, - timedInvokeTimeout: Duration? = null - ): ChangeChannelResponse { + suspend fun changeChannel(match: String + ,timedInvokeTimeout: Duration? = null): ChangeChannelResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_MATCH_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_MATCH_REQ), match) + tlvWriter.put(ContextSpecificTag(TAG_MATCH_REQ), match) tlvWriter.endStructure() val request: InvokeRequest = @@ -147,48 +186,55 @@ class ChannelCluster(private val controller: MatterController, private val endpo tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return ChangeChannelResponse(status_decoded, data_decoded) + return ChangeChannelResponse( + status_decoded, + data_decoded + ) } - suspend fun changeChannelByNumber( - majorNumber: UShort, - minorNumber: UShort, - timedInvokeTimeout: Duration? = null - ) { + suspend fun changeChannelByNumber(majorNumber: UShort + ,minorNumber: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -198,7 +244,7 @@ class ChannelCluster(private val controller: MatterController, private val endpo tlvWriter.put(ContextSpecificTag(TAG_MAJOR_NUMBER_REQ), majorNumber) val TAG_MINOR_NUMBER_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_MINOR_NUMBER_REQ), minorNumber) + tlvWriter.put(ContextSpecificTag(TAG_MINOR_NUMBER_REQ), minorNumber) tlvWriter.endStructure() val request: InvokeRequest = @@ -212,14 +258,15 @@ class ChannelCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun skipChannel(count: Short, timedInvokeTimeout: Duration? = null) { + suspend fun skipChannel(count: Short + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_COUNT_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_COUNT_REQ), count) + tlvWriter.put(ContextSpecificTag(TAG_COUNT_REQ), count) tlvWriter.endStructure() val request: InvokeRequest = @@ -233,26 +280,28 @@ class ChannelCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getProgramGuide( - startTime: UInt?, - endTime: UInt?, - channelList: List?, - pageToken: ChannelClusterPageTokenStruct?, - recordingFlag: UInt?, - externalIDList: List?, - data: ByteArray?, - timedInvokeTimeout: Duration? = null - ): ProgramGuideResponse { + suspend fun getProgramGuide(startTime: UInt? + ,endTime: UInt? + ,channelList: List? + ,pageToken: ChannelClusterPageTokenStruct? + ,recordingFlag: UInt? + ,externalIDList: List? + ,data: ByteArray? + ,timedInvokeTimeout: Duration? = null): ProgramGuideResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_START_TIME_REQ: Int = 0 - startTime?.let { tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) } + startTime?.let { + tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) + } val TAG_END_TIME_REQ: Int = 1 - endTime?.let { tlvWriter.put(ContextSpecificTag(TAG_END_TIME_REQ), endTime) } + endTime?.let { + tlvWriter.put(ContextSpecificTag(TAG_END_TIME_REQ), endTime) + } val TAG_CHANNEL_LIST_REQ: Int = 2 channelList?.let { @@ -264,10 +313,14 @@ class ChannelCluster(private val controller: MatterController, private val endpo } val TAG_PAGE_TOKEN_REQ: Int = 3 - pageToken?.let { pageToken.toTlv(ContextSpecificTag(TAG_PAGE_TOKEN_REQ), tlvWriter) } + pageToken?.let { + pageToken.toTlv(ContextSpecificTag(TAG_PAGE_TOKEN_REQ), tlvWriter) + } val TAG_RECORDING_FLAG_REQ: Int = 4 - recordingFlag?.let { tlvWriter.put(ContextSpecificTag(TAG_RECORDING_FLAG_REQ), recordingFlag) } + recordingFlag?.let { + tlvWriter.put(ContextSpecificTag(TAG_RECORDING_FLAG_REQ), recordingFlag) + } val TAG_EXTERNAL_I_D_LIST_REQ: Int = 5 externalIDList?.let { @@ -279,7 +332,9 @@ class ChannelCluster(private val controller: MatterController, private val endpo } val TAG_DATA_REQ: Int = 6 - data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } + data?.let { + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -296,51 +351,56 @@ class ChannelCluster(private val controller: MatterController, private val endpo tlvReader.enterStructure(AnonymousTag) val TAG_PAGING: Int = 0 var paging_decoded: ChannelClusterChannelPagingStruct? = null - + val TAG_PROGRAM_LIST: Int = 1 var programList_decoded: List? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_PAGING)) { - paging_decoded = ChannelClusterChannelPagingStruct.fromTlv(tag, tlvReader) + + if (tag == ContextSpecificTag(TAG_PAGING)) {paging_decoded = ChannelClusterChannelPagingStruct.fromTlv(tag, tlvReader)} + + if (tag == ContextSpecificTag(TAG_PROGRAM_LIST)) {programList_decoded = buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + }} + - if (tag == ContextSpecificTag(TAG_PROGRAM_LIST)) { - programList_decoded = - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { + else { tlvReader.skipElement() } } + + if (paging_decoded == null) { - throw IllegalStateException("paging not found in TLV") + throw IllegalStateException("paging not found in TLV") } - + + if (programList_decoded == null) { - throw IllegalStateException("programList not found in TLV") + throw IllegalStateException("programList not found in TLV") } + tlvReader.exitContainer() - return ProgramGuideResponse(paging_decoded, programList_decoded) + return ProgramGuideResponse( + paging_decoded, + programList_decoded + ) } - suspend fun recordProgram( - programIdentifier: String, - shouldRecordSeries: Boolean, - externalIDList: List, - data: ByteArray, - timedInvokeTimeout: Duration? = null - ) { + suspend fun recordProgram(programIdentifier: String + ,shouldRecordSeries: Boolean + ,externalIDList: List + ,data: ByteArray + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -354,13 +414,13 @@ class ChannelCluster(private val controller: MatterController, private val endpo val TAG_EXTERNAL_I_D_LIST_REQ: Int = 2 tlvWriter.startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST_REQ)) - for (item in externalIDList.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in externalIDList.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_DATA_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) tlvWriter.endStructure() val request: InvokeRequest = @@ -374,13 +434,11 @@ class ChannelCluster(private val controller: MatterController, private val endpo logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun cancelRecordProgram( - programIdentifier: String, - shouldRecordSeries: Boolean, - externalIDList: List, - data: ByteArray, - timedInvokeTimeout: Duration? = null - ) { + suspend fun cancelRecordProgram(programIdentifier: String + ,shouldRecordSeries: Boolean + ,externalIDList: List + ,data: ByteArray + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -394,13 +452,13 @@ class ChannelCluster(private val controller: MatterController, private val endpo val TAG_EXTERNAL_I_D_LIST_REQ: Int = 2 tlvWriter.startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST_REQ)) - for (item in externalIDList.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in externalIDList.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_DATA_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) tlvWriter.endStructure() val request: InvokeRequest = @@ -413,45 +471,51 @@ class ChannelCluster(private val controller: MatterController, private val endpo val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readChannelListAttribute(): ChannelListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readChannelListAttribute(): ChannelListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Channellist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Channellist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return ChannelListAttribute(decodedValue) } @@ -461,99 +525,105 @@ class ChannelCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ChannelListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ChannelListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Channellist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Channellist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ChannelListAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ChannelListAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ChannelListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLineupAttribute(): LineupAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLineupAttribute(): LineupAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lineup attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lineup attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterLineupInfoStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ChannelClusterLineupInfoStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LineupAttribute(decodedValue) } @@ -563,98 +633,104 @@ class ChannelCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LineupAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LineupAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Lineup attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lineup attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterLineupInfoStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(LineupAttributeSubscriptionState.Success(it)) } + val decodedValue: ChannelClusterLineupInfoStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(LineupAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LineupAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentChannelAttribute(): CurrentChannelAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentChannelAttribute(): CurrentChannelAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentchannel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentchannel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterChannelInfoStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ChannelClusterChannelInfoStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentChannelAttribute(decodedValue) } @@ -664,97 +740,101 @@ class ChannelCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentChannelAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentChannelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentchannel attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentchannel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterChannelInfoStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CurrentChannelAttributeSubscriptionState.Success(it)) } + val decodedValue: ChannelClusterChannelInfoStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CurrentChannelAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentChannelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -764,50 +844,45 @@ class ChannelCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -815,43 +890,49 @@ class ChannelCluster(private val controller: MatterController, private val endpo emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -861,50 +942,45 @@ class ChannelCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -912,43 +988,49 @@ class ChannelCluster(private val controller: MatterController, private val endpo emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -958,48 +1040,45 @@ class ChannelCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1007,43 +1086,49 @@ class ChannelCluster(private val controller: MatterController, private val endpo emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1053,48 +1138,45 @@ class ChannelCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,37 +1184,44 @@ class ChannelCluster(private val controller: MatterController, private val endpo emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1141,37 +1230,35 @@ class ChannelCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1183,37 +1270,44 @@ class ChannelCluster(private val controller: MatterController, private val endpo emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1222,38 +1316,34 @@ class ChannelCluster(private val controller: MatterController, private val endpo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1266,7 +1356,7 @@ class ChannelCluster(private val controller: MatterController, private val endpo emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt index 29633f95e9ab20..22dd04f551f5f8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt @@ -17,197 +17,250 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ColorControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class NumberOfPrimariesAttribute(val value: UByte?) +class ColorControlCluster(private val controller: MatterController, private val endpointId: UShort) {class NumberOfPrimariesAttribute( + val value: UByte? + ) sealed class NumberOfPrimariesAttributeSubscriptionState { - data class Success(val value: UByte?) : NumberOfPrimariesAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : NumberOfPrimariesAttributeSubscriptionState() + data class Error(val exception: Exception) : NumberOfPrimariesAttributeSubscriptionState() - object SubscriptionEstablished : NumberOfPrimariesAttributeSubscriptionState() - } - - class Primary1IntensityAttribute(val value: UByte?) + object SubscriptionEstablished : NumberOfPrimariesAttributeSubscriptionState() + } +class Primary1IntensityAttribute( + val value: UByte? + ) sealed class Primary1IntensityAttributeSubscriptionState { - data class Success(val value: UByte?) : Primary1IntensityAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : Primary1IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary1IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary1IntensityAttributeSubscriptionState() - } - - class Primary2IntensityAttribute(val value: UByte?) + object SubscriptionEstablished : Primary1IntensityAttributeSubscriptionState() + } +class Primary2IntensityAttribute( + val value: UByte? + ) sealed class Primary2IntensityAttributeSubscriptionState { - data class Success(val value: UByte?) : Primary2IntensityAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : Primary2IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary2IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary2IntensityAttributeSubscriptionState() - } - - class Primary3IntensityAttribute(val value: UByte?) + object SubscriptionEstablished : Primary2IntensityAttributeSubscriptionState() + } +class Primary3IntensityAttribute( + val value: UByte? + ) sealed class Primary3IntensityAttributeSubscriptionState { - data class Success(val value: UByte?) : Primary3IntensityAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : Primary3IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary3IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary3IntensityAttributeSubscriptionState() - } - - class Primary4IntensityAttribute(val value: UByte?) + object SubscriptionEstablished : Primary3IntensityAttributeSubscriptionState() + } +class Primary4IntensityAttribute( + val value: UByte? + ) sealed class Primary4IntensityAttributeSubscriptionState { - data class Success(val value: UByte?) : Primary4IntensityAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : Primary4IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary4IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary4IntensityAttributeSubscriptionState() - } - - class Primary5IntensityAttribute(val value: UByte?) + object SubscriptionEstablished : Primary4IntensityAttributeSubscriptionState() + } +class Primary5IntensityAttribute( + val value: UByte? + ) sealed class Primary5IntensityAttributeSubscriptionState { - data class Success(val value: UByte?) : Primary5IntensityAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : Primary5IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary5IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary5IntensityAttributeSubscriptionState() - } - - class Primary6IntensityAttribute(val value: UByte?) + object SubscriptionEstablished : Primary5IntensityAttributeSubscriptionState() + } +class Primary6IntensityAttribute( + val value: UByte? + ) sealed class Primary6IntensityAttributeSubscriptionState { - data class Success(val value: UByte?) : Primary6IntensityAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : Primary6IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary6IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary6IntensityAttributeSubscriptionState() - } - - class ColorPointRIntensityAttribute(val value: UByte?) + object SubscriptionEstablished : Primary6IntensityAttributeSubscriptionState() + } +class ColorPointRIntensityAttribute( + val value: UByte? + ) sealed class ColorPointRIntensityAttributeSubscriptionState { - data class Success(val value: UByte?) : ColorPointRIntensityAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : ColorPointRIntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : ColorPointRIntensityAttributeSubscriptionState() - object SubscriptionEstablished : ColorPointRIntensityAttributeSubscriptionState() - } - - class ColorPointGIntensityAttribute(val value: UByte?) + object SubscriptionEstablished : ColorPointRIntensityAttributeSubscriptionState() + } +class ColorPointGIntensityAttribute( + val value: UByte? + ) sealed class ColorPointGIntensityAttributeSubscriptionState { - data class Success(val value: UByte?) : ColorPointGIntensityAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : ColorPointGIntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : ColorPointGIntensityAttributeSubscriptionState() - object SubscriptionEstablished : ColorPointGIntensityAttributeSubscriptionState() - } - - class ColorPointBIntensityAttribute(val value: UByte?) + object SubscriptionEstablished : ColorPointGIntensityAttributeSubscriptionState() + } +class ColorPointBIntensityAttribute( + val value: UByte? + ) sealed class ColorPointBIntensityAttributeSubscriptionState { - data class Success(val value: UByte?) : ColorPointBIntensityAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : ColorPointBIntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : ColorPointBIntensityAttributeSubscriptionState() - object SubscriptionEstablished : ColorPointBIntensityAttributeSubscriptionState() - } - - class StartUpColorTemperatureMiredsAttribute(val value: UShort?) + object SubscriptionEstablished : ColorPointBIntensityAttributeSubscriptionState() + } +class StartUpColorTemperatureMiredsAttribute( + val value: UShort? + ) sealed class StartUpColorTemperatureMiredsAttributeSubscriptionState { - data class Success(val value: UShort?) : - StartUpColorTemperatureMiredsAttributeSubscriptionState() - - data class Error(val exception: Exception) : - StartUpColorTemperatureMiredsAttributeSubscriptionState() - - object SubscriptionEstablished : StartUpColorTemperatureMiredsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + data class Success( + val value: UShort? + ) : StartUpColorTemperatureMiredsAttributeSubscriptionState() + + data class Error(val exception: Exception) : StartUpColorTemperatureMiredsAttributeSubscriptionState() + + object SubscriptionEstablished : StartUpColorTemperatureMiredsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun moveToHue( - hue: UByte, - direction: UByte, - transitionTime: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveToHue(hue: UByte + ,direction: UByte + ,transitionTime: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -226,7 +279,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -240,13 +293,11 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveHue( - moveMode: UByte, - rate: UByte, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveHue(moveMode: UByte + ,rate: UByte + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -262,7 +313,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -276,14 +327,12 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepHue( - stepMode: UByte, - stepSize: UByte, - transitionTime: UByte, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun stepHue(stepMode: UByte + ,stepSize: UByte + ,transitionTime: UByte + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -302,7 +351,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -316,13 +365,11 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToSaturation( - saturation: UByte, - transitionTime: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveToSaturation(saturation: UByte + ,transitionTime: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -338,7 +385,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -352,13 +399,11 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveSaturation( - moveMode: UByte, - rate: UByte, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveSaturation(moveMode: UByte + ,rate: UByte + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -374,7 +419,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -388,14 +433,12 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepSaturation( - stepMode: UByte, - stepSize: UByte, - transitionTime: UByte, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun stepSaturation(stepMode: UByte + ,stepSize: UByte + ,transitionTime: UByte + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -414,7 +457,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -428,14 +471,12 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToHueAndSaturation( - hue: UByte, - saturation: UByte, - transitionTime: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveToHueAndSaturation(hue: UByte + ,saturation: UByte + ,transitionTime: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -454,7 +495,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -468,14 +509,12 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToColor( - colorX: UShort, - colorY: UShort, - transitionTime: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveToColor(colorX: UShort + ,colorY: UShort + ,transitionTime: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -494,7 +533,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -508,13 +547,11 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveColor( - rateX: Short, - rateY: Short, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveColor(rateX: Short + ,rateY: Short + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 8u val tlvWriter = TlvWriter() @@ -530,7 +567,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -544,14 +581,12 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepColor( - stepX: Short, - stepY: Short, - transitionTime: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun stepColor(stepX: Short + ,stepY: Short + ,transitionTime: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -570,7 +605,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -584,13 +619,11 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToColorTemperature( - colorTemperatureMireds: UShort, - transitionTime: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveToColorTemperature(colorTemperatureMireds: UShort + ,transitionTime: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 10u val tlvWriter = TlvWriter() @@ -606,7 +639,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -620,14 +653,12 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedMoveToHue( - enhancedHue: UShort, - direction: UByte, - transitionTime: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun enhancedMoveToHue(enhancedHue: UShort + ,direction: UByte + ,transitionTime: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -646,7 +677,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -660,13 +691,11 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedMoveHue( - moveMode: UByte, - rate: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun enhancedMoveHue(moveMode: UByte + ,rate: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 65u val tlvWriter = TlvWriter() @@ -682,7 +711,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -696,14 +725,12 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedStepHue( - stepMode: UByte, - stepSize: UShort, - transitionTime: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun enhancedStepHue(stepMode: UByte + ,stepSize: UShort + ,transitionTime: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 66u val tlvWriter = TlvWriter() @@ -722,7 +749,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -736,14 +763,12 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedMoveToHueAndSaturation( - enhancedHue: UShort, - saturation: UByte, - transitionTime: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun enhancedMoveToHueAndSaturation(enhancedHue: UShort + ,saturation: UByte + ,transitionTime: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 67u val tlvWriter = TlvWriter() @@ -762,7 +787,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -776,16 +801,14 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun colorLoopSet( - updateFlags: UByte, - action: UByte, - direction: UByte, - time: UShort, - startHue: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun colorLoopSet(updateFlags: UByte + ,action: UByte + ,direction: UByte + ,time: UShort + ,startHue: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 68u val tlvWriter = TlvWriter() @@ -810,7 +833,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 6 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -824,11 +847,9 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stopMoveStep( - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun stopMoveStep(optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 71u val tlvWriter = TlvWriter() @@ -838,7 +859,7 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -852,15 +873,13 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveColorTemperature( - moveMode: UByte, - rate: UShort, - colorTemperatureMinimumMireds: UShort, - colorTemperatureMaximumMireds: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveColorTemperature(moveMode: UByte + ,rate: UShort + ,colorTemperatureMinimumMireds: UShort + ,colorTemperatureMaximumMireds: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 75u val tlvWriter = TlvWriter() @@ -873,22 +892,16 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) val TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ: Int = 2 - tlvWriter.put( - ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), - colorTemperatureMinimumMireds - ) + tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), colorTemperatureMinimumMireds) val TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ: Int = 3 - tlvWriter.put( - ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), - colorTemperatureMaximumMireds - ) + tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), colorTemperatureMaximumMireds) val TAG_OPTIONS_MASK_REQ: Int = 4 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 5 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -902,16 +915,14 @@ class ColorControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepColorTemperature( - stepMode: UByte, - stepSize: UShort, - transitionTime: UShort, - colorTemperatureMinimumMireds: UShort, - colorTemperatureMaximumMireds: UShort, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun stepColorTemperature(stepMode: UByte + ,stepSize: UShort + ,transitionTime: UShort + ,colorTemperatureMinimumMireds: UShort + ,colorTemperatureMaximumMireds: UShort + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 76u val tlvWriter = TlvWriter() @@ -927,22 +938,16 @@ class ColorControlCluster( tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) val TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ: Int = 3 - tlvWriter.put( - ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), - colorTemperatureMinimumMireds - ) + tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), colorTemperatureMinimumMireds) val TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ: Int = 4 - tlvWriter.put( - ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), - colorTemperatureMaximumMireds - ) + tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), colorTemperatureMaximumMireds) val TAG_OPTIONS_MASK_REQ: Int = 5 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 6 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -955,39 +960,45 @@ class ColorControlCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } +suspend fun readCurrentHueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - suspend fun readCurrentHueAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currenthue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currenthue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -997,88 +1008,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currenthue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currenthue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentSaturationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - suspend fun readCurrentSaturationAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentsaturation attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentsaturation attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1088,90 +1105,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentsaturation attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentsaturation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRemainingTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u - suspend fun readRemainingTimeAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Remainingtime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Remainingtime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1181,88 +1202,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Remainingtime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Remainingtime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - suspend fun readCurrentXAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentx attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentx attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1272,88 +1299,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentx attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentx attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4u - suspend fun readCurrentYAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currenty attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currenty attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1363,88 +1396,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currenty attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currenty attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDriftCompensationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u - suspend fun readDriftCompensationAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Driftcompensation attribute not found in response" } + } + + requireNotNull(attributeData) { + "Driftcompensation attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1454,90 +1493,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Driftcompensation attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Driftcompensation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCompensationTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 6u - suspend fun readCompensationTextAttribute(): String? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Compensationtext attribute not found in response" } + } + + requireNotNull(attributeData) { + "Compensationtext attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1547,90 +1590,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Compensationtext attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Compensationtext attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorTemperatureMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u - suspend fun readColorTemperatureMiredsAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colortemperaturemireds attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colortemperaturemireds attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1640,86 +1687,91 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Colortemperaturemireds attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colortemperaturemireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 8u - suspend fun readColorModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colormode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colormode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -1728,37 +1780,35 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Colormode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colormode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1770,56 +1820,67 @@ class ColorControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u - suspend fun readOptionsAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 15u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Options attribute not found in response" } + } + + requireNotNull(attributeData) { + "Options attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeOptionsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOptionsAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 15u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1841,7 +1902,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOptionsAttribute( @@ -1849,37 +1910,35 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Options attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Options attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1891,42 +1950,48 @@ class ColorControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfPrimariesAttribute(): NumberOfPrimariesAttribute {val ATTRIBUTE_ID: UInt = 16u - suspend fun readNumberOfPrimariesAttribute(): NumberOfPrimariesAttribute { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofprimaries attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofprimaries attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NumberOfPrimariesAttribute(decodedValue) } @@ -1936,91 +2001,95 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NumberOfPrimariesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NumberOfPrimariesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofprimaries attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofprimaries attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NumberOfPrimariesAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NumberOfPrimariesAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NumberOfPrimariesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary1XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - suspend fun readPrimary1XAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary1x attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary1x attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2030,88 +2099,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary1x attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary1x attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary1YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - suspend fun readPrimary1YAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary1y attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary1y attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2121,93 +2196,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary1y attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary1y attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary1IntensityAttribute(): Primary1IntensityAttribute {val ATTRIBUTE_ID: UInt = 19u - suspend fun readPrimary1IntensityAttribute(): Primary1IntensityAttribute { - val ATTRIBUTE_ID: UInt = 19u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary1intensity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary1intensity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return Primary1IntensityAttribute(decodedValue) } @@ -2217,95 +2298,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - Primary1IntensityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(Primary1IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Primary1intensity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary1intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(Primary1IntensityAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(Primary1IntensityAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(Primary1IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary2XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 21u - suspend fun readPrimary2XAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 21u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary2x attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary2x attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2315,88 +2400,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary2x attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary2x attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary2YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 22u - suspend fun readPrimary2YAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 22u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary2y attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary2y attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2406,93 +2497,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary2y attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary2y attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary2IntensityAttribute(): Primary2IntensityAttribute {val ATTRIBUTE_ID: UInt = 23u - suspend fun readPrimary2IntensityAttribute(): Primary2IntensityAttribute { - val ATTRIBUTE_ID: UInt = 23u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary2intensity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary2intensity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return Primary2IntensityAttribute(decodedValue) } @@ -2502,95 +2599,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - Primary2IntensityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(Primary2IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Primary2intensity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary2intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(Primary2IntensityAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(Primary2IntensityAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(Primary2IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary3XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 25u - suspend fun readPrimary3XAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 25u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary3x attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary3x attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2600,88 +2701,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary3x attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary3x attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary3YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 26u - suspend fun readPrimary3YAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 26u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary3y attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary3y attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2691,93 +2798,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary3y attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary3y attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary3IntensityAttribute(): Primary3IntensityAttribute {val ATTRIBUTE_ID: UInt = 27u - suspend fun readPrimary3IntensityAttribute(): Primary3IntensityAttribute { - val ATTRIBUTE_ID: UInt = 27u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary3intensity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary3intensity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return Primary3IntensityAttribute(decodedValue) } @@ -2787,95 +2900,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - Primary3IntensityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(Primary3IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Primary3intensity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary3intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(Primary3IntensityAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(Primary3IntensityAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(Primary3IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary4XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 32u - suspend fun readPrimary4XAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 32u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary4x attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary4x attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2885,88 +3002,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary4x attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary4x attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary4YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 33u - suspend fun readPrimary4YAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 33u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary4y attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary4y attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2976,93 +3099,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary4y attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary4y attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary4IntensityAttribute(): Primary4IntensityAttribute {val ATTRIBUTE_ID: UInt = 34u - suspend fun readPrimary4IntensityAttribute(): Primary4IntensityAttribute { - val ATTRIBUTE_ID: UInt = 34u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary4intensity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary4intensity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return Primary4IntensityAttribute(decodedValue) } @@ -3072,95 +3201,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - Primary4IntensityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(Primary4IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Primary4intensity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary4intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(Primary4IntensityAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(Primary4IntensityAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(Primary4IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary5XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 36u - suspend fun readPrimary5XAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 36u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary5x attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary5x attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3170,88 +3303,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary5x attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary5x attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary5YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 37u - suspend fun readPrimary5YAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 37u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary5y attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary5y attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3261,93 +3400,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary5y attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary5y attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary5IntensityAttribute(): Primary5IntensityAttribute {val ATTRIBUTE_ID: UInt = 38u - suspend fun readPrimary5IntensityAttribute(): Primary5IntensityAttribute { - val ATTRIBUTE_ID: UInt = 38u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary5intensity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary5intensity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return Primary5IntensityAttribute(decodedValue) } @@ -3357,95 +3502,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - Primary5IntensityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(Primary5IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Primary5intensity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary5intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(Primary5IntensityAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(Primary5IntensityAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(Primary5IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary6XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 40u - suspend fun readPrimary6XAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 40u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary6x attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary6x attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3455,88 +3604,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary6x attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary6x attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary6YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 41u - suspend fun readPrimary6YAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 41u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary6y attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary6y attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3546,93 +3701,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Primary6y attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary6y attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPrimary6IntensityAttribute(): Primary6IntensityAttribute {val ATTRIBUTE_ID: UInt = 42u - suspend fun readPrimary6IntensityAttribute(): Primary6IntensityAttribute { - val ATTRIBUTE_ID: UInt = 42u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Primary6intensity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Primary6intensity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return Primary6IntensityAttribute(decodedValue) } @@ -3642,115 +3803,123 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - Primary6IntensityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(Primary6IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Primary6intensity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Primary6intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(Primary6IntensityAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(Primary6IntensityAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(Primary6IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWhitePointXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 48u - suspend fun readWhitePointXAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 48u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Whitepointx attribute not found in response" } + } + + requireNotNull(attributeData) { + "Whitepointx attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeWhitePointXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeWhitePointXAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3772,7 +3941,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWhitePointXAttribute( @@ -3780,108 +3949,118 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Whitepointx attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Whitepointx attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWhitePointYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 49u - suspend fun readWhitePointYAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 49u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Whitepointy attribute not found in response" } + } + + requireNotNull(attributeData) { + "Whitepointy attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeWhitePointYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeWhitePointYAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3903,7 +4082,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWhitePointYAttribute( @@ -3911,108 +4090,118 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Whitepointy attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Whitepointy attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorPointRXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 50u - suspend fun readColorPointRXAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 50u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorpointrx attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorpointrx attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeColorPointRXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointRXAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4034,7 +4223,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointRXAttribute( @@ -4042,108 +4231,118 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Colorpointrx attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorpointrx attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorPointRYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 51u - suspend fun readColorPointRYAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 51u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorpointry attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorpointry attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeColorPointRYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointRYAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 51u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4165,7 +4364,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointRYAttribute( @@ -4173,116 +4372,123 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Colorpointry attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorpointry attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute {val ATTRIBUTE_ID: UInt = 52u - suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute { - val ATTRIBUTE_ID: UInt = 52u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorpointrintensity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorpointrintensity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ColorPointRIntensityAttribute(decodedValue) } suspend fun writeColorPointRIntensityAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 52u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4304,7 +4510,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointRIntensityAttribute( @@ -4312,115 +4518,123 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ColorPointRIntensityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ColorPointRIntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Colorpointrintensity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorpointrintensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ColorPointRIntensityAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ColorPointRIntensityAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ColorPointRIntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorPointGXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 54u - suspend fun readColorPointGXAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 54u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorpointgx attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorpointgx attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeColorPointGXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointGXAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 54u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4442,7 +4656,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointGXAttribute( @@ -4450,108 +4664,118 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 54u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Colorpointgx attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorpointgx attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorPointGYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 55u - suspend fun readColorPointGYAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 55u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorpointgy attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorpointgy attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeColorPointGYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointGYAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 55u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4573,7 +4797,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointGYAttribute( @@ -4581,116 +4805,123 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 55u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Colorpointgy attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorpointgy attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute {val ATTRIBUTE_ID: UInt = 56u - suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute { - val ATTRIBUTE_ID: UInt = 56u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorpointgintensity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorpointgintensity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ColorPointGIntensityAttribute(decodedValue) } suspend fun writeColorPointGIntensityAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 56u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4712,7 +4943,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointGIntensityAttribute( @@ -4720,115 +4951,123 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 56u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ColorPointGIntensityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ColorPointGIntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Colorpointgintensity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorpointgintensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ColorPointGIntensityAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ColorPointGIntensityAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ColorPointGIntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorPointBXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 58u - suspend fun readColorPointBXAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 58u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorpointbx attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorpointbx attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeColorPointBXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointBXAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 58u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4850,7 +5089,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointBXAttribute( @@ -4858,108 +5097,118 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 58u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Colorpointbx attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorpointbx attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorPointBYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 59u - suspend fun readColorPointBYAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 59u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorpointby attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorpointby attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeColorPointBYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointBYAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 59u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4981,7 +5230,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointBYAttribute( @@ -4989,116 +5238,123 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 59u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Colorpointby attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorpointby attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute {val ATTRIBUTE_ID: UInt = 60u - suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute { - val ATTRIBUTE_ID: UInt = 60u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorpointbintensity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorpointbintensity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ColorPointBIntensityAttribute(decodedValue) } suspend fun writeColorPointBIntensityAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 60u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5120,7 +5376,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointBIntensityAttribute( @@ -5128,95 +5384,99 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 60u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ColorPointBIntensityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ColorPointBIntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Colorpointbintensity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorpointbintensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ColorPointBIntensityAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ColorPointBIntensityAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ColorPointBIntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEnhancedCurrentHueAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16384u - suspend fun readEnhancedCurrentHueAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16384u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Enhancedcurrenthue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Enhancedcurrenthue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5226,86 +5486,91 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Enhancedcurrenthue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Enhancedcurrenthue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEnhancedColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16385u - suspend fun readEnhancedColorModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 16385u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Enhancedcolormode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Enhancedcolormode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -5314,38 +5579,34 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16385u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Enhancedcolormode attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Enhancedcolormode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -5358,41 +5619,47 @@ class ColorControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorLoopActiveAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16386u - suspend fun readColorLoopActiveAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 16386u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorloopactive attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorloopactive attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5402,90 +5669,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16386u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Colorloopactive attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorloopactive attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorLoopDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16387u - suspend fun readColorLoopDirectionAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 16387u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorloopdirection attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorloopdirection attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5495,90 +5766,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16387u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Colorloopdirection attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorloopdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorLoopTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16388u - suspend fun readColorLoopTimeAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16388u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorlooptime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorlooptime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5588,88 +5863,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16388u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Colorlooptime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorlooptime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorLoopStartEnhancedHueAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16389u - suspend fun readColorLoopStartEnhancedHueAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16389u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorloopstartenhancedhue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorloopstartenhancedhue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5679,90 +5960,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16389u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Colorloopstartenhancedhue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorloopstartenhancedhue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorLoopStoredEnhancedHueAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16390u - suspend fun readColorLoopStoredEnhancedHueAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16390u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorloopstoredenhancedhue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorloopstoredenhancedhue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5772,86 +6057,91 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16390u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Colorloopstoredenhancedhue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorloopstoredenhancedhue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorCapabilitiesAttribute(): UShort {val ATTRIBUTE_ID: UInt = 16394u - suspend fun readColorCapabilitiesAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 16394u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colorcapabilities attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colorcapabilities attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -5860,38 +6150,34 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16394u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Colorcapabilities attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colorcapabilities attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -5904,41 +6190,47 @@ class ColorControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorTempPhysicalMinMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16395u - suspend fun readColorTempPhysicalMinMiredsAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16395u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colortempphysicalminmireds attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colortempphysicalminmireds attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5948,90 +6240,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16395u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Colortempphysicalminmireds attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colortempphysicalminmireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readColorTempPhysicalMaxMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16396u - suspend fun readColorTempPhysicalMaxMiredsAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16396u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Colortempphysicalmaxmireds attribute not found in response" } + } + + requireNotNull(attributeData) { + "Colortempphysicalmaxmireds attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6041,92 +6337,94 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16396u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Colortempphysicalmaxmireds attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Colortempphysicalmaxmireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCoupleColorTempToLevelMinMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16397u - suspend fun readCoupleColorTempToLevelMinMiredsAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16397u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Couplecolortemptolevelminmireds attribute not found in response" + } + + requireNotNull(attributeData) { + "Couplecolortemptolevelminmireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6136,120 +6434,123 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16397u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Couplecolortemptolevelminmireds attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Couplecolortemptolevelminmireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatureMiredsAttribute {val ATTRIBUTE_ID: UInt = 16400u - suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatureMiredsAttribute { - val ATTRIBUTE_ID: UInt = 16400u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupcolortemperaturemireds attribute not found in response" + } + + requireNotNull(attributeData) { + "Startupcolortemperaturemireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StartUpColorTemperatureMiredsAttribute(decodedValue) } suspend fun writeStartUpColorTemperatureMiredsAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16400u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6271,7 +6572,7 @@ class ColorControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpColorTemperatureMiredsAttribute( @@ -6279,99 +6580,101 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16400u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StartUpColorTemperatureMiredsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StartUpColorTemperatureMiredsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Startupcolortemperaturemireds attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Startupcolortemperaturemireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(StartUpColorTemperatureMiredsAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(StartUpColorTemperatureMiredsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -6381,50 +6684,45 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6432,43 +6730,49 @@ class ColorControlCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -6478,50 +6782,45 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6529,43 +6828,49 @@ class ColorControlCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -6575,48 +6880,45 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -6624,43 +6926,49 @@ class ColorControlCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -6670,48 +6978,45 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -6719,37 +7024,44 @@ class ColorControlCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -6758,37 +7070,35 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6800,37 +7110,44 @@ class ColorControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -6839,38 +7156,34 @@ class ColorControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -6883,7 +7196,7 @@ class ColorControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt index 4c08eb6499a918..034e54bd0d2c5a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt @@ -17,89 +17,122 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentAppObserverCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ContentAppMessageResponse(val status: UByte, val data: String?, val encodingHint: String?) - - class GeneratedCommandListAttribute(val value: List) +class ContentAppObserverCluster(private val controller: MatterController, private val endpointId: UShort) { + class ContentAppMessageResponse( + val status: UByte, + val data: String?, + val encodingHint: String? + ) +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun contentAppMessage( - data: String?, - encodingHint: String, - timedInvokeTimeout: Duration? = null - ): ContentAppMessageResponse { + suspend fun contentAppMessage(data: String? + ,encodingHint: String + ,timedInvokeTimeout: Duration? = null): ContentAppMessageResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DATA_REQ: Int = 0 - data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } + data?.let { + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + } val TAG_ENCODING_HINT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ENCODING_HINT_REQ), encodingHint) + tlvWriter.put(ContextSpecificTag(TAG_ENCODING_HINT_REQ), encodingHint) tlvWriter.endStructure() val request: InvokeRequest = @@ -116,94 +149,110 @@ class ContentAppObserverCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - + val TAG_ENCODING_HINT: Int = 2 var encodingHint_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_ENCODING_HINT)) { - encodingHint_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_ENCODING_HINT)) {encodingHint_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + + + tlvReader.exitContainer() - return ContentAppMessageResponse(status_decoded, data_decoded, encodingHint_decoded) + return ContentAppMessageResponse( + status_decoded, + data_decoded, + encodingHint_decoded + ) } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -213,50 +262,45 @@ class ContentAppObserverCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -264,43 +308,49 @@ class ContentAppObserverCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -310,50 +360,45 @@ class ContentAppObserverCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -361,43 +406,49 @@ class ContentAppObserverCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -407,48 +458,45 @@ class ContentAppObserverCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -456,43 +504,49 @@ class ContentAppObserverCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -502,48 +556,45 @@ class ContentAppObserverCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -551,37 +602,44 @@ class ContentAppObserverCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -590,37 +648,35 @@ class ContentAppObserverCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -632,37 +688,44 @@ class ContentAppObserverCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -671,38 +734,34 @@ class ContentAppObserverCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -715,7 +774,7 @@ class ContentAppObserverCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt index 327d7b9645c408..8da8313c8caed0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt @@ -17,110 +17,146 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ResetPINResponse(val PINCode: String) - - class OnDemandRatingsAttribute(val value: List?) +class ContentControlCluster(private val controller: MatterController, private val endpointId: UShort) { + class ResetPINResponse( + val PINCode: String + ) +class OnDemandRatingsAttribute( + val value: List? + ) sealed class OnDemandRatingsAttributeSubscriptionState { - data class Success(val value: List?) : - OnDemandRatingsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : OnDemandRatingsAttributeSubscriptionState() + data class Error(val exception: Exception) : OnDemandRatingsAttributeSubscriptionState() - object SubscriptionEstablished : OnDemandRatingsAttributeSubscriptionState() - } - - class ScheduledContentRatingsAttribute(val value: List?) + object SubscriptionEstablished : OnDemandRatingsAttributeSubscriptionState() + } +class ScheduledContentRatingsAttribute( + val value: List? + ) sealed class ScheduledContentRatingsAttributeSubscriptionState { - data class Success(val value: List?) : - ScheduledContentRatingsAttributeSubscriptionState() - - data class Error(val exception: Exception) : - ScheduledContentRatingsAttributeSubscriptionState() - - object SubscriptionEstablished : ScheduledContentRatingsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + data class Success( + val value: List? + ) : ScheduledContentRatingsAttributeSubscriptionState() + + data class Error(val exception: Exception) : ScheduledContentRatingsAttributeSubscriptionState() + + object SubscriptionEstablished : ScheduledContentRatingsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun updatePIN(oldPIN: String?, newPIN: String, timedInvokeTimeout: Duration? = null) { + suspend fun updatePIN(oldPIN: String? + ,newPIN: String + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_OLD_P_I_N_REQ: Int = 0 - oldPIN?.let { tlvWriter.put(ContextSpecificTag(TAG_OLD_P_I_N_REQ), oldPIN) } + oldPIN?.let { + tlvWriter.put(ContextSpecificTag(TAG_OLD_P_I_N_REQ), oldPIN) + } val TAG_NEW_P_I_N_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NEW_P_I_N_REQ), newPIN) + tlvWriter.put(ContextSpecificTag(TAG_NEW_P_I_N_REQ), newPIN) tlvWriter.endStructure() val request: InvokeRequest = @@ -138,7 +174,7 @@ class ContentControlCluster( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,31 +191,39 @@ class ContentControlCluster( tlvReader.enterStructure(AnonymousTag) val TAG_P_I_N_CODE: Int = 0 var PINCode_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_P_I_N_CODE)) { - PINCode_decoded = tlvReader.getString(tag) - } else { + + if (tag == ContextSpecificTag(TAG_P_I_N_CODE)) {PINCode_decoded = tlvReader.getString(tag)} + + + else { tlvReader.skipElement() } } + + if (PINCode_decoded == null) { - throw IllegalStateException("PINCode not found in TLV") + throw IllegalStateException("PINCode not found in TLV") } + tlvReader.exitContainer() - return ResetPINResponse(PINCode_decoded) + return ResetPINResponse( + PINCode_decoded + ) } suspend fun enable(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -197,7 +241,7 @@ class ContentControlCluster( val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -211,21 +255,23 @@ class ContentControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addBonusTime( - PINCode: String?, - bonusTime: UInt?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun addBonusTime(PINCode: String? + ,bonusTime: UInt? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } + PINCode?.let { + tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) + } val TAG_BONUS_TIME_REQ: Int = 1 - bonusTime?.let { tlvWriter.put(ContextSpecificTag(TAG_BONUS_TIME_REQ), bonusTime) } + bonusTime?.let { + tlvWriter.put(ContextSpecificTag(TAG_BONUS_TIME_REQ), bonusTime) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -239,14 +285,15 @@ class ContentControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setScreenDailyTime(screenTime: UInt, timedInvokeTimeout: Duration? = null) { + suspend fun setScreenDailyTime(screenTime: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 6u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SCREEN_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_SCREEN_TIME_REQ), screenTime) + tlvWriter.put(ContextSpecificTag(TAG_SCREEN_TIME_REQ), screenTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -264,7 +311,7 @@ class ContentControlCluster( val commandId: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -282,7 +329,7 @@ class ContentControlCluster( val commandId: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -296,14 +343,15 @@ class ContentControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setOnDemandRatingThreshold(rating: String, timedInvokeTimeout: Duration? = null) { + suspend fun setOnDemandRatingThreshold(rating: String + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 9u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_RATING_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) + tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) tlvWriter.endStructure() val request: InvokeRequest = @@ -317,17 +365,15 @@ class ContentControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setScheduledContentRatingThreshold( - rating: String, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setScheduledContentRatingThreshold(rating: String + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 10u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_RATING_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) + tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) tlvWriter.endStructure() val request: InvokeRequest = @@ -340,35 +386,42 @@ class ContentControlCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readEnabledAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Enabled attribute not found in response" } + } + + requireNotNull(attributeData) { + "Enabled attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -377,37 +430,35 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Enabled attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Enabled attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -419,47 +470,53 @@ class ContentControlCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOnDemandRatingsAttribute(): OnDemandRatingsAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOnDemandRatingsAttribute(): OnDemandRatingsAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Ondemandratings attribute not found in response" } + } + + requireNotNull(attributeData) { + "Ondemandratings attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return OnDemandRatingsAttribute(decodedValue) } @@ -469,96 +526,100 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OnDemandRatingsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OnDemandRatingsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Ondemandratings attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ondemandratings attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(OnDemandRatingsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(OnDemandRatingsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OnDemandRatingsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOnDemandRatingThresholdAttribute(): String? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOnDemandRatingThresholdAttribute(): String? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Ondemandratingthreshold attribute not found in response" } + } + + requireNotNull(attributeData) { + "Ondemandratingthreshold attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -568,96 +629,100 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Ondemandratingthreshold attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ondemandratingthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readScheduledContentRatingsAttribute(): ScheduledContentRatingsAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readScheduledContentRatingsAttribute(): ScheduledContentRatingsAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Scheduledcontentratings attribute not found in response" } + } + + requireNotNull(attributeData) { + "Scheduledcontentratings attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return ScheduledContentRatingsAttribute(decodedValue) } @@ -667,98 +732,100 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ScheduledContentRatingsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ScheduledContentRatingsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Scheduledcontentratings attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scheduledcontentratings attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ScheduledContentRatingsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ScheduledContentRatingsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ScheduledContentRatingsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readScheduledContentRatingThresholdAttribute(): String? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readScheduledContentRatingThresholdAttribute(): String? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduledcontentratingthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Scheduledcontentratingthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -768,90 +835,94 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Scheduledcontentratingthreshold attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scheduledcontentratingthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readScreenDailyTimeAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readScreenDailyTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Screendailytime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Screendailytime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -861,90 +932,94 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Screendailytime attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Screendailytime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readRemainingScreenTimeAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readRemainingScreenTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Remainingscreentime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Remainingscreentime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -954,86 +1029,91 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Remainingscreentime attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Remainingscreentime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBlockUnratedAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBlockUnratedAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Blockunrated attribute not found in response" } + } + + requireNotNull(attributeData) { + "Blockunrated attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -1042,37 +1122,35 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Blockunrated attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Blockunrated attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1084,43 +1162,49 @@ class ContentControlCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1130,50 +1214,45 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1181,43 +1260,49 @@ class ContentControlCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1227,50 +1312,45 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1278,43 +1358,49 @@ class ContentControlCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1324,48 +1410,45 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1373,43 +1456,49 @@ class ContentControlCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1419,48 +1508,45 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1468,37 +1554,44 @@ class ContentControlCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1507,37 +1600,35 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1549,37 +1640,44 @@ class ContentControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1588,38 +1686,34 @@ class ContentControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1632,7 +1726,7 @@ class ContentControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt index ae50ff527a8e2c..e9cc7486518443 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt @@ -17,92 +17,125 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class LauncherResponse(val status: UByte, val data: String?) - - class AcceptHeaderAttribute(val value: List?) +class ContentLauncherCluster(private val controller: MatterController, private val endpointId: UShort) { + class LauncherResponse( + val status: UByte, + val data: String? + ) +class AcceptHeaderAttribute( + val value: List? + ) sealed class AcceptHeaderAttributeSubscriptionState { - data class Success(val value: List?) : AcceptHeaderAttributeSubscriptionState() - + data class Success( + val value: List? + ) : AcceptHeaderAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptHeaderAttributeSubscriptionState() - object SubscriptionEstablished : AcceptHeaderAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AcceptHeaderAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun launchContent( - search: ContentLauncherClusterContentSearchStruct, - autoPlay: Boolean, - data: String?, - playbackPreferences: ContentLauncherClusterPlaybackPreferencesStruct?, - useCurrentContext: Boolean?, - timedInvokeTimeout: Duration? = null - ): LauncherResponse { + suspend fun launchContent(search: ContentLauncherClusterContentSearchStruct + ,autoPlay: Boolean + ,data: String? + ,playbackPreferences: ContentLauncherClusterPlaybackPreferencesStruct? + ,useCurrentContext: Boolean? + ,timedInvokeTimeout: Duration? = null): LauncherResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -115,7 +148,9 @@ class ContentLauncherCluster( tlvWriter.put(ContextSpecificTag(TAG_AUTO_PLAY_REQ), autoPlay) val TAG_DATA_REQ: Int = 2 - data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } + data?.let { + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + } val TAG_PLAYBACK_PREFERENCES_REQ: Int = 3 playbackPreferences?.let { @@ -125,7 +160,7 @@ class ContentLauncherCluster( val TAG_USE_CURRENT_CONTEXT_REQ: Int = 4 useCurrentContext?.let { tlvWriter.put(ContextSpecificTag(TAG_USE_CURRENT_CONTEXT_REQ), useCurrentContext) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -142,49 +177,56 @@ class ContentLauncherCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return LauncherResponse(status_decoded, data_decoded) + return LauncherResponse( + status_decoded, + data_decoded + ) } - suspend fun launchURL( - contentURL: String, - displayString: String?, - brandingInformation: ContentLauncherClusterBrandingInformationStruct?, - timedInvokeTimeout: Duration? = null - ): LauncherResponse { + suspend fun launchURL(contentURL: String + ,displayString: String? + ,brandingInformation: ContentLauncherClusterBrandingInformationStruct? + ,timedInvokeTimeout: Duration? = null): LauncherResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -194,12 +236,14 @@ class ContentLauncherCluster( tlvWriter.put(ContextSpecificTag(TAG_CONTENT_U_R_L_REQ), contentURL) val TAG_DISPLAY_STRING_REQ: Int = 1 - displayString?.let { tlvWriter.put(ContextSpecificTag(TAG_DISPLAY_STRING_REQ), displayString) } + displayString?.let { + tlvWriter.put(ContextSpecificTag(TAG_DISPLAY_STRING_REQ), displayString) + } val TAG_BRANDING_INFORMATION_REQ: Int = 2 brandingInformation?.let { brandingInformation.toTlv(ContextSpecificTag(TAG_BRANDING_INFORMATION_REQ), tlvWriter) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -216,81 +260,96 @@ class ContentLauncherCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return LauncherResponse(status_decoded, data_decoded) + return LauncherResponse( + status_decoded, + data_decoded + ) } - - suspend fun readAcceptHeaderAttribute(): AcceptHeaderAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptHeaderAttribute(): AcceptHeaderAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptheader attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptheader attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return AcceptHeaderAttribute(decodedValue) } @@ -300,94 +359,100 @@ class ContentLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptHeaderAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptHeaderAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Acceptheader attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptheader attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(AcceptHeaderAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(AcceptHeaderAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AcceptHeaderAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportedStreamingProtocolsAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedStreamingProtocolsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedstreamingprotocols attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedstreamingprotocols attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -397,92 +462,96 @@ class ContentLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedstreamingprotocols attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedstreamingprotocols attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -492,50 +561,45 @@ class ContentLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -543,43 +607,49 @@ class ContentLauncherCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -589,50 +659,45 @@ class ContentLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -640,43 +705,49 @@ class ContentLauncherCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -686,48 +757,45 @@ class ContentLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -735,43 +803,49 @@ class ContentLauncherCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -781,48 +855,45 @@ class ContentLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -830,37 +901,44 @@ class ContentLauncherCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -869,37 +947,35 @@ class ContentLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -911,37 +987,44 @@ class ContentLauncherCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -950,38 +1033,34 @@ class ContentLauncherCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -994,7 +1073,7 @@ class ContentLauncherCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt index af0c8860f08d12..6eba50d64ec9c8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt @@ -17,124 +17,149 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class LoadControlProgramsAttribute( +class DemandResponseLoadControlCluster(private val controller: MatterController, private val endpointId: UShort) {class LoadControlProgramsAttribute( val value: List ) sealed class LoadControlProgramsAttributeSubscriptionState { - data class Success(val value: List) : - LoadControlProgramsAttributeSubscriptionState() - + data class Success( + val value: List + ) : LoadControlProgramsAttributeSubscriptionState() + data class Error(val exception: Exception) : LoadControlProgramsAttributeSubscriptionState() - object SubscriptionEstablished : LoadControlProgramsAttributeSubscriptionState() - } - - class EventsAttribute(val value: List) + object SubscriptionEstablished : LoadControlProgramsAttributeSubscriptionState() + } +class EventsAttribute( + val value: List + ) sealed class EventsAttributeSubscriptionState { - data class Success(val value: List) : - EventsAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventsAttributeSubscriptionState() + data class Error(val exception: Exception) : EventsAttributeSubscriptionState() - object SubscriptionEstablished : EventsAttributeSubscriptionState() - } - - class ActiveEventsAttribute( + object SubscriptionEstablished : EventsAttributeSubscriptionState() + } +class ActiveEventsAttribute( val value: List ) sealed class ActiveEventsAttributeSubscriptionState { - data class Success(val value: List) : - ActiveEventsAttributeSubscriptionState() - + data class Success( + val value: List + ) : ActiveEventsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveEventsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveEventsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : ActiveEventsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun registerLoadControlProgramRequest( - loadControlProgram: DemandResponseLoadControlClusterLoadControlProgramStruct, - timedInvokeTimeout: Duration? = null - ) { + suspend fun registerLoadControlProgramRequest(loadControlProgram: DemandResponseLoadControlClusterLoadControlProgramStruct + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LOAD_CONTROL_PROGRAM_REQ: Int = 0 - loadControlProgram.toTlv(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_REQ), tlvWriter) + loadControlProgram.toTlv(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -148,17 +173,15 @@ class DemandResponseLoadControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unregisterLoadControlProgramRequest( - loadControlProgramID: ByteArray, - timedInvokeTimeout: Duration? = null - ) { + suspend fun unregisterLoadControlProgramRequest(loadControlProgramID: ByteArray + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LOAD_CONTROL_PROGRAM_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_I_D_REQ), loadControlProgramID) + tlvWriter.put(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_I_D_REQ), loadControlProgramID) tlvWriter.endStructure() val request: InvokeRequest = @@ -172,17 +195,15 @@ class DemandResponseLoadControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addLoadControlEventRequest( - event: DemandResponseLoadControlClusterLoadControlEventStruct, - timedInvokeTimeout: Duration? = null - ) { + suspend fun addLoadControlEventRequest(event: DemandResponseLoadControlClusterLoadControlEventStruct + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_EVENT_REQ: Int = 0 - event.toTlv(ContextSpecificTag(TAG_EVENT_REQ), tlvWriter) + event.toTlv(ContextSpecificTag(TAG_EVENT_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -196,11 +217,9 @@ class DemandResponseLoadControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun removeLoadControlEventRequest( - eventID: ByteArray, - cancelControl: UShort, - timedInvokeTimeout: Duration? = null - ) { + suspend fun removeLoadControlEventRequest(eventID: ByteArray + ,cancelControl: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -210,7 +229,7 @@ class DemandResponseLoadControlCluster( tlvWriter.put(ContextSpecificTag(TAG_EVENT_I_D_REQ), eventID) val TAG_CANCEL_CONTROL_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CANCEL_CONTROL_REQ), cancelControl) + tlvWriter.put(ContextSpecificTag(TAG_CANCEL_CONTROL_REQ), cancelControl) tlvWriter.endStructure() val request: InvokeRequest = @@ -228,7 +247,7 @@ class DemandResponseLoadControlCluster( val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -241,46 +260,47 @@ class DemandResponseLoadControlCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Loadcontrolprograms attribute not found in response" } + } + + requireNotNull(attributeData) { + "Loadcontrolprograms attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return LoadControlProgramsAttribute(decodedValue) } @@ -290,55 +310,45 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LoadControlProgramsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LoadControlProgramsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Loadcontrolprograms attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Loadcontrolprograms attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(LoadControlProgramsAttributeSubscriptionState.Success(decodedValue)) } @@ -346,37 +356,44 @@ class DemandResponseLoadControlCluster( emit(LoadControlProgramsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readNumberOfLoadControlProgramsAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readNumberOfLoadControlProgramsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofloadcontrolprograms attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofloadcontrolprograms attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -385,38 +402,34 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofloadcontrolprograms attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofloadcontrolprograms attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -429,45 +442,49 @@ class DemandResponseLoadControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventsAttribute(): EventsAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventsAttribute(): EventsAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Events attribute not found in response" } + } + + requireNotNull(attributeData) { + "Events attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader) - ) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return EventsAttribute(decodedValue) } @@ -477,53 +494,45 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Events attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Events attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(EventsAttributeSubscriptionState.Success(decodedValue)) } @@ -531,45 +540,49 @@ class DemandResponseLoadControlCluster( emit(EventsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readActiveEventsAttribute(): ActiveEventsAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readActiveEventsAttribute(): ActiveEventsAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activeevents attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activeevents attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader) - ) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return ActiveEventsAttribute(decodedValue) } @@ -579,53 +592,45 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveEventsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveEventsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Activeevents attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activeevents attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ActiveEventsAttributeSubscriptionState.Success(decodedValue)) } @@ -633,37 +638,44 @@ class DemandResponseLoadControlCluster( emit(ActiveEventsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readNumberOfEventsPerProgramAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readNumberOfEventsPerProgramAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofeventsperprogram attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofeventsperprogram attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -672,38 +684,34 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofeventsperprogram attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofeventsperprogram attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -716,37 +724,44 @@ class DemandResponseLoadControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readNumberOfTransitionsAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readNumberOfTransitionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberoftransitions attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberoftransitions attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -755,38 +770,34 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberoftransitions attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberoftransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -799,56 +810,67 @@ class DemandResponseLoadControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDefaultRandomStartAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDefaultRandomStartAttribute(): UByte {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Defaultrandomstart attribute not found in response" } + } + + requireNotNull(attributeData) { + "Defaultrandomstart attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeDefaultRandomStartAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultRandomStartAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -870,7 +892,7 @@ class DemandResponseLoadControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultRandomStartAttribute( @@ -878,38 +900,34 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Defaultrandomstart attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Defaultrandomstart attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -922,59 +940,67 @@ class DemandResponseLoadControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDefaultRandomDurationAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDefaultRandomDurationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Defaultrandomduration attribute not found in response" } + } + + requireNotNull(attributeData) { + "Defaultrandomduration attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } suspend fun writeDefaultRandomDurationAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -996,7 +1022,7 @@ class DemandResponseLoadControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultRandomDurationAttribute( @@ -1004,38 +1030,34 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Defaultrandomduration attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Defaultrandomduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1048,43 +1070,49 @@ class DemandResponseLoadControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1094,50 +1122,45 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1145,43 +1168,49 @@ class DemandResponseLoadControlCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1191,50 +1220,45 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1242,43 +1266,49 @@ class DemandResponseLoadControlCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1288,48 +1318,45 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1337,43 +1364,49 @@ class DemandResponseLoadControlCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1383,48 +1416,45 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1432,37 +1462,44 @@ class DemandResponseLoadControlCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1471,37 +1508,35 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1513,37 +1548,44 @@ class DemandResponseLoadControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1552,38 +1594,34 @@ class DemandResponseLoadControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1596,7 +1634,7 @@ class DemandResponseLoadControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt index 5ff9420be9baf0..e5b5a887fd60b2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt @@ -17,150 +17,206 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class DescriptorCluster(private val controller: MatterController, private val endpointId: UShort) { - class DeviceTypeListAttribute(val value: List) +class DescriptorCluster(private val controller: MatterController, private val endpointId: UShort) {class DeviceTypeListAttribute( + val value: List + ) sealed class DeviceTypeListAttributeSubscriptionState { - data class Success(val value: List) : - DeviceTypeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : DeviceTypeListAttributeSubscriptionState() + data class Error(val exception: Exception) : DeviceTypeListAttributeSubscriptionState() - object SubscriptionEstablished : DeviceTypeListAttributeSubscriptionState() - } - - class ServerListAttribute(val value: List) + object SubscriptionEstablished : DeviceTypeListAttributeSubscriptionState() + } +class ServerListAttribute( + val value: List + ) sealed class ServerListAttributeSubscriptionState { - data class Success(val value: List) : ServerListAttributeSubscriptionState() - + data class Success( + val value: List + ) : ServerListAttributeSubscriptionState() + data class Error(val exception: Exception) : ServerListAttributeSubscriptionState() - object SubscriptionEstablished : ServerListAttributeSubscriptionState() - } - - class ClientListAttribute(val value: List) + object SubscriptionEstablished : ServerListAttributeSubscriptionState() + } +class ClientListAttribute( + val value: List + ) sealed class ClientListAttributeSubscriptionState { - data class Success(val value: List) : ClientListAttributeSubscriptionState() - + data class Success( + val value: List + ) : ClientListAttributeSubscriptionState() + data class Error(val exception: Exception) : ClientListAttributeSubscriptionState() - object SubscriptionEstablished : ClientListAttributeSubscriptionState() - } - - class PartsListAttribute(val value: List) + object SubscriptionEstablished : ClientListAttributeSubscriptionState() + } +class PartsListAttribute( + val value: List + ) sealed class PartsListAttributeSubscriptionState { - data class Success(val value: List) : PartsListAttributeSubscriptionState() - + data class Success( + val value: List + ) : PartsListAttributeSubscriptionState() + data class Error(val exception: Exception) : PartsListAttributeSubscriptionState() - object SubscriptionEstablished : PartsListAttributeSubscriptionState() - } - - class TagListAttribute(val value: List?) + object SubscriptionEstablished : PartsListAttributeSubscriptionState() + } +class TagListAttribute( + val value: List? + ) sealed class TagListAttributeSubscriptionState { - data class Success(val value: List?) : - TagListAttributeSubscriptionState() - + data class Success( + val value: List? + ) : TagListAttributeSubscriptionState() + data class Error(val exception: Exception) : TagListAttributeSubscriptionState() - object SubscriptionEstablished : TagListAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : TagListAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Devicetypelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Devicetypelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return DeviceTypeListAttribute(decodedValue) } @@ -170,50 +226,45 @@ class DescriptorCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DeviceTypeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DeviceTypeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Devicetypelist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Devicetypelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(DeviceTypeListAttributeSubscriptionState.Success(decodedValue)) } @@ -221,43 +272,49 @@ class DescriptorCluster(private val controller: MatterController, private val en emit(DeviceTypeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readServerListAttribute(): ServerListAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readServerListAttribute(): ServerListAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Serverlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Serverlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return ServerListAttribute(decodedValue) } @@ -267,48 +324,45 @@ class DescriptorCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ServerListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ServerListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Serverlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Serverlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ServerListAttributeSubscriptionState.Success(decodedValue)) } @@ -316,43 +370,49 @@ class DescriptorCluster(private val controller: MatterController, private val en emit(ServerListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClientListAttribute(): ClientListAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClientListAttribute(): ClientListAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clientlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clientlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return ClientListAttribute(decodedValue) } @@ -362,48 +422,45 @@ class DescriptorCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ClientListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ClientListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Clientlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clientlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ClientListAttributeSubscriptionState.Success(decodedValue)) } @@ -411,43 +468,49 @@ class DescriptorCluster(private val controller: MatterController, private val en emit(ClientListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPartsListAttribute(): PartsListAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPartsListAttribute(): PartsListAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Partslist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Partslist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) } + tlvReader.exitContainer() + } + return PartsListAttribute(decodedValue) } @@ -457,48 +520,45 @@ class DescriptorCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PartsListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PartsListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Partslist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Partslist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(PartsListAttributeSubscriptionState.Success(decodedValue)) } @@ -506,47 +566,53 @@ class DescriptorCluster(private val controller: MatterController, private val en emit(PartsListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTagListAttribute(): TagListAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTagListAttribute(): TagListAttribute {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Taglist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Taglist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return TagListAttribute(decodedValue) } @@ -556,96 +622,102 @@ class DescriptorCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - TagListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(TagListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Taglist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Taglist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(TagListAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(TagListAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(TagListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -655,50 +727,45 @@ class DescriptorCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -706,43 +773,49 @@ class DescriptorCluster(private val controller: MatterController, private val en emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -752,50 +825,45 @@ class DescriptorCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -803,43 +871,49 @@ class DescriptorCluster(private val controller: MatterController, private val en emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -849,48 +923,45 @@ class DescriptorCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -898,43 +969,49 @@ class DescriptorCluster(private val controller: MatterController, private val en emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -944,48 +1021,45 @@ class DescriptorCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -993,37 +1067,44 @@ class DescriptorCluster(private val controller: MatterController, private val en emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1032,37 +1113,35 @@ class DescriptorCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1074,37 +1153,44 @@ class DescriptorCluster(private val controller: MatterController, private val en emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1113,38 +1199,34 @@ class DescriptorCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1157,7 +1239,7 @@ class DescriptorCluster(private val controller: MatterController, private val en emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt index eb68ec47c75ee1..701eae9cc163a1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt @@ -17,106 +17,131 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.LongSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class PowerAdjustmentCapabilityAttribute( +class DeviceEnergyManagementCluster(private val controller: MatterController, private val endpointId: UShort) {class PowerAdjustmentCapabilityAttribute( val value: List? ) sealed class PowerAdjustmentCapabilityAttributeSubscriptionState { - data class Success(val value: List?) : - PowerAdjustmentCapabilityAttributeSubscriptionState() - - data class Error(val exception: Exception) : - PowerAdjustmentCapabilityAttributeSubscriptionState() - - object SubscriptionEstablished : PowerAdjustmentCapabilityAttributeSubscriptionState() - } - - class ForecastAttribute(val value: DeviceEnergyManagementClusterForecastStruct?) + data class Success( + val value: List? + ) : PowerAdjustmentCapabilityAttributeSubscriptionState() + + data class Error(val exception: Exception) : PowerAdjustmentCapabilityAttributeSubscriptionState() + + object SubscriptionEstablished : PowerAdjustmentCapabilityAttributeSubscriptionState() + } +class ForecastAttribute( + val value: DeviceEnergyManagementClusterForecastStruct? + ) sealed class ForecastAttributeSubscriptionState { - data class Success(val value: DeviceEnergyManagementClusterForecastStruct?) : - ForecastAttributeSubscriptionState() - + data class Success( + val value: DeviceEnergyManagementClusterForecastStruct? + ) : ForecastAttributeSubscriptionState() + data class Error(val exception: Exception) : ForecastAttributeSubscriptionState() - object SubscriptionEstablished : ForecastAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : ForecastAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun powerAdjustRequest( - power: Long, - duration: UInt, - cause: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun powerAdjustRequest(power: Long + ,duration: UInt + ,cause: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -129,7 +154,7 @@ class DeviceEnergyManagementCluster( tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) val TAG_CAUSE_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -147,7 +172,7 @@ class DeviceEnergyManagementCluster( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -161,11 +186,9 @@ class DeviceEnergyManagementCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startTimeAdjustRequest( - requestedStartTime: UInt, - cause: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun startTimeAdjustRequest(requestedStartTime: UInt + ,cause: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -175,7 +198,7 @@ class DeviceEnergyManagementCluster( tlvWriter.put(ContextSpecificTag(TAG_REQUESTED_START_TIME_REQ), requestedStartTime) val TAG_CAUSE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -189,7 +212,9 @@ class DeviceEnergyManagementCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun pauseRequest(duration: UInt, cause: UByte, timedInvokeTimeout: Duration? = null) { + suspend fun pauseRequest(duration: UInt + ,cause: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -199,7 +224,7 @@ class DeviceEnergyManagementCluster( tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) val TAG_CAUSE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -217,7 +242,7 @@ class DeviceEnergyManagementCluster( val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -231,12 +256,10 @@ class DeviceEnergyManagementCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun modifyForecastRequest( - forecastId: UInt, - slotAdjustments: List, - cause: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun modifyForecastRequest(forecastId: UInt + ,slotAdjustments: List + ,cause: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -247,13 +270,13 @@ class DeviceEnergyManagementCluster( val TAG_SLOT_ADJUSTMENTS_REQ: Int = 1 tlvWriter.startArray(ContextSpecificTag(TAG_SLOT_ADJUSTMENTS_REQ)) - for (item in slotAdjustments.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in slotAdjustments.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_CAUSE_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -267,11 +290,9 @@ class DeviceEnergyManagementCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun requestConstraintBasedForecast( - constraints: List, - cause: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun requestConstraintBasedForecast(constraints: List + ,cause: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -279,13 +300,13 @@ class DeviceEnergyManagementCluster( val TAG_CONSTRAINTS_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_CONSTRAINTS_REQ)) - for (item in constraints.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in constraints.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_CAUSE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -303,7 +324,7 @@ class DeviceEnergyManagementCluster( val commandId: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -316,35 +337,42 @@ class DeviceEnergyManagementCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readESATypeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readESATypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Esatype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Esatype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -353,37 +381,35 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Esatype attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Esatype attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -395,37 +421,44 @@ class DeviceEnergyManagementCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readESACanGenerateAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readESACanGenerateAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Esacangenerate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Esacangenerate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -434,38 +467,34 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Esacangenerate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Esacangenerate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -478,37 +507,44 @@ class DeviceEnergyManagementCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readESAStateAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readESAStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Esastate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Esastate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -517,37 +553,35 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Esastate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Esastate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -559,37 +593,44 @@ class DeviceEnergyManagementCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAbsMinPowerAttribute(): Long { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAbsMinPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Absminpower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Absminpower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) + return decodedValue } @@ -598,37 +639,35 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Absminpower attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Absminpower attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -640,37 +679,44 @@ class DeviceEnergyManagementCluster( emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAbsMaxPowerAttribute(): Long { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAbsMaxPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Absmaxpower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Absmaxpower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) + return decodedValue } @@ -679,37 +725,35 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Absmaxpower attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Absmaxpower attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -721,52 +765,58 @@ class DeviceEnergyManagementCluster( emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPowerAdjustmentCapabilityAttribute(): PowerAdjustmentCapabilityAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPowerAdjustmentCapabilityAttribute(): PowerAdjustmentCapabilityAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Poweradjustmentcapability attribute not found in response" } + } + + requireNotNull(attributeData) { + "Poweradjustmentcapability attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null + val decodedValue: List? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PowerAdjustmentCapabilityAttribute(decodedValue) } @@ -776,113 +826,110 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PowerAdjustmentCapabilityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PowerAdjustmentCapabilityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Poweradjustmentcapability attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Poweradjustmentcapability attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: List? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(PowerAdjustmentCapabilityAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(PowerAdjustmentCapabilityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readForecastAttribute(): ForecastAttribute { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readForecastAttribute(): ForecastAttribute {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Forecast attribute not found in response" } + } + + requireNotNull(attributeData) { + "Forecast attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: DeviceEnergyManagementClusterForecastStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: DeviceEnergyManagementClusterForecastStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ForecastAttribute(decodedValue) } @@ -892,93 +939,99 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ForecastAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ForecastAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Forecast attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Forecast attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: DeviceEnergyManagementClusterForecastStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ForecastAttributeSubscriptionState.Success(it)) } + val decodedValue: DeviceEnergyManagementClusterForecastStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ForecastAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ForecastAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOptOutStateAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOptOutStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Optoutstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Optoutstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -988,90 +1041,96 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Optoutstate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Optoutstate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1081,50 +1140,45 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1132,43 +1186,49 @@ class DeviceEnergyManagementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1178,50 +1238,45 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1229,43 +1284,49 @@ class DeviceEnergyManagementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1275,48 +1336,45 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1324,43 +1382,49 @@ class DeviceEnergyManagementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1370,48 +1434,45 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1419,37 +1480,44 @@ class DeviceEnergyManagementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1458,37 +1526,35 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1500,37 +1566,44 @@ class DeviceEnergyManagementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1539,38 +1612,34 @@ class DeviceEnergyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1583,7 +1652,7 @@ class DeviceEnergyManagementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt index 0838a9e113ed40..3c04515cd4c86d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt @@ -17,85 +17,112 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DiagnosticLogsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { +class DiagnosticLogsCluster(private val controller: MatterController, private val endpointId: UShort) { class RetrieveLogsResponse( - val status: UByte, - val logContent: ByteArray, - val UTCTimeStamp: ULong?, + val status: UByte, + val logContent: ByteArray, + val UTCTimeStamp: ULong?, val timeSinceBoot: ULong? ) - - class GeneratedCommandListAttribute(val value: List) +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun retrieveLogsRequest( - intent: UByte, - requestedProtocol: UByte, - transferFileDesignator: String?, - timedInvokeTimeout: Duration? = null - ): RetrieveLogsResponse { + suspend fun retrieveLogsRequest(intent: UByte + ,requestedProtocol: UByte + ,transferFileDesignator: String? + ,timedInvokeTimeout: Duration? = null): RetrieveLogsResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -110,7 +137,7 @@ class DiagnosticLogsCluster( val TAG_TRANSFER_FILE_DESIGNATOR_REQ: Int = 2 transferFileDesignator?.let { tlvWriter.put(ContextSpecificTag(TAG_TRANSFER_FILE_DESIGNATOR_REQ), transferFileDesignator) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -127,65 +154,70 @@ class DiagnosticLogsCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_LOG_CONTENT: Int = 1 var logContent_decoded: ByteArray? = null - + val TAG_U_T_C_TIME_STAMP: Int = 2 var UTCTimeStamp_decoded: ULong? = null - + val TAG_TIME_SINCE_BOOT: Int = 3 var timeSinceBoot_decoded: ULong? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_LOG_CONTENT)) { - logContent_decoded = tlvReader.getByteArray(tag) - } - - if (tag == ContextSpecificTag(TAG_U_T_C_TIME_STAMP)) { - UTCTimeStamp_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_LOG_CONTENT)) {logContent_decoded = tlvReader.getByteArray(tag)} + + if (tag == ContextSpecificTag(TAG_U_T_C_TIME_STAMP)) {UTCTimeStamp_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getULong(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_TIME_SINCE_BOOT)) { - timeSinceBoot_decoded = + tlvReader.getULong(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_TIME_SINCE_BOOT)) {timeSinceBoot_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getULong(tag) - } else { - null - } - } - } else { + tlvReader.getULong(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (logContent_decoded == null) { - throw IllegalStateException("logContent not found in TLV") + throw IllegalStateException("logContent not found in TLV") } + + + + + tlvReader.exitContainer() @@ -196,41 +228,47 @@ class DiagnosticLogsCluster( timeSinceBoot_decoded ) } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -240,50 +278,45 @@ class DiagnosticLogsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -291,43 +324,49 @@ class DiagnosticLogsCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -337,50 +376,45 @@ class DiagnosticLogsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -388,43 +422,49 @@ class DiagnosticLogsCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -434,48 +474,45 @@ class DiagnosticLogsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -483,43 +520,49 @@ class DiagnosticLogsCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -529,48 +572,45 @@ class DiagnosticLogsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -578,37 +618,44 @@ class DiagnosticLogsCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -617,37 +664,35 @@ class DiagnosticLogsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -659,37 +704,44 @@ class DiagnosticLogsCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -698,38 +750,34 @@ class DiagnosticLogsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -742,7 +790,7 @@ class DiagnosticLogsCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt index b13261710a3be1..75b1724e213003 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt @@ -17,80 +17,110 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherAlarmCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class DishwasherAlarmCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun reset(alarms: UInt, timedInvokeTimeout: Duration? = null) { + suspend fun reset(alarms: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ALARMS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ALARMS_REQ), alarms) + tlvWriter.put(ContextSpecificTag(TAG_ALARMS_REQ), alarms) tlvWriter.endStructure() val request: InvokeRequest = @@ -104,14 +134,15 @@ class DishwasherAlarmCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun modifyEnabledAlarms(mask: UInt, timedInvokeTimeout: Duration? = null) { + suspend fun modifyEnabledAlarms(mask: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_MASK_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_MASK_REQ), mask) + tlvWriter.put(ContextSpecificTag(TAG_MASK_REQ), mask) tlvWriter.endStructure() val request: InvokeRequest = @@ -124,35 +155,42 @@ class DishwasherAlarmCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readMaskAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Mask attribute not found in response" } + } + + requireNotNull(attributeData) { + "Mask attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -161,37 +199,35 @@ class DishwasherAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Mask attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Mask attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -203,41 +239,47 @@ class DishwasherAlarmCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLatchAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLatchAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Latch attribute not found in response" } + } + + requireNotNull(attributeData) { + "Latch attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -247,84 +289,91 @@ class DishwasherAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Latch attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Latch attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStateAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "State attribute not found in response" } + } + + requireNotNull(attributeData) { + "State attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -333,37 +382,35 @@ class DishwasherAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "State attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "State attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -375,37 +422,44 @@ class DishwasherAlarmCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportedAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supported attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supported attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -414,37 +468,35 @@ class DishwasherAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Supported attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supported attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -456,43 +508,49 @@ class DishwasherAlarmCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -502,50 +560,45 @@ class DishwasherAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -553,43 +606,49 @@ class DishwasherAlarmCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -599,50 +658,45 @@ class DishwasherAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -650,43 +704,49 @@ class DishwasherAlarmCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -696,48 +756,45 @@ class DishwasherAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -745,43 +802,49 @@ class DishwasherAlarmCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -791,48 +854,45 @@ class DishwasherAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -840,37 +900,44 @@ class DishwasherAlarmCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -879,37 +946,35 @@ class DishwasherAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -921,37 +986,44 @@ class DishwasherAlarmCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -960,38 +1032,34 @@ class DishwasherAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1004,7 +1072,7 @@ class DishwasherAlarmCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt index 84be2a10cc560a..b9223830ec6740 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt @@ -17,120 +17,154 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherModeCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ChangeToModeResponse(val status: UByte, val statusText: String?) - - class SupportedModesAttribute(val value: List) +class DishwasherModeCluster(private val controller: MatterController, private val endpointId: UShort) { + class ChangeToModeResponse( + val status: UByte, + val statusText: String? + ) +class SupportedModesAttribute( + val value: List + ) sealed class SupportedModesAttributeSubscriptionState { - data class Success(val value: List) : - SupportedModesAttributeSubscriptionState() - + data class Success( + val value: List + ) : SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } - - class StartUpModeAttribute(val value: UByte?) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } +class StartUpModeAttribute( + val value: UByte? + ) sealed class StartUpModeAttributeSubscriptionState { - data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } - - class OnModeAttribute(val value: UByte?) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } +class OnModeAttribute( + val value: UByte? + ) sealed class OnModeAttributeSubscriptionState { - data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeout: Duration? = null - ): ChangeToModeResponse { + suspend fun changeToMode(newMode: UByte + ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -147,77 +181,92 @@ class DishwasherModeCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { - statusText_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return ChangeToModeResponse(status_decoded, statusText_decoded) + return ChangeToModeResponse( + status_decoded, + statusText_decoded + ) } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return SupportedModesAttribute(decodedValue) } @@ -227,50 +276,45 @@ class DishwasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedModesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -278,37 +322,44 @@ class DishwasherModeCluster( emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -317,37 +368,35 @@ class DishwasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -359,66 +408,76 @@ class DishwasherModeCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStartUpModeAttribute(): StartUpModeAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Startupmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Startupmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -440,7 +499,7 @@ class DishwasherModeCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -448,118 +507,128 @@ class DishwasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StartUpModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Startupmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(StartUpModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOnModeAttribute(): OnModeAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Onmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Onmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -581,7 +650,7 @@ class DishwasherModeCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -589,95 +658,101 @@ class DishwasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OnModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Onmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OnModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -687,50 +762,45 @@ class DishwasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -738,43 +808,49 @@ class DishwasherModeCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -784,50 +860,45 @@ class DishwasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -835,43 +906,49 @@ class DishwasherModeCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -881,48 +958,45 @@ class DishwasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -930,43 +1004,49 @@ class DishwasherModeCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -976,48 +1056,45 @@ class DishwasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1025,37 +1102,44 @@ class DishwasherModeCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1064,37 +1148,35 @@ class DishwasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1106,37 +1188,44 @@ class DishwasherModeCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1145,38 +1234,34 @@ class DishwasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1189,7 +1274,7 @@ class DishwasherModeCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt index f0a27f30273c39..3a8cd092c9d620 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt @@ -17,218 +17,257 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class DoorLockCluster(private val controller: MatterController, private val endpointId: UShort) { class GetWeekDayScheduleResponse( - val weekDayIndex: UByte, - val userIndex: UShort, - val status: UByte, - val daysMask: UByte?, - val startHour: UByte?, - val startMinute: UByte?, - val endHour: UByte?, + val weekDayIndex: UByte, + val userIndex: UShort, + val status: UByte, + val daysMask: UByte?, + val startHour: UByte?, + val startMinute: UByte?, + val endHour: UByte?, val endMinute: UByte? ) class GetYearDayScheduleResponse( - val yearDayIndex: UByte, - val userIndex: UShort, - val status: UByte, - val localStartTime: UInt?, + val yearDayIndex: UByte, + val userIndex: UShort, + val status: UByte, + val localStartTime: UInt?, val localEndTime: UInt? ) class GetHolidayScheduleResponse( - val holidayIndex: UByte, - val status: UByte, - val localStartTime: UInt?, - val localEndTime: UInt?, + val holidayIndex: UByte, + val status: UByte, + val localStartTime: UInt?, + val localEndTime: UInt?, val operatingMode: UByte? ) class GetUserResponse( - val userIndex: UShort, - val userName: String?, - val userUniqueID: UInt?, - val userStatus: UByte?, - val userType: UByte?, - val credentialRule: UByte?, - val credentials: List?, - val creatorFabricIndex: UByte?, - val lastModifiedFabricIndex: UByte?, + val userIndex: UShort, + val userName: String?, + val userUniqueID: UInt?, + val userStatus: UByte?, + val userType: UByte?, + val credentialRule: UByte?, + val credentials: List?, + val creatorFabricIndex: UByte?, + val lastModifiedFabricIndex: UByte?, val nextUserIndex: UShort? ) class SetCredentialResponse( - val status: UByte, - val userIndex: UShort?, + val status: UByte, + val userIndex: UShort?, val nextCredentialIndex: UShort? ) class GetCredentialStatusResponse( - val credentialExists: Boolean, - val userIndex: UShort?, - val creatorFabricIndex: UByte?, - val lastModifiedFabricIndex: UByte?, + val credentialExists: Boolean, + val userIndex: UShort?, + val creatorFabricIndex: UByte?, + val lastModifiedFabricIndex: UByte?, val nextCredentialIndex: UShort? ) - - class LockStateAttribute(val value: UByte?) +class LockStateAttribute( + val value: UByte? + ) sealed class LockStateAttributeSubscriptionState { - data class Success(val value: UByte?) : LockStateAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : LockStateAttributeSubscriptionState() + data class Error(val exception: Exception) : LockStateAttributeSubscriptionState() - object SubscriptionEstablished : LockStateAttributeSubscriptionState() - } - - class DoorStateAttribute(val value: UByte?) + object SubscriptionEstablished : LockStateAttributeSubscriptionState() + } +class DoorStateAttribute( + val value: UByte? + ) sealed class DoorStateAttributeSubscriptionState { - data class Success(val value: UByte?) : DoorStateAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : DoorStateAttributeSubscriptionState() + data class Error(val exception: Exception) : DoorStateAttributeSubscriptionState() - object SubscriptionEstablished : DoorStateAttributeSubscriptionState() - } - - class AliroReaderVerificationKeyAttribute(val value: ByteArray?) + object SubscriptionEstablished : DoorStateAttributeSubscriptionState() + } +class AliroReaderVerificationKeyAttribute( + val value: ByteArray? + ) sealed class AliroReaderVerificationKeyAttributeSubscriptionState { - data class Success(val value: ByteArray?) : - AliroReaderVerificationKeyAttributeSubscriptionState() - - data class Error(val exception: Exception) : - AliroReaderVerificationKeyAttributeSubscriptionState() - - object SubscriptionEstablished : AliroReaderVerificationKeyAttributeSubscriptionState() - } - - class AliroReaderGroupIdentifierAttribute(val value: ByteArray?) + data class Success( + val value: ByteArray? + ) : AliroReaderVerificationKeyAttributeSubscriptionState() + + data class Error(val exception: Exception) : AliroReaderVerificationKeyAttributeSubscriptionState() + + object SubscriptionEstablished : AliroReaderVerificationKeyAttributeSubscriptionState() + } +class AliroReaderGroupIdentifierAttribute( + val value: ByteArray? + ) sealed class AliroReaderGroupIdentifierAttributeSubscriptionState { - data class Success(val value: ByteArray?) : - AliroReaderGroupIdentifierAttributeSubscriptionState() - - data class Error(val exception: Exception) : - AliroReaderGroupIdentifierAttributeSubscriptionState() - - object SubscriptionEstablished : AliroReaderGroupIdentifierAttributeSubscriptionState() - } - - class AliroExpeditedTransactionSupportedProtocolVersionsAttribute(val value: List?) + data class Success( + val value: ByteArray? + ) : AliroReaderGroupIdentifierAttributeSubscriptionState() + + data class Error(val exception: Exception) : AliroReaderGroupIdentifierAttributeSubscriptionState() + + object SubscriptionEstablished : AliroReaderGroupIdentifierAttributeSubscriptionState() + } +class AliroExpeditedTransactionSupportedProtocolVersionsAttribute( + val value: List? + ) sealed class AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState { - data class Success(val value: List?) : - AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() - - data class Error(val exception: Exception) : - AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() - - object SubscriptionEstablished : - AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() - } - - class AliroGroupResolvingKeyAttribute(val value: ByteArray?) + data class Success( + val value: List? + ) : AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() + + data class Error(val exception: Exception) : AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() + + object SubscriptionEstablished : AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() + } +class AliroGroupResolvingKeyAttribute( + val value: ByteArray? + ) sealed class AliroGroupResolvingKeyAttributeSubscriptionState { - data class Success(val value: ByteArray?) : AliroGroupResolvingKeyAttributeSubscriptionState() - + data class Success( + val value: ByteArray? + ) : AliroGroupResolvingKeyAttributeSubscriptionState() + data class Error(val exception: Exception) : AliroGroupResolvingKeyAttributeSubscriptionState() - object SubscriptionEstablished : AliroGroupResolvingKeyAttributeSubscriptionState() - } - - class AliroSupportedBLEUWBProtocolVersionsAttribute(val value: List?) + object SubscriptionEstablished : AliroGroupResolvingKeyAttributeSubscriptionState() + } +class AliroSupportedBLEUWBProtocolVersionsAttribute( + val value: List? + ) sealed class AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState { - data class Success(val value: List?) : - AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() - - data class Error(val exception: Exception) : - AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() - - object SubscriptionEstablished : - AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + data class Success( + val value: List? + ) : AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() + + data class Error(val exception: Exception) : AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() + + object SubscriptionEstablished : AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun lockDoor(PINCode: ByteArray?, timedInvokeTimeout: Duration) { + suspend fun lockDoor(PINCode: ByteArray? + ,timedInvokeTimeout: Duration) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } + PINCode?.let { + tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -242,14 +281,17 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unlockDoor(PINCode: ByteArray?, timedInvokeTimeout: Duration) { + suspend fun unlockDoor(PINCode: ByteArray? + ,timedInvokeTimeout: Duration) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } + PINCode?.let { + tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -263,11 +305,9 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unlockWithTimeout( - timeout: UShort, - PINCode: ByteArray?, - timedInvokeTimeout: Duration - ) { + suspend fun unlockWithTimeout(timeout: UShort + ,PINCode: ByteArray? + ,timedInvokeTimeout: Duration) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -277,7 +317,9 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvWriter.put(ContextSpecificTag(TAG_TIMEOUT_REQ), timeout) val TAG_P_I_N_CODE_REQ: Int = 1 - PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } + PINCode?.let { + tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -291,16 +333,14 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setWeekDaySchedule( - weekDayIndex: UByte, - userIndex: UShort, - daysMask: UByte, - startHour: UByte, - startMinute: UByte, - endHour: UByte, - endMinute: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setWeekDaySchedule(weekDayIndex: UByte + ,userIndex: UShort + ,daysMask: UByte + ,startHour: UByte + ,startMinute: UByte + ,endHour: UByte + ,endMinute: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 11u val tlvWriter = TlvWriter() @@ -325,7 +365,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvWriter.put(ContextSpecificTag(TAG_END_HOUR_REQ), endHour) val TAG_END_MINUTE_REQ: Int = 6 - tlvWriter.put(ContextSpecificTag(TAG_END_MINUTE_REQ), endMinute) + tlvWriter.put(ContextSpecificTag(TAG_END_MINUTE_REQ), endMinute) tlvWriter.endStructure() val request: InvokeRequest = @@ -339,11 +379,9 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getWeekDaySchedule( - weekDayIndex: UByte, - userIndex: UShort, - timedInvokeTimeout: Duration? = null - ): GetWeekDayScheduleResponse { + suspend fun getWeekDaySchedule(weekDayIndex: UByte + ,userIndex: UShort + ,timedInvokeTimeout: Duration? = null): GetWeekDayScheduleResponse { val commandId: UInt = 12u val tlvWriter = TlvWriter() @@ -353,7 +391,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvWriter.put(ContextSpecificTag(TAG_WEEK_DAY_INDEX_REQ), weekDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -370,127 +408,131 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvReader.enterStructure(AnonymousTag) val TAG_WEEK_DAY_INDEX: Int = 0 var weekDayIndex_decoded: UByte? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_STATUS: Int = 2 var status_decoded: UByte? = null - + val TAG_DAYS_MASK: Int = 3 var daysMask_decoded: UByte? = null - + val TAG_START_HOUR: Int = 4 var startHour_decoded: UByte? = null - + val TAG_START_MINUTE: Int = 5 var startMinute_decoded: UByte? = null - + val TAG_END_HOUR: Int = 6 var endHour_decoded: UByte? = null - + val TAG_END_MINUTE: Int = 7 var endMinute_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_WEEK_DAY_INDEX)) { - weekDayIndex_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) { - userIndex_decoded = tlvReader.getUShort(tag) - } - - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DAYS_MASK)) { - daysMask_decoded = + + if (tag == ContextSpecificTag(TAG_WEEK_DAY_INDEX)) {weekDayIndex_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DAYS_MASK)) {daysMask_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_START_HOUR)) { - startHour_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_START_HOUR)) {startHour_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_START_MINUTE)) { - startMinute_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_START_MINUTE)) {startMinute_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_END_HOUR)) { - endHour_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_END_HOUR)) {endHour_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_END_MINUTE)) { - endMinute_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_END_MINUTE)) {endMinute_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } else { + tlvReader.getUByte(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (weekDayIndex_decoded == null) { - throw IllegalStateException("weekDayIndex not found in TLV") + throw IllegalStateException("weekDayIndex not found in TLV") } - + + if (userIndex_decoded == null) { - throw IllegalStateException("userIndex not found in TLV") + throw IllegalStateException("userIndex not found in TLV") } - + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") - } + throw IllegalStateException("status not found in TLV") + } + + + + + + + + + + + tlvReader.exitContainer() @@ -506,11 +548,9 @@ class DoorLockCluster(private val controller: MatterController, private val endp ) } - suspend fun clearWeekDaySchedule( - weekDayIndex: UByte, - userIndex: UShort, - timedInvokeTimeout: Duration? = null - ) { + suspend fun clearWeekDaySchedule(weekDayIndex: UByte + ,userIndex: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 13u val tlvWriter = TlvWriter() @@ -520,7 +560,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvWriter.put(ContextSpecificTag(TAG_WEEK_DAY_INDEX_REQ), weekDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -534,13 +574,11 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setYearDaySchedule( - yearDayIndex: UByte, - userIndex: UShort, - localStartTime: UInt, - localEndTime: UInt, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setYearDaySchedule(yearDayIndex: UByte + ,userIndex: UShort + ,localStartTime: UInt + ,localEndTime: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 14u val tlvWriter = TlvWriter() @@ -556,7 +594,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvWriter.put(ContextSpecificTag(TAG_LOCAL_START_TIME_REQ), localStartTime) val TAG_LOCAL_END_TIME_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_LOCAL_END_TIME_REQ), localEndTime) + tlvWriter.put(ContextSpecificTag(TAG_LOCAL_END_TIME_REQ), localEndTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -570,11 +608,9 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getYearDaySchedule( - yearDayIndex: UByte, - userIndex: UShort, - timedInvokeTimeout: Duration? = null - ): GetYearDayScheduleResponse { + suspend fun getYearDaySchedule(yearDayIndex: UByte + ,userIndex: UShort + ,timedInvokeTimeout: Duration? = null): GetYearDayScheduleResponse { val commandId: UInt = 15u val tlvWriter = TlvWriter() @@ -584,7 +620,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvWriter.put(ContextSpecificTag(TAG_YEAR_DAY_INDEX_REQ), yearDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -601,76 +637,80 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvReader.enterStructure(AnonymousTag) val TAG_YEAR_DAY_INDEX: Int = 0 var yearDayIndex_decoded: UByte? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_STATUS: Int = 2 var status_decoded: UByte? = null - + val TAG_LOCAL_START_TIME: Int = 3 var localStartTime_decoded: UInt? = null - + val TAG_LOCAL_END_TIME: Int = 4 var localEndTime_decoded: UInt? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_YEAR_DAY_INDEX)) { - yearDayIndex_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) { - userIndex_decoded = tlvReader.getUShort(tag) - } - - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) { - localStartTime_decoded = + + if (tag == ContextSpecificTag(TAG_YEAR_DAY_INDEX)) {yearDayIndex_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) {localStartTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) { - localEndTime_decoded = + tlvReader.getUInt(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) {localEndTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - } - } else { + tlvReader.getUInt(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (yearDayIndex_decoded == null) { - throw IllegalStateException("yearDayIndex not found in TLV") + throw IllegalStateException("yearDayIndex not found in TLV") } - + + if (userIndex_decoded == null) { - throw IllegalStateException("userIndex not found in TLV") + throw IllegalStateException("userIndex not found in TLV") } - + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + + + tlvReader.exitContainer() @@ -683,11 +723,9 @@ class DoorLockCluster(private val controller: MatterController, private val endp ) } - suspend fun clearYearDaySchedule( - yearDayIndex: UByte, - userIndex: UShort, - timedInvokeTimeout: Duration? = null - ) { + suspend fun clearYearDaySchedule(yearDayIndex: UByte + ,userIndex: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 16u val tlvWriter = TlvWriter() @@ -697,7 +735,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvWriter.put(ContextSpecificTag(TAG_YEAR_DAY_INDEX_REQ), yearDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -711,13 +749,11 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setHolidaySchedule( - holidayIndex: UByte, - localStartTime: UInt, - localEndTime: UInt, - operatingMode: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setHolidaySchedule(holidayIndex: UByte + ,localStartTime: UInt + ,localEndTime: UInt + ,operatingMode: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 17u val tlvWriter = TlvWriter() @@ -733,7 +769,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvWriter.put(ContextSpecificTag(TAG_LOCAL_END_TIME_REQ), localEndTime) val TAG_OPERATING_MODE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPERATING_MODE_REQ), operatingMode) + tlvWriter.put(ContextSpecificTag(TAG_OPERATING_MODE_REQ), operatingMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -747,17 +783,15 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getHolidaySchedule( - holidayIndex: UByte, - timedInvokeTimeout: Duration? = null - ): GetHolidayScheduleResponse { + suspend fun getHolidaySchedule(holidayIndex: UByte + ,timedInvokeTimeout: Duration? = null): GetHolidayScheduleResponse { val commandId: UInt = 18u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_HOLIDAY_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) + tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -774,82 +808,87 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvReader.enterStructure(AnonymousTag) val TAG_HOLIDAY_INDEX: Int = 0 var holidayIndex_decoded: UByte? = null - + val TAG_STATUS: Int = 1 var status_decoded: UByte? = null - + val TAG_LOCAL_START_TIME: Int = 2 var localStartTime_decoded: UInt? = null - + val TAG_LOCAL_END_TIME: Int = 3 var localEndTime_decoded: UInt? = null - + val TAG_OPERATING_MODE: Int = 4 var operatingMode_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_HOLIDAY_INDEX)) { - holidayIndex_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) { - localStartTime_decoded = + + if (tag == ContextSpecificTag(TAG_HOLIDAY_INDEX)) {holidayIndex_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) {localStartTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) { - localEndTime_decoded = + tlvReader.getUInt(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) {localEndTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_OPERATING_MODE)) { - operatingMode_decoded = + tlvReader.getUInt(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_OPERATING_MODE)) {operatingMode_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } else { + tlvReader.getUByte(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (holidayIndex_decoded == null) { - throw IllegalStateException("holidayIndex not found in TLV") + throw IllegalStateException("holidayIndex not found in TLV") } - + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + + + + + tlvReader.exitContainer() @@ -862,14 +901,15 @@ class DoorLockCluster(private val controller: MatterController, private val endp ) } - suspend fun clearHolidaySchedule(holidayIndex: UByte, timedInvokeTimeout: Duration? = null) { + suspend fun clearHolidaySchedule(holidayIndex: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 19u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_HOLIDAY_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) + tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -883,16 +923,14 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setUser( - operationType: UByte, - userIndex: UShort, - userName: String?, - userUniqueID: UInt?, - userStatus: UByte?, - userType: UByte?, - credentialRule: UByte?, - timedInvokeTimeout: Duration - ) { + suspend fun setUser(operationType: UByte + ,userIndex: UShort + ,userName: String? + ,userUniqueID: UInt? + ,userStatus: UByte? + ,userType: UByte? + ,credentialRule: UByte? + ,timedInvokeTimeout: Duration) { val commandId: UInt = 26u val tlvWriter = TlvWriter() @@ -905,21 +943,29 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) val TAG_USER_NAME_REQ: Int = 2 - userName?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_NAME_REQ), userName) } + userName?.let { + tlvWriter.put(ContextSpecificTag(TAG_USER_NAME_REQ), userName) + } val TAG_USER_UNIQUE_I_D_REQ: Int = 3 - userUniqueID?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_UNIQUE_I_D_REQ), userUniqueID) } + userUniqueID?.let { + tlvWriter.put(ContextSpecificTag(TAG_USER_UNIQUE_I_D_REQ), userUniqueID) + } val TAG_USER_STATUS_REQ: Int = 4 - userStatus?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) } + userStatus?.let { + tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) + } val TAG_USER_TYPE_REQ: Int = 5 - userType?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) } + userType?.let { + tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) + } val TAG_CREDENTIAL_RULE_REQ: Int = 6 credentialRule?.let { tlvWriter.put(ContextSpecificTag(TAG_CREDENTIAL_RULE_REQ), credentialRule) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -933,14 +979,15 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getUser(userIndex: UShort, timedInvokeTimeout: Duration? = null): GetUserResponse { + suspend fun getUser(userIndex: UShort + ,timedInvokeTimeout: Duration? = null): GetUserResponse { val commandId: UInt = 27u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_USER_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -957,188 +1004,194 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvReader.enterStructure(AnonymousTag) val TAG_USER_INDEX: Int = 0 var userIndex_decoded: UShort? = null - + val TAG_USER_NAME: Int = 1 var userName_decoded: String? = null - + val TAG_USER_UNIQUE_I_D: Int = 2 var userUniqueID_decoded: UInt? = null - + val TAG_USER_STATUS: Int = 3 var userStatus_decoded: UByte? = null - + val TAG_USER_TYPE: Int = 4 var userType_decoded: UByte? = null - + val TAG_CREDENTIAL_RULE: Int = 5 var credentialRule_decoded: UByte? = null - + val TAG_CREDENTIALS: Int = 6 var credentials_decoded: List? = null - + val TAG_CREATOR_FABRIC_INDEX: Int = 7 var creatorFabricIndex_decoded: UByte? = null - + val TAG_LAST_MODIFIED_FABRIC_INDEX: Int = 8 var lastModifiedFabricIndex_decoded: UByte? = null - + val TAG_NEXT_USER_INDEX: Int = 9 var nextUserIndex_decoded: UShort? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_USER_INDEX)) { - userIndex_decoded = tlvReader.getUShort(tag) - } - - if (tag == ContextSpecificTag(TAG_USER_NAME)) { - userName_decoded = + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_USER_NAME)) {userName_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getString(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_USER_UNIQUE_I_D)) { - userUniqueID_decoded = + tlvReader.getString(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_USER_UNIQUE_I_D)) {userUniqueID_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUInt(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_USER_STATUS)) { - userStatus_decoded = + tlvReader.getUInt(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_USER_STATUS)) {userStatus_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_USER_TYPE)) { - userType_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_USER_TYPE)) {userType_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_CREDENTIAL_RULE)) { - credentialRule_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_CREDENTIAL_RULE)) {credentialRule_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_CREDENTIALS)) { - credentials_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_CREDENTIALS)) {credentials_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) { - creatorFabricIndex_decoded = + buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) {creatorFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) { - lastModifiedFabricIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) {lastModifiedFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NEXT_USER_INDEX)) { - nextUserIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_NEXT_USER_INDEX)) {nextUserIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } else { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + + else { tlvReader.skipElement() } } + + if (userIndex_decoded == null) { - throw IllegalStateException("userIndex not found in TLV") - } + throw IllegalStateException("userIndex not found in TLV") + } + + + + + + + + + + + + + + + + + + + tlvReader.exitContainer() @@ -1156,14 +1209,15 @@ class DoorLockCluster(private val controller: MatterController, private val endp ) } - suspend fun clearUser(userIndex: UShort, timedInvokeTimeout: Duration) { + suspend fun clearUser(userIndex: UShort + ,timedInvokeTimeout: Duration) { val commandId: UInt = 29u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_USER_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -1177,15 +1231,13 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setCredential( - operationType: UByte, - credential: DoorLockClusterCredentialStruct, - credentialData: ByteArray, - userIndex: UShort?, - userStatus: UByte?, - userType: UByte?, - timedInvokeTimeout: Duration - ): SetCredentialResponse { + suspend fun setCredential(operationType: UByte + ,credential: DoorLockClusterCredentialStruct + ,credentialData: ByteArray + ,userIndex: UShort? + ,userStatus: UByte? + ,userType: UByte? + ,timedInvokeTimeout: Duration): SetCredentialResponse { val commandId: UInt = 34u val tlvWriter = TlvWriter() @@ -1201,13 +1253,19 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvWriter.put(ContextSpecificTag(TAG_CREDENTIAL_DATA_REQ), credentialData) val TAG_USER_INDEX_REQ: Int = 3 - userIndex?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) } + userIndex?.let { + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + } val TAG_USER_STATUS_REQ: Int = 4 - userStatus?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) } + userStatus?.let { + tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) + } val TAG_USER_TYPE_REQ: Int = 5 - userType?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) } + userType?.let { + tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1224,73 +1282,81 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_NEXT_CREDENTIAL_INDEX: Int = 2 var nextCredentialIndex_decoded: UShort? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) { - userIndex_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) { - nextCredentialIndex_decoded = + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) {nextCredentialIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } else { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + + + tlvReader.exitContainer() - return SetCredentialResponse(status_decoded, userIndex_decoded, nextCredentialIndex_decoded) + return SetCredentialResponse( + status_decoded, + userIndex_decoded, + nextCredentialIndex_decoded + ) } - suspend fun getCredentialStatus( - credential: DoorLockClusterCredentialStruct, - timedInvokeTimeout: Duration? = null - ): GetCredentialStatusResponse { + suspend fun getCredentialStatus(credential: DoorLockClusterCredentialStruct + ,timedInvokeTimeout: Duration? = null): GetCredentialStatusResponse { val commandId: UInt = 36u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_CREDENTIAL_REQ: Int = 0 - credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) + credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -1307,92 +1373,98 @@ class DoorLockCluster(private val controller: MatterController, private val endp tlvReader.enterStructure(AnonymousTag) val TAG_CREDENTIAL_EXISTS: Int = 0 var credentialExists_decoded: Boolean? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_CREATOR_FABRIC_INDEX: Int = 2 var creatorFabricIndex_decoded: UByte? = null - + val TAG_LAST_MODIFIED_FABRIC_INDEX: Int = 3 var lastModifiedFabricIndex_decoded: UByte? = null - + val TAG_NEXT_CREDENTIAL_INDEX: Int = 4 var nextCredentialIndex_decoded: UShort? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_CREDENTIAL_EXISTS)) { - credentialExists_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) { - userIndex_decoded = + + if (tag == ContextSpecificTag(TAG_CREDENTIAL_EXISTS)) {credentialExists_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) { - creatorFabricIndex_decoded = + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) {creatorFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) { - lastModifiedFabricIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) {lastModifiedFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) { - nextCredentialIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) {nextCredentialIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } else { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + + else { tlvReader.skipElement() } } + + if (credentialExists_decoded == null) { - throw IllegalStateException("credentialExists not found in TLV") - } + throw IllegalStateException("credentialExists not found in TLV") + } + + + + + + + + + tlvReader.exitContainer() @@ -1405,17 +1477,17 @@ class DoorLockCluster(private val controller: MatterController, private val endp ) } - suspend fun clearCredential( - credential: DoorLockClusterCredentialStruct?, - timedInvokeTimeout: Duration - ) { + suspend fun clearCredential(credential: DoorLockClusterCredentialStruct? + ,timedInvokeTimeout: Duration) { val commandId: UInt = 38u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_CREDENTIAL_REQ: Int = 0 - credential?.let { credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) } + credential?.let { + credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1429,14 +1501,17 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unboltDoor(PINCode: ByteArray?, timedInvokeTimeout: Duration) { + suspend fun unboltDoor(PINCode: ByteArray? + ,timedInvokeTimeout: Duration) { val commandId: UInt = 39u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } + PINCode?.let { + tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1450,13 +1525,11 @@ class DoorLockCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setAliroReaderConfig( - signingKey: ByteArray, - verificationKey: ByteArray, - groupIdentifier: ByteArray, - groupResolvingKey: ByteArray?, - timedInvokeTimeout: Duration - ) { + suspend fun setAliroReaderConfig(signingKey: ByteArray + ,verificationKey: ByteArray + ,groupIdentifier: ByteArray + ,groupResolvingKey: ByteArray? + ,timedInvokeTimeout: Duration) { val commandId: UInt = 40u val tlvWriter = TlvWriter() @@ -1474,7 +1547,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp val TAG_GROUP_RESOLVING_KEY_REQ: Int = 3 groupResolvingKey?.let { tlvWriter.put(ContextSpecificTag(TAG_GROUP_RESOLVING_KEY_REQ), groupResolvingKey) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1492,7 +1565,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp val commandId: UInt = 41u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -1505,40 +1578,46 @@ class DoorLockCluster(private val controller: MatterController, private val endp val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } +suspend fun readLockStateAttribute(): LockStateAttribute {val ATTRIBUTE_ID: UInt = 0u - suspend fun readLockStateAttribute(): LockStateAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lockstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lockstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LockStateAttribute(decodedValue) } @@ -1548,85 +1627,92 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LockStateAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LockStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Lockstate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lockstate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(LockStateAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(LockStateAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LockStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLockTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - suspend fun readLockTypeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Locktype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Locktype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -1635,37 +1721,35 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Locktype attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Locktype attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1677,37 +1761,44 @@ class DoorLockCluster(private val controller: MatterController, private val endp emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActuatorEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 2u - suspend fun readActuatorEnabledAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 2u + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - - val response = controller.read(readRequest) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Actuatorenabled attribute not found in response" } + } + + requireNotNull(attributeData) { + "Actuatorenabled attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -1716,38 +1807,34 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Actuatorenabled attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Actuatorenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1760,46 +1847,52 @@ class DoorLockCluster(private val controller: MatterController, private val endp emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDoorStateAttribute(): DoorStateAttribute {val ATTRIBUTE_ID: UInt = 3u - suspend fun readDoorStateAttribute(): DoorStateAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Doorstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Doorstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return DoorStateAttribute(decodedValue) } @@ -1809,113 +1902,123 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DoorStateAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DoorStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Doorstate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Doorstate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(DoorStateAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(DoorStateAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(DoorStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDoorOpenEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - suspend fun readDoorOpenEventsAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dooropenevents attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dooropenevents attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeDoorOpenEventsAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeDoorOpenEventsAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1937,7 +2040,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDoorOpenEventsAttribute( @@ -1945,110 +2048,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Dooropenevents attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dooropenevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDoorClosedEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u - suspend fun readDoorClosedEventsAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Doorclosedevents attribute not found in response" } + } + + requireNotNull(attributeData) { + "Doorclosedevents attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeDoorClosedEventsAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeDoorClosedEventsAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2070,7 +2181,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDoorClosedEventsAttribute( @@ -2078,110 +2189,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Doorclosedevents attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Doorclosedevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u - suspend fun readOpenPeriodAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Openperiod attribute not found in response" } + } + + requireNotNull(attributeData) { + "Openperiod attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeOpenPeriodAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeOpenPeriodAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2203,7 +2322,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOpenPeriodAttribute( @@ -2211,88 +2330,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Openperiod attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Openperiod attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfTotalUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - suspend fun readNumberOfTotalUsersSupportedAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberoftotaluserssupported attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberoftotaluserssupported attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2302,90 +2427,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberoftotaluserssupported attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberoftotaluserssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfPINUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - suspend fun readNumberOfPINUsersSupportedAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofpinuserssupported attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofpinuserssupported attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2395,90 +2524,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofpinuserssupported attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofpinuserssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfRFIDUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u - suspend fun readNumberOfRFIDUsersSupportedAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 19u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofrfiduserssupported attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofrfiduserssupported attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2488,92 +2621,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofrfiduserssupported attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofrfiduserssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfWeekDaySchedulesSupportedPerUserAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 20u - suspend fun readNumberOfWeekDaySchedulesSupportedPerUserAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 20u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofweekdayschedulessupportedperuser attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofweekdayschedulessupportedperuser attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2583,92 +2718,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofweekdayschedulessupportedperuser attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofweekdayschedulessupportedperuser attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfYearDaySchedulesSupportedPerUserAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 21u - suspend fun readNumberOfYearDaySchedulesSupportedPerUserAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 21u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofyeardayschedulessupportedperuser attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofyeardayschedulessupportedperuser attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2678,92 +2815,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofyeardayschedulessupportedperuser attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofyeardayschedulessupportedperuser attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfHolidaySchedulesSupportedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 22u - suspend fun readNumberOfHolidaySchedulesSupportedAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 22u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofholidayschedulessupported attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofholidayschedulessupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2773,90 +2912,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofholidayschedulessupported attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofholidayschedulessupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxPINCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 23u - suspend fun readMaxPINCodeLengthAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 23u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxpincodelength attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxpincodelength attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2866,90 +3009,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxpincodelength attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxpincodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinPINCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 24u - suspend fun readMinPINCodeLengthAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 24u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minpincodelength attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minpincodelength attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2959,90 +3106,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minpincodelength attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minpincodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxRFIDCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 25u - suspend fun readMaxRFIDCodeLengthAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 25u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxrfidcodelength attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxrfidcodelength attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3052,90 +3203,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxrfidcodelength attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxrfidcodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinRFIDCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u - suspend fun readMinRFIDCodeLengthAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 26u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minrfidcodelength attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minrfidcodelength attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3145,90 +3300,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minrfidcodelength attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minrfidcodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCredentialRulesSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 27u - suspend fun readCredentialRulesSupportAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 27u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Credentialrulessupport attribute not found in response" } + } + + requireNotNull(attributeData) { + "Credentialrulessupport attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3238,92 +3397,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Credentialrulessupport attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Credentialrulessupport attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfCredentialsSupportedPerUserAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 28u - suspend fun readNumberOfCredentialsSupportedPerUserAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 28u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofcredentialssupportedperuser attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofcredentialssupportedperuser attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3333,110 +3494,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofcredentialssupportedperuser attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofcredentialssupportedperuser attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLanguageAttribute(): String? {val ATTRIBUTE_ID: UInt = 33u - suspend fun readLanguageAttribute(): String? { - val ATTRIBUTE_ID: UInt = 33u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Language attribute not found in response" } + } + + requireNotNull(attributeData) { + "Language attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeLanguageAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeLanguageAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3458,7 +3627,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLanguageAttribute( @@ -3466,108 +3635,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Language attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Language attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLEDSettingsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u - suspend fun readLEDSettingsAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 34u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Ledsettings attribute not found in response" } + } + + requireNotNull(attributeData) { + "Ledsettings attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeLEDSettingsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeLEDSettingsAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 34u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3589,7 +3768,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLEDSettingsAttribute( @@ -3597,103 +3776,114 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Ledsettings attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ledsettings attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAutoRelockTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 35u - suspend fun readAutoRelockTimeAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 35u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Autorelocktime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Autorelocktime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } - suspend fun writeAutoRelockTimeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeAutoRelockTimeAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 35u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3715,7 +3905,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAutoRelockTimeAttribute( @@ -3723,38 +3913,34 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Autorelocktime attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Autorelocktime attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3767,61 +3953,71 @@ class DoorLockCluster(private val controller: MatterController, private val endp emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSoundVolumeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 36u - suspend fun readSoundVolumeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 36u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Soundvolume attribute not found in response" } + } + + requireNotNull(attributeData) { + "Soundvolume attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeSoundVolumeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeSoundVolumeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 36u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3843,7 +4039,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSoundVolumeAttribute( @@ -3851,103 +4047,114 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Soundvolume attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Soundvolume attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOperatingModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 37u - suspend fun readOperatingModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 37u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operatingmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operatingmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeOperatingModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOperatingModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 37u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3969,7 +4176,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOperatingModeAttribute( @@ -3977,37 +4184,35 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Operatingmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operatingmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4019,37 +4224,44 @@ class DoorLockCluster(private val controller: MatterController, private val endp emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSupportedOperatingModesAttribute(): UShort {val ATTRIBUTE_ID: UInt = 38u - suspend fun readSupportedOperatingModesAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 38u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedoperatingmodes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedoperatingmodes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -4058,38 +4270,34 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedoperatingmodes attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedoperatingmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -4102,41 +4310,47 @@ class DoorLockCluster(private val controller: MatterController, private val endp emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDefaultConfigurationRegisterAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 39u - suspend fun readDefaultConfigurationRegisterAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 39u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Defaultconfigurationregister attribute not found in response" } + } + + requireNotNull(attributeData) { + "Defaultconfigurationregister attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4146,113 +4360,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Defaultconfigurationregister attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Defaultconfigurationregister attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEnableLocalProgrammingAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 40u - suspend fun readEnableLocalProgrammingAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 40u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Enablelocalprogramming attribute not found in response" } + } + + requireNotNull(attributeData) { + "Enablelocalprogramming attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeEnableLocalProgrammingAttribute( value: Boolean, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 40u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4274,7 +4493,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnableLocalProgrammingAttribute( @@ -4282,113 +4501,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Enablelocalprogramming attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Enablelocalprogramming attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEnableOneTouchLockingAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 41u - suspend fun readEnableOneTouchLockingAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 41u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Enableonetouchlocking attribute not found in response" } + } + + requireNotNull(attributeData) { + "Enableonetouchlocking attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeEnableOneTouchLockingAttribute( value: Boolean, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 41u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4410,7 +4634,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnableOneTouchLockingAttribute( @@ -4418,113 +4642,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Enableonetouchlocking attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Enableonetouchlocking attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEnableInsideStatusLEDAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 42u - suspend fun readEnableInsideStatusLEDAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 42u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Enableinsidestatusled attribute not found in response" } + } + + requireNotNull(attributeData) { + "Enableinsidestatusled attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeEnableInsideStatusLEDAttribute( value: Boolean, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 42u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4546,7 +4775,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnableInsideStatusLEDAttribute( @@ -4554,113 +4783,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Enableinsidestatusled attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Enableinsidestatusled attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEnablePrivacyModeButtonAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 43u - suspend fun readEnablePrivacyModeButtonAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 43u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Enableprivacymodebutton attribute not found in response" } + } + + requireNotNull(attributeData) { + "Enableprivacymodebutton attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeEnablePrivacyModeButtonAttribute( value: Boolean, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 43u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4682,7 +4916,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnablePrivacyModeButtonAttribute( @@ -4690,113 +4924,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 43u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Enableprivacymodebutton attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Enableprivacymodebutton attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLocalProgrammingFeaturesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 44u - suspend fun readLocalProgrammingFeaturesAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 44u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Localprogrammingfeatures attribute not found in response" } + } + + requireNotNull(attributeData) { + "Localprogrammingfeatures attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeLocalProgrammingFeaturesAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 44u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4818,7 +5057,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocalProgrammingFeaturesAttribute( @@ -4826,110 +5065,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 44u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Localprogrammingfeatures attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Localprogrammingfeatures attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWrongCodeEntryLimitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 48u - suspend fun readWrongCodeEntryLimitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 48u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Wrongcodeentrylimit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Wrongcodeentrylimit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeWrongCodeEntryLimitAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeWrongCodeEntryLimitAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4951,7 +5198,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWrongCodeEntryLimitAttribute( @@ -4959,113 +5206,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Wrongcodeentrylimit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Wrongcodeentrylimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 49u - suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 49u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Usercodetemporarydisabletime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Usercodetemporarydisabletime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeUserCodeTemporaryDisableTimeAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5087,7 +5339,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUserCodeTemporaryDisableTimeAttribute( @@ -5095,110 +5347,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Usercodetemporarydisabletime attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Usercodetemporarydisabletime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSendPINOverTheAirAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 50u - suspend fun readSendPINOverTheAirAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 50u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Sendpinovertheair attribute not found in response" } + } + + requireNotNull(attributeData) { + "Sendpinovertheair attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeSendPINOverTheAirAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { + suspend fun writeSendPINOverTheAirAttribute( + value: Boolean, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5220,7 +5480,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSendPINOverTheAirAttribute( @@ -5228,113 +5488,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Sendpinovertheair attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Sendpinovertheair attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRequirePINforRemoteOperationAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 51u - suspend fun readRequirePINforRemoteOperationAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 51u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Requirepinforremoteoperation attribute not found in response" } + } + + requireNotNull(attributeData) { + "Requirepinforremoteoperation attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeRequirePINforRemoteOperationAttribute( value: Boolean, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 51u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5356,7 +5621,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRequirePINforRemoteOperationAttribute( @@ -5364,113 +5629,118 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Requirepinforremoteoperation attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Requirepinforremoteoperation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readExpiringUserTimeoutAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 53u - suspend fun readExpiringUserTimeoutAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 53u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Expiringusertimeout attribute not found in response" } + } + + requireNotNull(attributeData) { + "Expiringusertimeout attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeExpiringUserTimeoutAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 53u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5492,7 +5762,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeExpiringUserTimeoutAttribute( @@ -5500,95 +5770,99 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Expiringusertimeout attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Expiringusertimeout attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAliroReaderVerificationKeyAttribute(): AliroReaderVerificationKeyAttribute {val ATTRIBUTE_ID: UInt = 128u - suspend fun readAliroReaderVerificationKeyAttribute(): AliroReaderVerificationKeyAttribute { - val ATTRIBUTE_ID: UInt = 128u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Aliroreaderverificationkey attribute not found in response" } + } + + requireNotNull(attributeData) { + "Aliroreaderverificationkey attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AliroReaderVerificationKeyAttribute(decodedValue) } @@ -5598,102 +5872,104 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 128u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AliroReaderVerificationKeyAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AliroReaderVerificationKeyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Aliroreaderverificationkey attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Aliroreaderverificationkey attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(AliroReaderVerificationKeyAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(AliroReaderVerificationKeyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAliroReaderGroupIdentifierAttribute(): AliroReaderGroupIdentifierAttribute {val ATTRIBUTE_ID: UInt = 129u - suspend fun readAliroReaderGroupIdentifierAttribute(): AliroReaderGroupIdentifierAttribute { - val ATTRIBUTE_ID: UInt = 129u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Aliroreadergroupidentifier attribute not found in response" } + } + + requireNotNull(attributeData) { + "Aliroreadergroupidentifier attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AliroReaderGroupIdentifierAttribute(decodedValue) } @@ -5703,99 +5979,99 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 129u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AliroReaderGroupIdentifierAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AliroReaderGroupIdentifierAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Aliroreadergroupidentifier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Aliroreadergroupidentifier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(AliroReaderGroupIdentifierAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(AliroReaderGroupIdentifierAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAliroReaderGroupSubIdentifierAttribute(): ByteArray? {val ATTRIBUTE_ID: UInt = 130u - suspend fun readAliroReaderGroupSubIdentifierAttribute(): ByteArray? { - val ATTRIBUTE_ID: UInt = 130u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreadergroupsubidentifier attribute not found in response" + } + + requireNotNull(attributeData) { + "Aliroreadergroupsubidentifier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } + val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5805,99 +6081,100 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 130u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteArraySubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Aliroreadergroupsubidentifier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Aliroreadergroupsubidentifier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } + val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ByteArraySubscriptionState.Success(it)) } + decodedValue?.let { + emit(ByteArraySubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAliroExpeditedTransactionSupportedProtocolVersionsAttribute(): AliroExpeditedTransactionSupportedProtocolVersionsAttribute {val ATTRIBUTE_ID: UInt = 131u - suspend fun readAliroExpeditedTransactionSupportedProtocolVersionsAttribute(): - AliroExpeditedTransactionSupportedProtocolVersionsAttribute { - val ATTRIBUTE_ID: UInt = 131u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in response" + } + + requireNotNull(attributeData) { + "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return AliroExpeditedTransactionSupportedProtocolVersionsAttribute(decodedValue) } @@ -5907,110 +6184,105 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 131u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { - emit( - AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Success( - it - ) - ) + emit(AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { - emit( - AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState - .SubscriptionEstablished - ) + emit(AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAliroGroupResolvingKeyAttribute(): AliroGroupResolvingKeyAttribute {val ATTRIBUTE_ID: UInt = 132u - suspend fun readAliroGroupResolvingKeyAttribute(): AliroGroupResolvingKeyAttribute { - val ATTRIBUTE_ID: UInt = 132u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Alirogroupresolvingkey attribute not found in response" } + } + + requireNotNull(attributeData) { + "Alirogroupresolvingkey attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AliroGroupResolvingKeyAttribute(decodedValue) } @@ -6020,104 +6292,105 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 132u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AliroGroupResolvingKeyAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AliroGroupResolvingKeyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Alirogroupresolvingkey attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Alirogroupresolvingkey attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AliroGroupResolvingKeyAttributeSubscriptionState.Success(it)) } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AliroGroupResolvingKeyAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AliroGroupResolvingKeyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAliroSupportedBLEUWBProtocolVersionsAttribute(): AliroSupportedBLEUWBProtocolVersionsAttribute {val ATTRIBUTE_ID: UInt = 133u - suspend fun readAliroSupportedBLEUWBProtocolVersionsAttribute(): - AliroSupportedBLEUWBProtocolVersionsAttribute { - val ATTRIBUTE_ID: UInt = 133u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirosupportedbleuwbprotocolversions attribute not found in response" + } + + requireNotNull(attributeData) { + "Alirosupportedbleuwbprotocolversions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return AliroSupportedBLEUWBProtocolVersionsAttribute(decodedValue) } @@ -6127,100 +6400,100 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 133u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Alirosupportedbleuwbprotocolversions attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Alirosupportedbleuwbprotocolversions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { emit(AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { - emit( - AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.SubscriptionEstablished - ) + emit(AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAliroBLEAdvertisingVersionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 134u - suspend fun readAliroBLEAdvertisingVersionAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 134u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Alirobleadvertisingversion attribute not found in response" } + } + + requireNotNull(attributeData) { + "Alirobleadvertisingversion attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6230,92 +6503,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 134u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Alirobleadvertisingversion attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Alirobleadvertisingversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfAliroCredentialIssuerKeysSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 135u - suspend fun readNumberOfAliroCredentialIssuerKeysSupportedAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 135u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofalirocredentialissuerkeyssupported attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofalirocredentialissuerkeyssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6325,92 +6600,94 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 135u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofalirocredentialissuerkeyssupported attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofalirocredentialissuerkeyssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfAliroEndpointKeysSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 136u - suspend fun readNumberOfAliroEndpointKeysSupportedAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 136u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofaliroendpointkeyssupported attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofaliroendpointkeyssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6420,92 +6697,96 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 136u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofaliroendpointkeyssupported attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofaliroendpointkeyssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -6515,50 +6796,45 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6566,43 +6842,49 @@ class DoorLockCluster(private val controller: MatterController, private val endp emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -6612,50 +6894,45 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6663,43 +6940,49 @@ class DoorLockCluster(private val controller: MatterController, private val endp emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -6709,48 +6992,45 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -6758,43 +7038,49 @@ class DoorLockCluster(private val controller: MatterController, private val endp emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -6804,48 +7090,45 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -6853,37 +7136,44 @@ class DoorLockCluster(private val controller: MatterController, private val endp emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -6892,37 +7182,35 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6934,37 +7222,44 @@ class DoorLockCluster(private val controller: MatterController, private val endp emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -6973,38 +7268,34 @@ class DoorLockCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7017,7 +7308,7 @@ class DoorLockCluster(private val controller: MatterController, private val endp emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt index 8be25c67fbcda4..ef3d5e33dd62a4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt @@ -17,160 +17,200 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class ElectricalEnergyMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class AccuracyAttribute(val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct) +class ElectricalEnergyMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class AccuracyAttribute( + val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct + ) sealed class AccuracyAttributeSubscriptionState { - data class Success(val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct) : - AccuracyAttributeSubscriptionState() - + data class Success( + val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct + ) : AccuracyAttributeSubscriptionState() + data class Error(val exception: Exception) : AccuracyAttributeSubscriptionState() - object SubscriptionEstablished : AccuracyAttributeSubscriptionState() - } - - class CumulativeEnergyImportedAttribute( + object SubscriptionEstablished : AccuracyAttributeSubscriptionState() + } +class CumulativeEnergyImportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class CumulativeEnergyImportedAttributeSubscriptionState { - data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : - CumulativeEnergyImportedAttributeSubscriptionState() - - data class Error(val exception: Exception) : - CumulativeEnergyImportedAttributeSubscriptionState() - - object SubscriptionEstablished : CumulativeEnergyImportedAttributeSubscriptionState() - } + data class Success( + val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? + ) : CumulativeEnergyImportedAttributeSubscriptionState() + + data class Error(val exception: Exception) : CumulativeEnergyImportedAttributeSubscriptionState() - class CumulativeEnergyExportedAttribute( + object SubscriptionEstablished : CumulativeEnergyImportedAttributeSubscriptionState() + } +class CumulativeEnergyExportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class CumulativeEnergyExportedAttributeSubscriptionState { - data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : - CumulativeEnergyExportedAttributeSubscriptionState() - - data class Error(val exception: Exception) : - CumulativeEnergyExportedAttributeSubscriptionState() - - object SubscriptionEstablished : CumulativeEnergyExportedAttributeSubscriptionState() - } + data class Success( + val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? + ) : CumulativeEnergyExportedAttributeSubscriptionState() + + data class Error(val exception: Exception) : CumulativeEnergyExportedAttributeSubscriptionState() - class PeriodicEnergyImportedAttribute( + object SubscriptionEstablished : CumulativeEnergyExportedAttributeSubscriptionState() + } +class PeriodicEnergyImportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class PeriodicEnergyImportedAttributeSubscriptionState { - data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : - PeriodicEnergyImportedAttributeSubscriptionState() - + data class Success( + val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? + ) : PeriodicEnergyImportedAttributeSubscriptionState() + data class Error(val exception: Exception) : PeriodicEnergyImportedAttributeSubscriptionState() - object SubscriptionEstablished : PeriodicEnergyImportedAttributeSubscriptionState() - } - - class PeriodicEnergyExportedAttribute( + object SubscriptionEstablished : PeriodicEnergyImportedAttributeSubscriptionState() + } +class PeriodicEnergyExportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class PeriodicEnergyExportedAttributeSubscriptionState { - data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : - PeriodicEnergyExportedAttributeSubscriptionState() - + data class Success( + val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? + ) : PeriodicEnergyExportedAttributeSubscriptionState() + data class Error(val exception: Exception) : PeriodicEnergyExportedAttributeSubscriptionState() - object SubscriptionEstablished : PeriodicEnergyExportedAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : PeriodicEnergyExportedAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readAccuracyAttribute(): AccuracyAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readAccuracyAttribute(): AccuracyAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Accuracy attribute not found in response" } + } + + requireNotNull(attributeData) { + "Accuracy attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = - ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader) + return AccuracyAttribute(decodedValue) } @@ -180,45 +220,39 @@ class ElectricalEnergyMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AccuracyAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AccuracyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Accuracy attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Accuracy attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = - ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv( - AnonymousTag, - tlvReader - ) + val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader) emit(AccuracyAttributeSubscriptionState.Success(decodedValue)) } @@ -226,46 +260,52 @@ class ElectricalEnergyMeasurementCluster( emit(AccuracyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCumulativeEnergyImportedAttribute(): CumulativeEnergyImportedAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCumulativeEnergyImportedAttribute(): CumulativeEnergyImportedAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Cumulativeenergyimported attribute not found in response" } + } + + requireNotNull(attributeData) { + "Cumulativeenergyimported attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CumulativeEnergyImportedAttribute(decodedValue) } @@ -275,103 +315,104 @@ class ElectricalEnergyMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CumulativeEnergyImportedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CumulativeEnergyImportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Cumulativeenergyimported attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Cumulativeenergyimported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( - AnonymousTag, - tlvReader - ) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CumulativeEnergyImportedAttributeSubscriptionState.Success(it)) } + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CumulativeEnergyImportedAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CumulativeEnergyImportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCumulativeEnergyExportedAttribute(): CumulativeEnergyExportedAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCumulativeEnergyExportedAttribute(): CumulativeEnergyExportedAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Cumulativeenergyexported attribute not found in response" } + } + + requireNotNull(attributeData) { + "Cumulativeenergyexported attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CumulativeEnergyExportedAttribute(decodedValue) } @@ -381,103 +422,104 @@ class ElectricalEnergyMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CumulativeEnergyExportedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CumulativeEnergyExportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Cumulativeenergyexported attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Cumulativeenergyexported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( - AnonymousTag, - tlvReader - ) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CumulativeEnergyExportedAttributeSubscriptionState.Success(it)) } + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CumulativeEnergyExportedAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CumulativeEnergyExportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeriodicEnergyImportedAttribute(): PeriodicEnergyImportedAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeriodicEnergyImportedAttribute(): PeriodicEnergyImportedAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Periodicenergyimported attribute not found in response" } + } + + requireNotNull(attributeData) { + "Periodicenergyimported attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeriodicEnergyImportedAttribute(decodedValue) } @@ -487,103 +529,104 @@ class ElectricalEnergyMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeriodicEnergyImportedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeriodicEnergyImportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Periodicenergyimported attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Periodicenergyimported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( - AnonymousTag, - tlvReader - ) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeriodicEnergyImportedAttributeSubscriptionState.Success(it)) } + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeriodicEnergyImportedAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeriodicEnergyImportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeriodicEnergyExportedAttribute(): PeriodicEnergyExportedAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeriodicEnergyExportedAttribute(): PeriodicEnergyExportedAttribute {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Periodicenergyexported attribute not found in response" } + } + + requireNotNull(attributeData) { + "Periodicenergyexported attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeriodicEnergyExportedAttribute(decodedValue) } @@ -593,100 +636,101 @@ class ElectricalEnergyMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeriodicEnergyExportedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeriodicEnergyExportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Periodicenergyexported attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Periodicenergyexported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( - AnonymousTag, - tlvReader - ) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeriodicEnergyExportedAttributeSubscriptionState.Success(it)) } + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeriodicEnergyExportedAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeriodicEnergyExportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -696,50 +740,45 @@ class ElectricalEnergyMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -747,43 +786,49 @@ class ElectricalEnergyMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -793,50 +838,45 @@ class ElectricalEnergyMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -844,43 +884,49 @@ class ElectricalEnergyMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -890,48 +936,45 @@ class ElectricalEnergyMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -939,43 +982,49 @@ class ElectricalEnergyMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -985,48 +1034,45 @@ class ElectricalEnergyMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1034,37 +1080,44 @@ class ElectricalEnergyMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1073,37 +1126,35 @@ class ElectricalEnergyMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1115,37 +1166,44 @@ class ElectricalEnergyMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1154,38 +1212,34 @@ class ElectricalEnergyMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1198,7 +1252,7 @@ class ElectricalEnergyMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt index a44e1544733646..0fec4dc6624459 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt @@ -17,84 +17,106 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.ByteSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.ShortSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ElectricalMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class ElectricalMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun getProfileInfoCommand(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -108,12 +130,10 @@ class ElectricalMeasurementCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getMeasurementProfileCommand( - attributeId: UShort, - startTime: UInt, - numberOfIntervals: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun getMeasurementProfileCommand(attributeId: UShort + ,startTime: UInt + ,numberOfIntervals: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -126,7 +146,7 @@ class ElectricalMeasurementCluster( tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) val TAG_NUMBER_OF_INTERVALS_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_NUMBER_OF_INTERVALS_REQ), numberOfIntervals) + tlvWriter.put(ContextSpecificTag(TAG_NUMBER_OF_INTERVALS_REQ), numberOfIntervals) tlvWriter.endStructure() val request: InvokeRequest = @@ -139,39 +159,45 @@ class ElectricalMeasurementCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } +suspend fun readMeasurementTypeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 0u - suspend fun readMeasurementTypeAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementtype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementtype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -181,90 +207,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementtype attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementtype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 256u - suspend fun readDcVoltageAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 256u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dcvoltage attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dcvoltage attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -274,88 +304,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 256u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Dcvoltage attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dcvoltage attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcVoltageMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 257u - suspend fun readDcVoltageMinAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 257u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dcvoltagemin attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dcvoltagemin attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -365,88 +401,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 257u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Dcvoltagemin attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dcvoltagemin attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcVoltageMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 258u - suspend fun readDcVoltageMaxAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 258u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dcvoltagemax attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dcvoltagemax attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -456,88 +498,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 258u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Dcvoltagemax attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dcvoltagemax attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 259u - suspend fun readDcCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 259u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dccurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dccurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -547,88 +595,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 259u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Dccurrent attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dccurrent attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcCurrentMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 260u - suspend fun readDcCurrentMinAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 260u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dccurrentmin attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dccurrentmin attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -638,88 +692,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 260u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Dccurrentmin attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dccurrentmin attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcCurrentMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 261u - suspend fun readDcCurrentMaxAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 261u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dccurrentmax attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dccurrentmax attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -729,88 +789,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 261u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Dccurrentmax attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dccurrentmax attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcPowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 262u - suspend fun readDcPowerAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 262u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dcpower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dcpower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -820,88 +886,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 262u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Dcpower attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dcpower attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcPowerMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 263u - suspend fun readDcPowerMinAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 263u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dcpowermin attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dcpowermin attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -911,88 +983,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 263u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Dcpowermin attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dcpowermin attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcPowerMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 264u - suspend fun readDcPowerMaxAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 264u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dcpowermax attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dcpowermax attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1002,88 +1080,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 264u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Dcpowermax attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dcpowermax attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcVoltageMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 512u - suspend fun readDcVoltageMultiplierAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 512u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dcvoltagemultiplier attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dcvoltagemultiplier attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1093,90 +1177,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 512u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Dcvoltagemultiplier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dcvoltagemultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcVoltageDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 513u - suspend fun readDcVoltageDivisorAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 513u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dcvoltagedivisor attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dcvoltagedivisor attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1186,90 +1274,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 513u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Dcvoltagedivisor attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dcvoltagedivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcCurrentMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 514u - suspend fun readDcCurrentMultiplierAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 514u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dccurrentmultiplier attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dccurrentmultiplier attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1279,90 +1371,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 514u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Dccurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dccurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcCurrentDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 515u - suspend fun readDcCurrentDivisorAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 515u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dccurrentdivisor attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dccurrentdivisor attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1372,90 +1468,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 515u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Dccurrentdivisor attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dccurrentdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcPowerMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 516u - suspend fun readDcPowerMultiplierAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 516u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dcpowermultiplier attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dcpowermultiplier attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1465,90 +1565,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 516u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Dcpowermultiplier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dcpowermultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDcPowerDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 517u - suspend fun readDcPowerDivisorAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 517u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dcpowerdivisor attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dcpowerdivisor attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1558,90 +1662,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 517u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Dcpowerdivisor attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dcpowerdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 768u - suspend fun readAcFrequencyAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 768u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acfrequency attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acfrequency attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1651,88 +1759,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 768u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Acfrequency attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acfrequency attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcFrequencyMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 769u - suspend fun readAcFrequencyMinAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 769u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acfrequencymin attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acfrequencymin attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1742,90 +1856,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 769u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acfrequencymin attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acfrequencymin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcFrequencyMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 770u - suspend fun readAcFrequencyMaxAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 770u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acfrequencymax attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acfrequencymax attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1835,90 +1953,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 770u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acfrequencymax attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acfrequencymax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNeutralCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 771u - suspend fun readNeutralCurrentAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 771u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Neutralcurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Neutralcurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1928,90 +2050,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 771u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Neutralcurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Neutralcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTotalActivePowerAttribute(): Int? {val ATTRIBUTE_ID: UInt = 772u - suspend fun readTotalActivePowerAttribute(): Int? { - val ATTRIBUTE_ID: UInt = 772u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Totalactivepower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Totalactivepower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } + val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2021,90 +2147,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 772u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - IntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Totalactivepower attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Totalactivepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } + val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(IntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(IntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTotalReactivePowerAttribute(): Int? {val ATTRIBUTE_ID: UInt = 773u - suspend fun readTotalReactivePowerAttribute(): Int? { - val ATTRIBUTE_ID: UInt = 773u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Totalreactivepower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Totalreactivepower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } + val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2114,90 +2244,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 773u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - IntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Totalreactivepower attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Totalreactivepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } + val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(IntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(IntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTotalApparentPowerAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 774u - suspend fun readTotalApparentPowerAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 774u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Totalapparentpower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Totalapparentpower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2207,90 +2341,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 774u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Totalapparentpower attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Totalapparentpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasured1stHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 775u - suspend fun readMeasured1stHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 775u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measured1stharmoniccurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measured1stharmoniccurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2300,90 +2438,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 775u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measured1stharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measured1stharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasured3rdHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 776u - suspend fun readMeasured3rdHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 776u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measured3rdharmoniccurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measured3rdharmoniccurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2393,90 +2535,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 776u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measured3rdharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measured3rdharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasured5thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 777u - suspend fun readMeasured5thHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 777u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measured5thharmoniccurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measured5thharmoniccurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2486,90 +2632,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 777u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measured5thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measured5thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasured7thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 778u - suspend fun readMeasured7thHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 778u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measured7thharmoniccurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measured7thharmoniccurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2579,90 +2729,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 778u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measured7thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measured7thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasured9thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 779u - suspend fun readMeasured9thHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 779u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measured9thharmoniccurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measured9thharmoniccurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2672,90 +2826,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 779u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measured9thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measured9thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasured11thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 780u - suspend fun readMeasured11thHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 780u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measured11thharmoniccurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measured11thharmoniccurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2765,92 +2923,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 780u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measured11thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measured11thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasuredPhase1stHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 781u - suspend fun readMeasuredPhase1stHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 781u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase1stharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase1stharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2860,92 +3020,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 781u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measuredphase1stharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase1stharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasuredPhase3rdHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 782u - suspend fun readMeasuredPhase3rdHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 782u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase3rdharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase3rdharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2955,92 +3117,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 782u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measuredphase3rdharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase3rdharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasuredPhase5thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 783u - suspend fun readMeasuredPhase5thHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 783u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase5thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase5thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3050,92 +3214,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 783u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measuredphase5thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase5thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasuredPhase7thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 784u - suspend fun readMeasuredPhase7thHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 784u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase7thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase7thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3145,92 +3311,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 784u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measuredphase7thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase7thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasuredPhase9thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 785u - suspend fun readMeasuredPhase9thHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 785u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase9thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase9thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3240,92 +3408,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 785u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measuredphase9thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase9thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeasuredPhase11thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 786u - suspend fun readMeasuredPhase11thHarmonicCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 786u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase11thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase11thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3335,90 +3505,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 786u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measuredphase11thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredphase11thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcFrequencyMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1024u - suspend fun readAcFrequencyMultiplierAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1024u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acfrequencymultiplier attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acfrequencymultiplier attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3428,90 +3602,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1024u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acfrequencymultiplier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acfrequencymultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcFrequencyDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1025u - suspend fun readAcFrequencyDivisorAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1025u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acfrequencydivisor attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acfrequencydivisor attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3521,90 +3699,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1025u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acfrequencydivisor attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acfrequencydivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPowerMultiplierAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1026u - suspend fun readPowerMultiplierAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 1026u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Powermultiplier attribute not found in response" } + } + + requireNotNull(attributeData) { + "Powermultiplier attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3614,90 +3796,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1026u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Powermultiplier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Powermultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPowerDivisorAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1027u - suspend fun readPowerDivisorAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 1027u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Powerdivisor attribute not found in response" } + } + + requireNotNull(attributeData) { + "Powerdivisor attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3707,88 +3893,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1027u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Powerdivisor attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Powerdivisor attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readHarmonicCurrentMultiplierAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 1028u - suspend fun readHarmonicCurrentMultiplierAttribute(): Byte? { - val ATTRIBUTE_ID: UInt = 1028u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Harmoniccurrentmultiplier attribute not found in response" } + } + + requireNotNull(attributeData) { + "Harmoniccurrentmultiplier attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3798,92 +3990,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1028u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Harmoniccurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Harmoniccurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPhaseHarmonicCurrentMultiplierAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 1029u - suspend fun readPhaseHarmonicCurrentMultiplierAttribute(): Byte? { - val ATTRIBUTE_ID: UInt = 1029u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaseharmoniccurrentmultiplier attribute not found in response" + } + + requireNotNull(attributeData) { + "Phaseharmoniccurrentmultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3893,90 +4087,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1029u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Phaseharmoniccurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Phaseharmoniccurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInstantaneousVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1280u - suspend fun readInstantaneousVoltageAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 1280u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Instantaneousvoltage attribute not found in response" } + } + + requireNotNull(attributeData) { + "Instantaneousvoltage attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3986,90 +4184,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1280u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Instantaneousvoltage attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Instantaneousvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInstantaneousLineCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1281u - suspend fun readInstantaneousLineCurrentAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1281u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Instantaneouslinecurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Instantaneouslinecurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4079,90 +4281,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1281u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Instantaneouslinecurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Instantaneouslinecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInstantaneousActiveCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1282u - suspend fun readInstantaneousActiveCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 1282u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Instantaneousactivecurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Instantaneousactivecurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4172,90 +4378,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1282u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Instantaneousactivecurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Instantaneousactivecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInstantaneousReactiveCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1283u - suspend fun readInstantaneousReactiveCurrentAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 1283u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Instantaneousreactivecurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Instantaneousreactivecurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4265,90 +4475,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1283u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Instantaneousreactivecurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Instantaneousreactivecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInstantaneousPowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1284u - suspend fun readInstantaneousPowerAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 1284u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Instantaneouspower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Instantaneouspower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4358,90 +4572,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1284u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Instantaneouspower attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Instantaneouspower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1285u - suspend fun readRmsVoltageAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1285u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltage attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltage attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4451,88 +4669,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1285u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rmsvoltage attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltage attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1286u - suspend fun readRmsVoltageMinAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1286u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltagemin attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltagemin attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4542,88 +4766,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1286u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rmsvoltagemin attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltagemin attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1287u - suspend fun readRmsVoltageMaxAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1287u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltagemax attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltagemax attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4633,88 +4863,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1287u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rmsvoltagemax attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltagemax attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1288u - suspend fun readRmsCurrentAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1288u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmscurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmscurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4724,88 +4960,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1288u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rmscurrent attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmscurrent attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsCurrentMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1289u - suspend fun readRmsCurrentMinAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1289u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmscurrentmin attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmscurrentmin attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4815,88 +5057,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1289u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rmscurrentmin attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmscurrentmin attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsCurrentMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1290u - suspend fun readRmsCurrentMaxAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1290u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmscurrentmax attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmscurrentmax attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4906,88 +5154,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1290u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rmscurrentmax attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmscurrentmax attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActivePowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1291u - suspend fun readActivePowerAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 1291u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activepower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activepower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4997,88 +5251,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1291u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Activepower attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activepower attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActivePowerMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1292u - suspend fun readActivePowerMinAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 1292u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activepowermin attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activepowermin attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5088,90 +5348,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1292u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activepowermin attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activepowermin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActivePowerMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1293u - suspend fun readActivePowerMaxAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 1293u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activepowermax attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activepowermax attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5181,90 +5445,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1293u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activepowermax attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activepowermax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readReactivePowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1294u - suspend fun readReactivePowerAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 1294u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Reactivepower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Reactivepower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5274,88 +5542,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1294u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Reactivepower attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Reactivepower attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readApparentPowerAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1295u - suspend fun readApparentPowerAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1295u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Apparentpower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Apparentpower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5365,88 +5639,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1295u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Apparentpower attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Apparentpower attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPowerFactorAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 1296u - suspend fun readPowerFactorAttribute(): Byte? { - val ATTRIBUTE_ID: UInt = 1296u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Powerfactor attribute not found in response" } + } + + requireNotNull(attributeData) { + "Powerfactor attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5456,113 +5736,118 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1296u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Powerfactor attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Powerfactor attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1297u - suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1297u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiod attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeAverageRmsVoltageMeasurementPeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1297u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5584,7 +5869,7 @@ class ElectricalMeasurementCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAverageRmsVoltageMeasurementPeriodAttribute( @@ -5592,115 +5877,118 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1297u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiod attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1299u - suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1299u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounter attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounter attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeAverageRmsUnderVoltageCounterAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1299u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5722,7 +6010,7 @@ class ElectricalMeasurementCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAverageRmsUnderVoltageCounterAttribute( @@ -5730,113 +6018,118 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1299u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounter attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounter attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1300u - suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1300u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsextremeovervoltageperiod attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiod attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeRmsExtremeOverVoltagePeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1300u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5858,7 +6151,7 @@ class ElectricalMeasurementCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsExtremeOverVoltagePeriodAttribute( @@ -5866,113 +6159,118 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1300u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiod attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1301u - suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1301u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsextremeundervoltageperiod attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiod attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeRmsExtremeUnderVoltagePeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1301u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5994,7 +6292,7 @@ class ElectricalMeasurementCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsExtremeUnderVoltagePeriodAttribute( @@ -6002,113 +6300,118 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1301u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiod attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageSagPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1302u - suspend fun readRmsVoltageSagPeriodAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1302u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltagesagperiod attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiod attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeRmsVoltageSagPeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1302u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6130,7 +6433,7 @@ class ElectricalMeasurementCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsVoltageSagPeriodAttribute( @@ -6138,113 +6441,118 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1302u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiod attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageSwellPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1303u - suspend fun readRmsVoltageSwellPeriodAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1303u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltageswellperiod attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiod attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeRmsVoltageSwellPeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1303u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6266,7 +6574,7 @@ class ElectricalMeasurementCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsVoltageSwellPeriodAttribute( @@ -6274,90 +6582,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1303u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiod attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcVoltageMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1536u - suspend fun readAcVoltageMultiplierAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1536u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acvoltagemultiplier attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acvoltagemultiplier attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6367,90 +6679,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1536u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acvoltagemultiplier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acvoltagemultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcVoltageDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1537u - suspend fun readAcVoltageDivisorAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1537u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acvoltagedivisor attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acvoltagedivisor attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6460,90 +6776,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1537u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acvoltagedivisor attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acvoltagedivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcCurrentMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1538u - suspend fun readAcCurrentMultiplierAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1538u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Accurrentmultiplier attribute not found in response" } + } + + requireNotNull(attributeData) { + "Accurrentmultiplier attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6553,90 +6873,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1538u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Accurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Accurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcCurrentDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1539u - suspend fun readAcCurrentDivisorAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1539u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Accurrentdivisor attribute not found in response" } + } + + requireNotNull(attributeData) { + "Accurrentdivisor attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6646,90 +6970,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1539u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Accurrentdivisor attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Accurrentdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcPowerMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1540u - suspend fun readAcPowerMultiplierAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1540u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acpowermultiplier attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acpowermultiplier attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6739,90 +7067,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1540u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acpowermultiplier attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acpowermultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcPowerDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1541u - suspend fun readAcPowerDivisorAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1541u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acpowerdivisor attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acpowerdivisor attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6832,110 +7164,118 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1541u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acpowerdivisor attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acpowerdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOverloadAlarmsMaskAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1792u - suspend fun readOverloadAlarmsMaskAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 1792u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Overloadalarmsmask attribute not found in response" } + } + + requireNotNull(attributeData) { + "Overloadalarmsmask attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeOverloadAlarmsMaskAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOverloadAlarmsMaskAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1792u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6957,7 +7297,7 @@ class ElectricalMeasurementCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOverloadAlarmsMaskAttribute( @@ -6965,90 +7305,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1792u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Overloadalarmsmask attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Overloadalarmsmask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readVoltageOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1793u - suspend fun readVoltageOverloadAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 1793u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Voltageoverload attribute not found in response" } + } + + requireNotNull(attributeData) { + "Voltageoverload attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -7058,90 +7402,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1793u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Voltageoverload attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Voltageoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1794u - suspend fun readCurrentOverloadAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 1794u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentoverload attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentoverload attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -7151,113 +7499,118 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1794u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentoverload attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcOverloadAlarmsMaskAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2048u - suspend fun readAcOverloadAlarmsMaskAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2048u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acoverloadalarmsmask attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acoverloadalarmsmask attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeAcOverloadAlarmsMaskAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2048u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7279,7 +7632,7 @@ class ElectricalMeasurementCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAcOverloadAlarmsMaskAttribute( @@ -7287,90 +7640,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2048u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acoverloadalarmsmask attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acoverloadalarmsmask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcVoltageOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2049u - suspend fun readAcVoltageOverloadAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2049u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acvoltageoverload attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acvoltageoverload attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -7380,90 +7737,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2049u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acvoltageoverload attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acvoltageoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcCurrentOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2050u - suspend fun readAcCurrentOverloadAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2050u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Accurrentoverload attribute not found in response" } + } + + requireNotNull(attributeData) { + "Accurrentoverload attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -7473,90 +7834,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2050u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Accurrentoverload attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Accurrentoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcActivePowerOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2051u - suspend fun readAcActivePowerOverloadAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2051u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acactivepoweroverload attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acactivepoweroverload attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -7566,90 +7931,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2051u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acactivepoweroverload attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acactivepoweroverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcReactivePowerOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2052u - suspend fun readAcReactivePowerOverloadAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2052u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acreactivepoweroverload attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acreactivepoweroverload attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -7659,90 +8028,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2052u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acreactivepoweroverload attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acreactivepoweroverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAverageRmsOverVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2053u - suspend fun readAverageRmsOverVoltageAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2053u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagermsovervoltage attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagermsovervoltage attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -7752,90 +8125,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2053u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagermsovervoltage attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsovervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAverageRmsUnderVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2054u - suspend fun readAverageRmsUnderVoltageAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2054u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagermsundervoltage attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagermsundervoltage attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -7845,90 +8222,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2054u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagermsundervoltage attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsundervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsExtremeOverVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2055u - suspend fun readRmsExtremeOverVoltageAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2055u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsextremeovervoltage attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltage attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -7938,90 +8319,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2055u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsextremeovervoltage attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsExtremeUnderVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2056u - suspend fun readRmsExtremeUnderVoltageAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2056u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsextremeundervoltage attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltage attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -8031,90 +8416,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2056u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsextremeundervoltage attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageSagAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2057u - suspend fun readRmsVoltageSagAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2057u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltagesag attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltagesag attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -8124,88 +8513,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2057u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rmsvoltagesag attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltagesag attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageSwellAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2058u - suspend fun readRmsVoltageSwellAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2058u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltageswell attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltageswell attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -8215,90 +8610,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2058u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltageswell attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltageswell attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLineCurrentPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2305u - suspend fun readLineCurrentPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2305u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Linecurrentphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Linecurrentphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -8308,90 +8707,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2305u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Linecurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Linecurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } - } - } - } - - suspend fun readActiveCurrentPhaseBAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2306u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + } + } + } +suspend fun readActiveCurrentPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2306u - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activecurrentphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activecurrentphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -8401,90 +8804,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2306u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activecurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activecurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readReactiveCurrentPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2307u - suspend fun readReactiveCurrentPhaseBAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2307u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Reactivecurrentphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Reactivecurrentphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -8494,90 +8901,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2307u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Reactivecurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Reactivecurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltagePhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2309u - suspend fun readRmsVoltagePhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2309u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltagephaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltagephaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -8587,90 +8998,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2309u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltagephaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltagephaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageMinPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2310u - suspend fun readRmsVoltageMinPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2310u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltageminphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltageminphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -8680,90 +9095,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2310u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltageminphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltageminphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageMaxPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2311u - suspend fun readRmsVoltageMaxPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2311u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltagemaxphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltagemaxphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -8773,90 +9192,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2311u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltagemaxphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltagemaxphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsCurrentPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2312u - suspend fun readRmsCurrentPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2312u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmscurrentphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmscurrentphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -8866,90 +9289,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2312u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmscurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmscurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsCurrentMinPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2313u - suspend fun readRmsCurrentMinPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2313u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmscurrentminphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmscurrentminphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -8959,90 +9386,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2313u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmscurrentminphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmscurrentminphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsCurrentMaxPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2314u - suspend fun readRmsCurrentMaxPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2314u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmscurrentmaxphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmscurrentmaxphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -9052,90 +9483,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2314u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmscurrentmaxphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmscurrentmaxphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActivePowerPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2315u - suspend fun readActivePowerPhaseBAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2315u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activepowerphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activepowerphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -9145,90 +9580,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2315u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activepowerphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activepowerphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActivePowerMinPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2316u - suspend fun readActivePowerMinPhaseBAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2316u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activepowerminphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activepowerminphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -9238,90 +9677,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2316u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activepowerminphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activepowerminphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActivePowerMaxPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2317u - suspend fun readActivePowerMaxPhaseBAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2317u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activepowermaxphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activepowermaxphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -9331,90 +9774,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2317u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activepowermaxphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activepowermaxphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readReactivePowerPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2318u - suspend fun readReactivePowerPhaseBAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2318u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Reactivepowerphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Reactivepowerphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -9424,90 +9871,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2318u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Reactivepowerphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Reactivepowerphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readApparentPowerPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2319u - suspend fun readApparentPowerPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2319u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Apparentpowerphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Apparentpowerphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -9517,90 +9968,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2319u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Apparentpowerphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Apparentpowerphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPowerFactorPhaseBAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 2320u - suspend fun readPowerFactorPhaseBAttribute(): Byte? { - val ATTRIBUTE_ID: UInt = 2320u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Powerfactorphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Powerfactorphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -9610,92 +10065,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2320u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Powerfactorphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Powerfactorphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAverageRmsVoltageMeasurementPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2321u - suspend fun readAverageRmsVoltageMeasurementPeriodPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2321u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -9705,92 +10162,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2321u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAverageRmsOverVoltageCounterPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2322u - suspend fun readAverageRmsOverVoltageCounterPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2322u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -9800,92 +10259,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2322u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAverageRmsUnderVoltageCounterPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2323u - suspend fun readAverageRmsUnderVoltageCounterPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2323u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -9895,92 +10356,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2323u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsExtremeOverVoltagePeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2324u - suspend fun readRmsExtremeOverVoltagePeriodPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2324u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -9990,92 +10453,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2324u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsExtremeUnderVoltagePeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2325u - suspend fun readRmsExtremeUnderVoltagePeriodPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2325u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -10085,90 +10550,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2325u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageSagPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2326u - suspend fun readRmsVoltageSagPeriodPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2326u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltagesagperiodphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiodphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -10178,90 +10647,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2326u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageSwellPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2327u - suspend fun readRmsVoltageSwellPeriodPhaseBAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2327u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltageswellperiodphaseb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiodphaseb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -10271,90 +10744,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2327u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLineCurrentPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2561u - suspend fun readLineCurrentPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2561u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Linecurrentphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Linecurrentphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -10364,90 +10841,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2561u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Linecurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Linecurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActiveCurrentPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2562u - suspend fun readActiveCurrentPhaseCAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2562u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activecurrentphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activecurrentphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -10457,90 +10938,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2562u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activecurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activecurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readReactiveCurrentPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2563u - suspend fun readReactiveCurrentPhaseCAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2563u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Reactivecurrentphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Reactivecurrentphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -10550,90 +11035,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2563u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Reactivecurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Reactivecurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltagePhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2565u - suspend fun readRmsVoltagePhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2565u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltagephasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltagephasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -10643,90 +11132,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2565u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltagephasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltagephasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageMinPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2566u - suspend fun readRmsVoltageMinPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2566u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltageminphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltageminphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -10736,90 +11229,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2566u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltageminphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltageminphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageMaxPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2567u - suspend fun readRmsVoltageMaxPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2567u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltagemaxphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltagemaxphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -10829,90 +11326,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2567u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltagemaxphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltagemaxphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsCurrentPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2568u - suspend fun readRmsCurrentPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2568u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmscurrentphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmscurrentphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -10922,90 +11423,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2568u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmscurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmscurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsCurrentMinPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2569u - suspend fun readRmsCurrentMinPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2569u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmscurrentminphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmscurrentminphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -11015,90 +11520,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2569u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmscurrentminphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmscurrentminphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsCurrentMaxPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2570u - suspend fun readRmsCurrentMaxPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2570u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmscurrentmaxphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmscurrentmaxphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -11108,90 +11617,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2570u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmscurrentmaxphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmscurrentmaxphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActivePowerPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2571u - suspend fun readActivePowerPhaseCAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2571u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activepowerphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activepowerphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -11201,90 +11714,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2571u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activepowerphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activepowerphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActivePowerMinPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2572u - suspend fun readActivePowerMinPhaseCAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2572u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activepowerminphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activepowerminphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -11294,90 +11811,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2572u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activepowerminphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activepowerminphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActivePowerMaxPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2573u - suspend fun readActivePowerMaxPhaseCAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2573u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activepowermaxphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activepowermaxphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -11387,90 +11908,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2573u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activepowermaxphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activepowermaxphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readReactivePowerPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2574u - suspend fun readReactivePowerPhaseCAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2574u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Reactivepowerphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Reactivepowerphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -11480,90 +12005,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2574u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Reactivepowerphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Reactivepowerphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readApparentPowerPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2575u - suspend fun readApparentPowerPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2575u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Apparentpowerphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Apparentpowerphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -11573,90 +12102,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2575u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Apparentpowerphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Apparentpowerphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPowerFactorPhaseCAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 2576u - suspend fun readPowerFactorPhaseCAttribute(): Byte? { - val ATTRIBUTE_ID: UInt = 2576u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Powerfactorphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Powerfactorphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -11666,92 +12199,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2576u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Powerfactorphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Powerfactorphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAverageRmsVoltageMeasurementPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2577u - suspend fun readAverageRmsVoltageMeasurementPeriodPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2577u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -11761,92 +12296,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2577u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAverageRmsOverVoltageCounterPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2578u - suspend fun readAverageRmsOverVoltageCounterPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2578u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -11856,92 +12393,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2578u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAverageRmsUnderVoltageCounterPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2579u - suspend fun readAverageRmsUnderVoltageCounterPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2579u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -11951,92 +12490,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2579u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsExtremeOverVoltagePeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2580u - suspend fun readRmsExtremeOverVoltagePeriodPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2580u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -12046,92 +12587,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2580u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsExtremeUnderVoltagePeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2581u - suspend fun readRmsExtremeUnderVoltagePeriodPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2581u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -12141,90 +12684,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2581u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageSagPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2582u - suspend fun readRmsVoltageSagPeriodPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2582u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltagesagperiodphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiodphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -12234,90 +12781,94 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2582u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRmsVoltageSwellPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2583u - suspend fun readRmsVoltageSwellPeriodPhaseCAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2583u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rmsvoltageswellperiodphasec attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiodphasec attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -12327,92 +12878,96 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2583u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -12422,50 +12977,45 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -12473,43 +13023,49 @@ class ElectricalMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -12519,50 +13075,45 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -12570,43 +13121,49 @@ class ElectricalMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -12616,48 +13173,45 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -12665,43 +13219,49 @@ class ElectricalMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -12711,48 +13271,45 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -12760,37 +13317,44 @@ class ElectricalMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -12799,37 +13363,35 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -12841,37 +13403,44 @@ class ElectricalMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -12880,38 +13449,34 @@ class ElectricalMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -12924,7 +13489,7 @@ class ElectricalMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt index 20363bff38ec5a..0d532702cc4872 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt @@ -17,30 +17,45 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.LongSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter @@ -48,206 +63,259 @@ class EnergyEvseCluster(private val controller: MatterController, private val en class GetTargetsResponse( val chargingTargetSchedules: List ) - - class StateAttribute(val value: UByte?) +class StateAttribute( + val value: UByte? + ) sealed class StateAttributeSubscriptionState { - data class Success(val value: UByte?) : StateAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : StateAttributeSubscriptionState() + data class Error(val exception: Exception) : StateAttributeSubscriptionState() - object SubscriptionEstablished : StateAttributeSubscriptionState() - } - - class ChargingEnabledUntilAttribute(val value: UInt?) + object SubscriptionEstablished : StateAttributeSubscriptionState() + } +class ChargingEnabledUntilAttribute( + val value: UInt? + ) sealed class ChargingEnabledUntilAttributeSubscriptionState { - data class Success(val value: UInt?) : ChargingEnabledUntilAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : ChargingEnabledUntilAttributeSubscriptionState() + data class Error(val exception: Exception) : ChargingEnabledUntilAttributeSubscriptionState() - object SubscriptionEstablished : ChargingEnabledUntilAttributeSubscriptionState() - } - - class DischargingEnabledUntilAttribute(val value: UInt?) + object SubscriptionEstablished : ChargingEnabledUntilAttributeSubscriptionState() + } +class DischargingEnabledUntilAttribute( + val value: UInt? + ) sealed class DischargingEnabledUntilAttributeSubscriptionState { - data class Success(val value: UInt?) : DischargingEnabledUntilAttributeSubscriptionState() - - data class Error(val exception: Exception) : - DischargingEnabledUntilAttributeSubscriptionState() - - object SubscriptionEstablished : DischargingEnabledUntilAttributeSubscriptionState() - } - - class NextChargeStartTimeAttribute(val value: UInt?) + data class Success( + val value: UInt? + ) : DischargingEnabledUntilAttributeSubscriptionState() + + data class Error(val exception: Exception) : DischargingEnabledUntilAttributeSubscriptionState() + + object SubscriptionEstablished : DischargingEnabledUntilAttributeSubscriptionState() + } +class NextChargeStartTimeAttribute( + val value: UInt? + ) sealed class NextChargeStartTimeAttributeSubscriptionState { - data class Success(val value: UInt?) : NextChargeStartTimeAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : NextChargeStartTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : NextChargeStartTimeAttributeSubscriptionState() - object SubscriptionEstablished : NextChargeStartTimeAttributeSubscriptionState() - } - - class NextChargeTargetTimeAttribute(val value: UInt?) + object SubscriptionEstablished : NextChargeStartTimeAttributeSubscriptionState() + } +class NextChargeTargetTimeAttribute( + val value: UInt? + ) sealed class NextChargeTargetTimeAttributeSubscriptionState { - data class Success(val value: UInt?) : NextChargeTargetTimeAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : NextChargeTargetTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : NextChargeTargetTimeAttributeSubscriptionState() - object SubscriptionEstablished : NextChargeTargetTimeAttributeSubscriptionState() - } - - class NextChargeRequiredEnergyAttribute(val value: Long?) + object SubscriptionEstablished : NextChargeTargetTimeAttributeSubscriptionState() + } +class NextChargeRequiredEnergyAttribute( + val value: Long? + ) sealed class NextChargeRequiredEnergyAttributeSubscriptionState { - data class Success(val value: Long?) : NextChargeRequiredEnergyAttributeSubscriptionState() - - data class Error(val exception: Exception) : - NextChargeRequiredEnergyAttributeSubscriptionState() - - object SubscriptionEstablished : NextChargeRequiredEnergyAttributeSubscriptionState() - } - - class NextChargeTargetSoCAttribute(val value: UByte?) + data class Success( + val value: Long? + ) : NextChargeRequiredEnergyAttributeSubscriptionState() + + data class Error(val exception: Exception) : NextChargeRequiredEnergyAttributeSubscriptionState() + + object SubscriptionEstablished : NextChargeRequiredEnergyAttributeSubscriptionState() + } +class NextChargeTargetSoCAttribute( + val value: UByte? + ) sealed class NextChargeTargetSoCAttributeSubscriptionState { - data class Success(val value: UByte?) : NextChargeTargetSoCAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : NextChargeTargetSoCAttributeSubscriptionState() + data class Error(val exception: Exception) : NextChargeTargetSoCAttributeSubscriptionState() - object SubscriptionEstablished : NextChargeTargetSoCAttributeSubscriptionState() - } - - class ApproximateEVEfficiencyAttribute(val value: UShort?) + object SubscriptionEstablished : NextChargeTargetSoCAttributeSubscriptionState() + } +class ApproximateEVEfficiencyAttribute( + val value: UShort? + ) sealed class ApproximateEVEfficiencyAttributeSubscriptionState { - data class Success(val value: UShort?) : ApproximateEVEfficiencyAttributeSubscriptionState() - - data class Error(val exception: Exception) : - ApproximateEVEfficiencyAttributeSubscriptionState() - - object SubscriptionEstablished : ApproximateEVEfficiencyAttributeSubscriptionState() - } - - class StateOfChargeAttribute(val value: UByte?) + data class Success( + val value: UShort? + ) : ApproximateEVEfficiencyAttributeSubscriptionState() + + data class Error(val exception: Exception) : ApproximateEVEfficiencyAttributeSubscriptionState() + + object SubscriptionEstablished : ApproximateEVEfficiencyAttributeSubscriptionState() + } +class StateOfChargeAttribute( + val value: UByte? + ) sealed class StateOfChargeAttributeSubscriptionState { - data class Success(val value: UByte?) : StateOfChargeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : StateOfChargeAttributeSubscriptionState() + data class Error(val exception: Exception) : StateOfChargeAttributeSubscriptionState() - object SubscriptionEstablished : StateOfChargeAttributeSubscriptionState() - } - - class BatteryCapacityAttribute(val value: Long?) + object SubscriptionEstablished : StateOfChargeAttributeSubscriptionState() + } +class BatteryCapacityAttribute( + val value: Long? + ) sealed class BatteryCapacityAttributeSubscriptionState { - data class Success(val value: Long?) : BatteryCapacityAttributeSubscriptionState() - + data class Success( + val value: Long? + ) : BatteryCapacityAttributeSubscriptionState() + data class Error(val exception: Exception) : BatteryCapacityAttributeSubscriptionState() - object SubscriptionEstablished : BatteryCapacityAttributeSubscriptionState() - } - - class VehicleIDAttribute(val value: String?) + object SubscriptionEstablished : BatteryCapacityAttributeSubscriptionState() + } +class VehicleIDAttribute( + val value: String? + ) sealed class VehicleIDAttributeSubscriptionState { - data class Success(val value: String?) : VehicleIDAttributeSubscriptionState() - + data class Success( + val value: String? + ) : VehicleIDAttributeSubscriptionState() + data class Error(val exception: Exception) : VehicleIDAttributeSubscriptionState() - object SubscriptionEstablished : VehicleIDAttributeSubscriptionState() - } - - class SessionIDAttribute(val value: UInt?) + object SubscriptionEstablished : VehicleIDAttributeSubscriptionState() + } +class SessionIDAttribute( + val value: UInt? + ) sealed class SessionIDAttributeSubscriptionState { - data class Success(val value: UInt?) : SessionIDAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : SessionIDAttributeSubscriptionState() + data class Error(val exception: Exception) : SessionIDAttributeSubscriptionState() - object SubscriptionEstablished : SessionIDAttributeSubscriptionState() - } - - class SessionDurationAttribute(val value: UInt?) + object SubscriptionEstablished : SessionIDAttributeSubscriptionState() + } +class SessionDurationAttribute( + val value: UInt? + ) sealed class SessionDurationAttributeSubscriptionState { - data class Success(val value: UInt?) : SessionDurationAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : SessionDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : SessionDurationAttributeSubscriptionState() - object SubscriptionEstablished : SessionDurationAttributeSubscriptionState() - } - - class SessionEnergyChargedAttribute(val value: Long?) + object SubscriptionEstablished : SessionDurationAttributeSubscriptionState() + } +class SessionEnergyChargedAttribute( + val value: Long? + ) sealed class SessionEnergyChargedAttributeSubscriptionState { - data class Success(val value: Long?) : SessionEnergyChargedAttributeSubscriptionState() - + data class Success( + val value: Long? + ) : SessionEnergyChargedAttributeSubscriptionState() + data class Error(val exception: Exception) : SessionEnergyChargedAttributeSubscriptionState() - object SubscriptionEstablished : SessionEnergyChargedAttributeSubscriptionState() - } - - class SessionEnergyDischargedAttribute(val value: Long?) + object SubscriptionEstablished : SessionEnergyChargedAttributeSubscriptionState() + } +class SessionEnergyDischargedAttribute( + val value: Long? + ) sealed class SessionEnergyDischargedAttributeSubscriptionState { - data class Success(val value: Long?) : SessionEnergyDischargedAttributeSubscriptionState() - - data class Error(val exception: Exception) : - SessionEnergyDischargedAttributeSubscriptionState() - - object SubscriptionEstablished : SessionEnergyDischargedAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + data class Success( + val value: Long? + ) : SessionEnergyDischargedAttributeSubscriptionState() + + data class Error(val exception: Exception) : SessionEnergyDischargedAttributeSubscriptionState() + + object SubscriptionEstablished : SessionEnergyDischargedAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun disable(timedInvokeTimeout: Duration) { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -261,12 +329,10 @@ class EnergyEvseCluster(private val controller: MatterController, private val en logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableCharging( - chargingEnabledUntil: UInt?, - minimumChargeCurrent: Long, - maximumChargeCurrent: Long, - timedInvokeTimeout: Duration - ) { + suspend fun enableCharging(chargingEnabledUntil: UInt? + ,minimumChargeCurrent: Long + ,maximumChargeCurrent: Long + ,timedInvokeTimeout: Duration) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -281,7 +347,7 @@ class EnergyEvseCluster(private val controller: MatterController, private val en tlvWriter.put(ContextSpecificTag(TAG_MINIMUM_CHARGE_CURRENT_REQ), minimumChargeCurrent) val TAG_MAXIMUM_CHARGE_CURRENT_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_CHARGE_CURRENT_REQ), maximumChargeCurrent) + tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_CHARGE_CURRENT_REQ), maximumChargeCurrent) tlvWriter.endStructure() val request: InvokeRequest = @@ -295,11 +361,9 @@ class EnergyEvseCluster(private val controller: MatterController, private val en logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableDischarging( - dischargingEnabledUntil: UInt?, - maximumDischargeCurrent: Long, - timedInvokeTimeout: Duration - ) { + suspend fun enableDischarging(dischargingEnabledUntil: UInt? + ,maximumDischargeCurrent: Long + ,timedInvokeTimeout: Duration) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -311,7 +375,7 @@ class EnergyEvseCluster(private val controller: MatterController, private val en } val TAG_MAXIMUM_DISCHARGE_CURRENT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_DISCHARGE_CURRENT_REQ), maximumDischargeCurrent) + tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_DISCHARGE_CURRENT_REQ), maximumDischargeCurrent) tlvWriter.endStructure() val request: InvokeRequest = @@ -329,7 +393,7 @@ class EnergyEvseCluster(private val controller: MatterController, private val en val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -343,10 +407,8 @@ class EnergyEvseCluster(private val controller: MatterController, private val en logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTargets( - chargingTargetSchedules: List, - timedInvokeTimeout: Duration - ) { + suspend fun setTargets(chargingTargetSchedules: List + ,timedInvokeTimeout: Duration) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -354,10 +416,10 @@ class EnergyEvseCluster(private val controller: MatterController, private val en val TAG_CHARGING_TARGET_SCHEDULES_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_CHARGING_TARGET_SCHEDULES_REQ)) - for (item in chargingTargetSchedules.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in chargingTargetSchedules.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -375,7 +437,7 @@ class EnergyEvseCluster(private val controller: MatterController, private val en val commandId: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -392,38 +454,45 @@ class EnergyEvseCluster(private val controller: MatterController, private val en tlvReader.enterStructure(AnonymousTag) val TAG_CHARGING_TARGET_SCHEDULES: Int = 0 var chargingTargetSchedules_decoded: List? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_CHARGING_TARGET_SCHEDULES)) { - chargingTargetSchedules_decoded = - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(EnergyEvseClusterChargingTargetScheduleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { + + if (tag == ContextSpecificTag(TAG_CHARGING_TARGET_SCHEDULES)) {chargingTargetSchedules_decoded = buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(EnergyEvseClusterChargingTargetScheduleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }} + + + else { tlvReader.skipElement() } } + + if (chargingTargetSchedules_decoded == null) { - throw IllegalStateException("chargingTargetSchedules not found in TLV") + throw IllegalStateException("chargingTargetSchedules not found in TLV") } + tlvReader.exitContainer() - return GetTargetsResponse(chargingTargetSchedules_decoded) + return GetTargetsResponse( + chargingTargetSchedules_decoded + ) } suspend fun clearTargets(timedInvokeTimeout: Duration) { val commandId: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -436,40 +505,46 @@ class EnergyEvseCluster(private val controller: MatterController, private val en val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } +suspend fun readStateAttribute(): StateAttribute {val ATTRIBUTE_ID: UInt = 0u - suspend fun readStateAttribute(): StateAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "State attribute not found in response" } + } + + requireNotNull(attributeData) { + "State attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StateAttribute(decodedValue) } @@ -479,85 +554,92 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StateAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "State attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "State attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(StateAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StateAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSupplyStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - suspend fun readSupplyStateAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supplystate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supplystate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -566,37 +648,35 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Supplystate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supplystate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -608,37 +688,44 @@ class EnergyEvseCluster(private val controller: MatterController, private val en emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFaultStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - suspend fun readFaultStateAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Faultstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Faultstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -647,37 +734,35 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Faultstate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Faultstate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -689,42 +774,48 @@ class EnergyEvseCluster(private val controller: MatterController, private val en emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readChargingEnabledUntilAttribute(): ChargingEnabledUntilAttribute {val ATTRIBUTE_ID: UInt = 3u - suspend fun readChargingEnabledUntilAttribute(): ChargingEnabledUntilAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Chargingenableduntil attribute not found in response" } + } + + requireNotNull(attributeData) { + "Chargingenableduntil attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ChargingEnabledUntilAttribute(decodedValue) } @@ -734,96 +825,100 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ChargingEnabledUntilAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ChargingEnabledUntilAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Chargingenableduntil attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Chargingenableduntil attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(ChargingEnabledUntilAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ChargingEnabledUntilAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ChargingEnabledUntilAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDischargingEnabledUntilAttribute(): DischargingEnabledUntilAttribute {val ATTRIBUTE_ID: UInt = 4u - suspend fun readDischargingEnabledUntilAttribute(): DischargingEnabledUntilAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dischargingenableduntil attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dischargingenableduntil attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return DischargingEnabledUntilAttribute(decodedValue) } @@ -833,91 +928,96 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DischargingEnabledUntilAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DischargingEnabledUntilAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Dischargingenableduntil attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dischargingenableduntil attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(DischargingEnabledUntilAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(DischargingEnabledUntilAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(DischargingEnabledUntilAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCircuitCapacityAttribute(): Long {val ATTRIBUTE_ID: UInt = 5u - suspend fun readCircuitCapacityAttribute(): Long { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Circuitcapacity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Circuitcapacity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) + return decodedValue } @@ -926,38 +1026,34 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Circuitcapacity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Circuitcapacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -970,37 +1066,44 @@ class EnergyEvseCluster(private val controller: MatterController, private val en emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinimumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = 6u - suspend fun readMinimumChargeCurrentAttribute(): Long { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minimumchargecurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minimumchargecurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) + return decodedValue } @@ -1009,38 +1112,34 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minimumchargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minimumchargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1053,37 +1152,44 @@ class EnergyEvseCluster(private val controller: MatterController, private val en emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaximumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = 7u - suspend fun readMaximumChargeCurrentAttribute(): Long { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maximumchargecurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maximumchargecurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) + return decodedValue } @@ -1092,38 +1198,34 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maximumchargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maximumchargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1136,41 +1238,47 @@ class EnergyEvseCluster(private val controller: MatterController, private val en emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaximumDischargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UInt = 8u - suspend fun readMaximumDischargeCurrentAttribute(): Long? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maximumdischargecurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maximumdischargecurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } + val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1180,113 +1288,118 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maximumdischargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maximumdischargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } + val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(LongSubscriptionState.Success(it)) } + decodedValue?.let { + emit(LongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readUserMaximumChargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UInt = 9u - suspend fun readUserMaximumChargeCurrentAttribute(): Long? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Usermaximumchargecurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Usermaximumchargecurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } + val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeUserMaximumChargeCurrentAttribute( value: Long, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1308,7 +1421,7 @@ class EnergyEvseCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUserMaximumChargeCurrentAttribute( @@ -1316,113 +1429,118 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Usermaximumchargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Usermaximumchargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } + val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(LongSubscriptionState.Success(it)) } + decodedValue?.let { + emit(LongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRandomizationDelayWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 10u - suspend fun readRandomizationDelayWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Randomizationdelaywindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Randomizationdelaywindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeRandomizationDelayWindowAttribute( value: UInt, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1444,7 +1562,7 @@ class EnergyEvseCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRandomizationDelayWindowAttribute( @@ -1452,95 +1570,99 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Randomizationdelaywindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Randomizationdelaywindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNextChargeStartTimeAttribute(): NextChargeStartTimeAttribute {val ATTRIBUTE_ID: UInt = 35u - suspend fun readNextChargeStartTimeAttribute(): NextChargeStartTimeAttribute { - val ATTRIBUTE_ID: UInt = 35u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nextchargestarttime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nextchargestarttime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NextChargeStartTimeAttribute(decodedValue) } @@ -1550,100 +1672,104 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NextChargeStartTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NextChargeStartTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nextchargestarttime attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nextchargestarttime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(NextChargeStartTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(NextChargeStartTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeStartTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNextChargeTargetTimeAttribute(): NextChargeTargetTimeAttribute {val ATTRIBUTE_ID: UInt = 36u - suspend fun readNextChargeTargetTimeAttribute(): NextChargeTargetTimeAttribute { - val ATTRIBUTE_ID: UInt = 36u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nextchargetargettime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nextchargetargettime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NextChargeTargetTimeAttribute(decodedValue) } @@ -1653,100 +1779,104 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NextChargeTargetTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NextChargeTargetTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nextchargetargettime attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nextchargetargettime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(NextChargeTargetTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(NextChargeTargetTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeTargetTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNextChargeRequiredEnergyAttribute(): NextChargeRequiredEnergyAttribute {val ATTRIBUTE_ID: UInt = 37u - suspend fun readNextChargeRequiredEnergyAttribute(): NextChargeRequiredEnergyAttribute { - val ATTRIBUTE_ID: UInt = 37u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nextchargerequiredenergy attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nextchargerequiredenergy attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NextChargeRequiredEnergyAttribute(decodedValue) } @@ -1756,100 +1886,104 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NextChargeRequiredEnergyAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NextChargeRequiredEnergyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nextchargerequiredenergy attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nextchargerequiredenergy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(NextChargeRequiredEnergyAttributeSubscriptionState.Success(it)) } + val decodedValue: Long? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(NextChargeRequiredEnergyAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeRequiredEnergyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNextChargeTargetSoCAttribute(): NextChargeTargetSoCAttribute {val ATTRIBUTE_ID: UInt = 38u - suspend fun readNextChargeTargetSoCAttribute(): NextChargeTargetSoCAttribute { - val ATTRIBUTE_ID: UInt = 38u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nextchargetargetsoc attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nextchargetargetsoc attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NextChargeTargetSoCAttribute(decodedValue) } @@ -1859,123 +1993,128 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NextChargeTargetSoCAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NextChargeTargetSoCAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nextchargetargetsoc attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nextchargetargetsoc attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(NextChargeTargetSoCAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(NextChargeTargetSoCAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeTargetSoCAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttribute {val ATTRIBUTE_ID: UInt = 39u - suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttribute { - val ATTRIBUTE_ID: UInt = 39u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Approximateevefficiency attribute not found in response" } + } + + requireNotNull(attributeData) { + "Approximateevefficiency attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ApproximateEVEfficiencyAttribute(decodedValue) } suspend fun writeApproximateEVEfficiencyAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 39u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1997,7 +2136,7 @@ class EnergyEvseCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeApproximateEVEfficiencyAttribute( @@ -2005,100 +2144,104 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ApproximateEVEfficiencyAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ApproximateEVEfficiencyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Approximateevefficiency attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Approximateevefficiency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ApproximateEVEfficiencyAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ApproximateEVEfficiencyAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ApproximateEVEfficiencyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readStateOfChargeAttribute(): StateOfChargeAttribute {val ATTRIBUTE_ID: UInt = 48u - suspend fun readStateOfChargeAttribute(): StateOfChargeAttribute { - val ATTRIBUTE_ID: UInt = 48u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Stateofcharge attribute not found in response" } + } + + requireNotNull(attributeData) { + "Stateofcharge attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StateOfChargeAttribute(decodedValue) } @@ -2108,98 +2251,104 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StateOfChargeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StateOfChargeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Stateofcharge attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Stateofcharge attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(StateOfChargeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(StateOfChargeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StateOfChargeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatteryCapacityAttribute(): BatteryCapacityAttribute {val ATTRIBUTE_ID: UInt = 49u - suspend fun readBatteryCapacityAttribute(): BatteryCapacityAttribute { - val ATTRIBUTE_ID: UInt = 49u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batterycapacity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batterycapacity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return BatteryCapacityAttribute(decodedValue) } @@ -2209,100 +2358,104 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BatteryCapacityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BatteryCapacityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batterycapacity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batterycapacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(BatteryCapacityAttributeSubscriptionState.Success(it)) } + val decodedValue: Long? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(BatteryCapacityAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BatteryCapacityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readVehicleIDAttribute(): VehicleIDAttribute {val ATTRIBUTE_ID: UInt = 50u - suspend fun readVehicleIDAttribute(): VehicleIDAttribute { - val ATTRIBUTE_ID: UInt = 50u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Vehicleid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Vehicleid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: String? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return VehicleIDAttribute(decodedValue) } @@ -2312,94 +2465,100 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - VehicleIDAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(VehicleIDAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Vehicleid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Vehicleid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(VehicleIDAttributeSubscriptionState.Success(it)) } + val decodedValue: String? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(VehicleIDAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(VehicleIDAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSessionIDAttribute(): SessionIDAttribute {val ATTRIBUTE_ID: UInt = 64u - suspend fun readSessionIDAttribute(): SessionIDAttribute { - val ATTRIBUTE_ID: UInt = 64u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Sessionid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Sessionid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SessionIDAttribute(decodedValue) } @@ -2409,90 +2568,96 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 64u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SessionIDAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SessionIDAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Sessionid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Sessionid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(SessionIDAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(SessionIDAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SessionIDAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSessionDurationAttribute(): SessionDurationAttribute {val ATTRIBUTE_ID: UInt = 65u - suspend fun readSessionDurationAttribute(): SessionDurationAttribute { - val ATTRIBUTE_ID: UInt = 65u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Sessionduration attribute not found in response" } + } + + requireNotNull(attributeData) { + "Sessionduration attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SessionDurationAttribute(decodedValue) } @@ -2502,92 +2667,96 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SessionDurationAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SessionDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Sessionduration attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Sessionduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(SessionDurationAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(SessionDurationAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SessionDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSessionEnergyChargedAttribute(): SessionEnergyChargedAttribute {val ATTRIBUTE_ID: UInt = 66u - suspend fun readSessionEnergyChargedAttribute(): SessionEnergyChargedAttribute { - val ATTRIBUTE_ID: UInt = 66u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Sessionenergycharged attribute not found in response" } + } + + requireNotNull(attributeData) { + "Sessionenergycharged attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SessionEnergyChargedAttribute(decodedValue) } @@ -2597,96 +2766,100 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 66u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SessionEnergyChargedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SessionEnergyChargedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Sessionenergycharged attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Sessionenergycharged attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(SessionEnergyChargedAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(SessionEnergyChargedAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SessionEnergyChargedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSessionEnergyDischargedAttribute(): SessionEnergyDischargedAttribute {val ATTRIBUTE_ID: UInt = 67u - suspend fun readSessionEnergyDischargedAttribute(): SessionEnergyDischargedAttribute { - val ATTRIBUTE_ID: UInt = 67u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Sessionenergydischarged attribute not found in response" } + } + + requireNotNull(attributeData) { + "Sessionenergydischarged attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SessionEnergyDischargedAttribute(decodedValue) } @@ -2696,97 +2869,101 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 67u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SessionEnergyDischargedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SessionEnergyDischargedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Sessionenergydischarged attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Sessionenergydischarged attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(SessionEnergyDischargedAttributeSubscriptionState.Success(it)) } + val decodedValue: Long? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(SessionEnergyDischargedAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SessionEnergyDischargedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -2796,50 +2973,45 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2847,43 +3019,49 @@ class EnergyEvseCluster(private val controller: MatterController, private val en emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -2893,50 +3071,45 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2944,43 +3117,49 @@ class EnergyEvseCluster(private val controller: MatterController, private val en emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -2990,48 +3169,45 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -3039,43 +3215,49 @@ class EnergyEvseCluster(private val controller: MatterController, private val en emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -3085,48 +3267,45 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -3134,37 +3313,44 @@ class EnergyEvseCluster(private val controller: MatterController, private val en emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -3173,37 +3359,35 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3215,37 +3399,44 @@ class EnergyEvseCluster(private val controller: MatterController, private val en emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -3254,38 +3445,34 @@ class EnergyEvseCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3298,7 +3485,7 @@ class EnergyEvseCluster(private val controller: MatterController, private val en emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt index 8030bbd3cf96d0..0ac2734058b8eb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt @@ -17,143 +17,184 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyPreferenceCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class EnergyBalancesAttribute(val value: List?) +class EnergyPreferenceCluster(private val controller: MatterController, private val endpointId: UShort) {class EnergyBalancesAttribute( + val value: List? + ) sealed class EnergyBalancesAttributeSubscriptionState { - data class Success(val value: List?) : - EnergyBalancesAttributeSubscriptionState() - + data class Success( + val value: List? + ) : EnergyBalancesAttributeSubscriptionState() + data class Error(val exception: Exception) : EnergyBalancesAttributeSubscriptionState() - object SubscriptionEstablished : EnergyBalancesAttributeSubscriptionState() - } - - class EnergyPrioritiesAttribute(val value: List?) + object SubscriptionEstablished : EnergyBalancesAttributeSubscriptionState() + } +class EnergyPrioritiesAttribute( + val value: List? + ) sealed class EnergyPrioritiesAttributeSubscriptionState { - data class Success(val value: List?) : EnergyPrioritiesAttributeSubscriptionState() - + data class Success( + val value: List? + ) : EnergyPrioritiesAttributeSubscriptionState() + data class Error(val exception: Exception) : EnergyPrioritiesAttributeSubscriptionState() - object SubscriptionEstablished : EnergyPrioritiesAttributeSubscriptionState() - } - - class LowPowerModeSensitivitiesAttribute(val value: List?) + object SubscriptionEstablished : EnergyPrioritiesAttributeSubscriptionState() + } +class LowPowerModeSensitivitiesAttribute( + val value: List? + ) sealed class LowPowerModeSensitivitiesAttributeSubscriptionState { - data class Success(val value: List?) : - LowPowerModeSensitivitiesAttributeSubscriptionState() - - data class Error(val exception: Exception) : - LowPowerModeSensitivitiesAttributeSubscriptionState() - - object SubscriptionEstablished : LowPowerModeSensitivitiesAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + data class Success( + val value: List? + ) : LowPowerModeSensitivitiesAttributeSubscriptionState() + + data class Error(val exception: Exception) : LowPowerModeSensitivitiesAttributeSubscriptionState() + + object SubscriptionEstablished : LowPowerModeSensitivitiesAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readEnergyBalancesAttribute(): EnergyBalancesAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readEnergyBalancesAttribute(): EnergyBalancesAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Energybalances attribute not found in response" } + } + + requireNotNull(attributeData) { + "Energybalances attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return EnergyBalancesAttribute(decodedValue) } @@ -163,119 +204,124 @@ class EnergyPreferenceCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EnergyBalancesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EnergyBalancesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Energybalances attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Energybalances attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(EnergyBalancesAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(EnergyBalancesAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(EnergyBalancesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentEnergyBalanceAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentEnergyBalanceAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentenergybalance attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentenergybalance attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeCurrentEnergyBalanceAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -297,7 +343,7 @@ class EnergyPreferenceCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCurrentEnergyBalanceAttribute( @@ -305,96 +351,100 @@ class EnergyPreferenceCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentenergybalance attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentenergybalance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEnergyPrioritiesAttribute(): EnergyPrioritiesAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEnergyPrioritiesAttribute(): EnergyPrioritiesAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Energypriorities attribute not found in response" } + } + + requireNotNull(attributeData) { + "Energypriorities attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return EnergyPrioritiesAttribute(decodedValue) } @@ -404,102 +454,106 @@ class EnergyPreferenceCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EnergyPrioritiesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EnergyPrioritiesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Energypriorities attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Energypriorities attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(EnergyPrioritiesAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(EnergyPrioritiesAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(EnergyPrioritiesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLowPowerModeSensitivitiesAttribute(): LowPowerModeSensitivitiesAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLowPowerModeSensitivitiesAttribute(): LowPowerModeSensitivitiesAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lowpowermodesensitivities attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lowpowermodesensitivities attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return LowPowerModeSensitivitiesAttribute(decodedValue) } @@ -509,123 +563,124 @@ class EnergyPreferenceCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LowPowerModeSensitivitiesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LowPowerModeSensitivitiesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lowpowermodesensitivities attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lowpowermodesensitivities attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { emit(LowPowerModeSensitivitiesAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(LowPowerModeSensitivitiesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentLowPowerModeSensitivityAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentLowPowerModeSensitivityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlowpowermodesensitivity attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentlowpowermodesensitivity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeCurrentLowPowerModeSensitivityAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -647,7 +702,7 @@ class EnergyPreferenceCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCurrentLowPowerModeSensitivityAttribute( @@ -655,92 +710,96 @@ class EnergyPreferenceCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentlowpowermodesensitivity attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentlowpowermodesensitivity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -750,50 +809,45 @@ class EnergyPreferenceCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -801,43 +855,49 @@ class EnergyPreferenceCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -847,50 +907,45 @@ class EnergyPreferenceCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -898,43 +953,49 @@ class EnergyPreferenceCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -944,48 +1005,45 @@ class EnergyPreferenceCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -993,43 +1051,49 @@ class EnergyPreferenceCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1039,48 +1103,45 @@ class EnergyPreferenceCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1088,37 +1149,44 @@ class EnergyPreferenceCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1127,37 +1195,35 @@ class EnergyPreferenceCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1169,37 +1235,44 @@ class EnergyPreferenceCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1208,38 +1281,34 @@ class EnergyPreferenceCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1252,7 +1321,7 @@ class EnergyPreferenceCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt index 42447fc0dc649a..296db7e7974d5b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt @@ -17,107 +17,145 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EthernetNetworkDiagnosticsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class PHYRateAttribute(val value: UByte?) +class EthernetNetworkDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class PHYRateAttribute( + val value: UByte? + ) sealed class PHYRateAttributeSubscriptionState { - data class Success(val value: UByte?) : PHYRateAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : PHYRateAttributeSubscriptionState() + data class Error(val exception: Exception) : PHYRateAttributeSubscriptionState() - object SubscriptionEstablished : PHYRateAttributeSubscriptionState() - } - - class FullDuplexAttribute(val value: Boolean?) + object SubscriptionEstablished : PHYRateAttributeSubscriptionState() + } +class FullDuplexAttribute( + val value: Boolean? + ) sealed class FullDuplexAttributeSubscriptionState { - data class Success(val value: Boolean?) : FullDuplexAttributeSubscriptionState() - + data class Success( + val value: Boolean? + ) : FullDuplexAttributeSubscriptionState() + data class Error(val exception: Exception) : FullDuplexAttributeSubscriptionState() - object SubscriptionEstablished : FullDuplexAttributeSubscriptionState() - } - - class CarrierDetectAttribute(val value: Boolean?) + object SubscriptionEstablished : FullDuplexAttributeSubscriptionState() + } +class CarrierDetectAttribute( + val value: Boolean? + ) sealed class CarrierDetectAttributeSubscriptionState { - data class Success(val value: Boolean?) : CarrierDetectAttributeSubscriptionState() - + data class Success( + val value: Boolean? + ) : CarrierDetectAttributeSubscriptionState() + data class Error(val exception: Exception) : CarrierDetectAttributeSubscriptionState() - object SubscriptionEstablished : CarrierDetectAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : CarrierDetectAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCounts(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -130,44 +168,50 @@ class EthernetNetworkDiagnosticsCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readPHYRateAttribute(): PHYRateAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPHYRateAttribute(): PHYRateAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Phyrate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Phyrate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PHYRateAttribute(decodedValue) } @@ -177,98 +221,104 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PHYRateAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PHYRateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Phyrate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Phyrate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PHYRateAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PHYRateAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PHYRateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFullDuplexAttribute(): FullDuplexAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFullDuplexAttribute(): FullDuplexAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Fullduplex attribute not found in response" } + } + + requireNotNull(attributeData) { + "Fullduplex attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Boolean? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return FullDuplexAttribute(decodedValue) } @@ -278,93 +328,99 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FullDuplexAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FullDuplexAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Fullduplex attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Fullduplex attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(FullDuplexAttributeSubscriptionState.Success(it)) } + val decodedValue: Boolean? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(FullDuplexAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FullDuplexAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPacketRxCountAttribute(): ULong? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPacketRxCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Packetrxcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Packetrxcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -374,88 +430,94 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Packetrxcount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Packetrxcount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ULongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPacketTxCountAttribute(): ULong? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPacketTxCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Packettxcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Packettxcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -465,88 +527,94 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Packettxcount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Packettxcount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ULongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTxErrCountAttribute(): ULong? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTxErrCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txerrcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txerrcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -556,88 +624,94 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Txerrcount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txerrcount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ULongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCollisionCountAttribute(): ULong? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCollisionCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Collisioncount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Collisioncount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -647,90 +721,94 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Collisioncount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Collisioncount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ULongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOverrunCountAttribute(): ULong? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOverrunCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Overruncount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Overruncount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -740,93 +818,99 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Overruncount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Overruncount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ULongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCarrierDetectAttribute(): CarrierDetectAttribute { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCarrierDetectAttribute(): CarrierDetectAttribute {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Carrierdetect attribute not found in response" } + } + + requireNotNull(attributeData) { + "Carrierdetect attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Boolean? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CarrierDetectAttribute(decodedValue) } @@ -836,93 +920,99 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CarrierDetectAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CarrierDetectAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Carrierdetect attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Carrierdetect attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CarrierDetectAttributeSubscriptionState.Success(it)) } + val decodedValue: Boolean? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CarrierDetectAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CarrierDetectAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTimeSinceResetAttribute(): ULong? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTimeSinceResetAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Timesincereset attribute not found in response" } + } + + requireNotNull(attributeData) { + "Timesincereset attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -932,92 +1022,96 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Timesincereset attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Timesincereset attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ULongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1027,50 +1121,45 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1078,43 +1167,49 @@ class EthernetNetworkDiagnosticsCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1124,50 +1219,45 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1175,43 +1265,49 @@ class EthernetNetworkDiagnosticsCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1221,48 +1317,45 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1270,43 +1363,49 @@ class EthernetNetworkDiagnosticsCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1316,48 +1415,45 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1365,37 +1461,44 @@ class EthernetNetworkDiagnosticsCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1404,37 +1507,35 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1446,37 +1547,44 @@ class EthernetNetworkDiagnosticsCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1485,38 +1593,34 @@ class EthernetNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1529,7 +1633,7 @@ class EthernetNetworkDiagnosticsCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt index 12baa895406dac..6d0e58a6d5b9b2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt @@ -17,99 +17,131 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class FanControlCluster(private val controller: MatterController, private val endpointId: UShort) { - class PercentSettingAttribute(val value: UByte?) +class FanControlCluster(private val controller: MatterController, private val endpointId: UShort) {class PercentSettingAttribute( + val value: UByte? + ) sealed class PercentSettingAttributeSubscriptionState { - data class Success(val value: UByte?) : PercentSettingAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : PercentSettingAttributeSubscriptionState() + data class Error(val exception: Exception) : PercentSettingAttributeSubscriptionState() - object SubscriptionEstablished : PercentSettingAttributeSubscriptionState() - } - - class SpeedSettingAttribute(val value: UByte?) + object SubscriptionEstablished : PercentSettingAttributeSubscriptionState() + } +class SpeedSettingAttribute( + val value: UByte? + ) sealed class SpeedSettingAttributeSubscriptionState { - data class Success(val value: UByte?) : SpeedSettingAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : SpeedSettingAttributeSubscriptionState() + data class Error(val exception: Exception) : SpeedSettingAttributeSubscriptionState() - object SubscriptionEstablished : SpeedSettingAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : SpeedSettingAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun step( - direction: UByte, - wrap: Boolean?, - lowestOff: Boolean?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun step(direction: UByte + ,wrap: Boolean? + ,lowestOff: Boolean? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -119,10 +151,14 @@ class FanControlCluster(private val controller: MatterController, private val en tlvWriter.put(ContextSpecificTag(TAG_DIRECTION_REQ), direction) val TAG_WRAP_REQ: Int = 1 - wrap?.let { tlvWriter.put(ContextSpecificTag(TAG_WRAP_REQ), wrap) } + wrap?.let { + tlvWriter.put(ContextSpecificTag(TAG_WRAP_REQ), wrap) + } val TAG_LOWEST_OFF_REQ: Int = 2 - lowestOff?.let { tlvWriter.put(ContextSpecificTag(TAG_LOWEST_OFF_REQ), lowestOff) } + lowestOff?.let { + tlvWriter.put(ContextSpecificTag(TAG_LOWEST_OFF_REQ), lowestOff) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -135,54 +171,65 @@ class FanControlCluster(private val controller: MatterController, private val en val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readFanModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFanModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Fanmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Fanmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeFanModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeFanModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -204,7 +251,7 @@ class FanControlCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFanModeAttribute( @@ -212,37 +259,35 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Fanmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Fanmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -254,37 +299,44 @@ class FanControlCluster(private val controller: MatterController, private val en emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFanModeSequenceAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFanModeSequenceAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Fanmodesequence attribute not found in response" } + } + + requireNotNull(attributeData) { + "Fanmodesequence attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -293,38 +345,34 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Fanmodesequence attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Fanmodesequence attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -337,62 +385,72 @@ class FanControlCluster(private val controller: MatterController, private val en emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPercentSettingAttribute(): PercentSettingAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPercentSettingAttribute(): PercentSettingAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Percentsetting attribute not found in response" } + } + + requireNotNull(attributeData) { + "Percentsetting attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PercentSettingAttribute(decodedValue) } - suspend fun writePercentSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writePercentSettingAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -414,7 +472,7 @@ class FanControlCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePercentSettingAttribute( @@ -422,87 +480,92 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PercentSettingAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PercentSettingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Percentsetting attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Percentsetting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PercentSettingAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PercentSettingAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PercentSettingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPercentCurrentAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPercentCurrentAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Percentcurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Percentcurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -511,38 +574,34 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Percentcurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Percentcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -555,41 +614,47 @@ class FanControlCluster(private val controller: MatterController, private val en emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSpeedMaxAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSpeedMaxAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Speedmax attribute not found in response" } + } + + requireNotNull(attributeData) { + "Speedmax attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -599,113 +664,123 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Speedmax attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Speedmax attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Speedsetting attribute not found in response" } + } + + requireNotNull(attributeData) { + "Speedsetting attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SpeedSettingAttribute(decodedValue) } - suspend fun writeSpeedSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeSpeedSettingAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -727,7 +802,7 @@ class FanControlCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSpeedSettingAttribute( @@ -735,93 +810,99 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SpeedSettingAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SpeedSettingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Speedsetting attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Speedsetting attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(SpeedSettingAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(SpeedSettingAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SpeedSettingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSpeedCurrentAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSpeedCurrentAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Speedcurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Speedcurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -831,88 +912,94 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Speedcurrent attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Speedcurrent attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readRockSupportAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readRockSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rocksupport attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rocksupport attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -922,108 +1009,118 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rocksupport attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rocksupport attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readRockSettingAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readRockSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rocksetting attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rocksetting attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeRockSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeRockSettingAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1045,7 +1142,7 @@ class FanControlCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRockSettingAttribute( @@ -1053,88 +1150,94 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rocksetting attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rocksetting attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readWindSupportAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readWindSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Windsupport attribute not found in response" } + } + + requireNotNull(attributeData) { + "Windsupport attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1144,108 +1247,118 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Windsupport attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Windsupport attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readWindSettingAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readWindSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Windsetting attribute not found in response" } + } + + requireNotNull(attributeData) { + "Windsetting attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeWindSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeWindSettingAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1267,7 +1380,7 @@ class FanControlCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWindSettingAttribute( @@ -1275,108 +1388,118 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Windsetting attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Windsetting attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAirflowDirectionAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 11u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAirflowDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Airflowdirection attribute not found in response" } + } + + requireNotNull(attributeData) { + "Airflowdirection attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeAirflowDirectionAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeAirflowDirectionAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 11u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1398,7 +1521,7 @@ class FanControlCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAirflowDirectionAttribute( @@ -1406,92 +1529,96 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Airflowdirection attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Airflowdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1501,50 +1628,45 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1552,43 +1674,49 @@ class FanControlCluster(private val controller: MatterController, private val en emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1598,50 +1726,45 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1649,43 +1772,49 @@ class FanControlCluster(private val controller: MatterController, private val en emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1695,48 +1824,45 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1744,43 +1870,49 @@ class FanControlCluster(private val controller: MatterController, private val en emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1790,48 +1922,45 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1839,37 +1968,44 @@ class FanControlCluster(private val controller: MatterController, private val en emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1878,37 +2014,35 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1920,37 +2054,44 @@ class FanControlCluster(private val controller: MatterController, private val en emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1959,38 +2100,34 @@ class FanControlCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2003,7 +2140,7 @@ class FanControlCluster(private val controller: MatterController, private val en emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt index 5597bfd94af98a..cd6627c787c57a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt @@ -17,80 +17,107 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class FaultInjectionCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class FaultInjectionCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun failAtFault( - type: UByte, - id: UInt, - numCallsToSkip: UInt, - numCallsToFail: UInt, - takeMutex: Boolean, - timedInvokeTimeout: Duration? = null - ) { + suspend fun failAtFault(type: UByte + ,id: UInt + ,numCallsToSkip: UInt + ,numCallsToFail: UInt + ,takeMutex: Boolean + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -109,7 +136,7 @@ class FaultInjectionCluster( tlvWriter.put(ContextSpecificTag(TAG_NUM_CALLS_TO_FAIL_REQ), numCallsToFail) val TAG_TAKE_MUTEX_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_TAKE_MUTEX_REQ), takeMutex) + tlvWriter.put(ContextSpecificTag(TAG_TAKE_MUTEX_REQ), takeMutex) tlvWriter.endStructure() val request: InvokeRequest = @@ -123,12 +150,10 @@ class FaultInjectionCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun failRandomlyAtFault( - type: UByte, - id: UInt, - percentage: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun failRandomlyAtFault(type: UByte + ,id: UInt + ,percentage: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -141,7 +166,7 @@ class FaultInjectionCluster( tlvWriter.put(ContextSpecificTag(TAG_ID_REQ), id) val TAG_PERCENTAGE_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_PERCENTAGE_REQ), percentage) + tlvWriter.put(ContextSpecificTag(TAG_PERCENTAGE_REQ), percentage) tlvWriter.endStructure() val request: InvokeRequest = @@ -154,41 +179,47 @@ class FaultInjectionCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -198,50 +229,45 @@ class FaultInjectionCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -249,43 +275,49 @@ class FaultInjectionCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -295,50 +327,45 @@ class FaultInjectionCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -346,43 +373,49 @@ class FaultInjectionCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -392,48 +425,45 @@ class FaultInjectionCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -441,43 +471,49 @@ class FaultInjectionCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -487,48 +523,45 @@ class FaultInjectionCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -536,37 +569,44 @@ class FaultInjectionCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -575,37 +615,35 @@ class FaultInjectionCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -617,37 +655,44 @@ class FaultInjectionCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -656,38 +701,34 @@ class FaultInjectionCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -700,7 +741,7 @@ class FaultInjectionCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt index 4fe3dd45c9ccd6..f36bab66f10935 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt @@ -17,109 +17,154 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class FixedLabelCluster(private val controller: MatterController, private val endpointId: UShort) { - class LabelListAttribute(val value: List) +class FixedLabelCluster(private val controller: MatterController, private val endpointId: UShort) {class LabelListAttribute( + val value: List + ) sealed class LabelListAttributeSubscriptionState { - data class Success(val value: List) : - LabelListAttributeSubscriptionState() - + data class Success( + val value: List + ) : LabelListAttributeSubscriptionState() + data class Error(val exception: Exception) : LabelListAttributeSubscriptionState() - object SubscriptionEstablished : LabelListAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : LabelListAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readLabelListAttribute(): LabelListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Labellist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Labellist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return LabelListAttribute(decodedValue) } @@ -129,48 +174,45 @@ class FixedLabelCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LabelListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LabelListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Labellist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Labellist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(LabelListAttributeSubscriptionState.Success(decodedValue)) } @@ -178,43 +220,49 @@ class FixedLabelCluster(private val controller: MatterController, private val en emit(LabelListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -224,50 +272,45 @@ class FixedLabelCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -275,43 +318,49 @@ class FixedLabelCluster(private val controller: MatterController, private val en emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -321,50 +370,45 @@ class FixedLabelCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -372,43 +416,49 @@ class FixedLabelCluster(private val controller: MatterController, private val en emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -418,48 +468,45 @@ class FixedLabelCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -467,43 +514,49 @@ class FixedLabelCluster(private val controller: MatterController, private val en emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -513,48 +566,45 @@ class FixedLabelCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -562,37 +612,44 @@ class FixedLabelCluster(private val controller: MatterController, private val en emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -601,37 +658,35 @@ class FixedLabelCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -643,37 +698,44 @@ class FixedLabelCluster(private val controller: MatterController, private val en emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -682,38 +744,34 @@ class FixedLabelCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -726,7 +784,7 @@ class FixedLabelCluster(private val controller: MatterController, private val en emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt index 35d293bd0a4ca9..4987d915eb1c39 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt @@ -17,130 +17,179 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class FlowMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: UShort?) +class FlowMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: UShort? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: UShort?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: UShort?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: UShort? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: UShort?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: UShort?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: UShort? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: UShort?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -150,90 +199,96 @@ class FlowMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -243,92 +298,96 @@ class FlowMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -338,91 +397,95 @@ class FlowMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readToleranceAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Tolerance attribute not found in response" } + } + + requireNotNull(attributeData) { + "Tolerance attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -432,90 +495,96 @@ class FlowMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Tolerance attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -525,50 +594,45 @@ class FlowMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -576,43 +640,49 @@ class FlowMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -622,50 +692,45 @@ class FlowMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -673,43 +738,49 @@ class FlowMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -719,48 +790,45 @@ class FlowMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -768,43 +836,49 @@ class FlowMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -814,48 +888,45 @@ class FlowMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -863,37 +934,44 @@ class FlowMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -902,37 +980,35 @@ class FlowMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -944,37 +1020,44 @@ class FlowMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -983,38 +1066,34 @@ class FlowMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1027,7 +1106,7 @@ class FlowMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt index c60f4e6484a856..472a14b09e3fea 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt @@ -17,156 +17,209 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class FormaldehydeConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) +class FormaldehydeConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Float? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Float? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Float? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class PeakMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class PeakMeasuredValueAttribute( + val value: Float? + ) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } - - class AverageMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } +class AverageMeasuredValueAttribute( + val value: Float? + ) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -176,98 +229,104 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -277,100 +336,104 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -380,100 +443,104 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeakMeasuredValueAttribute(decodedValue) } @@ -483,95 +550,99 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeakMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -581,95 +652,99 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AverageMeasuredValueAttribute(decodedValue) } @@ -679,95 +754,99 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AverageMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -777,90 +856,94 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUncertaintyAttribute(): Float? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + return decodedValue } @@ -870,88 +953,94 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(FloatSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementUnitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -961,90 +1050,94 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementMediumAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1054,90 +1147,94 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLevelValueAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1147,90 +1244,96 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1240,50 +1343,45 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1291,43 +1389,49 @@ class FormaldehydeConcentrationMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1337,50 +1441,45 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1388,43 +1487,49 @@ class FormaldehydeConcentrationMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1434,48 +1539,45 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1483,43 +1585,49 @@ class FormaldehydeConcentrationMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1529,48 +1637,45 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1578,37 +1683,44 @@ class FormaldehydeConcentrationMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1617,37 +1729,35 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1659,37 +1769,44 @@ class FormaldehydeConcentrationMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1698,38 +1815,34 @@ class FormaldehydeConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1742,12 +1855,11 @@ class FormaldehydeConcentrationMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = - Logger.getLogger(FormaldehydeConcentrationMeasurementCluster::class.java.name) + private val logger = Logger.getLogger(FormaldehydeConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1067u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt index f16803780a0253..6427becbb270e0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt @@ -17,102 +17,132 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.UShortSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralCommissioningCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ArmFailSafeResponse(val errorCode: UByte, val debugText: String) - - class SetRegulatoryConfigResponse(val errorCode: UByte, val debugText: String) +class GeneralCommissioningCluster(private val controller: MatterController, private val endpointId: UShort) { + class ArmFailSafeResponse( + val errorCode: UByte, + val debugText: String + ) - class CommissioningCompleteResponse(val errorCode: UByte, val debugText: String) + class SetRegulatoryConfigResponse( + val errorCode: UByte, + val debugText: String + ) - class BasicCommissioningInfoAttribute( + class CommissioningCompleteResponse( + val errorCode: UByte, + val debugText: String + ) +class BasicCommissioningInfoAttribute( val value: GeneralCommissioningClusterBasicCommissioningInfo ) sealed class BasicCommissioningInfoAttributeSubscriptionState { - data class Success(val value: GeneralCommissioningClusterBasicCommissioningInfo) : - BasicCommissioningInfoAttributeSubscriptionState() - + data class Success( + val value: GeneralCommissioningClusterBasicCommissioningInfo + ) : BasicCommissioningInfoAttributeSubscriptionState() + data class Error(val exception: Exception) : BasicCommissioningInfoAttributeSubscriptionState() - object SubscriptionEstablished : BasicCommissioningInfoAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : BasicCommissioningInfoAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun armFailSafe( - expiryLengthSeconds: UShort, - breadcrumb: ULong, - timedInvokeTimeout: Duration? = null - ): ArmFailSafeResponse { + suspend fun armFailSafe(expiryLengthSeconds: UShort + ,breadcrumb: ULong + ,timedInvokeTimeout: Duration? = null): ArmFailSafeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -122,7 +152,7 @@ class GeneralCommissioningCluster( tlvWriter.put(ContextSpecificTag(TAG_EXPIRY_LENGTH_SECONDS_REQ), expiryLengthSeconds) val TAG_BREADCRUMB_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) tlvWriter.endStructure() val request: InvokeRequest = @@ -139,43 +169,49 @@ class GeneralCommissioningCluster( tlvReader.enterStructure(AnonymousTag) val TAG_ERROR_CODE: Int = 0 var errorCode_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { - errorCode_decoded = tlvReader.getUByte(tag) - } + + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) {errorCode_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = tlvReader.getString(tag)} + - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = tlvReader.getString(tag) - } else { + else { tlvReader.skipElement() } } + + if (errorCode_decoded == null) { - throw IllegalStateException("errorCode not found in TLV") + throw IllegalStateException("errorCode not found in TLV") } - + + if (debugText_decoded == null) { - throw IllegalStateException("debugText not found in TLV") + throw IllegalStateException("debugText not found in TLV") } + tlvReader.exitContainer() - return ArmFailSafeResponse(errorCode_decoded, debugText_decoded) + return ArmFailSafeResponse( + errorCode_decoded, + debugText_decoded + ) } - suspend fun setRegulatoryConfig( - newRegulatoryConfig: UByte, - countryCode: String, - breadcrumb: ULong, - timedInvokeTimeout: Duration? = null - ): SetRegulatoryConfigResponse { + suspend fun setRegulatoryConfig(newRegulatoryConfig: UByte + ,countryCode: String + ,breadcrumb: ULong + ,timedInvokeTimeout: Duration? = null): SetRegulatoryConfigResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -188,7 +224,7 @@ class GeneralCommissioningCluster( tlvWriter.put(ContextSpecificTag(TAG_COUNTRY_CODE_REQ), countryCode) val TAG_BREADCRUMB_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) tlvWriter.endStructure() val request: InvokeRequest = @@ -205,44 +241,50 @@ class GeneralCommissioningCluster( tlvReader.enterStructure(AnonymousTag) val TAG_ERROR_CODE: Int = 0 var errorCode_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { - errorCode_decoded = tlvReader.getUByte(tag) - } + + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) {errorCode_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = tlvReader.getString(tag)} + - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = tlvReader.getString(tag) - } else { + else { tlvReader.skipElement() } } + + if (errorCode_decoded == null) { - throw IllegalStateException("errorCode not found in TLV") + throw IllegalStateException("errorCode not found in TLV") } - + + if (debugText_decoded == null) { - throw IllegalStateException("debugText not found in TLV") + throw IllegalStateException("debugText not found in TLV") } + tlvReader.exitContainer() - return SetRegulatoryConfigResponse(errorCode_decoded, debugText_decoded) + return SetRegulatoryConfigResponse( + errorCode_decoded, + debugText_decoded + ) } - suspend fun commissioningComplete( - timedInvokeTimeout: Duration? = null - ): CommissioningCompleteResponse { + suspend fun commissioningComplete(timedInvokeTimeout: Duration? = null): CommissioningCompleteResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -259,84 +301,103 @@ class GeneralCommissioningCluster( tlvReader.enterStructure(AnonymousTag) val TAG_ERROR_CODE: Int = 0 var errorCode_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { - errorCode_decoded = tlvReader.getUByte(tag) - } + + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) {errorCode_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = tlvReader.getString(tag)} + - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = tlvReader.getString(tag) - } else { + else { tlvReader.skipElement() } } + + if (errorCode_decoded == null) { - throw IllegalStateException("errorCode not found in TLV") + throw IllegalStateException("errorCode not found in TLV") } - + + if (debugText_decoded == null) { - throw IllegalStateException("debugText not found in TLV") + throw IllegalStateException("debugText not found in TLV") } + tlvReader.exitContainer() - return CommissioningCompleteResponse(errorCode_decoded, debugText_decoded) + return CommissioningCompleteResponse( + errorCode_decoded, + debugText_decoded + ) } - - suspend fun readBreadcrumbAttribute(): ULong { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBreadcrumbAttribute(): ULong {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Breadcrumb attribute not found in response" } + } + + requireNotNull(attributeData) { + "Breadcrumb attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + return decodedValue } - suspend fun writeBreadcrumbAttribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeBreadcrumbAttribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -358,7 +419,7 @@ class GeneralCommissioningCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBreadcrumbAttribute( @@ -366,37 +427,35 @@ class GeneralCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Breadcrumb attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Breadcrumb attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -408,37 +467,43 @@ class GeneralCommissioningCluster( emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Basiccommissioninginfo attribute not found in response" } + } + + requireNotNull(attributeData) { + "Basiccommissioninginfo attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = - GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) + val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) + return BasicCommissioningInfoAttribute(decodedValue) } @@ -448,44 +513,39 @@ class GeneralCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BasicCommissioningInfoAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BasicCommissioningInfoAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Basiccommissioninginfo attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Basiccommissioninginfo attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = - GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) + val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) emit(BasicCommissioningInfoAttributeSubscriptionState.Success(decodedValue)) } @@ -493,37 +553,44 @@ class GeneralCommissioningCluster( emit(BasicCommissioningInfoAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readRegulatoryConfigAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readRegulatoryConfigAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Regulatoryconfig attribute not found in response" } + } + + requireNotNull(attributeData) { + "Regulatoryconfig attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -532,38 +599,34 @@ class GeneralCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Regulatoryconfig attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Regulatoryconfig attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -576,37 +639,44 @@ class GeneralCommissioningCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLocationCapabilityAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLocationCapabilityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Locationcapability attribute not found in response" } + } + + requireNotNull(attributeData) { + "Locationcapability attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -615,38 +685,34 @@ class GeneralCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Locationcapability attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Locationcapability attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -659,37 +725,44 @@ class GeneralCommissioningCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportsConcurrentConnectionAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportsConcurrentConnectionAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportsconcurrentconnection attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportsconcurrentconnection attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -698,38 +771,34 @@ class GeneralCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportsconcurrentconnection attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportsconcurrentconnection attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -742,43 +811,49 @@ class GeneralCommissioningCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -788,50 +863,45 @@ class GeneralCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -839,43 +909,49 @@ class GeneralCommissioningCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -885,50 +961,45 @@ class GeneralCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -936,43 +1007,49 @@ class GeneralCommissioningCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -982,48 +1059,45 @@ class GeneralCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1031,43 +1105,49 @@ class GeneralCommissioningCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1077,48 +1157,45 @@ class GeneralCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1126,37 +1203,44 @@ class GeneralCommissioningCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1165,37 +1249,35 @@ class GeneralCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1207,37 +1289,44 @@ class GeneralCommissioningCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1246,38 +1335,34 @@ class GeneralCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1290,7 +1375,7 @@ class GeneralCommissioningCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt index cdc7a18ad10d15..f2e917cb082f20 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt @@ -17,123 +17,161 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralDiagnosticsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class TimeSnapshotResponse(val systemTimeMs: ULong, val posixTimeMs: ULong?) - - class NetworkInterfacesAttribute(val value: List) +class GeneralDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) { + class TimeSnapshotResponse( + val systemTimeMs: ULong, + val posixTimeMs: ULong? + ) +class NetworkInterfacesAttribute( + val value: List + ) sealed class NetworkInterfacesAttributeSubscriptionState { - data class Success(val value: List) : - NetworkInterfacesAttributeSubscriptionState() - + data class Success( + val value: List + ) : NetworkInterfacesAttributeSubscriptionState() + data class Error(val exception: Exception) : NetworkInterfacesAttributeSubscriptionState() - object SubscriptionEstablished : NetworkInterfacesAttributeSubscriptionState() - } - - class ActiveHardwareFaultsAttribute(val value: List?) + object SubscriptionEstablished : NetworkInterfacesAttributeSubscriptionState() + } +class ActiveHardwareFaultsAttribute( + val value: List? + ) sealed class ActiveHardwareFaultsAttributeSubscriptionState { - data class Success(val value: List?) : ActiveHardwareFaultsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : ActiveHardwareFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveHardwareFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveHardwareFaultsAttributeSubscriptionState() - } - - class ActiveRadioFaultsAttribute(val value: List?) + object SubscriptionEstablished : ActiveHardwareFaultsAttributeSubscriptionState() + } +class ActiveRadioFaultsAttribute( + val value: List? + ) sealed class ActiveRadioFaultsAttributeSubscriptionState { - data class Success(val value: List?) : ActiveRadioFaultsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : ActiveRadioFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveRadioFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveRadioFaultsAttributeSubscriptionState() - } - - class ActiveNetworkFaultsAttribute(val value: List?) + object SubscriptionEstablished : ActiveRadioFaultsAttributeSubscriptionState() + } +class ActiveNetworkFaultsAttribute( + val value: List? + ) sealed class ActiveNetworkFaultsAttributeSubscriptionState { - data class Success(val value: List?) : ActiveNetworkFaultsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : ActiveNetworkFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveNetworkFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveNetworkFaultsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : ActiveNetworkFaultsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun testEventTrigger( - enableKey: ByteArray, - eventTrigger: ULong, - timedInvokeTimeout: Duration? = null - ) { + suspend fun testEventTrigger(enableKey: ByteArray + ,eventTrigger: ULong + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -143,7 +181,7 @@ class GeneralDiagnosticsCluster( tlvWriter.put(ContextSpecificTag(TAG_ENABLE_KEY_REQ), enableKey) val TAG_EVENT_TRIGGER_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_EVENT_TRIGGER_REQ), eventTrigger) + tlvWriter.put(ContextSpecificTag(TAG_EVENT_TRIGGER_REQ), eventTrigger) tlvWriter.endStructure() val request: InvokeRequest = @@ -161,7 +199,7 @@ class GeneralDiagnosticsCluster( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -178,78 +216,93 @@ class GeneralDiagnosticsCluster( tlvReader.enterStructure(AnonymousTag) val TAG_SYSTEM_TIME_MS: Int = 0 var systemTimeMs_decoded: ULong? = null - + val TAG_POSIX_TIME_MS: Int = 1 var posixTimeMs_decoded: ULong? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_SYSTEM_TIME_MS)) { - systemTimeMs_decoded = tlvReader.getULong(tag) - } - - if (tag == ContextSpecificTag(TAG_POSIX_TIME_MS)) { - posixTimeMs_decoded = + + if (tag == ContextSpecificTag(TAG_SYSTEM_TIME_MS)) {systemTimeMs_decoded = tlvReader.getULong(tag)} + + if (tag == ContextSpecificTag(TAG_POSIX_TIME_MS)) {posixTimeMs_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getULong(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } else { + tlvReader.getULong(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + + else { tlvReader.skipElement() } } + + if (systemTimeMs_decoded == null) { - throw IllegalStateException("systemTimeMs not found in TLV") + throw IllegalStateException("systemTimeMs not found in TLV") } + + + tlvReader.exitContainer() - return TimeSnapshotResponse(systemTimeMs_decoded, posixTimeMs_decoded) + return TimeSnapshotResponse( + systemTimeMs_decoded, + posixTimeMs_decoded + ) } - - suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Networkinterfaces attribute not found in response" } + } + + requireNotNull(attributeData) { + "Networkinterfaces attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return NetworkInterfacesAttribute(decodedValue) } @@ -259,50 +312,45 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NetworkInterfacesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NetworkInterfacesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Networkinterfaces attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Networkinterfaces attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(NetworkInterfacesAttributeSubscriptionState.Success(decodedValue)) } @@ -310,37 +358,44 @@ class GeneralDiagnosticsCluster( emit(NetworkInterfacesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readRebootCountAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readRebootCountAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rebootcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rebootcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -349,37 +404,35 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rebootcount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rebootcount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -391,41 +444,47 @@ class GeneralDiagnosticsCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUpTimeAttribute(): ULong? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUpTimeAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uptime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uptime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -435,88 +494,94 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uptime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uptime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ULongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTotalOperationalHoursAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTotalOperationalHoursAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Totaloperationalhours attribute not found in response" } + } + + requireNotNull(attributeData) { + "Totaloperationalhours attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -526,90 +591,94 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Totaloperationalhours attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Totaloperationalhours attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBootReasonAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBootReasonAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Bootreason attribute not found in response" } + } + + requireNotNull(attributeData) { + "Bootreason attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -619,94 +688,100 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Bootreason attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Bootreason attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readActiveHardwareFaultsAttribute(): ActiveHardwareFaultsAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readActiveHardwareFaultsAttribute(): ActiveHardwareFaultsAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activehardwarefaults attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activehardwarefaults attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return ActiveHardwareFaultsAttribute(decodedValue) } @@ -716,102 +791,106 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveHardwareFaultsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveHardwareFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activehardwarefaults attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activehardwarefaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ActiveHardwareFaultsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ActiveHardwareFaultsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ActiveHardwareFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readActiveRadioFaultsAttribute(): ActiveRadioFaultsAttribute { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readActiveRadioFaultsAttribute(): ActiveRadioFaultsAttribute {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activeradiofaults attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activeradiofaults attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return ActiveRadioFaultsAttribute(decodedValue) } @@ -821,102 +900,106 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveRadioFaultsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveRadioFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activeradiofaults attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activeradiofaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ActiveRadioFaultsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ActiveRadioFaultsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ActiveRadioFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readActiveNetworkFaultsAttribute(): ActiveNetworkFaultsAttribute { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readActiveNetworkFaultsAttribute(): ActiveNetworkFaultsAttribute {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activenetworkfaults attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activenetworkfaults attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return ActiveNetworkFaultsAttribute(decodedValue) } @@ -926,92 +1009,97 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveNetworkFaultsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveNetworkFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activenetworkfaults attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activenetworkfaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ActiveNetworkFaultsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ActiveNetworkFaultsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ActiveNetworkFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTestEventTriggersEnabledAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTestEventTriggersEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Testeventtriggersenabled attribute not found in response" } + } + + requireNotNull(attributeData) { + "Testeventtriggersenabled attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -1020,38 +1108,34 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Testeventtriggersenabled attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Testeventtriggersenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1064,43 +1148,49 @@ class GeneralDiagnosticsCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1110,50 +1200,45 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1161,43 +1246,49 @@ class GeneralDiagnosticsCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1207,50 +1298,45 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1258,43 +1344,49 @@ class GeneralDiagnosticsCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1304,48 +1396,45 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1353,43 +1442,49 @@ class GeneralDiagnosticsCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1399,48 +1494,45 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1448,37 +1540,44 @@ class GeneralDiagnosticsCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1487,37 +1586,35 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1529,37 +1626,44 @@ class GeneralDiagnosticsCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1568,38 +1672,34 @@ class GeneralDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1612,7 +1712,7 @@ class GeneralDiagnosticsCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt index 7d6a660be3afb0..975133eb203f79 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt @@ -17,112 +17,144 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GroupKeyManagementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class KeySetReadResponse(val groupKeySet: GroupKeyManagementClusterGroupKeySetStruct) - - class KeySetReadAllIndicesResponse(val groupKeySetIDs: List) +class GroupKeyManagementCluster(private val controller: MatterController, private val endpointId: UShort) { + class KeySetReadResponse( + val groupKeySet: GroupKeyManagementClusterGroupKeySetStruct + ) - class GroupKeyMapAttribute(val value: List) + class KeySetReadAllIndicesResponse( + val groupKeySetIDs: List + ) +class GroupKeyMapAttribute( + val value: List + ) sealed class GroupKeyMapAttributeSubscriptionState { - data class Success(val value: List) : - GroupKeyMapAttributeSubscriptionState() - + data class Success( + val value: List + ) : GroupKeyMapAttributeSubscriptionState() + data class Error(val exception: Exception) : GroupKeyMapAttributeSubscriptionState() - object SubscriptionEstablished : GroupKeyMapAttributeSubscriptionState() - } - - class GroupTableAttribute(val value: List) + object SubscriptionEstablished : GroupKeyMapAttributeSubscriptionState() + } +class GroupTableAttribute( + val value: List + ) sealed class GroupTableAttributeSubscriptionState { - data class Success(val value: List) : - GroupTableAttributeSubscriptionState() - + data class Success( + val value: List + ) : GroupTableAttributeSubscriptionState() + data class Error(val exception: Exception) : GroupTableAttributeSubscriptionState() - object SubscriptionEstablished : GroupTableAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : GroupTableAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun keySetWrite( - groupKeySet: GroupKeyManagementClusterGroupKeySetStruct, - timedInvokeTimeout: Duration? = null - ) { + suspend fun keySetWrite(groupKeySet: GroupKeyManagementClusterGroupKeySetStruct + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_KEY_SET_REQ: Int = 0 - groupKeySet.toTlv(ContextSpecificTag(TAG_GROUP_KEY_SET_REQ), tlvWriter) + groupKeySet.toTlv(ContextSpecificTag(TAG_GROUP_KEY_SET_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -136,17 +168,15 @@ class GroupKeyManagementCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun keySetRead( - groupKeySetID: UShort, - timedInvokeTimeout: Duration? = null - ): KeySetReadResponse { + suspend fun keySetRead(groupKeySetID: UShort + ,timedInvokeTimeout: Duration? = null): KeySetReadResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_KEY_SET_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) tlvWriter.endStructure() val request: InvokeRequest = @@ -163,34 +193,43 @@ class GroupKeyManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_GROUP_KEY_SET: Int = 0 var groupKeySet_decoded: GroupKeyManagementClusterGroupKeySetStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET)) { - groupKeySet_decoded = GroupKeyManagementClusterGroupKeySetStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET)) {groupKeySet_decoded = GroupKeyManagementClusterGroupKeySetStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (groupKeySet_decoded == null) { - throw IllegalStateException("groupKeySet not found in TLV") + throw IllegalStateException("groupKeySet not found in TLV") } + tlvReader.exitContainer() - return KeySetReadResponse(groupKeySet_decoded) + return KeySetReadResponse( + groupKeySet_decoded + ) } - suspend fun keySetRemove(groupKeySetID: UShort, timedInvokeTimeout: Duration? = null) { + suspend fun keySetRemove(groupKeySetID: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_KEY_SET_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) tlvWriter.endStructure() val request: InvokeRequest = @@ -204,13 +243,11 @@ class GroupKeyManagementCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun keySetReadAllIndices( - timedInvokeTimeout: Duration? = null - ): KeySetReadAllIndicesResponse { + suspend fun keySetReadAllIndices(timedInvokeTimeout: Duration? = null): KeySetReadAllIndicesResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -227,94 +264,108 @@ class GroupKeyManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_GROUP_KEY_SET_I_DS: Int = 0 var groupKeySetIDs_decoded: List? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET_I_DS)) { - groupKeySetIDs_decoded = - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { + + if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET_I_DS)) {groupKeySetIDs_decoded = buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + }} + + + else { tlvReader.skipElement() } } + + if (groupKeySetIDs_decoded == null) { - throw IllegalStateException("groupKeySetIDs not found in TLV") + throw IllegalStateException("groupKeySetIDs not found in TLV") } + tlvReader.exitContainer() - return KeySetReadAllIndicesResponse(groupKeySetIDs_decoded) + return KeySetReadAllIndicesResponse( + groupKeySetIDs_decoded + ) } - - suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Groupkeymap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Groupkeymap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return GroupKeyMapAttribute(decodedValue) } suspend fun writeGroupKeyMapAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -336,7 +387,7 @@ class GroupKeyManagementCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeGroupKeyMapAttribute( @@ -344,48 +395,45 @@ class GroupKeyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GroupKeyMapAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GroupKeyMapAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Groupkeymap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Groupkeymap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(GroupKeyMapAttributeSubscriptionState.Success(decodedValue)) } @@ -393,43 +441,49 @@ class GroupKeyManagementCluster( emit(GroupKeyMapAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGroupTableAttribute(): GroupTableAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGroupTableAttribute(): GroupTableAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Grouptable attribute not found in response" } + } + + requireNotNull(attributeData) { + "Grouptable attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return GroupTableAttribute(decodedValue) } @@ -439,48 +493,45 @@ class GroupKeyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GroupTableAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GroupTableAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Grouptable attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Grouptable attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(GroupTableAttributeSubscriptionState.Success(decodedValue)) } @@ -488,37 +539,44 @@ class GroupKeyManagementCluster( emit(GroupTableAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxGroupsPerFabricAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxGroupsPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxgroupsperfabric attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxgroupsperfabric attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -527,38 +585,34 @@ class GroupKeyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxgroupsperfabric attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxgroupsperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -571,37 +625,44 @@ class GroupKeyManagementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxGroupKeysPerFabricAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxGroupKeysPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxgroupkeysperfabric attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxgroupkeysperfabric attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -610,38 +671,34 @@ class GroupKeyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxgroupkeysperfabric attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxgroupkeysperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -654,43 +711,49 @@ class GroupKeyManagementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -700,50 +763,45 @@ class GroupKeyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -751,43 +809,49 @@ class GroupKeyManagementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -797,50 +861,45 @@ class GroupKeyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -848,43 +907,49 @@ class GroupKeyManagementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -894,48 +959,45 @@ class GroupKeyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -943,43 +1005,49 @@ class GroupKeyManagementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -989,48 +1057,45 @@ class GroupKeyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1038,37 +1103,44 @@ class GroupKeyManagementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1077,37 +1149,35 @@ class GroupKeyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1119,37 +1189,44 @@ class GroupKeyManagementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1158,38 +1235,34 @@ class GroupKeyManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1202,7 +1275,7 @@ class GroupKeyManagementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt index ca466afbdd0f61..3236b70b54bf79 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt @@ -17,83 +17,125 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class GroupsCluster(private val controller: MatterController, private val endpointId: UShort) { - class AddGroupResponse(val status: UByte, val groupID: UShort) - - class ViewGroupResponse(val status: UByte, val groupID: UShort, val groupName: String) - - class GetGroupMembershipResponse(val capacity: UByte?, val groupList: List) - - class RemoveGroupResponse(val status: UByte, val groupID: UShort) - - class GeneratedCommandListAttribute(val value: List) + class AddGroupResponse( + val status: UByte, + val groupID: UShort + ) + + class ViewGroupResponse( + val status: UByte, + val groupID: UShort, + val groupName: String + ) + + class GetGroupMembershipResponse( + val capacity: UByte?, + val groupList: List + ) + + class RemoveGroupResponse( + val status: UByte, + val groupID: UShort + ) +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun addGroup( - groupID: UShort, - groupName: String, - timedInvokeTimeout: Duration? = null - ): AddGroupResponse { + suspend fun addGroup(groupID: UShort + ,groupName: String + ,timedInvokeTimeout: Duration? = null): AddGroupResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -103,7 +145,7 @@ class GroupsCluster(private val controller: MatterController, private val endpoi tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_GROUP_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) tlvWriter.endStructure() val request: InvokeRequest = @@ -120,45 +162,54 @@ class GroupsCluster(private val controller: MatterController, private val endpoi tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} + - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { - groupID_decoded = tlvReader.getUShort(tag) - } else { + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } + tlvReader.exitContainer() - return AddGroupResponse(status_decoded, groupID_decoded) + return AddGroupResponse( + status_decoded, + groupID_decoded + ) } - suspend fun viewGroup(groupID: UShort, timedInvokeTimeout: Duration? = null): ViewGroupResponse { + suspend fun viewGroup(groupID: UShort + ,timedInvokeTimeout: Duration? = null): ViewGroupResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -175,52 +226,58 @@ class GroupsCluster(private val controller: MatterController, private val endpoi tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_GROUP_NAME: Int = 2 var groupName_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { - groupID_decoded = tlvReader.getUShort(tag) - } + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_NAME)) {groupName_decoded = tlvReader.getString(tag)} + - if (tag == ContextSpecificTag(TAG_GROUP_NAME)) { - groupName_decoded = tlvReader.getString(tag) - } else { + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - + + if (groupName_decoded == null) { - throw IllegalStateException("groupName not found in TLV") + throw IllegalStateException("groupName not found in TLV") } + tlvReader.exitContainer() - return ViewGroupResponse(status_decoded, groupID_decoded, groupName_decoded) + return ViewGroupResponse( + status_decoded, + groupID_decoded, + groupName_decoded + ) } - suspend fun getGroupMembership( - groupList: List, - timedInvokeTimeout: Duration? = null - ): GetGroupMembershipResponse { + suspend fun getGroupMembership(groupList: List + ,timedInvokeTimeout: Duration? = null): GetGroupMembershipResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -228,10 +285,10 @@ class GroupsCluster(private val controller: MatterController, private val endpoi val TAG_GROUP_LIST_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_GROUP_LIST_REQ)) - for (item in groupList.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in groupList.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -248,62 +305,68 @@ class GroupsCluster(private val controller: MatterController, private val endpoi tlvReader.enterStructure(AnonymousTag) val TAG_CAPACITY: Int = 0 var capacity_decoded: UByte? = null - + val TAG_GROUP_LIST: Int = 1 var groupList_decoded: List? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_CAPACITY)) { - capacity_decoded = + + if (tag == ContextSpecificTag(TAG_CAPACITY)) {capacity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - } + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_GROUP_LIST)) {groupList_decoded = buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) } + tlvReader.exitContainer() + }} + - if (tag == ContextSpecificTag(TAG_GROUP_LIST)) { - groupList_decoded = - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { + else { tlvReader.skipElement() } } + + + + if (groupList_decoded == null) { - throw IllegalStateException("groupList not found in TLV") + throw IllegalStateException("groupList not found in TLV") } + tlvReader.exitContainer() - return GetGroupMembershipResponse(capacity_decoded, groupList_decoded) + return GetGroupMembershipResponse( + capacity_decoded, + groupList_decoded + ) } - suspend fun removeGroup( - groupID: UShort, - timedInvokeTimeout: Duration? = null - ): RemoveGroupResponse { + suspend fun removeGroup(groupID: UShort + ,timedInvokeTimeout: Duration? = null): RemoveGroupResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -320,42 +383,50 @@ class GroupsCluster(private val controller: MatterController, private val endpoi tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} + - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { - groupID_decoded = tlvReader.getUShort(tag) - } else { + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } + tlvReader.exitContainer() - return RemoveGroupResponse(status_decoded, groupID_decoded) + return RemoveGroupResponse( + status_decoded, + groupID_decoded + ) } suspend fun removeAllGroups(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -369,11 +440,9 @@ class GroupsCluster(private val controller: MatterController, private val endpoi logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addGroupIfIdentifying( - groupID: UShort, - groupName: String, - timedInvokeTimeout: Duration? = null - ) { + suspend fun addGroupIfIdentifying(groupID: UShort + ,groupName: String + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -383,7 +452,7 @@ class GroupsCluster(private val controller: MatterController, private val endpoi tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_GROUP_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) tlvWriter.endStructure() val request: InvokeRequest = @@ -396,35 +465,42 @@ class GroupsCluster(private val controller: MatterController, private val endpoi val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readNameSupportAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readNameSupportAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Namesupport attribute not found in response" } + } + + requireNotNull(attributeData) { + "Namesupport attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -433,37 +509,35 @@ class GroupsCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Namesupport attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Namesupport attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -475,43 +549,49 @@ class GroupsCluster(private val controller: MatterController, private val endpoi emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -521,50 +601,45 @@ class GroupsCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -572,43 +647,49 @@ class GroupsCluster(private val controller: MatterController, private val endpoi emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -618,50 +699,45 @@ class GroupsCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -669,43 +745,49 @@ class GroupsCluster(private val controller: MatterController, private val endpoi emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -715,48 +797,45 @@ class GroupsCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -764,43 +843,49 @@ class GroupsCluster(private val controller: MatterController, private val endpoi emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -810,48 +895,45 @@ class GroupsCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -859,37 +941,44 @@ class GroupsCluster(private val controller: MatterController, private val endpoi emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -898,37 +987,35 @@ class GroupsCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -940,37 +1027,44 @@ class GroupsCluster(private val controller: MatterController, private val endpoi emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -979,38 +1073,34 @@ class GroupsCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1023,7 +1113,7 @@ class GroupsCluster(private val controller: MatterController, private val endpoi emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt index 4d7d42bebb7c47..8ca45695cd230c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt @@ -17,104 +17,132 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class HepaFilterMonitoringCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class LastChangedTimeAttribute(val value: UInt?) +class HepaFilterMonitoringCluster(private val controller: MatterController, private val endpointId: UShort) {class LastChangedTimeAttribute( + val value: UInt? + ) sealed class LastChangedTimeAttributeSubscriptionState { - data class Success(val value: UInt?) : LastChangedTimeAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : LastChangedTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : LastChangedTimeAttributeSubscriptionState() - object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() - } - - class ReplacementProductListAttribute( + object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() + } +class ReplacementProductListAttribute( val value: List? ) sealed class ReplacementProductListAttributeSubscriptionState { - data class Success(val value: List?) : - ReplacementProductListAttributeSubscriptionState() - + data class Success( + val value: List? + ) : ReplacementProductListAttributeSubscriptionState() + data class Error(val exception: Exception) : ReplacementProductListAttributeSubscriptionState() - object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCondition(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -127,39 +155,45 @@ class HepaFilterMonitoringCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readConditionAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readConditionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Condition attribute not found in response" } + } + + requireNotNull(attributeData) { + "Condition attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -169,88 +203,94 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Condition attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Condition attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDegradationDirectionAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDegradationDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Degradationdirection attribute not found in response" } + } + + requireNotNull(attributeData) { + "Degradationdirection attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -260,86 +300,91 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Degradationdirection attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Degradationdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readChangeIndicationAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Changeindication attribute not found in response" } + } + + requireNotNull(attributeData) { + "Changeindication attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -348,38 +393,34 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Changeindication attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Changeindication attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -392,41 +433,47 @@ class HepaFilterMonitoringCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readInPlaceIndicatorAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readInPlaceIndicatorAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Inplaceindicator attribute not found in response" } + } + + requireNotNull(attributeData) { + "Inplaceindicator attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -436,115 +483,123 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Inplaceindicator attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Inplaceindicator attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lastchangedtime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lastchangedtime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LastChangedTimeAttribute(decodedValue) } - suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeLastChangedTimeAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -566,7 +621,7 @@ class HepaFilterMonitoringCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLastChangedTimeAttribute( @@ -574,103 +629,105 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LastChangedTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LastChangedTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lastchangedtime attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lastchangedtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(LastChangedTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(LastChangedTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LastChangedTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Replacementproductlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Replacementproductlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - HepaFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader) - ) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(HepaFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return ReplacementProductListAttribute(decodedValue) } @@ -680,103 +737,102 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ReplacementProductListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ReplacementProductListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Replacementproductlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Replacementproductlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - HepaFilterMonitoringClusterReplacementProductStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ReplacementProductListAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(HepaFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ReplacementProductListAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ReplacementProductListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -786,50 +842,45 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -837,43 +888,49 @@ class HepaFilterMonitoringCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -883,50 +940,45 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -934,43 +986,49 @@ class HepaFilterMonitoringCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -980,48 +1038,45 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1029,43 +1084,49 @@ class HepaFilterMonitoringCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1075,48 +1136,45 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1124,37 +1182,44 @@ class HepaFilterMonitoringCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1163,37 +1228,35 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1205,37 +1268,44 @@ class HepaFilterMonitoringCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1244,38 +1314,34 @@ class HepaFilterMonitoringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1288,7 +1354,7 @@ class HepaFilterMonitoringCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt index 9421d92a1742f7..fe2a372f2188bd 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt @@ -17,98 +17,127 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class IcdManagementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class RegisterClientResponse(val ICDCounter: UInt) - - class StayActiveResponse(val promisedActiveDuration: UInt) +class IcdManagementCluster(private val controller: MatterController, private val endpointId: UShort) { + class RegisterClientResponse( + val ICDCounter: UInt + ) - class RegisteredClientsAttribute( + class StayActiveResponse( + val promisedActiveDuration: UInt + ) +class RegisteredClientsAttribute( val value: List? ) sealed class RegisteredClientsAttributeSubscriptionState { - data class Success(val value: List?) : - RegisteredClientsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : RegisteredClientsAttributeSubscriptionState() + data class Error(val exception: Exception) : RegisteredClientsAttributeSubscriptionState() - object SubscriptionEstablished : RegisteredClientsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : RegisteredClientsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun registerClient( - checkInNodeID: ULong, - monitoredSubject: ULong, - key: ByteArray, - verificationKey: ByteArray?, - timedInvokeTimeout: Duration? = null - ): RegisterClientResponse { + suspend fun registerClient(checkInNodeID: ULong + ,monitoredSubject: ULong + ,key: ByteArray + ,verificationKey: ByteArray? + ,timedInvokeTimeout: Duration? = null): RegisterClientResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -126,7 +155,7 @@ class IcdManagementCluster( val TAG_VERIFICATION_KEY_REQ: Int = 3 verificationKey?.let { tlvWriter.put(ContextSpecificTag(TAG_VERIFICATION_KEY_REQ), verificationKey) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -143,31 +172,37 @@ class IcdManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_I_C_D_COUNTER: Int = 0 var ICDCounter_decoded: UInt? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_I_C_D_COUNTER)) { - ICDCounter_decoded = tlvReader.getUInt(tag) - } else { + + if (tag == ContextSpecificTag(TAG_I_C_D_COUNTER)) {ICDCounter_decoded = tlvReader.getUInt(tag)} + + + else { tlvReader.skipElement() } } + + if (ICDCounter_decoded == null) { - throw IllegalStateException("ICDCounter not found in TLV") + throw IllegalStateException("ICDCounter not found in TLV") } + tlvReader.exitContainer() - return RegisterClientResponse(ICDCounter_decoded) + return RegisterClientResponse( + ICDCounter_decoded + ) } - suspend fun unregisterClient( - checkInNodeID: ULong, - verificationKey: ByteArray?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun unregisterClient(checkInNodeID: ULong + ,verificationKey: ByteArray? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -179,7 +214,7 @@ class IcdManagementCluster( val TAG_VERIFICATION_KEY_REQ: Int = 1 verificationKey?.let { tlvWriter.put(ContextSpecificTag(TAG_VERIFICATION_KEY_REQ), verificationKey) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -197,7 +232,7 @@ class IcdManagementCluster( val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -214,54 +249,69 @@ class IcdManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_PROMISED_ACTIVE_DURATION: Int = 0 var promisedActiveDuration_decoded: UInt? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_PROMISED_ACTIVE_DURATION)) { - promisedActiveDuration_decoded = tlvReader.getUInt(tag) - } else { + + if (tag == ContextSpecificTag(TAG_PROMISED_ACTIVE_DURATION)) {promisedActiveDuration_decoded = tlvReader.getUInt(tag)} + + + else { tlvReader.skipElement() } } + + if (promisedActiveDuration_decoded == null) { - throw IllegalStateException("promisedActiveDuration not found in TLV") + throw IllegalStateException("promisedActiveDuration not found in TLV") } + tlvReader.exitContainer() - return StayActiveResponse(promisedActiveDuration_decoded) + return StayActiveResponse( + promisedActiveDuration_decoded + ) } - - suspend fun readIdleModeDurationAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readIdleModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Idlemodeduration attribute not found in response" } + } + + requireNotNull(attributeData) { + "Idlemodeduration attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -270,38 +320,34 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Idlemodeduration attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Idlemodeduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -314,37 +360,44 @@ class IcdManagementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readActiveModeDurationAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readActiveModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activemodeduration attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activemodeduration attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -353,38 +406,34 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activemodeduration attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activemodeduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -397,37 +446,44 @@ class IcdManagementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readActiveModeThresholdAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readActiveModeThresholdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activemodethreshold attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activemodethreshold attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -436,38 +492,34 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activemodethreshold attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activemodethreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -480,47 +532,53 @@ class IcdManagementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readRegisteredClientsAttribute(): RegisteredClientsAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readRegisteredClientsAttribute(): RegisteredClientsAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Registeredclients attribute not found in response" } + } + + requireNotNull(attributeData) { + "Registeredclients attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(IcdManagementClusterMonitoringRegistrationStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(IcdManagementClusterMonitoringRegistrationStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return RegisteredClientsAttribute(decodedValue) } @@ -530,101 +588,100 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - RegisteredClientsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(RegisteredClientsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Registeredclients attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Registeredclients attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - IcdManagementClusterMonitoringRegistrationStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(RegisteredClientsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(IcdManagementClusterMonitoringRegistrationStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(RegisteredClientsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(RegisteredClientsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readICDCounterAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readICDCounterAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Icdcounter attribute not found in response" } + } + + requireNotNull(attributeData) { + "Icdcounter attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -634,88 +691,94 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Icdcounter attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Icdcounter attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClientsSupportedPerFabricAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClientsSupportedPerFabricAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clientssupportedperfabric attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clientssupportedperfabric attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -725,90 +788,94 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clientssupportedperfabric attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clientssupportedperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUserActiveModeTriggerHintAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUserActiveModeTriggerHintAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Useractivemodetriggerhint attribute not found in response" } + } + + requireNotNull(attributeData) { + "Useractivemodetriggerhint attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -818,92 +885,94 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Useractivemodetriggerhint attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Useractivemodetriggerhint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUserActiveModeTriggerInstructionAttribute(): String? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUserActiveModeTriggerInstructionAttribute(): String? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Useractivemodetriggerinstruction attribute not found in response" + } + + requireNotNull(attributeData) { + "Useractivemodetriggerinstruction attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -913,90 +982,94 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Useractivemodetriggerinstruction attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Useractivemodetriggerinstruction attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOperatingModeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOperatingModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operatingmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operatingmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1006,90 +1079,96 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Operatingmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operatingmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1099,50 +1178,45 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1150,43 +1224,49 @@ class IcdManagementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1196,50 +1276,45 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1247,43 +1322,49 @@ class IcdManagementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1293,48 +1374,45 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1342,43 +1420,49 @@ class IcdManagementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1388,48 +1472,45 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1437,37 +1518,44 @@ class IcdManagementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1476,37 +1564,35 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1518,37 +1604,44 @@ class IcdManagementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1557,38 +1650,34 @@ class IcdManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1601,7 +1690,7 @@ class IcdManagementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt index f7ed262f1a73ba..cdf0dd8d361438 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt @@ -17,81 +17,110 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class IdentifyCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) +class IdentifyCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun identify(identifyTime: UShort, timedInvokeTimeout: Duration? = null) { + suspend fun identify(identifyTime: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_IDENTIFY_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_IDENTIFY_TIME_REQ), identifyTime) + tlvWriter.put(ContextSpecificTag(TAG_IDENTIFY_TIME_REQ), identifyTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -105,11 +134,9 @@ class IdentifyCluster(private val controller: MatterController, private val endp logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun triggerEffect( - effectIdentifier: UByte, - effectVariant: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun triggerEffect(effectIdentifier: UByte + ,effectVariant: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -119,7 +146,7 @@ class IdentifyCluster(private val controller: MatterController, private val endp tlvWriter.put(ContextSpecificTag(TAG_EFFECT_IDENTIFIER_REQ), effectIdentifier) val TAG_EFFECT_VARIANT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) + tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) tlvWriter.endStructure() val request: InvokeRequest = @@ -132,54 +159,65 @@ class IdentifyCluster(private val controller: MatterController, private val endp val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readIdentifyTimeAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readIdentifyTimeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Identifytime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Identifytime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } - suspend fun writeIdentifyTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeIdentifyTimeAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -201,7 +239,7 @@ class IdentifyCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeIdentifyTimeAttribute( @@ -209,37 +247,35 @@ class IdentifyCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Identifytime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Identifytime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -251,37 +287,44 @@ class IdentifyCluster(private val controller: MatterController, private val endp emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readIdentifyTypeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readIdentifyTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Identifytype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Identifytype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -290,37 +333,35 @@ class IdentifyCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Identifytype attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Identifytype attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -332,43 +373,49 @@ class IdentifyCluster(private val controller: MatterController, private val endp emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -378,50 +425,45 @@ class IdentifyCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -429,43 +471,49 @@ class IdentifyCluster(private val controller: MatterController, private val endp emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -475,50 +523,45 @@ class IdentifyCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -526,43 +569,49 @@ class IdentifyCluster(private val controller: MatterController, private val endp emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -572,48 +621,45 @@ class IdentifyCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -621,43 +667,49 @@ class IdentifyCluster(private val controller: MatterController, private val endp emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -667,48 +719,45 @@ class IdentifyCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -716,37 +765,44 @@ class IdentifyCluster(private val controller: MatterController, private val endp emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -755,37 +811,35 @@ class IdentifyCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -797,37 +851,44 @@ class IdentifyCluster(private val controller: MatterController, private val endp emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -836,38 +897,34 @@ class IdentifyCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -880,7 +937,7 @@ class IdentifyCluster(private val controller: MatterController, private val endp emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt index 3fbcfa85674aff..cbfb9f08ed8a40 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt @@ -17,140 +17,192 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class IlluminanceMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: UShort?) +class IlluminanceMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: UShort? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: UShort?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: UShort?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: UShort? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: UShort?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: UShort?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: UShort? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: UShort?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class LightSensorTypeAttribute(val value: UByte?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class LightSensorTypeAttribute( + val value: UByte? + ) sealed class LightSensorTypeAttributeSubscriptionState { - data class Success(val value: UByte?) : LightSensorTypeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : LightSensorTypeAttributeSubscriptionState() + data class Error(val exception: Exception) : LightSensorTypeAttributeSubscriptionState() - object SubscriptionEstablished : LightSensorTypeAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : LightSensorTypeAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -160,90 +212,96 @@ class IlluminanceMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -253,92 +311,96 @@ class IlluminanceMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -348,91 +410,95 @@ class IlluminanceMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readToleranceAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Tolerance attribute not found in response" } + } + + requireNotNull(attributeData) { + "Tolerance attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -442,93 +508,99 @@ class IlluminanceMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Tolerance attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLightSensorTypeAttribute(): LightSensorTypeAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLightSensorTypeAttribute(): LightSensorTypeAttribute {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lightsensortype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lightsensortype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LightSensorTypeAttribute(decodedValue) } @@ -538,97 +610,101 @@ class IlluminanceMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LightSensorTypeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LightSensorTypeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lightsensortype attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lightsensortype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(LightSensorTypeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(LightSensorTypeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LightSensorTypeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -638,50 +714,45 @@ class IlluminanceMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -689,43 +760,49 @@ class IlluminanceMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -735,50 +812,45 @@ class IlluminanceMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -786,43 +858,49 @@ class IlluminanceMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -832,48 +910,45 @@ class IlluminanceMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -881,43 +956,49 @@ class IlluminanceMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -927,48 +1008,45 @@ class IlluminanceMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -976,37 +1054,44 @@ class IlluminanceMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1015,37 +1100,35 @@ class IlluminanceMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1057,37 +1140,44 @@ class IlluminanceMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1096,38 +1186,34 @@ class IlluminanceMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1140,7 +1226,7 @@ class IlluminanceMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt index 8e65a58bb20e56..168b0718b0ff16 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt @@ -17,79 +17,114 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class KeypadInputCluster(private val controller: MatterController, private val endpointId: UShort) { - class SendKeyResponse(val status: UByte) - - class GeneratedCommandListAttribute(val value: List) + class SendKeyResponse( + val status: UByte + ) +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun sendKey(keyCode: UByte, timedInvokeTimeout: Duration? = null): SendKeyResponse { + suspend fun sendKey(keyCode: UByte + ,timedInvokeTimeout: Duration? = null): SendKeyResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_KEY_CODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_KEY_CODE_REQ), keyCode) + tlvWriter.put(ContextSpecificTag(TAG_KEY_CODE_REQ), keyCode) tlvWriter.endStructure() val request: InvokeRequest = @@ -106,60 +141,74 @@ class KeypadInputCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } else { + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + tlvReader.exitContainer() - return SendKeyResponse(status_decoded) + return SendKeyResponse( + status_decoded + ) } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -169,50 +218,45 @@ class KeypadInputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -220,43 +264,49 @@ class KeypadInputCluster(private val controller: MatterController, private val e emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -266,50 +316,45 @@ class KeypadInputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -317,43 +362,49 @@ class KeypadInputCluster(private val controller: MatterController, private val e emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -363,48 +414,45 @@ class KeypadInputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -412,43 +460,49 @@ class KeypadInputCluster(private val controller: MatterController, private val e emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -458,48 +512,45 @@ class KeypadInputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -507,37 +558,44 @@ class KeypadInputCluster(private val controller: MatterController, private val e emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -546,37 +604,35 @@ class KeypadInputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -588,37 +644,44 @@ class KeypadInputCluster(private val controller: MatterController, private val e emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -627,38 +690,34 @@ class KeypadInputCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -671,7 +730,7 @@ class KeypadInputCluster(private val controller: MatterController, private val e emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt index f782f3ec082767..c4800abe53cffd 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt @@ -17,125 +17,167 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryDryerControlsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SupportedDrynessLevelsAttribute(val value: List) +class LaundryDryerControlsCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedDrynessLevelsAttribute( + val value: List + ) sealed class SupportedDrynessLevelsAttributeSubscriptionState { - data class Success(val value: List) : SupportedDrynessLevelsAttributeSubscriptionState() - + data class Success( + val value: List + ) : SupportedDrynessLevelsAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedDrynessLevelsAttributeSubscriptionState() - object SubscriptionEstablished : SupportedDrynessLevelsAttributeSubscriptionState() - } - - class SelectedDrynessLevelAttribute(val value: UByte?) + object SubscriptionEstablished : SupportedDrynessLevelsAttributeSubscriptionState() + } +class SelectedDrynessLevelAttribute( + val value: UByte? + ) sealed class SelectedDrynessLevelAttributeSubscriptionState { - data class Success(val value: UByte?) : SelectedDrynessLevelAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : SelectedDrynessLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : SelectedDrynessLevelAttributeSubscriptionState() - object SubscriptionEstablished : SelectedDrynessLevelAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : SelectedDrynessLevelAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supporteddrynesslevels attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supporteddrynesslevels attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + return SupportedDrynessLevelsAttribute(decodedValue) } @@ -145,50 +187,45 @@ class LaundryDryerControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedDrynessLevelsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedDrynessLevelsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supporteddrynesslevels attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supporteddrynesslevels attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(SupportedDrynessLevelsAttributeSubscriptionState.Success(decodedValue)) } @@ -196,65 +233,72 @@ class LaundryDryerControlsCluster( emit(SupportedDrynessLevelsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Selecteddrynesslevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Selecteddrynesslevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SelectedDrynessLevelAttribute(decodedValue) } suspend fun writeSelectedDrynessLevelAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -276,7 +320,7 @@ class LaundryDryerControlsCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSelectedDrynessLevelAttribute( @@ -284,93 +328,97 @@ class LaundryDryerControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SelectedDrynessLevelAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SelectedDrynessLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Selecteddrynesslevel attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Selecteddrynesslevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(SelectedDrynessLevelAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(SelectedDrynessLevelAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SelectedDrynessLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -380,50 +428,45 @@ class LaundryDryerControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -431,43 +474,49 @@ class LaundryDryerControlsCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -477,50 +526,45 @@ class LaundryDryerControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -528,43 +572,49 @@ class LaundryDryerControlsCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -574,48 +624,45 @@ class LaundryDryerControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -623,43 +670,49 @@ class LaundryDryerControlsCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -669,48 +722,45 @@ class LaundryDryerControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -718,37 +768,44 @@ class LaundryDryerControlsCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -757,37 +814,35 @@ class LaundryDryerControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -799,37 +854,44 @@ class LaundryDryerControlsCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -838,38 +900,34 @@ class LaundryDryerControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -882,7 +940,7 @@ class LaundryDryerControlsCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt index 42b5ed96fc640a..2e547ec206a574 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt @@ -17,140 +17,184 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherControlsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SpinSpeedsAttribute(val value: List?) +class LaundryWasherControlsCluster(private val controller: MatterController, private val endpointId: UShort) {class SpinSpeedsAttribute( + val value: List? + ) sealed class SpinSpeedsAttributeSubscriptionState { - data class Success(val value: List?) : SpinSpeedsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : SpinSpeedsAttributeSubscriptionState() + data class Error(val exception: Exception) : SpinSpeedsAttributeSubscriptionState() - object SubscriptionEstablished : SpinSpeedsAttributeSubscriptionState() - } - - class SpinSpeedCurrentAttribute(val value: UByte?) + object SubscriptionEstablished : SpinSpeedsAttributeSubscriptionState() + } +class SpinSpeedCurrentAttribute( + val value: UByte? + ) sealed class SpinSpeedCurrentAttributeSubscriptionState { - data class Success(val value: UByte?) : SpinSpeedCurrentAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : SpinSpeedCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : SpinSpeedCurrentAttributeSubscriptionState() - object SubscriptionEstablished : SpinSpeedCurrentAttributeSubscriptionState() - } - - class SupportedRinsesAttribute(val value: List?) + object SubscriptionEstablished : SpinSpeedCurrentAttributeSubscriptionState() + } +class SupportedRinsesAttribute( + val value: List? + ) sealed class SupportedRinsesAttributeSubscriptionState { - data class Success(val value: List?) : SupportedRinsesAttributeSubscriptionState() - + data class Success( + val value: List? + ) : SupportedRinsesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedRinsesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedRinsesAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : SupportedRinsesAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readSpinSpeedsAttribute(): SpinSpeedsAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readSpinSpeedsAttribute(): SpinSpeedsAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Spinspeeds attribute not found in response" } + } + + requireNotNull(attributeData) { + "Spinspeeds attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return SpinSpeedsAttribute(decodedValue) } @@ -160,119 +204,129 @@ class LaundryWasherControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SpinSpeedsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SpinSpeedsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Spinspeeds attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Spinspeeds attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(SpinSpeedsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(SpinSpeedsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SpinSpeedsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Spinspeedcurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Spinspeedcurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SpinSpeedCurrentAttribute(decodedValue) } - suspend fun writeSpinSpeedCurrentAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeSpinSpeedCurrentAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -294,7 +348,7 @@ class LaundryWasherControlsCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSpinSpeedCurrentAttribute( @@ -302,115 +356,123 @@ class LaundryWasherControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SpinSpeedCurrentAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SpinSpeedCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Spinspeedcurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Spinspeedcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(SpinSpeedCurrentAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(SpinSpeedCurrentAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SpinSpeedCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readNumberOfRinsesAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readNumberOfRinsesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofrinses attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofrinses attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeNumberOfRinsesAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeNumberOfRinsesAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -432,7 +494,7 @@ class LaundryWasherControlsCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNumberOfRinsesAttribute( @@ -440,96 +502,100 @@ class LaundryWasherControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofrinses attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofrinses attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportedRinsesAttribute(): SupportedRinsesAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedRinsesAttribute(): SupportedRinsesAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedrinses attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedrinses attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return SupportedRinsesAttribute(decodedValue) } @@ -539,98 +605,102 @@ class LaundryWasherControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedRinsesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedRinsesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedrinses attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedrinses attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(SupportedRinsesAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(SupportedRinsesAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SupportedRinsesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -640,50 +710,45 @@ class LaundryWasherControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -691,43 +756,49 @@ class LaundryWasherControlsCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -737,50 +808,45 @@ class LaundryWasherControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -788,43 +854,49 @@ class LaundryWasherControlsCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -834,48 +906,45 @@ class LaundryWasherControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -883,43 +952,49 @@ class LaundryWasherControlsCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -929,48 +1004,45 @@ class LaundryWasherControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -978,37 +1050,44 @@ class LaundryWasherControlsCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1017,37 +1096,35 @@ class LaundryWasherControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1059,37 +1136,44 @@ class LaundryWasherControlsCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1098,38 +1182,34 @@ class LaundryWasherControlsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1142,7 +1222,7 @@ class LaundryWasherControlsCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt index 39984ca8d45b8c..3094ee32e0a394 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt @@ -17,120 +17,154 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherModeCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ChangeToModeResponse(val status: UByte, val statusText: String?) - - class SupportedModesAttribute(val value: List) +class LaundryWasherModeCluster(private val controller: MatterController, private val endpointId: UShort) { + class ChangeToModeResponse( + val status: UByte, + val statusText: String? + ) +class SupportedModesAttribute( + val value: List + ) sealed class SupportedModesAttributeSubscriptionState { - data class Success(val value: List) : - SupportedModesAttributeSubscriptionState() - + data class Success( + val value: List + ) : SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } - - class StartUpModeAttribute(val value: UByte?) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } +class StartUpModeAttribute( + val value: UByte? + ) sealed class StartUpModeAttributeSubscriptionState { - data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } - - class OnModeAttribute(val value: UByte?) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } +class OnModeAttribute( + val value: UByte? + ) sealed class OnModeAttributeSubscriptionState { - data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeout: Duration? = null - ): ChangeToModeResponse { + suspend fun changeToMode(newMode: UByte + ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -147,77 +181,92 @@ class LaundryWasherModeCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { - statusText_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return ChangeToModeResponse(status_decoded, statusText_decoded) + return ChangeToModeResponse( + status_decoded, + statusText_decoded + ) } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return SupportedModesAttribute(decodedValue) } @@ -227,50 +276,45 @@ class LaundryWasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedModesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -278,37 +322,44 @@ class LaundryWasherModeCluster( emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -317,37 +368,35 @@ class LaundryWasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -359,66 +408,76 @@ class LaundryWasherModeCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStartUpModeAttribute(): StartUpModeAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Startupmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Startupmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -440,7 +499,7 @@ class LaundryWasherModeCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -448,118 +507,128 @@ class LaundryWasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StartUpModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Startupmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(StartUpModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOnModeAttribute(): OnModeAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Onmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Onmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -581,7 +650,7 @@ class LaundryWasherModeCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -589,95 +658,101 @@ class LaundryWasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OnModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Onmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OnModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -687,50 +762,45 @@ class LaundryWasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -738,43 +808,49 @@ class LaundryWasherModeCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -784,50 +860,45 @@ class LaundryWasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -835,43 +906,49 @@ class LaundryWasherModeCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -881,48 +958,45 @@ class LaundryWasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -930,43 +1004,49 @@ class LaundryWasherModeCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -976,48 +1056,45 @@ class LaundryWasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1025,37 +1102,44 @@ class LaundryWasherModeCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1064,37 +1148,35 @@ class LaundryWasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1106,37 +1188,44 @@ class LaundryWasherModeCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1145,38 +1234,34 @@ class LaundryWasherModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1189,7 +1274,7 @@ class LaundryWasherModeCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt index aa67210f9b5551..293ad3ccf28462 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt @@ -17,143 +17,184 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LevelControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class CurrentLevelAttribute(val value: UByte?) +class LevelControlCluster(private val controller: MatterController, private val endpointId: UShort) {class CurrentLevelAttribute( + val value: UByte? + ) sealed class CurrentLevelAttributeSubscriptionState { - data class Success(val value: UByte?) : CurrentLevelAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : CurrentLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentLevelAttributeSubscriptionState() - object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() - } - - class OnLevelAttribute(val value: UByte?) + object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() + } +class OnLevelAttribute( + val value: UByte? + ) sealed class OnLevelAttributeSubscriptionState { - data class Success(val value: UByte?) : OnLevelAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : OnLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : OnLevelAttributeSubscriptionState() - object SubscriptionEstablished : OnLevelAttributeSubscriptionState() - } - - class OnTransitionTimeAttribute(val value: UShort?) + object SubscriptionEstablished : OnLevelAttributeSubscriptionState() + } +class OnTransitionTimeAttribute( + val value: UShort? + ) sealed class OnTransitionTimeAttributeSubscriptionState { - data class Success(val value: UShort?) : OnTransitionTimeAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : OnTransitionTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnTransitionTimeAttributeSubscriptionState() - object SubscriptionEstablished : OnTransitionTimeAttributeSubscriptionState() - } - - class OffTransitionTimeAttribute(val value: UShort?) + object SubscriptionEstablished : OnTransitionTimeAttributeSubscriptionState() + } +class OffTransitionTimeAttribute( + val value: UShort? + ) sealed class OffTransitionTimeAttributeSubscriptionState { - data class Success(val value: UShort?) : OffTransitionTimeAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : OffTransitionTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : OffTransitionTimeAttributeSubscriptionState() - object SubscriptionEstablished : OffTransitionTimeAttributeSubscriptionState() - } - - class DefaultMoveRateAttribute(val value: UByte?) + object SubscriptionEstablished : OffTransitionTimeAttributeSubscriptionState() + } +class DefaultMoveRateAttribute( + val value: UByte? + ) sealed class DefaultMoveRateAttributeSubscriptionState { - data class Success(val value: UByte?) : DefaultMoveRateAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : DefaultMoveRateAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultMoveRateAttributeSubscriptionState() - object SubscriptionEstablished : DefaultMoveRateAttributeSubscriptionState() - } - - class StartUpCurrentLevelAttribute(val value: UByte?) + object SubscriptionEstablished : DefaultMoveRateAttributeSubscriptionState() + } +class StartUpCurrentLevelAttribute( + val value: UByte? + ) sealed class StartUpCurrentLevelAttributeSubscriptionState { - data class Success(val value: UByte?) : StartUpCurrentLevelAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : StartUpCurrentLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpCurrentLevelAttributeSubscriptionState() - object SubscriptionEstablished : StartUpCurrentLevelAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : StartUpCurrentLevelAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun moveToLevel( - level: UByte, - transitionTime: UShort?, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveToLevel(level: UByte + ,transitionTime: UShort? + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -171,7 +212,7 @@ class LevelControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -185,13 +226,11 @@ class LevelControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun move( - moveMode: UByte, - rate: UByte?, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun move(moveMode: UByte + ,rate: UByte? + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -201,13 +240,15 @@ class LevelControlCluster( tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) val TAG_RATE_REQ: Int = 1 - rate?.let { tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) } + rate?.let { + tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) + } val TAG_OPTIONS_MASK_REQ: Int = 2 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -221,14 +262,12 @@ class LevelControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun step( - stepMode: UByte, - stepSize: UByte, - transitionTime: UShort?, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun step(stepMode: UByte + ,stepSize: UByte + ,transitionTime: UShort? + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -249,7 +288,7 @@ class LevelControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -263,11 +302,9 @@ class LevelControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stop( - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun stop(optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -277,7 +314,7 @@ class LevelControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -291,13 +328,11 @@ class LevelControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToLevelWithOnOff( - level: UByte, - transitionTime: UShort?, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveToLevelWithOnOff(level: UByte + ,transitionTime: UShort? + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -315,7 +350,7 @@ class LevelControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -329,13 +364,11 @@ class LevelControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveWithOnOff( - moveMode: UByte, - rate: UByte?, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun moveWithOnOff(moveMode: UByte + ,rate: UByte? + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -345,13 +378,15 @@ class LevelControlCluster( tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) val TAG_RATE_REQ: Int = 1 - rate?.let { tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) } + rate?.let { + tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) + } val TAG_OPTIONS_MASK_REQ: Int = 2 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -365,14 +400,12 @@ class LevelControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepWithOnOff( - stepMode: UByte, - stepSize: UByte, - transitionTime: UShort?, - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun stepWithOnOff(stepMode: UByte + ,stepSize: UByte + ,transitionTime: UShort? + ,optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -393,7 +426,7 @@ class LevelControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -407,11 +440,9 @@ class LevelControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stopWithOnOff( - optionsMask: UByte, - optionsOverride: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun stopWithOnOff(optionsMask: UByte + ,optionsOverride: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -421,7 +452,7 @@ class LevelControlCluster( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -435,14 +466,15 @@ class LevelControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToClosestFrequency(frequency: UShort, timedInvokeTimeout: Duration? = null) { + suspend fun moveToClosestFrequency(frequency: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_FREQUENCY_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_FREQUENCY_REQ), frequency) + tlvWriter.put(ContextSpecificTag(TAG_FREQUENCY_REQ), frequency) tlvWriter.endStructure() val request: InvokeRequest = @@ -455,40 +487,46 @@ class LevelControlCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } +suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute {val ATTRIBUTE_ID: UInt = 0u - suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentLevelAttribute(decodedValue) } @@ -498,89 +536,95 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentLevelAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentlevel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentlevel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(CurrentLevelAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(CurrentLevelAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRemainingTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u - suspend fun readRemainingTimeAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Remainingtime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Remainingtime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -590,88 +634,94 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Remainingtime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Remainingtime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - suspend fun readMinLevelAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -681,88 +731,94 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Minlevel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minlevel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u - suspend fun readMaxLevelAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -772,88 +828,94 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxlevel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxlevel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4u - suspend fun readCurrentFrequencyAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentfrequency attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentfrequency attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -863,90 +925,94 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentfrequency attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u - suspend fun readMinFrequencyAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minfrequency attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minfrequency attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -956,88 +1022,94 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Minfrequency attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minfrequency attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u - suspend fun readMaxFrequencyAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxfrequency attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxfrequency attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1047,103 +1119,114 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxfrequency attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxfrequency attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u - suspend fun readOptionsAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 15u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Options attribute not found in response" } + } + + requireNotNull(attributeData) { + "Options attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeOptionsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOptionsAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 15u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1165,7 +1248,7 @@ class LevelControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOptionsAttribute( @@ -1173,37 +1256,35 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Options attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Options attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1215,64 +1296,71 @@ class LevelControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOnOffTransitionTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - suspend fun readOnOffTransitionTimeAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Onofftransitiontime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Onofftransitiontime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeOnOffTransitionTimeAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1294,7 +1382,7 @@ class LevelControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnOffTransitionTimeAttribute( @@ -1302,111 +1390,119 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Onofftransitiontime attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Onofftransitiontime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOnLevelAttribute(): OnLevelAttribute {val ATTRIBUTE_ID: UInt = 17u - suspend fun readOnLevelAttribute(): OnLevelAttribute { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Onlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Onlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OnLevelAttribute(decodedValue) } - suspend fun writeOnLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOnLevelAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1428,7 +1524,7 @@ class LevelControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnLevelAttribute( @@ -1436,114 +1532,124 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OnLevelAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OnLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Onlevel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Onlevel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(OnLevelAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(OnLevelAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OnLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute {val ATTRIBUTE_ID: UInt = 18u - suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Ontransitiontime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Ontransitiontime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OnTransitionTimeAttribute(decodedValue) } - suspend fun writeOnTransitionTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeOnTransitionTimeAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1565,7 +1671,7 @@ class LevelControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnTransitionTimeAttribute( @@ -1573,120 +1679,128 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OnTransitionTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OnTransitionTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Ontransitiontime attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ontransitiontime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OnTransitionTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OnTransitionTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OnTransitionTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute {val ATTRIBUTE_ID: UInt = 19u - suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute { - val ATTRIBUTE_ID: UInt = 19u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Offtransitiontime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Offtransitiontime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OffTransitionTimeAttribute(decodedValue) } - suspend fun writeOffTransitionTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeOffTransitionTimeAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 19u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1708,7 +1822,7 @@ class LevelControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOffTransitionTimeAttribute( @@ -1716,120 +1830,128 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OffTransitionTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OffTransitionTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Offtransitiontime attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Offtransitiontime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OffTransitionTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OffTransitionTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OffTransitionTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute {val ATTRIBUTE_ID: UInt = 20u - suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute { - val ATTRIBUTE_ID: UInt = 20u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Defaultmoverate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Defaultmoverate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return DefaultMoveRateAttribute(decodedValue) } - suspend fun writeDefaultMoveRateAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultMoveRateAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1851,7 +1973,7 @@ class LevelControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultMoveRateAttribute( @@ -1859,120 +1981,128 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DefaultMoveRateAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DefaultMoveRateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Defaultmoverate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Defaultmoverate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(DefaultMoveRateAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(DefaultMoveRateAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(DefaultMoveRateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute {val ATTRIBUTE_ID: UInt = 16384u - suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute { - val ATTRIBUTE_ID: UInt = 16384u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Startupcurrentlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Startupcurrentlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StartUpCurrentLevelAttribute(decodedValue) } - suspend fun writeStartUpCurrentLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpCurrentLevelAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16384u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1994,7 +2124,7 @@ class LevelControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpCurrentLevelAttribute( @@ -2002,97 +2132,101 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StartUpCurrentLevelAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StartUpCurrentLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Startupcurrentlevel attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Startupcurrentlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(StartUpCurrentLevelAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(StartUpCurrentLevelAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StartUpCurrentLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -2102,50 +2236,45 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2153,43 +2282,49 @@ class LevelControlCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -2199,50 +2334,45 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2250,43 +2380,49 @@ class LevelControlCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -2296,48 +2432,45 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2345,43 +2478,49 @@ class LevelControlCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -2391,48 +2530,45 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2440,37 +2576,44 @@ class LevelControlCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -2479,37 +2622,35 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2521,37 +2662,44 @@ class LevelControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2560,38 +2708,34 @@ class LevelControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2604,7 +2748,7 @@ class LevelControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt index 3eb0f7f602ddea..d2c92eb1b5c1f9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt @@ -17,129 +17,172 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LocalizationConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SupportedLocalesAttribute(val value: List) +class LocalizationConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedLocalesAttribute( + val value: List + ) sealed class SupportedLocalesAttributeSubscriptionState { - data class Success(val value: List) : SupportedLocalesAttributeSubscriptionState() - + data class Success( + val value: List + ) : SupportedLocalesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedLocalesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedLocalesAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : SupportedLocalesAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readActiveLocaleAttribute(): String { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readActiveLocaleAttribute(): String {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activelocale attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activelocale attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } - suspend fun writeActiveLocaleAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeActiveLocaleAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -161,7 +204,7 @@ class LocalizationConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeActiveLocaleAttribute( @@ -169,37 +212,35 @@ class LocalizationConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Activelocale attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activelocale attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -211,43 +252,49 @@ class LocalizationConfigurationCluster( emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedlocales attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedlocales attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) } + tlvReader.exitContainer() + } + return SupportedLocalesAttribute(decodedValue) } @@ -257,50 +304,45 @@ class LocalizationConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedLocalesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedLocalesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedlocales attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedlocales attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(SupportedLocalesAttributeSubscriptionState.Success(decodedValue)) } @@ -308,43 +350,49 @@ class LocalizationConfigurationCluster( emit(SupportedLocalesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -354,50 +402,45 @@ class LocalizationConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -405,43 +448,49 @@ class LocalizationConfigurationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -451,50 +500,45 @@ class LocalizationConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -502,43 +546,49 @@ class LocalizationConfigurationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -548,48 +598,45 @@ class LocalizationConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -597,43 +644,49 @@ class LocalizationConfigurationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -643,48 +696,45 @@ class LocalizationConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -692,37 +742,44 @@ class LocalizationConfigurationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -731,37 +788,35 @@ class LocalizationConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -773,37 +828,44 @@ class LocalizationConfigurationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -812,38 +874,34 @@ class LocalizationConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -856,7 +914,7 @@ class LocalizationConfigurationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt index b0ca32ffc850b8..93f537837ccd34 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt @@ -17,73 +17,106 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LowPowerCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) +class LowPowerCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun sleep(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -96,41 +129,47 @@ class LowPowerCluster(private val controller: MatterController, private val endp val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -140,50 +179,45 @@ class LowPowerCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -191,43 +225,49 @@ class LowPowerCluster(private val controller: MatterController, private val endp emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -237,50 +277,45 @@ class LowPowerCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -288,43 +323,49 @@ class LowPowerCluster(private val controller: MatterController, private val endp emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -334,48 +375,45 @@ class LowPowerCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -383,43 +421,49 @@ class LowPowerCluster(private val controller: MatterController, private val endp emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -429,48 +473,45 @@ class LowPowerCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -478,37 +519,44 @@ class LowPowerCluster(private val controller: MatterController, private val endp emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -517,37 +565,35 @@ class LowPowerCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -559,37 +605,44 @@ class LowPowerCluster(private val controller: MatterController, private val endp emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -598,38 +651,34 @@ class LowPowerCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -642,7 +691,7 @@ class LowPowerCluster(private val controller: MatterController, private val endp emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt index 96e656cd0a7bc9..d26de7c78f7c10 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt @@ -17,89 +17,123 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaInputCluster(private val controller: MatterController, private val endpointId: UShort) { - class InputListAttribute(val value: List) +class MediaInputCluster(private val controller: MatterController, private val endpointId: UShort) {class InputListAttribute( + val value: List + ) sealed class InputListAttributeSubscriptionState { - data class Success(val value: List) : - InputListAttributeSubscriptionState() - + data class Success( + val value: List + ) : InputListAttributeSubscriptionState() + data class Error(val exception: Exception) : InputListAttributeSubscriptionState() - object SubscriptionEstablished : InputListAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : InputListAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun selectInput(index: UByte, timedInvokeTimeout: Duration? = null) { + suspend fun selectInput(index: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) + tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) tlvWriter.endStructure() val request: InvokeRequest = @@ -117,7 +151,7 @@ class MediaInputCluster(private val controller: MatterController, private val en val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -135,7 +169,7 @@ class MediaInputCluster(private val controller: MatterController, private val en val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -149,7 +183,9 @@ class MediaInputCluster(private val controller: MatterController, private val en logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun renameInput(index: UByte, name: String, timedInvokeTimeout: Duration? = null) { + suspend fun renameInput(index: UByte + ,name: String + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -159,7 +195,7 @@ class MediaInputCluster(private val controller: MatterController, private val en tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) val TAG_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) + tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) tlvWriter.endStructure() val request: InvokeRequest = @@ -172,41 +208,47 @@ class MediaInputCluster(private val controller: MatterController, private val en val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readInputListAttribute(): InputListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readInputListAttribute(): InputListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Inputlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Inputlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return InputListAttribute(decodedValue) } @@ -216,48 +258,45 @@ class MediaInputCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - InputListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(InputListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Inputlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Inputlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(InputListAttributeSubscriptionState.Success(decodedValue)) } @@ -265,37 +304,44 @@ class MediaInputCluster(private val controller: MatterController, private val en emit(InputListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentInputAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentInputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentinput attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentinput attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -304,37 +350,35 @@ class MediaInputCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentinput attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentinput attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -346,43 +390,49 @@ class MediaInputCluster(private val controller: MatterController, private val en emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -392,50 +442,45 @@ class MediaInputCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -443,43 +488,49 @@ class MediaInputCluster(private val controller: MatterController, private val en emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -489,50 +540,45 @@ class MediaInputCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -540,43 +586,49 @@ class MediaInputCluster(private val controller: MatterController, private val en emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -586,48 +638,45 @@ class MediaInputCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -635,43 +684,49 @@ class MediaInputCluster(private val controller: MatterController, private val en emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -681,48 +736,45 @@ class MediaInputCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -730,37 +782,44 @@ class MediaInputCluster(private val controller: MatterController, private val en emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -769,37 +828,35 @@ class MediaInputCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -811,37 +868,44 @@ class MediaInputCluster(private val controller: MatterController, private val en emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -850,38 +914,34 @@ class MediaInputCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -894,7 +954,7 @@ class MediaInputCluster(private val controller: MatterController, private val en emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt index 12b2afd339765b..189d95aadc2ba5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt @@ -17,176 +17,228 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.FloatSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaPlaybackCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class PlaybackResponse(val status: UByte, val data: String?) - - class StartTimeAttribute(val value: ULong?) +class MediaPlaybackCluster(private val controller: MatterController, private val endpointId: UShort) { + class PlaybackResponse( + val status: UByte, + val data: String? + ) +class StartTimeAttribute( + val value: ULong? + ) sealed class StartTimeAttributeSubscriptionState { - data class Success(val value: ULong?) : StartTimeAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : StartTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartTimeAttributeSubscriptionState() - object SubscriptionEstablished : StartTimeAttributeSubscriptionState() - } - - class DurationAttribute(val value: ULong?) + object SubscriptionEstablished : StartTimeAttributeSubscriptionState() + } +class DurationAttribute( + val value: ULong? + ) sealed class DurationAttributeSubscriptionState { - data class Success(val value: ULong?) : DurationAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : DurationAttributeSubscriptionState() + data class Error(val exception: Exception) : DurationAttributeSubscriptionState() - object SubscriptionEstablished : DurationAttributeSubscriptionState() - } - - class SampledPositionAttribute(val value: MediaPlaybackClusterPlaybackPositionStruct?) + object SubscriptionEstablished : DurationAttributeSubscriptionState() + } +class SampledPositionAttribute( + val value: MediaPlaybackClusterPlaybackPositionStruct? + ) sealed class SampledPositionAttributeSubscriptionState { - data class Success(val value: MediaPlaybackClusterPlaybackPositionStruct?) : - SampledPositionAttributeSubscriptionState() - + data class Success( + val value: MediaPlaybackClusterPlaybackPositionStruct? + ) : SampledPositionAttributeSubscriptionState() + data class Error(val exception: Exception) : SampledPositionAttributeSubscriptionState() - object SubscriptionEstablished : SampledPositionAttributeSubscriptionState() - } - - class SeekRangeEndAttribute(val value: ULong?) + object SubscriptionEstablished : SampledPositionAttributeSubscriptionState() + } +class SeekRangeEndAttribute( + val value: ULong? + ) sealed class SeekRangeEndAttributeSubscriptionState { - data class Success(val value: ULong?) : SeekRangeEndAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : SeekRangeEndAttributeSubscriptionState() + data class Error(val exception: Exception) : SeekRangeEndAttributeSubscriptionState() - object SubscriptionEstablished : SeekRangeEndAttributeSubscriptionState() - } - - class SeekRangeStartAttribute(val value: ULong?) + object SubscriptionEstablished : SeekRangeEndAttributeSubscriptionState() + } +class SeekRangeStartAttribute( + val value: ULong? + ) sealed class SeekRangeStartAttributeSubscriptionState { - data class Success(val value: ULong?) : SeekRangeStartAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : SeekRangeStartAttributeSubscriptionState() + data class Error(val exception: Exception) : SeekRangeStartAttributeSubscriptionState() - object SubscriptionEstablished : SeekRangeStartAttributeSubscriptionState() - } - - class ActiveAudioTrackAttribute(val value: MediaPlaybackClusterTrackStruct?) + object SubscriptionEstablished : SeekRangeStartAttributeSubscriptionState() + } +class ActiveAudioTrackAttribute( + val value: MediaPlaybackClusterTrackStruct? + ) sealed class ActiveAudioTrackAttributeSubscriptionState { - data class Success(val value: MediaPlaybackClusterTrackStruct?) : - ActiveAudioTrackAttributeSubscriptionState() - + data class Success( + val value: MediaPlaybackClusterTrackStruct? + ) : ActiveAudioTrackAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveAudioTrackAttributeSubscriptionState() - object SubscriptionEstablished : ActiveAudioTrackAttributeSubscriptionState() - } - - class AvailableAudioTracksAttribute(val value: List?) + object SubscriptionEstablished : ActiveAudioTrackAttributeSubscriptionState() + } +class AvailableAudioTracksAttribute( + val value: List? + ) sealed class AvailableAudioTracksAttributeSubscriptionState { - data class Success(val value: List?) : - AvailableAudioTracksAttributeSubscriptionState() - + data class Success( + val value: List? + ) : AvailableAudioTracksAttributeSubscriptionState() + data class Error(val exception: Exception) : AvailableAudioTracksAttributeSubscriptionState() - object SubscriptionEstablished : AvailableAudioTracksAttributeSubscriptionState() - } - - class ActiveTextTrackAttribute(val value: MediaPlaybackClusterTrackStruct?) + object SubscriptionEstablished : AvailableAudioTracksAttributeSubscriptionState() + } +class ActiveTextTrackAttribute( + val value: MediaPlaybackClusterTrackStruct? + ) sealed class ActiveTextTrackAttributeSubscriptionState { - data class Success(val value: MediaPlaybackClusterTrackStruct?) : - ActiveTextTrackAttributeSubscriptionState() - + data class Success( + val value: MediaPlaybackClusterTrackStruct? + ) : ActiveTextTrackAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveTextTrackAttributeSubscriptionState() - object SubscriptionEstablished : ActiveTextTrackAttributeSubscriptionState() - } - - class AvailableTextTracksAttribute(val value: List?) + object SubscriptionEstablished : ActiveTextTrackAttributeSubscriptionState() + } +class AvailableTextTracksAttribute( + val value: List? + ) sealed class AvailableTextTracksAttributeSubscriptionState { - data class Success(val value: List?) : - AvailableTextTracksAttributeSubscriptionState() - + data class Success( + val value: List? + ) : AvailableTextTracksAttributeSubscriptionState() + data class Error(val exception: Exception) : AvailableTextTracksAttributeSubscriptionState() - object SubscriptionEstablished : AvailableTextTracksAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AvailableTextTracksAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun play(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -203,48 +255,57 @@ class MediaPlaybackCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return PlaybackResponse(status_decoded, data_decoded) + return PlaybackResponse( + status_decoded, + data_decoded + ) } suspend fun pause(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -261,48 +322,57 @@ class MediaPlaybackCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return PlaybackResponse(status_decoded, data_decoded) + return PlaybackResponse( + status_decoded, + data_decoded + ) } suspend fun stop(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -319,48 +389,57 @@ class MediaPlaybackCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return PlaybackResponse(status_decoded, data_decoded) + return PlaybackResponse( + status_decoded, + data_decoded + ) } suspend fun startOver(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -377,48 +456,57 @@ class MediaPlaybackCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return PlaybackResponse(status_decoded, data_decoded) + return PlaybackResponse( + status_decoded, + data_decoded + ) } suspend fun previous(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -435,48 +523,57 @@ class MediaPlaybackCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return PlaybackResponse(status_decoded, data_decoded) + return PlaybackResponse( + status_decoded, + data_decoded + ) } suspend fun next(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -493,47 +590,54 @@ class MediaPlaybackCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return PlaybackResponse(status_decoded, data_decoded) + return PlaybackResponse( + status_decoded, + data_decoded + ) } - suspend fun rewind( - audioAdvanceUnmuted: Boolean?, - timedInvokeTimeout: Duration? = null - ): PlaybackResponse { + suspend fun rewind(audioAdvanceUnmuted: Boolean? + ,timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -542,7 +646,7 @@ class MediaPlaybackCluster( val TAG_AUDIO_ADVANCE_UNMUTED_REQ: Int = 0 audioAdvanceUnmuted?.let { tlvWriter.put(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED_REQ), audioAdvanceUnmuted) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -559,47 +663,54 @@ class MediaPlaybackCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return PlaybackResponse(status_decoded, data_decoded) + return PlaybackResponse( + status_decoded, + data_decoded + ) } - suspend fun fastForward( - audioAdvanceUnmuted: Boolean?, - timedInvokeTimeout: Duration? = null - ): PlaybackResponse { + suspend fun fastForward(audioAdvanceUnmuted: Boolean? + ,timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -608,7 +719,7 @@ class MediaPlaybackCluster( val TAG_AUDIO_ADVANCE_UNMUTED_REQ: Int = 0 audioAdvanceUnmuted?.let { tlvWriter.put(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED_REQ), audioAdvanceUnmuted) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -625,57 +736,61 @@ class MediaPlaybackCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return PlaybackResponse(status_decoded, data_decoded) + return PlaybackResponse( + status_decoded, + data_decoded + ) } - suspend fun skipForward( - deltaPositionMilliseconds: ULong, - timedInvokeTimeout: Duration? = null - ): PlaybackResponse { + suspend fun skipForward(deltaPositionMilliseconds: ULong + ,timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DELTA_POSITION_MILLISECONDS_REQ: Int = 0 - tlvWriter.put( - ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), - deltaPositionMilliseconds - ) + tlvWriter.put(ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), deltaPositionMilliseconds) tlvWriter.endStructure() val request: InvokeRequest = @@ -692,57 +807,61 @@ class MediaPlaybackCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return PlaybackResponse(status_decoded, data_decoded) + return PlaybackResponse( + status_decoded, + data_decoded + ) } - suspend fun skipBackward( - deltaPositionMilliseconds: ULong, - timedInvokeTimeout: Duration? = null - ): PlaybackResponse { + suspend fun skipBackward(deltaPositionMilliseconds: ULong + ,timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DELTA_POSITION_MILLISECONDS_REQ: Int = 0 - tlvWriter.put( - ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), - deltaPositionMilliseconds - ) + tlvWriter.put(ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), deltaPositionMilliseconds) tlvWriter.endStructure() val request: InvokeRequest = @@ -759,51 +878,61 @@ class MediaPlaybackCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return PlaybackResponse(status_decoded, data_decoded) + return PlaybackResponse( + status_decoded, + data_decoded + ) } - suspend fun seek(position: ULong, timedInvokeTimeout: Duration? = null): PlaybackResponse { + suspend fun seek(position: ULong + ,timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_POSITION_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_POSITION_REQ), position) + tlvWriter.put(ContextSpecificTag(TAG_POSITION_REQ), position) tlvWriter.endStructure() val request: InvokeRequest = @@ -820,48 +949,55 @@ class MediaPlaybackCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return PlaybackResponse(status_decoded, data_decoded) + return PlaybackResponse( + status_decoded, + data_decoded + ) } - suspend fun activateAudioTrack( - trackID: String, - audioOutputIndex: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun activateAudioTrack(trackID: String + ,audioOutputIndex: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 12u val tlvWriter = TlvWriter() @@ -871,7 +1007,7 @@ class MediaPlaybackCluster( tlvWriter.put(ContextSpecificTag(TAG_TRACK_I_D_REQ), trackID) val TAG_AUDIO_OUTPUT_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX_REQ), audioOutputIndex) + tlvWriter.put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX_REQ), audioOutputIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -885,14 +1021,15 @@ class MediaPlaybackCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun activateTextTrack(trackID: String, timedInvokeTimeout: Duration? = null) { + suspend fun activateTextTrack(trackID: String + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 13u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TRACK_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TRACK_I_D_REQ), trackID) + tlvWriter.put(ContextSpecificTag(TAG_TRACK_I_D_REQ), trackID) tlvWriter.endStructure() val request: InvokeRequest = @@ -910,7 +1047,7 @@ class MediaPlaybackCluster( val commandId: UInt = 14u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -923,35 +1060,42 @@ class MediaPlaybackCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } +suspend fun readCurrentStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - suspend fun readCurrentStateAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -960,37 +1104,35 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentstate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentstate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1002,46 +1144,52 @@ class MediaPlaybackCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readStartTimeAttribute(): StartTimeAttribute {val ATTRIBUTE_ID: UInt = 1u - suspend fun readStartTimeAttribute(): StartTimeAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Starttime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Starttime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StartTimeAttribute(decodedValue) } @@ -1051,98 +1199,104 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StartTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StartTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Starttime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Starttime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(StartTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(StartTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StartTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDurationAttribute(): DurationAttribute {val ATTRIBUTE_ID: UInt = 2u - suspend fun readDurationAttribute(): DurationAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Duration attribute not found in response" } + } + + requireNotNull(attributeData) { + "Duration attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return DurationAttribute(decodedValue) } @@ -1152,98 +1306,104 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DurationAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Duration attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Duration attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(DurationAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(DurationAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(DurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSampledPositionAttribute(): SampledPositionAttribute {val ATTRIBUTE_ID: UInt = 3u - suspend fun readSampledPositionAttribute(): SampledPositionAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Sampledposition attribute not found in response" } + } + + requireNotNull(attributeData) { + "Sampledposition attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SampledPositionAttribute(decodedValue) } @@ -1253,95 +1413,99 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SampledPositionAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SampledPositionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Sampledposition attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Sampledposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(SampledPositionAttributeSubscriptionState.Success(it)) } + val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(SampledPositionAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SampledPositionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPlaybackSpeedAttribute(): Float? {val ATTRIBUTE_ID: UInt = 4u - suspend fun readPlaybackSpeedAttribute(): Float? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Playbackspeed attribute not found in response" } + } + + requireNotNull(attributeData) { + "Playbackspeed attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1351,93 +1515,99 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Playbackspeed attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Playbackspeed attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(FloatSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSeekRangeEndAttribute(): SeekRangeEndAttribute {val ATTRIBUTE_ID: UInt = 5u - suspend fun readSeekRangeEndAttribute(): SeekRangeEndAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Seekrangeend attribute not found in response" } + } + + requireNotNull(attributeData) { + "Seekrangeend attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SeekRangeEndAttribute(decodedValue) } @@ -1447,98 +1617,104 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SeekRangeEndAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SeekRangeEndAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Seekrangeend attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Seekrangeend attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(SeekRangeEndAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(SeekRangeEndAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SeekRangeEndAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSeekRangeStartAttribute(): SeekRangeStartAttribute {val ATTRIBUTE_ID: UInt = 6u - suspend fun readSeekRangeStartAttribute(): SeekRangeStartAttribute { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Seekrangestart attribute not found in response" } + } + + requireNotNull(attributeData) { + "Seekrangestart attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SeekRangeStartAttribute(decodedValue) } @@ -1548,100 +1724,104 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SeekRangeStartAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SeekRangeStartAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Seekrangestart attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Seekrangestart attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(SeekRangeStartAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(SeekRangeStartAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SeekRangeStartAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActiveAudioTrackAttribute(): ActiveAudioTrackAttribute {val ATTRIBUTE_ID: UInt = 7u - suspend fun readActiveAudioTrackAttribute(): ActiveAudioTrackAttribute { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activeaudiotrack attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activeaudiotrack attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ActiveAudioTrackAttribute(decodedValue) } @@ -1651,106 +1831,110 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveAudioTrackAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveAudioTrackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activeaudiotrack attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activeaudiotrack attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ActiveAudioTrackAttributeSubscriptionState.Success(it)) } + val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ActiveAudioTrackAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ActiveAudioTrackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAvailableAudioTracksAttribute(): AvailableAudioTracksAttribute {val ATTRIBUTE_ID: UInt = 8u - suspend fun readAvailableAudioTracksAttribute(): AvailableAudioTracksAttribute { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Availableaudiotracks attribute not found in response" } + } + + requireNotNull(attributeData) { + "Availableaudiotracks attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null + val decodedValue: List? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AvailableAudioTracksAttribute(decodedValue) } @@ -1760,106 +1944,110 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AvailableAudioTracksAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AvailableAudioTracksAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Availableaudiotracks attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Availableaudiotracks attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AvailableAudioTracksAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AvailableAudioTracksAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AvailableAudioTracksAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActiveTextTrackAttribute(): ActiveTextTrackAttribute {val ATTRIBUTE_ID: UInt = 9u - suspend fun readActiveTextTrackAttribute(): ActiveTextTrackAttribute { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activetexttrack attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activetexttrack attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ActiveTextTrackAttribute(decodedValue) } @@ -1869,106 +2057,110 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveTextTrackAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveTextTrackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activetexttrack attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activetexttrack attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ActiveTextTrackAttributeSubscriptionState.Success(it)) } + val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ActiveTextTrackAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ActiveTextTrackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAvailableTextTracksAttribute(): AvailableTextTracksAttribute {val ATTRIBUTE_ID: UInt = 10u - suspend fun readAvailableTextTracksAttribute(): AvailableTextTracksAttribute { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Availabletexttracks attribute not found in response" } + } + + requireNotNull(attributeData) { + "Availabletexttracks attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null + val decodedValue: List? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AvailableTextTracksAttribute(decodedValue) } @@ -1978,103 +2170,107 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AvailableTextTracksAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AvailableTextTracksAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Availabletexttracks attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Availabletexttracks attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AvailableTextTracksAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AvailableTextTracksAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AvailableTextTracksAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -2084,50 +2280,45 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2135,43 +2326,49 @@ class MediaPlaybackCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -2181,50 +2378,45 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2232,43 +2424,49 @@ class MediaPlaybackCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -2278,48 +2476,45 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2327,43 +2522,49 @@ class MediaPlaybackCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -2373,48 +2574,45 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2422,37 +2620,44 @@ class MediaPlaybackCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -2461,37 +2666,35 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2503,37 +2706,44 @@ class MediaPlaybackCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2542,38 +2752,34 @@ class MediaPlaybackCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2586,7 +2792,7 @@ class MediaPlaybackCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt index 2548f9fdc3e725..08a1b816898255 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt @@ -17,104 +17,139 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MicrowaveOvenControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SupportedWattsAttribute(val value: List?) +class MicrowaveOvenControlCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedWattsAttribute( + val value: List? + ) sealed class SupportedWattsAttributeSubscriptionState { - data class Success(val value: List?) : SupportedWattsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : SupportedWattsAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedWattsAttributeSubscriptionState() - object SubscriptionEstablished : SupportedWattsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : SupportedWattsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setCookingParameters( - cookMode: UByte?, - cookTime: UInt?, - powerSetting: UByte?, - wattSettingIndex: UByte?, - startAfterSetting: Boolean?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setCookingParameters(cookMode: UByte? + ,cookTime: UInt? + ,powerSetting: UByte? + ,wattSettingIndex: UByte? + ,startAfterSetting: Boolean? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_COOK_MODE_REQ: Int = 0 - cookMode?.let { tlvWriter.put(ContextSpecificTag(TAG_COOK_MODE_REQ), cookMode) } + cookMode?.let { + tlvWriter.put(ContextSpecificTag(TAG_COOK_MODE_REQ), cookMode) + } val TAG_COOK_TIME_REQ: Int = 1 - cookTime?.let { tlvWriter.put(ContextSpecificTag(TAG_COOK_TIME_REQ), cookTime) } + cookTime?.let { + tlvWriter.put(ContextSpecificTag(TAG_COOK_TIME_REQ), cookTime) + } val TAG_POWER_SETTING_REQ: Int = 2 - powerSetting?.let { tlvWriter.put(ContextSpecificTag(TAG_POWER_SETTING_REQ), powerSetting) } + powerSetting?.let { + tlvWriter.put(ContextSpecificTag(TAG_POWER_SETTING_REQ), powerSetting) + } val TAG_WATT_SETTING_INDEX_REQ: Int = 3 wattSettingIndex?.let { @@ -124,7 +159,7 @@ class MicrowaveOvenControlCluster( val TAG_START_AFTER_SETTING_REQ: Int = 4 startAfterSetting?.let { tlvWriter.put(ContextSpecificTag(TAG_START_AFTER_SETTING_REQ), startAfterSetting) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -138,14 +173,15 @@ class MicrowaveOvenControlCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addMoreTime(timeToAdd: UInt, timedInvokeTimeout: Duration? = null) { + suspend fun addMoreTime(timeToAdd: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TIME_TO_ADD_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TIME_TO_ADD_REQ), timeToAdd) + tlvWriter.put(ContextSpecificTag(TAG_TIME_TO_ADD_REQ), timeToAdd) tlvWriter.endStructure() val request: InvokeRequest = @@ -158,35 +194,42 @@ class MicrowaveOvenControlCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readCookTimeAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Cooktime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Cooktime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -195,37 +238,35 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Cooktime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Cooktime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -237,37 +278,44 @@ class MicrowaveOvenControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxCookTimeAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxcooktime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxcooktime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -276,37 +324,35 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxcooktime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxcooktime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -318,41 +364,47 @@ class MicrowaveOvenControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPowerSettingAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPowerSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Powersetting attribute not found in response" } + } + + requireNotNull(attributeData) { + "Powersetting attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -362,88 +414,94 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Powersetting attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Powersetting attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinPowerAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinPowerAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minpower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minpower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -453,88 +511,94 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Minpower attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minpower attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxPowerAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxPowerAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxpower attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxpower attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -544,88 +608,94 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxpower attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxpower attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPowerStepAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPowerStepAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Powerstep attribute not found in response" } + } + + requireNotNull(attributeData) { + "Powerstep attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -635,94 +705,100 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Powerstep attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Powerstep attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportedWattsAttribute(): SupportedWattsAttribute { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedWattsAttribute(): SupportedWattsAttribute {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedwatts attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedwatts attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return SupportedWattsAttribute(decodedValue) } @@ -732,96 +808,100 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedWattsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedWattsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedwatts attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedwatts attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(SupportedWattsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(SupportedWattsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SupportedWattsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSelectedWattIndexAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSelectedWattIndexAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Selectedwattindex attribute not found in response" } + } + + requireNotNull(attributeData) { + "Selectedwattindex attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -831,90 +911,94 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Selectedwattindex attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Selectedwattindex attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readWattRatingAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readWattRatingAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Wattrating attribute not found in response" } + } + + requireNotNull(attributeData) { + "Wattrating attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -924,90 +1008,96 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Wattrating attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Wattrating attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1017,50 +1107,45 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1068,43 +1153,49 @@ class MicrowaveOvenControlCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1114,50 +1205,45 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1165,43 +1251,49 @@ class MicrowaveOvenControlCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1211,48 +1303,45 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1260,43 +1349,49 @@ class MicrowaveOvenControlCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1306,48 +1401,45 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1355,37 +1447,44 @@ class MicrowaveOvenControlCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1394,37 +1493,35 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1436,37 +1533,44 @@ class MicrowaveOvenControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1475,38 +1579,34 @@ class MicrowaveOvenControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1519,7 +1619,7 @@ class MicrowaveOvenControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt index 8362dcb4500717..70c0c2f0b02c69 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt @@ -17,113 +17,154 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class MicrowaveOvenModeCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SupportedModesAttribute(val value: List) +class MicrowaveOvenModeCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedModesAttribute( + val value: List + ) sealed class SupportedModesAttributeSubscriptionState { - data class Success(val value: List) : - SupportedModesAttributeSubscriptionState() - + data class Success( + val value: List + ) : SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return SupportedModesAttribute(decodedValue) } @@ -133,50 +174,45 @@ class MicrowaveOvenModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedModesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -184,37 +220,44 @@ class MicrowaveOvenModeCluster( emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -223,37 +266,35 @@ class MicrowaveOvenModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -265,43 +306,49 @@ class MicrowaveOvenModeCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -311,50 +358,45 @@ class MicrowaveOvenModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -362,43 +404,49 @@ class MicrowaveOvenModeCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -408,50 +456,45 @@ class MicrowaveOvenModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -459,43 +502,49 @@ class MicrowaveOvenModeCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -505,48 +554,45 @@ class MicrowaveOvenModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -554,43 +600,49 @@ class MicrowaveOvenModeCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -600,48 +652,45 @@ class MicrowaveOvenModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -649,37 +698,44 @@ class MicrowaveOvenModeCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -688,37 +744,35 @@ class MicrowaveOvenModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -730,37 +784,44 @@ class MicrowaveOvenModeCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -769,38 +830,34 @@ class MicrowaveOvenModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -813,7 +870,7 @@ class MicrowaveOvenModeCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt index 0119244a4e3865..e07ee80f76b046 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt @@ -17,123 +17,162 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ModeSelectCluster(private val controller: MatterController, private val endpointId: UShort) { - class StandardNamespaceAttribute(val value: UShort?) +class ModeSelectCluster(private val controller: MatterController, private val endpointId: UShort) {class StandardNamespaceAttribute( + val value: UShort? + ) sealed class StandardNamespaceAttributeSubscriptionState { - data class Success(val value: UShort?) : StandardNamespaceAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : StandardNamespaceAttributeSubscriptionState() + data class Error(val exception: Exception) : StandardNamespaceAttributeSubscriptionState() - object SubscriptionEstablished : StandardNamespaceAttributeSubscriptionState() - } - - class SupportedModesAttribute(val value: List) + object SubscriptionEstablished : StandardNamespaceAttributeSubscriptionState() + } +class SupportedModesAttribute( + val value: List + ) sealed class SupportedModesAttributeSubscriptionState { - data class Success(val value: List) : - SupportedModesAttributeSubscriptionState() - + data class Success( + val value: List + ) : SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } - - class StartUpModeAttribute(val value: UByte?) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } +class StartUpModeAttribute( + val value: UByte? + ) sealed class StartUpModeAttributeSubscriptionState { - data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } - - class OnModeAttribute(val value: UByte?) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } +class OnModeAttribute( + val value: UByte? + ) sealed class OnModeAttributeSubscriptionState { - data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte, timedInvokeTimeout: Duration? = null) { + suspend fun changeToMode(newMode: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -146,35 +185,42 @@ class ModeSelectCluster(private val controller: MatterController, private val en val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readDescriptionAttribute(): String { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Description attribute not found in response" } + } + + requireNotNull(attributeData) { + "Description attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } @@ -183,37 +229,35 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Description attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Description attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -225,42 +269,48 @@ class ModeSelectCluster(private val controller: MatterController, private val en emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStandardNamespaceAttribute(): StandardNamespaceAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStandardNamespaceAttribute(): StandardNamespaceAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Standardnamespace attribute not found in response" } + } + + requireNotNull(attributeData) { + "Standardnamespace attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StandardNamespaceAttribute(decodedValue) } @@ -270,93 +320,97 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StandardNamespaceAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StandardNamespaceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Standardnamespace attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Standardnamespace attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(StandardNamespaceAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(StandardNamespaceAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StandardNamespaceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return SupportedModesAttribute(decodedValue) } @@ -366,50 +420,45 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedModesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -417,37 +466,44 @@ class ModeSelectCluster(private val controller: MatterController, private val en emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -456,37 +512,35 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -498,66 +552,76 @@ class ModeSelectCluster(private val controller: MatterController, private val en emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStartUpModeAttribute(): StartUpModeAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Startupmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Startupmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -579,7 +643,7 @@ class ModeSelectCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -587,118 +651,128 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StartUpModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Startupmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(StartUpModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOnModeAttribute(): OnModeAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Onmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Onmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -720,7 +794,7 @@ class ModeSelectCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -728,95 +802,101 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OnModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Onmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OnModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -826,50 +906,45 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -877,43 +952,49 @@ class ModeSelectCluster(private val controller: MatterController, private val en emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -923,50 +1004,45 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -974,43 +1050,49 @@ class ModeSelectCluster(private val controller: MatterController, private val en emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1020,48 +1102,45 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1069,43 +1148,49 @@ class ModeSelectCluster(private val controller: MatterController, private val en emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1115,48 +1200,45 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1164,37 +1246,44 @@ class ModeSelectCluster(private val controller: MatterController, private val en emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1203,37 +1292,35 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1245,37 +1332,44 @@ class ModeSelectCluster(private val controller: MatterController, private val en emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1284,38 +1378,34 @@ class ModeSelectCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1328,7 +1418,7 @@ class ModeSelectCluster(private val controller: MatterController, private val en emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt index c7568cff62a71f..87f6e08bbd6d68 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt @@ -17,166 +17,209 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class NetworkCommissioningCluster( - private val controller: MatterController, - private val endpointId: UShort -) { +class NetworkCommissioningCluster(private val controller: MatterController, private val endpointId: UShort) { class ScanNetworksResponse( - val networkingStatus: UByte, - val debugText: String?, - val wiFiScanResults: List?, + val networkingStatus: UByte, + val debugText: String?, + val wiFiScanResults: List?, val threadScanResults: List? ) class NetworkConfigResponse( - val networkingStatus: UByte, - val debugText: String?, - val networkIndex: UByte?, - val clientIdentity: ByteArray?, + val networkingStatus: UByte, + val debugText: String?, + val networkIndex: UByte?, + val clientIdentity: ByteArray?, val possessionSignature: ByteArray? ) class ConnectNetworkResponse( - val networkingStatus: UByte, - val debugText: String?, + val networkingStatus: UByte, + val debugText: String?, val errorValue: Int? ) - class QueryIdentityResponse(val identity: ByteArray, val possessionSignature: ByteArray?) - - class NetworksAttribute(val value: List) + class QueryIdentityResponse( + val identity: ByteArray, + val possessionSignature: ByteArray? + ) +class NetworksAttribute( + val value: List + ) sealed class NetworksAttributeSubscriptionState { - data class Success(val value: List) : - NetworksAttributeSubscriptionState() - + data class Success( + val value: List + ) : NetworksAttributeSubscriptionState() + data class Error(val exception: Exception) : NetworksAttributeSubscriptionState() - object SubscriptionEstablished : NetworksAttributeSubscriptionState() - } - - class LastNetworkingStatusAttribute(val value: UByte?) + object SubscriptionEstablished : NetworksAttributeSubscriptionState() + } +class LastNetworkingStatusAttribute( + val value: UByte? + ) sealed class LastNetworkingStatusAttributeSubscriptionState { - data class Success(val value: UByte?) : LastNetworkingStatusAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : LastNetworkingStatusAttributeSubscriptionState() + data class Error(val exception: Exception) : LastNetworkingStatusAttributeSubscriptionState() - object SubscriptionEstablished : LastNetworkingStatusAttributeSubscriptionState() - } - - class LastNetworkIDAttribute(val value: ByteArray?) + object SubscriptionEstablished : LastNetworkingStatusAttributeSubscriptionState() + } +class LastNetworkIDAttribute( + val value: ByteArray? + ) sealed class LastNetworkIDAttributeSubscriptionState { - data class Success(val value: ByteArray?) : LastNetworkIDAttributeSubscriptionState() - + data class Success( + val value: ByteArray? + ) : LastNetworkIDAttributeSubscriptionState() + data class Error(val exception: Exception) : LastNetworkIDAttributeSubscriptionState() - object SubscriptionEstablished : LastNetworkIDAttributeSubscriptionState() - } - - class LastConnectErrorValueAttribute(val value: Int?) + object SubscriptionEstablished : LastNetworkIDAttributeSubscriptionState() + } +class LastConnectErrorValueAttribute( + val value: Int? + ) sealed class LastConnectErrorValueAttributeSubscriptionState { - data class Success(val value: Int?) : LastConnectErrorValueAttributeSubscriptionState() - + data class Success( + val value: Int? + ) : LastConnectErrorValueAttributeSubscriptionState() + data class Error(val exception: Exception) : LastConnectErrorValueAttributeSubscriptionState() - object SubscriptionEstablished : LastConnectErrorValueAttributeSubscriptionState() - } - - class SupportedWiFiBandsAttribute(val value: List?) + object SubscriptionEstablished : LastConnectErrorValueAttributeSubscriptionState() + } +class SupportedWiFiBandsAttribute( + val value: List? + ) sealed class SupportedWiFiBandsAttributeSubscriptionState { - data class Success(val value: List?) : SupportedWiFiBandsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : SupportedWiFiBandsAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedWiFiBandsAttributeSubscriptionState() - object SubscriptionEstablished : SupportedWiFiBandsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : SupportedWiFiBandsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun scanNetworks( - ssid: ByteArray?, - breadcrumb: ULong?, - timedInvokeTimeout: Duration? = null - ): ScanNetworksResponse { + suspend fun scanNetworks(ssid: ByteArray? + ,breadcrumb: ULong? + ,timedInvokeTimeout: Duration? = null): ScanNetworksResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SSID_REQ: Int = 0 - ssid?.let { tlvWriter.put(ContextSpecificTag(TAG_SSID_REQ), ssid) } + ssid?.let { + tlvWriter.put(ContextSpecificTag(TAG_SSID_REQ), ssid) + } val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + breadcrumb?.let { + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -193,96 +236,89 @@ class NetworkCommissioningCluster( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_WI_FI_SCAN_RESULTS: Int = 2 - var wiFiScanResults_decoded: List? = - null - + var wiFiScanResults_decoded: List? = null + val TAG_THREAD_SCAN_RESULTS: Int = 3 - var threadScanResults_decoded: - List? = - null + var threadScanResults_decoded: List? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { - networkingStatus_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_WI_FI_SCAN_RESULTS)) { - wiFiScanResults_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_WI_FI_SCAN_RESULTS)) {wiFiScanResults_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add( - NetworkCommissioningClusterWiFiInterfaceScanResultStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - } else { - null - } - } + buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(NetworkCommissioningClusterWiFiInterfaceScanResultStruct.fromTlv(AnonymousTag, tlvReader)) } - - if (tag == ContextSpecificTag(TAG_THREAD_SCAN_RESULTS)) { - threadScanResults_decoded = + tlvReader.exitContainer() + } + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_THREAD_SCAN_RESULTS)) {threadScanResults_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add( - NetworkCommissioningClusterThreadInterfaceScanResultStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - } else { - null - } - } - } else { + buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(NetworkCommissioningClusterThreadInterfaceScanResultStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } + + + + + + + tlvReader.exitContainer() @@ -294,15 +330,13 @@ class NetworkCommissioningCluster( ) } - suspend fun addOrUpdateWiFiNetwork( - ssid: ByteArray, - credentials: ByteArray, - breadcrumb: ULong?, - networkIdentity: ByteArray?, - clientIdentifier: ByteArray?, - possessionNonce: ByteArray?, - timedInvokeTimeout: Duration? = null - ): NetworkConfigResponse { + suspend fun addOrUpdateWiFiNetwork(ssid: ByteArray + ,credentials: ByteArray + ,breadcrumb: ULong? + ,networkIdentity: ByteArray? + ,clientIdentifier: ByteArray? + ,possessionNonce: ByteArray? + ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -315,7 +349,9 @@ class NetworkCommissioningCluster( tlvWriter.put(ContextSpecificTag(TAG_CREDENTIALS_REQ), credentials) val TAG_BREADCRUMB_REQ: Int = 2 - breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + breadcrumb?.let { + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + } val TAG_NETWORK_IDENTITY_REQ: Int = 3 networkIdentity?.let { @@ -330,7 +366,7 @@ class NetworkCommissioningCluster( val TAG_POSSESSION_NONCE_REQ: Int = 5 possessionNonce?.let { tlvWriter.put(ContextSpecificTag(TAG_POSSESSION_NONCE_REQ), possessionNonce) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -347,88 +383,94 @@ class NetworkCommissioningCluster( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { - networkingStatus_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { - networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { - clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { - possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } else { + tlvReader.getByteArray(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } + + + + + + + + + tlvReader.exitContainer() @@ -441,11 +483,9 @@ class NetworkCommissioningCluster( ) } - suspend fun addOrUpdateThreadNetwork( - operationalDataset: ByteArray, - breadcrumb: ULong?, - timedInvokeTimeout: Duration? = null - ): NetworkConfigResponse { + suspend fun addOrUpdateThreadNetwork(operationalDataset: ByteArray + ,breadcrumb: ULong? + ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -455,7 +495,9 @@ class NetworkCommissioningCluster( tlvWriter.put(ContextSpecificTag(TAG_OPERATIONAL_DATASET_REQ), operationalDataset) val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + breadcrumb?.let { + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -472,88 +514,94 @@ class NetworkCommissioningCluster( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { - networkingStatus_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { - networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { - clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { - possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } else { + tlvReader.getByteArray(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } + + + + + + + + + tlvReader.exitContainer() @@ -566,11 +614,9 @@ class NetworkCommissioningCluster( ) } - suspend fun removeNetwork( - networkID: ByteArray, - breadcrumb: ULong?, - timedInvokeTimeout: Duration? = null - ): NetworkConfigResponse { + suspend fun removeNetwork(networkID: ByteArray + ,breadcrumb: ULong? + ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -580,7 +626,9 @@ class NetworkCommissioningCluster( tlvWriter.put(ContextSpecificTag(TAG_NETWORK_I_D_REQ), networkID) val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + breadcrumb?.let { + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -597,88 +645,94 @@ class NetworkCommissioningCluster( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { - networkingStatus_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { - networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { - clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { - possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } else { + tlvReader.getByteArray(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } + + + + + + + + + tlvReader.exitContainer() @@ -691,11 +745,9 @@ class NetworkCommissioningCluster( ) } - suspend fun connectNetwork( - networkID: ByteArray, - breadcrumb: ULong?, - timedInvokeTimeout: Duration? = null - ): ConnectNetworkResponse { + suspend fun connectNetwork(networkID: ByteArray + ,breadcrumb: ULong? + ,timedInvokeTimeout: Duration? = null): ConnectNetworkResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -705,7 +757,9 @@ class NetworkCommissioningCluster( tlvWriter.put(ContextSpecificTag(TAG_NETWORK_I_D_REQ), networkID) val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + breadcrumb?.let { + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -722,67 +776,75 @@ class NetworkCommissioningCluster( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_ERROR_VALUE: Int = 2 var errorValue_decoded: Int? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { - networkingStatus_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_ERROR_VALUE)) { - errorValue_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_ERROR_VALUE)) {errorValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getInt(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } else { + tlvReader.getInt(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + + else { tlvReader.skipElement() } } + + if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } + + + + + tlvReader.exitContainer() - return ConnectNetworkResponse(networkingStatus_decoded, debugText_decoded, errorValue_decoded) + return ConnectNetworkResponse( + networkingStatus_decoded, + debugText_decoded, + errorValue_decoded + ) } - suspend fun reorderNetwork( - networkID: ByteArray, - networkIndex: UByte, - breadcrumb: ULong?, - timedInvokeTimeout: Duration? = null - ): NetworkConfigResponse { + suspend fun reorderNetwork(networkID: ByteArray + ,networkIndex: UByte + ,breadcrumb: ULong? + ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { val commandId: UInt = 8u val tlvWriter = TlvWriter() @@ -795,7 +857,9 @@ class NetworkCommissioningCluster( tlvWriter.put(ContextSpecificTag(TAG_NETWORK_INDEX_REQ), networkIndex) val TAG_BREADCRUMB_REQ: Int = 2 - breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } + breadcrumb?.let { + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -812,88 +876,94 @@ class NetworkCommissioningCluster( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { - networkingStatus_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = + + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { - networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { - clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { - possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } else { + tlvReader.getByteArray(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } + + + + + + + + + tlvReader.exitContainer() @@ -906,11 +976,9 @@ class NetworkCommissioningCluster( ) } - suspend fun queryIdentity( - keyIdentifier: ByteArray, - possessionNonce: ByteArray?, - timedInvokeTimeout: Duration? = null - ): QueryIdentityResponse { + suspend fun queryIdentity(keyIdentifier: ByteArray + ,possessionNonce: ByteArray? + ,timedInvokeTimeout: Duration? = null): QueryIdentityResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -922,7 +990,7 @@ class NetworkCommissioningCluster( val TAG_POSSESSION_NONCE_REQ: Int = 1 possessionNonce?.let { tlvWriter.put(ContextSpecificTag(TAG_POSSESSION_NONCE_REQ), possessionNonce) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -939,71 +1007,87 @@ class NetworkCommissioningCluster( tlvReader.enterStructure(AnonymousTag) val TAG_IDENTITY: Int = 0 var identity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 1 var possessionSignature_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_IDENTITY)) { - identity_decoded = tlvReader.getByteArray(tag) - } - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { - possessionSignature_decoded = + + if (tag == ContextSpecificTag(TAG_IDENTITY)) {identity_decoded = tlvReader.getByteArray(tag)} + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } else { + tlvReader.getByteArray(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (identity_decoded == null) { - throw IllegalStateException("identity not found in TLV") + throw IllegalStateException("identity not found in TLV") } + + + tlvReader.exitContainer() - return QueryIdentityResponse(identity_decoded, possessionSignature_decoded) + return QueryIdentityResponse( + identity_decoded, + possessionSignature_decoded + ) } +suspend fun readMaxNetworksAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - suspend fun readMaxNetworksAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxnetworks attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxnetworks attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -1012,37 +1096,35 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxnetworks attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxnetworks attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1054,43 +1136,49 @@ class NetworkCommissioningCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNetworksAttribute(): NetworksAttribute {val ATTRIBUTE_ID: UInt = 1u - suspend fun readNetworksAttribute(): NetworksAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Networks attribute not found in response" } + } + + requireNotNull(attributeData) { + "Networks attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return NetworksAttribute(decodedValue) } @@ -1100,48 +1188,45 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NetworksAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NetworksAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Networks attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Networks attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(NetworksAttributeSubscriptionState.Success(decodedValue)) } @@ -1149,41 +1234,47 @@ class NetworkCommissioningCluster( emit(NetworksAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readScanMaxTimeSecondsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - suspend fun readScanMaxTimeSecondsAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Scanmaxtimeseconds attribute not found in response" } + } + + requireNotNull(attributeData) { + "Scanmaxtimeseconds attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1193,90 +1284,94 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Scanmaxtimeseconds attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scanmaxtimeseconds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readConnectMaxTimeSecondsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u - suspend fun readConnectMaxTimeSecondsAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Connectmaxtimeseconds attribute not found in response" } + } + + requireNotNull(attributeData) { + "Connectmaxtimeseconds attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1286,105 +1381,114 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Connectmaxtimeseconds attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Connectmaxtimeseconds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4u - suspend fun readInterfaceEnabledAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Interfaceenabled attribute not found in response" } + } + + requireNotNull(attributeData) { + "Interfaceenabled attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } - suspend fun writeInterfaceEnabledAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { + suspend fun writeInterfaceEnabledAttribute( + value: Boolean, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1406,7 +1510,7 @@ class NetworkCommissioningCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInterfaceEnabledAttribute( @@ -1414,38 +1518,34 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Interfaceenabled attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Interfaceenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1458,42 +1558,48 @@ class NetworkCommissioningCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLastNetworkingStatusAttribute(): LastNetworkingStatusAttribute {val ATTRIBUTE_ID: UInt = 5u - suspend fun readLastNetworkingStatusAttribute(): LastNetworkingStatusAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lastnetworkingstatus attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lastnetworkingstatus attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LastNetworkingStatusAttribute(decodedValue) } @@ -1503,92 +1609,96 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LastNetworkingStatusAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LastNetworkingStatusAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lastnetworkingstatus attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lastnetworkingstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(LastNetworkingStatusAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(LastNetworkingStatusAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LastNetworkingStatusAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLastNetworkIDAttribute(): LastNetworkIDAttribute {val ATTRIBUTE_ID: UInt = 6u - suspend fun readLastNetworkIDAttribute(): LastNetworkIDAttribute { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lastnetworkid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lastnetworkid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LastNetworkIDAttribute(decodedValue) } @@ -1598,90 +1708,96 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LastNetworkIDAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LastNetworkIDAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Lastnetworkid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lastnetworkid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(LastNetworkIDAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(LastNetworkIDAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LastNetworkIDAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLastConnectErrorValueAttribute(): LastConnectErrorValueAttribute {val ATTRIBUTE_ID: UInt = 7u - suspend fun readLastConnectErrorValueAttribute(): LastConnectErrorValueAttribute { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lastconnecterrorvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lastconnecterrorvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = - if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LastConnectErrorValueAttribute(decodedValue) } @@ -1691,97 +1807,101 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LastConnectErrorValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LastConnectErrorValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lastconnecterrorvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lastconnecterrorvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = - if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(LastConnectErrorValueAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(LastConnectErrorValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LastConnectErrorValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSupportedWiFiBandsAttribute(): SupportedWiFiBandsAttribute {val ATTRIBUTE_ID: UInt = 8u - suspend fun readSupportedWiFiBandsAttribute(): SupportedWiFiBandsAttribute { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedwifibands attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedwifibands attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return SupportedWiFiBandsAttribute(decodedValue) } @@ -1791,96 +1911,100 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedWiFiBandsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedWiFiBandsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedwifibands attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedwifibands attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(SupportedWiFiBandsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(SupportedWiFiBandsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SupportedWiFiBandsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSupportedThreadFeaturesAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 9u - suspend fun readSupportedThreadFeaturesAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedthreadfeatures attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedthreadfeatures attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1890,90 +2014,94 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedthreadfeatures attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedthreadfeatures attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readThreadVersionAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 10u - suspend fun readThreadVersionAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Threadversion attribute not found in response" } + } + + requireNotNull(attributeData) { + "Threadversion attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1983,90 +2111,96 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Threadversion attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Threadversion attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -2076,50 +2210,45 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2127,43 +2256,49 @@ class NetworkCommissioningCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -2173,50 +2308,45 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2224,43 +2354,49 @@ class NetworkCommissioningCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -2270,48 +2406,45 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2319,43 +2452,49 @@ class NetworkCommissioningCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -2365,48 +2504,45 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2414,37 +2550,44 @@ class NetworkCommissioningCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -2453,37 +2596,35 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2495,37 +2636,44 @@ class NetworkCommissioningCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2534,38 +2682,34 @@ class NetworkCommissioningCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2578,7 +2722,7 @@ class NetworkCommissioningCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt index d44ee68b808e62..d34170fb14b72c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt @@ -17,156 +17,209 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class NitrogenDioxideConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) +class NitrogenDioxideConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Float? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Float? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Float? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class PeakMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class PeakMeasuredValueAttribute( + val value: Float? + ) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } - - class AverageMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } +class AverageMeasuredValueAttribute( + val value: Float? + ) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -176,98 +229,104 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -277,100 +336,104 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -380,100 +443,104 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeakMeasuredValueAttribute(decodedValue) } @@ -483,95 +550,99 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeakMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -581,95 +652,99 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AverageMeasuredValueAttribute(decodedValue) } @@ -679,95 +754,99 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AverageMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -777,90 +856,94 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUncertaintyAttribute(): Float? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + return decodedValue } @@ -870,88 +953,94 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(FloatSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementUnitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -961,90 +1050,94 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementMediumAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1054,90 +1147,94 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLevelValueAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1147,90 +1244,96 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1240,50 +1343,45 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1291,43 +1389,49 @@ class NitrogenDioxideConcentrationMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1337,50 +1441,45 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1388,43 +1487,49 @@ class NitrogenDioxideConcentrationMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1434,48 +1539,45 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1483,43 +1585,49 @@ class NitrogenDioxideConcentrationMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1529,48 +1637,45 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1578,37 +1683,44 @@ class NitrogenDioxideConcentrationMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1617,37 +1729,35 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1659,37 +1769,44 @@ class NitrogenDioxideConcentrationMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1698,38 +1815,34 @@ class NitrogenDioxideConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1742,12 +1855,11 @@ class NitrogenDioxideConcentrationMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = - Logger.getLogger(NitrogenDioxideConcentrationMeasurementCluster::class.java.name) + private val logger = Logger.getLogger(NitrogenDioxideConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1043u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt index 8dd16f44cabe05..f568e8f24179fb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt @@ -17,100 +17,136 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OccupancySensingCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class OccupancySensingCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readOccupancyAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readOccupancyAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Occupancy attribute not found in response" } + } + + requireNotNull(attributeData) { + "Occupancy attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -119,37 +155,35 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Occupancy attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Occupancy attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -161,37 +195,44 @@ class OccupancySensingCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOccupancySensorTypeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOccupancySensorTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Occupancysensortype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Occupancysensortype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -200,38 +241,34 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Occupancysensortype attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Occupancysensortype attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -244,37 +281,44 @@ class OccupancySensingCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOccupancySensorTypeBitmapAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOccupancySensorTypeBitmapAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Occupancysensortypebitmap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Occupancysensortypebitmap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -283,38 +327,34 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Occupancysensortypebitmap attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Occupancysensortypebitmap attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -327,64 +367,71 @@ class OccupancySensingCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Piroccupiedtounoccupieddelay attribute not found in response" } + } + + requireNotNull(attributeData) { + "Piroccupiedtounoccupieddelay attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writePIROccupiedToUnoccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -406,7 +453,7 @@ class OccupancySensingCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePIROccupiedToUnoccupiedDelayAttribute( @@ -414,113 +461,118 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Piroccupiedtounoccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Piroccupiedtounoccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Pirunoccupiedtooccupieddelay attribute not found in response" } + } + + requireNotNull(attributeData) { + "Pirunoccupiedtooccupieddelay attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writePIRUnoccupiedToOccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -542,7 +594,7 @@ class OccupancySensingCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePIRUnoccupiedToOccupiedDelayAttribute( @@ -550,115 +602,118 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Pirunoccupiedtooccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Pirunoccupiedtooccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 18u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pirunoccupiedtooccupiedthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Pirunoccupiedtooccupiedthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writePIRUnoccupiedToOccupiedThresholdAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -680,7 +735,7 @@ class OccupancySensingCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePIRUnoccupiedToOccupiedThresholdAttribute( @@ -688,115 +743,118 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Pirunoccupiedtooccupiedthreshold attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Pirunoccupiedtooccupiedthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 32u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 32u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicoccupiedtounoccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Ultrasonicoccupiedtounoccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeUltrasonicOccupiedToUnoccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 32u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -818,7 +876,7 @@ class OccupancySensingCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUltrasonicOccupiedToUnoccupiedDelayAttribute( @@ -826,115 +884,118 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Ultrasonicoccupiedtounoccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ultrasonicoccupiedtounoccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 33u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 33u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeUltrasonicUnoccupiedToOccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -956,7 +1017,7 @@ class OccupancySensingCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUltrasonicUnoccupiedToOccupiedDelayAttribute( @@ -964,115 +1025,118 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 34u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeUltrasonicUnoccupiedToOccupiedThresholdAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 34u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1094,7 +1158,7 @@ class OccupancySensingCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUltrasonicUnoccupiedToOccupiedThresholdAttribute( @@ -1102,115 +1166,118 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 48u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 48u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactoccupiedtounoccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Physicalcontactoccupiedtounoccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writePhysicalContactOccupiedToUnoccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1232,7 +1299,7 @@ class OccupancySensingCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePhysicalContactOccupiedToUnoccupiedDelayAttribute( @@ -1240,115 +1307,118 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Physicalcontactoccupiedtounoccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Physicalcontactoccupiedtounoccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 49u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 49u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writePhysicalContactUnoccupiedToOccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1370,7 +1440,7 @@ class OccupancySensingCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePhysicalContactUnoccupiedToOccupiedDelayAttribute( @@ -1378,115 +1448,118 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 50u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 50u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writePhysicalContactUnoccupiedToOccupiedThresholdAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1508,7 +1581,7 @@ class OccupancySensingCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePhysicalContactUnoccupiedToOccupiedThresholdAttribute( @@ -1516,92 +1589,96 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1611,50 +1688,45 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1662,43 +1734,49 @@ class OccupancySensingCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1708,50 +1786,45 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1759,43 +1832,49 @@ class OccupancySensingCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1805,48 +1884,45 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1854,43 +1930,49 @@ class OccupancySensingCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1900,48 +1982,45 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1949,37 +2028,44 @@ class OccupancySensingCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1988,37 +2074,35 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2030,37 +2114,44 @@ class OccupancySensingCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2069,38 +2160,34 @@ class OccupancySensingCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2113,7 +2200,7 @@ class OccupancySensingCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt index b0801165c6d93c..8897b4bd04a433 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt @@ -17,88 +17,119 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OnOffCluster(private val controller: MatterController, private val endpointId: UShort) { - class StartUpOnOffAttribute(val value: UByte?) +class OnOffCluster(private val controller: MatterController, private val endpointId: UShort) {class StartUpOnOffAttribute( + val value: UByte? + ) sealed class StartUpOnOffAttributeSubscriptionState { - data class Success(val value: UByte?) : StartUpOnOffAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : StartUpOnOffAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpOnOffAttributeSubscriptionState() - object SubscriptionEstablished : StartUpOnOffAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : StartUpOnOffAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun off(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -116,7 +147,7 @@ class OnOffCluster(private val controller: MatterController, private val endpoin val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -134,7 +165,7 @@ class OnOffCluster(private val controller: MatterController, private val endpoin val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -148,11 +179,9 @@ class OnOffCluster(private val controller: MatterController, private val endpoin logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun offWithEffect( - effectIdentifier: UByte, - effectVariant: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun offWithEffect(effectIdentifier: UByte + ,effectVariant: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -162,7 +191,7 @@ class OnOffCluster(private val controller: MatterController, private val endpoin tlvWriter.put(ContextSpecificTag(TAG_EFFECT_IDENTIFIER_REQ), effectIdentifier) val TAG_EFFECT_VARIANT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) + tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) tlvWriter.endStructure() val request: InvokeRequest = @@ -180,7 +209,7 @@ class OnOffCluster(private val controller: MatterController, private val endpoin val commandId: UInt = 65u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -194,12 +223,10 @@ class OnOffCluster(private val controller: MatterController, private val endpoin logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun onWithTimedOff( - onOffControl: UByte, - onTime: UShort, - offWaitTime: UShort, - timedInvokeTimeout: Duration? = null - ) { + suspend fun onWithTimedOff(onOffControl: UByte + ,onTime: UShort + ,offWaitTime: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 66u val tlvWriter = TlvWriter() @@ -212,7 +239,7 @@ class OnOffCluster(private val controller: MatterController, private val endpoin tlvWriter.put(ContextSpecificTag(TAG_ON_TIME_REQ), onTime) val TAG_OFF_WAIT_TIME_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_OFF_WAIT_TIME_REQ), offWaitTime) + tlvWriter.put(ContextSpecificTag(TAG_OFF_WAIT_TIME_REQ), offWaitTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -225,35 +252,42 @@ class OnOffCluster(private val controller: MatterController, private val endpoin val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readOnOffAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOnOffAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Onoff attribute not found in response" } + } + + requireNotNull(attributeData) { + "Onoff attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -262,37 +296,35 @@ class OnOffCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Onoff attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Onoff attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -304,41 +336,47 @@ class OnOffCluster(private val controller: MatterController, private val endpoin emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGlobalSceneControlAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 16384u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGlobalSceneControlAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Globalscenecontrol attribute not found in response" } + } + + requireNotNull(attributeData) { + "Globalscenecontrol attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -348,110 +386,118 @@ class OnOffCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Globalscenecontrol attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Globalscenecontrol attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOnTimeAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16385u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOnTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16385u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Ontime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Ontime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeOnTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeOnTimeAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16385u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -473,7 +519,7 @@ class OnOffCluster(private val controller: MatterController, private val endpoin throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnTimeAttribute( @@ -481,108 +527,118 @@ class OnOffCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16385u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Ontime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ontime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOffWaitTimeAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16386u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOffWaitTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16386u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Offwaittime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Offwaittime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeOffWaitTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeOffWaitTimeAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16386u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -604,7 +660,7 @@ class OnOffCluster(private val controller: MatterController, private val endpoin throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOffWaitTimeAttribute( @@ -612,113 +668,123 @@ class OnOffCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16386u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Offwaittime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Offwaittime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute { - val ATTRIBUTE_ID: UInt = 16387u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute {val ATTRIBUTE_ID: UInt = 16387u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Startuponoff attribute not found in response" } + } + + requireNotNull(attributeData) { + "Startuponoff attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StartUpOnOffAttribute(decodedValue) } - suspend fun writeStartUpOnOffAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpOnOffAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16387u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -740,7 +806,7 @@ class OnOffCluster(private val controller: MatterController, private val endpoin throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpOnOffAttribute( @@ -748,95 +814,101 @@ class OnOffCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16387u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StartUpOnOffAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StartUpOnOffAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Startuponoff attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Startuponoff attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(StartUpOnOffAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(StartUpOnOffAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StartUpOnOffAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -846,50 +918,45 @@ class OnOffCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -897,43 +964,49 @@ class OnOffCluster(private val controller: MatterController, private val endpoin emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -943,50 +1016,45 @@ class OnOffCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -994,43 +1062,49 @@ class OnOffCluster(private val controller: MatterController, private val endpoin emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1040,48 +1114,45 @@ class OnOffCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1089,43 +1160,49 @@ class OnOffCluster(private val controller: MatterController, private val endpoin emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1135,48 +1212,45 @@ class OnOffCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1184,37 +1258,44 @@ class OnOffCluster(private val controller: MatterController, private val endpoin emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1223,37 +1304,35 @@ class OnOffCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1265,37 +1344,44 @@ class OnOffCluster(private val controller: MatterController, private val endpoin emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1304,38 +1390,34 @@ class OnOffCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1348,7 +1430,7 @@ class OnOffCluster(private val controller: MatterController, private val endpoin emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt index 7359a28163aae6..d30268d4c2280c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt @@ -17,100 +17,136 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OnOffSwitchConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class OnOffSwitchConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readSwitchTypeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readSwitchTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Switchtype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Switchtype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -119,37 +155,35 @@ class OnOffSwitchConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Switchtype attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Switchtype attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -161,56 +195,67 @@ class OnOffSwitchConfigurationCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSwitchActionsAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSwitchActionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Switchactions attribute not found in response" } + } + + requireNotNull(attributeData) { + "Switchactions attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeSwitchActionsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeSwitchActionsAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -232,7 +277,7 @@ class OnOffSwitchConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSwitchActionsAttribute( @@ -240,37 +285,35 @@ class OnOffSwitchConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Switchactions attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Switchactions attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -282,43 +325,49 @@ class OnOffSwitchConfigurationCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -328,50 +377,45 @@ class OnOffSwitchConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -379,43 +423,49 @@ class OnOffSwitchConfigurationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -425,50 +475,45 @@ class OnOffSwitchConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -476,43 +521,49 @@ class OnOffSwitchConfigurationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -522,48 +573,45 @@ class OnOffSwitchConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -571,43 +619,49 @@ class OnOffSwitchConfigurationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -617,48 +671,45 @@ class OnOffSwitchConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -666,37 +717,44 @@ class OnOffSwitchConfigurationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -705,37 +763,35 @@ class OnOffSwitchConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -747,37 +803,44 @@ class OnOffSwitchConfigurationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -786,38 +849,34 @@ class OnOffSwitchConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -830,7 +889,7 @@ class OnOffSwitchConfigurationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt index cfc1103e4216f4..ee45ff6bc3af2a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt @@ -17,129 +17,169 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalCredentialsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { +class OperationalCredentialsCluster(private val controller: MatterController, private val endpointId: UShort) { class AttestationResponse( - val attestationElements: ByteArray, + val attestationElements: ByteArray, val attestationSignature: ByteArray ) - class CertificateChainResponse(val certificate: ByteArray) - - class CSRResponse(val NOCSRElements: ByteArray, val attestationSignature: ByteArray) + class CertificateChainResponse( + val certificate: ByteArray + ) - class NOCResponse(val statusCode: UByte, val fabricIndex: UByte?, val debugText: String?) + class CSRResponse( + val NOCSRElements: ByteArray, + val attestationSignature: ByteArray + ) - class NOCsAttribute(val value: List) + class NOCResponse( + val statusCode: UByte, + val fabricIndex: UByte?, + val debugText: String? + ) +class NOCsAttribute( + val value: List + ) sealed class NOCsAttributeSubscriptionState { - data class Success(val value: List) : - NOCsAttributeSubscriptionState() - + data class Success( + val value: List + ) : NOCsAttributeSubscriptionState() + data class Error(val exception: Exception) : NOCsAttributeSubscriptionState() - object SubscriptionEstablished : NOCsAttributeSubscriptionState() - } - - class FabricsAttribute(val value: List) + object SubscriptionEstablished : NOCsAttributeSubscriptionState() + } +class FabricsAttribute( + val value: List + ) sealed class FabricsAttributeSubscriptionState { - data class Success(val value: List) : - FabricsAttributeSubscriptionState() - + data class Success( + val value: List + ) : FabricsAttributeSubscriptionState() + data class Error(val exception: Exception) : FabricsAttributeSubscriptionState() - object SubscriptionEstablished : FabricsAttributeSubscriptionState() - } - - class TrustedRootCertificatesAttribute(val value: List) + object SubscriptionEstablished : FabricsAttributeSubscriptionState() + } +class TrustedRootCertificatesAttribute( + val value: List + ) sealed class TrustedRootCertificatesAttributeSubscriptionState { - data class Success(val value: List) : - TrustedRootCertificatesAttributeSubscriptionState() - - data class Error(val exception: Exception) : - TrustedRootCertificatesAttributeSubscriptionState() - - object SubscriptionEstablished : TrustedRootCertificatesAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + data class Success( + val value: List + ) : TrustedRootCertificatesAttributeSubscriptionState() + + data class Error(val exception: Exception) : TrustedRootCertificatesAttributeSubscriptionState() + + object SubscriptionEstablished : TrustedRootCertificatesAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun attestationRequest( - attestationNonce: ByteArray, - timedInvokeTimeout: Duration? = null - ): AttestationResponse { + suspend fun attestationRequest(attestationNonce: ByteArray + ,timedInvokeTimeout: Duration? = null): AttestationResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ATTESTATION_NONCE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ATTESTATION_NONCE_REQ), attestationNonce) + tlvWriter.put(ContextSpecificTag(TAG_ATTESTATION_NONCE_REQ), attestationNonce) tlvWriter.endStructure() val request: InvokeRequest = @@ -156,48 +196,54 @@ class OperationalCredentialsCluster( tlvReader.enterStructure(AnonymousTag) val TAG_ATTESTATION_ELEMENTS: Int = 0 var attestationElements_decoded: ByteArray? = null - + val TAG_ATTESTATION_SIGNATURE: Int = 1 var attestationSignature_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_ATTESTATION_ELEMENTS)) { - attestationElements_decoded = tlvReader.getByteArray(tag) - } + + if (tag == ContextSpecificTag(TAG_ATTESTATION_ELEMENTS)) {attestationElements_decoded = tlvReader.getByteArray(tag)} + + if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) {attestationSignature_decoded = tlvReader.getByteArray(tag)} + - if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) { - attestationSignature_decoded = tlvReader.getByteArray(tag) - } else { + else { tlvReader.skipElement() } } + + if (attestationElements_decoded == null) { - throw IllegalStateException("attestationElements not found in TLV") + throw IllegalStateException("attestationElements not found in TLV") } - + + if (attestationSignature_decoded == null) { - throw IllegalStateException("attestationSignature not found in TLV") + throw IllegalStateException("attestationSignature not found in TLV") } + tlvReader.exitContainer() - return AttestationResponse(attestationElements_decoded, attestationSignature_decoded) + return AttestationResponse( + attestationElements_decoded, + attestationSignature_decoded + ) } - suspend fun certificateChainRequest( - certificateType: UByte, - timedInvokeTimeout: Duration? = null - ): CertificateChainResponse { + suspend fun certificateChainRequest(certificateType: UByte + ,timedInvokeTimeout: Duration? = null): CertificateChainResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_CERTIFICATE_TYPE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_CERTIFICATE_TYPE_REQ), certificateType) + tlvWriter.put(ContextSpecificTag(TAG_CERTIFICATE_TYPE_REQ), certificateType) tlvWriter.endStructure() val request: InvokeRequest = @@ -214,31 +260,37 @@ class OperationalCredentialsCluster( tlvReader.enterStructure(AnonymousTag) val TAG_CERTIFICATE: Int = 0 var certificate_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_CERTIFICATE)) { - certificate_decoded = tlvReader.getByteArray(tag) - } else { + + if (tag == ContextSpecificTag(TAG_CERTIFICATE)) {certificate_decoded = tlvReader.getByteArray(tag)} + + + else { tlvReader.skipElement() } } + + if (certificate_decoded == null) { - throw IllegalStateException("certificate not found in TLV") + throw IllegalStateException("certificate not found in TLV") } + tlvReader.exitContainer() - return CertificateChainResponse(certificate_decoded) + return CertificateChainResponse( + certificate_decoded + ) } - suspend fun CSRRequest( - CSRNonce: ByteArray, - isForUpdateNOC: Boolean?, - timedInvokeTimeout: Duration? = null - ): CSRResponse { + suspend fun CSRRequest(CSRNonce: ByteArray + ,isForUpdateNOC: Boolean? + ,timedInvokeTimeout: Duration? = null): CSRResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -250,7 +302,7 @@ class OperationalCredentialsCluster( val TAG_IS_FOR_UPDATE_N_O_C_REQ: Int = 1 isForUpdateNOC?.let { tlvWriter.put(ContextSpecificTag(TAG_IS_FOR_UPDATE_N_O_C_REQ), isForUpdateNOC) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -267,45 +319,51 @@ class OperationalCredentialsCluster( tlvReader.enterStructure(AnonymousTag) val TAG_N_O_C_S_R_ELEMENTS: Int = 0 var NOCSRElements_decoded: ByteArray? = null - + val TAG_ATTESTATION_SIGNATURE: Int = 1 var attestationSignature_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_N_O_C_S_R_ELEMENTS)) { - NOCSRElements_decoded = tlvReader.getByteArray(tag) - } + + if (tag == ContextSpecificTag(TAG_N_O_C_S_R_ELEMENTS)) {NOCSRElements_decoded = tlvReader.getByteArray(tag)} + + if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) {attestationSignature_decoded = tlvReader.getByteArray(tag)} + - if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) { - attestationSignature_decoded = tlvReader.getByteArray(tag) - } else { + else { tlvReader.skipElement() } } + + if (NOCSRElements_decoded == null) { - throw IllegalStateException("NOCSRElements not found in TLV") + throw IllegalStateException("NOCSRElements not found in TLV") } - + + if (attestationSignature_decoded == null) { - throw IllegalStateException("attestationSignature not found in TLV") + throw IllegalStateException("attestationSignature not found in TLV") } + tlvReader.exitContainer() - return CSRResponse(NOCSRElements_decoded, attestationSignature_decoded) + return CSRResponse( + NOCSRElements_decoded, + attestationSignature_decoded + ) } - suspend fun addNOC( - NOCValue: ByteArray, - ICACValue: ByteArray?, - IPKValue: ByteArray, - caseAdminSubject: ULong, - adminVendorId: UShort, - timedInvokeTimeout: Duration? = null - ): NOCResponse { + suspend fun addNOC(NOCValue: ByteArray + ,ICACValue: ByteArray? + ,IPKValue: ByteArray + ,caseAdminSubject: ULong + ,adminVendorId: UShort + ,timedInvokeTimeout: Duration? = null): NOCResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -315,7 +373,9 @@ class OperationalCredentialsCluster( tlvWriter.put(ContextSpecificTag(TAG_N_O_C_VALUE_REQ), NOCValue) val TAG_I_C_A_C_VALUE_REQ: Int = 1 - ICACValue?.let { tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) } + ICACValue?.let { + tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) + } val TAG_I_P_K_VALUE_REQ: Int = 2 tlvWriter.put(ContextSpecificTag(TAG_I_P_K_VALUE_REQ), IPKValue) @@ -324,7 +384,7 @@ class OperationalCredentialsCluster( tlvWriter.put(ContextSpecificTag(TAG_CASE_ADMIN_SUBJECT_REQ), caseAdminSubject) val TAG_ADMIN_VENDOR_ID_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_ADMIN_VENDOR_ID_REQ), adminVendorId) + tlvWriter.put(ContextSpecificTag(TAG_ADMIN_VENDOR_ID_REQ), adminVendorId) tlvWriter.endStructure() val request: InvokeRequest = @@ -341,65 +401,73 @@ class OperationalCredentialsCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { - statusCode_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { - fabricIndex_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } + + + + + tlvReader.exitContainer() - return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) + return NOCResponse( + statusCode_decoded, + fabricIndex_decoded, + debugText_decoded + ) } - suspend fun updateNOC( - NOCValue: ByteArray, - ICACValue: ByteArray?, - timedInvokeTimeout: Duration? = null - ): NOCResponse { + suspend fun updateNOC(NOCValue: ByteArray + ,ICACValue: ByteArray? + ,timedInvokeTimeout: Duration? = null): NOCResponse { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -409,7 +477,9 @@ class OperationalCredentialsCluster( tlvWriter.put(ContextSpecificTag(TAG_N_O_C_VALUE_REQ), NOCValue) val TAG_I_C_A_C_VALUE_REQ: Int = 1 - ICACValue?.let { tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) } + ICACValue?.let { + tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -426,68 +496,79 @@ class OperationalCredentialsCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { - statusCode_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { - fabricIndex_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } + + + + + tlvReader.exitContainer() - return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) + return NOCResponse( + statusCode_decoded, + fabricIndex_decoded, + debugText_decoded + ) } - suspend fun updateFabricLabel(label: String, timedInvokeTimeout: Duration? = null): NOCResponse { + suspend fun updateFabricLabel(label: String + ,timedInvokeTimeout: Duration? = null): NOCResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LABEL_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LABEL_REQ), label) + tlvWriter.put(ContextSpecificTag(TAG_LABEL_REQ), label) tlvWriter.endStructure() val request: InvokeRequest = @@ -504,68 +585,79 @@ class OperationalCredentialsCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { - statusCode_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { - fabricIndex_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } + + + + + tlvReader.exitContainer() - return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) + return NOCResponse( + statusCode_decoded, + fabricIndex_decoded, + debugText_decoded + ) } - suspend fun removeFabric(fabricIndex: UByte, timedInvokeTimeout: Duration? = null): NOCResponse { + suspend fun removeFabric(fabricIndex: UByte + ,timedInvokeTimeout: Duration? = null): NOCResponse { val commandId: UInt = 10u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_FABRIC_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_FABRIC_INDEX_REQ), fabricIndex) + tlvWriter.put(ContextSpecificTag(TAG_FABRIC_INDEX_REQ), fabricIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -582,71 +674,79 @@ class OperationalCredentialsCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { - statusCode_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { - fabricIndex_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { - debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } + + + + + tlvReader.exitContainer() - return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) + return NOCResponse( + statusCode_decoded, + fabricIndex_decoded, + debugText_decoded + ) } - suspend fun addTrustedRootCertificate( - rootCACertificate: ByteArray, - timedInvokeTimeout: Duration? = null - ) { + suspend fun addTrustedRootCertificate(rootCACertificate: ByteArray + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ROOT_C_A_CERTIFICATE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ROOT_C_A_CERTIFICATE_REQ), rootCACertificate) + tlvWriter.put(ContextSpecificTag(TAG_ROOT_C_A_CERTIFICATE_REQ), rootCACertificate) tlvWriter.endStructure() val request: InvokeRequest = @@ -659,41 +759,47 @@ class OperationalCredentialsCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readNOCsAttribute(): NOCsAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readNOCsAttribute(): NOCsAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nocs attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nocs attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return NOCsAttribute(decodedValue) } @@ -703,48 +809,45 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NOCsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NOCsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Nocs attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nocs attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(NOCsAttributeSubscriptionState.Success(decodedValue)) } @@ -752,43 +855,49 @@ class OperationalCredentialsCluster( emit(NOCsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFabricsAttribute(): FabricsAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFabricsAttribute(): FabricsAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Fabrics attribute not found in response" } + } + + requireNotNull(attributeData) { + "Fabrics attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(OperationalCredentialsClusterFabricDescriptorStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterFabricDescriptorStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return FabricsAttribute(decodedValue) } @@ -798,53 +907,45 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FabricsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FabricsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Fabrics attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Fabrics attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - OperationalCredentialsClusterFabricDescriptorStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterFabricDescriptorStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(FabricsAttributeSubscriptionState.Success(decodedValue)) } @@ -852,37 +953,44 @@ class OperationalCredentialsCluster( emit(FabricsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportedFabricsAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedfabrics attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedfabrics attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -891,38 +999,34 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedfabrics attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedfabrics attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -935,37 +1039,44 @@ class OperationalCredentialsCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCommissionedFabricsAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCommissionedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Commissionedfabrics attribute not found in response" } + } + + requireNotNull(attributeData) { + "Commissionedfabrics attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -974,38 +1085,34 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Commissionedfabrics attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Commissionedfabrics attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1018,43 +1125,49 @@ class OperationalCredentialsCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttribute {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Trustedrootcertificates attribute not found in response" } + } + + requireNotNull(attributeData) { + "Trustedrootcertificates attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) } + tlvReader.exitContainer() + } + return TrustedRootCertificatesAttribute(decodedValue) } @@ -1064,50 +1177,45 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - TrustedRootCertificatesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(TrustedRootCertificatesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Trustedrootcertificates attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Trustedrootcertificates attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(TrustedRootCertificatesAttributeSubscriptionState.Success(decodedValue)) } @@ -1115,37 +1223,44 @@ class OperationalCredentialsCluster( emit(TrustedRootCertificatesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentFabricIndexAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentFabricIndexAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentfabricindex attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentfabricindex attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -1154,38 +1269,34 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentfabricindex attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentfabricindex attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1198,43 +1309,49 @@ class OperationalCredentialsCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1244,50 +1361,45 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1295,43 +1407,49 @@ class OperationalCredentialsCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1341,50 +1459,45 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1392,43 +1505,49 @@ class OperationalCredentialsCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1438,48 +1557,45 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,43 +1603,49 @@ class OperationalCredentialsCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1533,48 +1655,45 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1582,37 +1701,44 @@ class OperationalCredentialsCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1621,37 +1747,35 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1663,37 +1787,44 @@ class OperationalCredentialsCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1702,38 +1833,34 @@ class OperationalCredentialsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1746,7 +1873,7 @@ class OperationalCredentialsCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt index 68dd297ecea977..e9f4f326e1fdbe 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt @@ -17,136 +17,175 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalStateCluster( - private val controller: MatterController, - private val endpointId: UShort -) { +class OperationalStateCluster(private val controller: MatterController, private val endpointId: UShort) { class OperationalCommandResponse( val commandResponseState: OperationalStateClusterErrorStateStruct ) - - class PhaseListAttribute(val value: List?) +class PhaseListAttribute( + val value: List? + ) sealed class PhaseListAttributeSubscriptionState { - data class Success(val value: List?) : PhaseListAttributeSubscriptionState() - + data class Success( + val value: List? + ) : PhaseListAttributeSubscriptionState() + data class Error(val exception: Exception) : PhaseListAttributeSubscriptionState() - object SubscriptionEstablished : PhaseListAttributeSubscriptionState() - } - - class CurrentPhaseAttribute(val value: UByte?) + object SubscriptionEstablished : PhaseListAttributeSubscriptionState() + } +class CurrentPhaseAttribute( + val value: UByte? + ) sealed class CurrentPhaseAttributeSubscriptionState { - data class Success(val value: UByte?) : CurrentPhaseAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : CurrentPhaseAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPhaseAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() - } - - class CountdownTimeAttribute(val value: UInt?) + object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() + } +class CountdownTimeAttribute( + val value: UInt? + ) sealed class CountdownTimeAttributeSubscriptionState { - data class Success(val value: UInt?) : CountdownTimeAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : CountdownTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : CountdownTimeAttributeSubscriptionState() - object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() - } - - class OperationalStateListAttribute( + object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() + } +class OperationalStateListAttribute( val value: List ) sealed class OperationalStateListAttributeSubscriptionState { - data class Success(val value: List) : - OperationalStateListAttributeSubscriptionState() - + data class Success( + val value: List + ) : OperationalStateListAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalStateListAttributeSubscriptionState() - object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() - } - - class OperationalErrorAttribute(val value: OperationalStateClusterErrorStateStruct) + object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() + } +class OperationalErrorAttribute( + val value: OperationalStateClusterErrorStateStruct + ) sealed class OperationalErrorAttributeSubscriptionState { - data class Success(val value: OperationalStateClusterErrorStateStruct) : - OperationalErrorAttributeSubscriptionState() - + data class Success( + val value: OperationalStateClusterErrorStateStruct + ) : OperationalErrorAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalErrorAttributeSubscriptionState() - object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun pause(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -163,32 +202,39 @@ class OperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } suspend fun stop(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -205,32 +251,39 @@ class OperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } suspend fun start(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -247,32 +300,39 @@ class OperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } suspend fun resume(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -289,66 +349,79 @@ class OperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } - - suspend fun readPhaseListAttribute(): PhaseListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Phaselist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Phaselist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null + val decodedValue: List? = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PhaseListAttribute(decodedValue) } @@ -358,96 +431,102 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PhaseListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PhaseListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Phaselist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Phaselist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PhaseListAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PhaseListAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PhaseListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentphase attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentphase attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentPhaseAttribute(decodedValue) } @@ -457,94 +536,100 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentPhaseAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentPhaseAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentphase attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentphase attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CurrentPhaseAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CurrentPhaseAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPhaseAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Countdowntime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Countdowntime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CountdownTimeAttribute(decodedValue) } @@ -554,95 +639,101 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CountdownTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CountdownTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Countdowntime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Countdowntime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CountdownTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CountdownTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CountdownTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return OperationalStateListAttribute(decodedValue) } @@ -652,50 +743,45 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OperationalStateListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OperationalStateListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(OperationalStateListAttributeSubscriptionState.Success(decodedValue)) } @@ -703,37 +789,44 @@ class OperationalStateCluster( emit(OperationalStateListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOperationalStateAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationalstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -742,38 +835,34 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -786,37 +875,43 @@ class OperationalStateCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationalerror attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OperationalStateClusterErrorStateStruct = - OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: OperationalStateClusterErrorStateStruct = OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + return OperationalErrorAttribute(decodedValue) } @@ -826,44 +921,39 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OperationalErrorAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OperationalErrorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OperationalStateClusterErrorStateStruct = - OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: OperationalStateClusterErrorStateStruct = OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) emit(OperationalErrorAttributeSubscriptionState.Success(decodedValue)) } @@ -871,43 +961,49 @@ class OperationalStateCluster( emit(OperationalErrorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -917,50 +1013,45 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -968,43 +1059,49 @@ class OperationalStateCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1014,50 +1111,45 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1065,43 +1157,49 @@ class OperationalStateCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1111,48 +1209,45 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1160,43 +1255,49 @@ class OperationalStateCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1206,48 +1307,45 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1255,37 +1353,44 @@ class OperationalStateCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1294,37 +1399,35 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1336,37 +1439,44 @@ class OperationalStateCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1375,38 +1485,34 @@ class OperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1419,7 +1525,7 @@ class OperationalStateCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt index 5f109918016959..ad0f41fcd07f31 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt @@ -17,96 +17,126 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OtaSoftwareUpdateProviderCluster( - private val controller: MatterController, - private val endpointId: UShort -) { +class OtaSoftwareUpdateProviderCluster(private val controller: MatterController, private val endpointId: UShort) { class QueryImageResponse( - val status: UByte, - val delayedActionTime: UInt?, - val imageURI: String?, - val softwareVersion: UInt?, - val softwareVersionString: String?, - val updateToken: ByteArray?, - val userConsentNeeded: Boolean?, + val status: UByte, + val delayedActionTime: UInt?, + val imageURI: String?, + val softwareVersion: UInt?, + val softwareVersionString: String?, + val updateToken: ByteArray?, + val userConsentNeeded: Boolean?, val metadataForRequestor: ByteArray? ) - class ApplyUpdateResponse(val action: UByte, val delayedActionTime: UInt) - - class GeneratedCommandListAttribute(val value: List) + class ApplyUpdateResponse( + val action: UByte, + val delayedActionTime: UInt + ) +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun queryImage( - vendorID: UShort, - productID: UShort, - softwareVersion: UInt, - protocolsSupported: List, - hardwareVersion: UShort?, - location: String?, - requestorCanConsent: Boolean?, - metadataForProvider: ByteArray?, - timedInvokeTimeout: Duration? = null - ): QueryImageResponse { + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun queryImage(vendorID: UShort + ,productID: UShort + ,softwareVersion: UInt + ,protocolsSupported: List + ,hardwareVersion: UShort? + ,location: String? + ,requestorCanConsent: Boolean? + ,metadataForProvider: ByteArray? + ,timedInvokeTimeout: Duration? = null): QueryImageResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -123,10 +153,10 @@ class OtaSoftwareUpdateProviderCluster( val TAG_PROTOCOLS_SUPPORTED_REQ: Int = 3 tlvWriter.startArray(ContextSpecificTag(TAG_PROTOCOLS_SUPPORTED_REQ)) - for (item in protocolsSupported.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in protocolsSupported.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val TAG_HARDWARE_VERSION_REQ: Int = 4 hardwareVersion?.let { @@ -134,7 +164,9 @@ class OtaSoftwareUpdateProviderCluster( } val TAG_LOCATION_REQ: Int = 5 - location?.let { tlvWriter.put(ContextSpecificTag(TAG_LOCATION_REQ), location) } + location?.let { + tlvWriter.put(ContextSpecificTag(TAG_LOCATION_REQ), location) + } val TAG_REQUESTOR_CAN_CONSENT_REQ: Int = 6 requestorCanConsent?.let { @@ -144,7 +176,7 @@ class OtaSoftwareUpdateProviderCluster( val TAG_METADATA_FOR_PROVIDER_REQ: Int = 7 metadataForProvider?.let { tlvWriter.put(ContextSpecificTag(TAG_METADATA_FOR_PROVIDER_REQ), metadataForProvider) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -161,139 +193,145 @@ class OtaSoftwareUpdateProviderCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DELAYED_ACTION_TIME: Int = 1 var delayedActionTime_decoded: UInt? = null - + val TAG_IMAGE_U_R_I: Int = 2 var imageURI_decoded: String? = null - + val TAG_SOFTWARE_VERSION: Int = 3 var softwareVersion_decoded: UInt? = null - + val TAG_SOFTWARE_VERSION_STRING: Int = 4 var softwareVersionString_decoded: String? = null - + val TAG_UPDATE_TOKEN: Int = 5 var updateToken_decoded: ByteArray? = null - + val TAG_USER_CONSENT_NEEDED: Int = 6 var userConsentNeeded_decoded: Boolean? = null - + val TAG_METADATA_FOR_REQUESTOR: Int = 7 var metadataForRequestor_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) { - delayedActionTime_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) {delayedActionTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_IMAGE_U_R_I)) { - imageURI_decoded = + tlvReader.getUInt(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_IMAGE_U_R_I)) {imageURI_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION)) { - softwareVersion_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION)) {softwareVersion_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION_STRING)) { - softwareVersionString_decoded = + tlvReader.getUInt(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION_STRING)) {softwareVersionString_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_UPDATE_TOKEN)) { - updateToken_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_UPDATE_TOKEN)) {updateToken_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_USER_CONSENT_NEEDED)) { - userConsentNeeded_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_USER_CONSENT_NEEDED)) {userConsentNeeded_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_METADATA_FOR_REQUESTOR)) { - metadataForRequestor_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_METADATA_FOR_REQUESTOR)) {metadataForRequestor_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - } - } else { + tlvReader.getByteArray(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + + + + + + + + + + + + + tlvReader.exitContainer() @@ -309,11 +347,9 @@ class OtaSoftwareUpdateProviderCluster( ) } - suspend fun applyUpdateRequest( - updateToken: ByteArray, - newVersion: UInt, - timedInvokeTimeout: Duration? = null - ): ApplyUpdateResponse { + suspend fun applyUpdateRequest(updateToken: ByteArray + ,newVersion: UInt + ,timedInvokeTimeout: Duration? = null): ApplyUpdateResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -323,7 +359,7 @@ class OtaSoftwareUpdateProviderCluster( tlvWriter.put(ContextSpecificTag(TAG_UPDATE_TOKEN_REQ), updateToken) val TAG_NEW_VERSION_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NEW_VERSION_REQ), newVersion) + tlvWriter.put(ContextSpecificTag(TAG_NEW_VERSION_REQ), newVersion) tlvWriter.endStructure() val request: InvokeRequest = @@ -340,42 +376,48 @@ class OtaSoftwareUpdateProviderCluster( tlvReader.enterStructure(AnonymousTag) val TAG_ACTION: Int = 0 var action_decoded: UByte? = null - + val TAG_DELAYED_ACTION_TIME: Int = 1 var delayedActionTime_decoded: UInt? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_ACTION)) { - action_decoded = tlvReader.getUByte(tag) - } + + if (tag == ContextSpecificTag(TAG_ACTION)) {action_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) {delayedActionTime_decoded = tlvReader.getUInt(tag)} + - if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) { - delayedActionTime_decoded = tlvReader.getUInt(tag) - } else { + else { tlvReader.skipElement() } } + + if (action_decoded == null) { - throw IllegalStateException("action not found in TLV") + throw IllegalStateException("action not found in TLV") } - + + if (delayedActionTime_decoded == null) { - throw IllegalStateException("delayedActionTime not found in TLV") + throw IllegalStateException("delayedActionTime not found in TLV") } + tlvReader.exitContainer() - return ApplyUpdateResponse(action_decoded, delayedActionTime_decoded) + return ApplyUpdateResponse( + action_decoded, + delayedActionTime_decoded + ) } - suspend fun notifyUpdateApplied( - updateToken: ByteArray, - softwareVersion: UInt, - timedInvokeTimeout: Duration? = null - ) { + suspend fun notifyUpdateApplied(updateToken: ByteArray + ,softwareVersion: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -385,7 +427,7 @@ class OtaSoftwareUpdateProviderCluster( tlvWriter.put(ContextSpecificTag(TAG_UPDATE_TOKEN_REQ), updateToken) val TAG_SOFTWARE_VERSION_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SOFTWARE_VERSION_REQ), softwareVersion) + tlvWriter.put(ContextSpecificTag(TAG_SOFTWARE_VERSION_REQ), softwareVersion) tlvWriter.endStructure() val request: InvokeRequest = @@ -398,41 +440,47 @@ class OtaSoftwareUpdateProviderCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -442,50 +490,45 @@ class OtaSoftwareUpdateProviderCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -493,43 +536,49 @@ class OtaSoftwareUpdateProviderCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -539,50 +588,45 @@ class OtaSoftwareUpdateProviderCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -590,43 +634,49 @@ class OtaSoftwareUpdateProviderCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -636,48 +686,45 @@ class OtaSoftwareUpdateProviderCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -685,43 +732,49 @@ class OtaSoftwareUpdateProviderCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -731,48 +784,45 @@ class OtaSoftwareUpdateProviderCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -780,37 +830,44 @@ class OtaSoftwareUpdateProviderCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -819,37 +876,35 @@ class OtaSoftwareUpdateProviderCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -861,37 +916,44 @@ class OtaSoftwareUpdateProviderCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -900,38 +962,34 @@ class OtaSoftwareUpdateProviderCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -944,7 +1002,7 @@ class OtaSoftwareUpdateProviderCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt index 35f2a59e30fac9..1309276b36b0d1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt @@ -17,108 +17,133 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OtaSoftwareUpdateRequestorCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class DefaultOTAProvidersAttribute( +class OtaSoftwareUpdateRequestorCluster(private val controller: MatterController, private val endpointId: UShort) {class DefaultOTAProvidersAttribute( val value: List ) sealed class DefaultOTAProvidersAttributeSubscriptionState { - data class Success(val value: List) : - DefaultOTAProvidersAttributeSubscriptionState() - + data class Success( + val value: List + ) : DefaultOTAProvidersAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultOTAProvidersAttributeSubscriptionState() - object SubscriptionEstablished : DefaultOTAProvidersAttributeSubscriptionState() - } - - class UpdateStateProgressAttribute(val value: UByte?) + object SubscriptionEstablished : DefaultOTAProvidersAttributeSubscriptionState() + } +class UpdateStateProgressAttribute( + val value: UByte? + ) sealed class UpdateStateProgressAttributeSubscriptionState { - data class Success(val value: UByte?) : UpdateStateProgressAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : UpdateStateProgressAttributeSubscriptionState() + data class Error(val exception: Exception) : UpdateStateProgressAttributeSubscriptionState() - object SubscriptionEstablished : UpdateStateProgressAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : UpdateStateProgressAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun announceOTAProvider( - providerNodeID: ULong, - vendorID: UShort, - announcementReason: UByte, - metadataForNode: ByteArray?, - endpoint: UShort, - timedInvokeTimeout: Duration? = null - ) { + suspend fun announceOTAProvider(providerNodeID: ULong + ,vendorID: UShort + ,announcementReason: UByte + ,metadataForNode: ByteArray? + ,endpoint: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -139,7 +164,7 @@ class OtaSoftwareUpdateRequestorCluster( } val TAG_ENDPOINT_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_ENDPOINT_REQ), endpoint) + tlvWriter.put(ContextSpecificTag(TAG_ENDPOINT_REQ), endpoint) tlvWriter.endStructure() val request: InvokeRequest = @@ -152,68 +177,75 @@ class OtaSoftwareUpdateRequestorCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Defaultotaproviders attribute not found in response" } + } + + requireNotNull(attributeData) { + "Defaultotaproviders attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return DefaultOTAProvidersAttribute(decodedValue) } suspend fun writeDefaultOTAProvidersAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -235,7 +267,7 @@ class OtaSoftwareUpdateRequestorCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultOTAProvidersAttribute( @@ -243,52 +275,45 @@ class OtaSoftwareUpdateRequestorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DefaultOTAProvidersAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DefaultOTAProvidersAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Defaultotaproviders attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Defaultotaproviders attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader) - ) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(DefaultOTAProvidersAttributeSubscriptionState.Success(decodedValue)) } @@ -296,37 +321,44 @@ class OtaSoftwareUpdateRequestorCluster( emit(DefaultOTAProvidersAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUpdatePossibleAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUpdatePossibleAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Updatepossible attribute not found in response" } + } + + requireNotNull(attributeData) { + "Updatepossible attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -335,38 +367,34 @@ class OtaSoftwareUpdateRequestorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Updatepossible attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Updatepossible attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -379,37 +407,44 @@ class OtaSoftwareUpdateRequestorCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUpdateStateAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUpdateStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Updatestate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Updatestate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -418,37 +453,35 @@ class OtaSoftwareUpdateRequestorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Updatestate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Updatestate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -460,42 +493,48 @@ class OtaSoftwareUpdateRequestorCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUpdateStateProgressAttribute(): UpdateStateProgressAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUpdateStateProgressAttribute(): UpdateStateProgressAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Updatestateprogress attribute not found in response" } + } + + requireNotNull(attributeData) { + "Updatestateprogress attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return UpdateStateProgressAttribute(decodedValue) } @@ -505,93 +544,97 @@ class OtaSoftwareUpdateRequestorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UpdateStateProgressAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UpdateStateProgressAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Updatestateprogress attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Updatestateprogress attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(UpdateStateProgressAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(UpdateStateProgressAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UpdateStateProgressAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -601,50 +644,45 @@ class OtaSoftwareUpdateRequestorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -652,43 +690,49 @@ class OtaSoftwareUpdateRequestorCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -698,50 +742,45 @@ class OtaSoftwareUpdateRequestorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -749,43 +788,49 @@ class OtaSoftwareUpdateRequestorCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -795,48 +840,45 @@ class OtaSoftwareUpdateRequestorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -844,43 +886,49 @@ class OtaSoftwareUpdateRequestorCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -890,48 +938,45 @@ class OtaSoftwareUpdateRequestorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -939,37 +984,44 @@ class OtaSoftwareUpdateRequestorCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -978,37 +1030,35 @@ class OtaSoftwareUpdateRequestorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1020,37 +1070,44 @@ class OtaSoftwareUpdateRequestorCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1059,38 +1116,34 @@ class OtaSoftwareUpdateRequestorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1103,7 +1156,7 @@ class OtaSoftwareUpdateRequestorCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt index 86aeb3500ceee6..4ca4bd4f9307c1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt @@ -17,136 +17,175 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenCavityOperationalStateCluster( - private val controller: MatterController, - private val endpointId: UShort -) { +class OvenCavityOperationalStateCluster(private val controller: MatterController, private val endpointId: UShort) { class OperationalCommandResponse( val commandResponseState: OvenCavityOperationalStateClusterErrorStateStruct ) - - class PhaseListAttribute(val value: List?) +class PhaseListAttribute( + val value: List? + ) sealed class PhaseListAttributeSubscriptionState { - data class Success(val value: List?) : PhaseListAttributeSubscriptionState() - + data class Success( + val value: List? + ) : PhaseListAttributeSubscriptionState() + data class Error(val exception: Exception) : PhaseListAttributeSubscriptionState() - object SubscriptionEstablished : PhaseListAttributeSubscriptionState() - } - - class CurrentPhaseAttribute(val value: UByte?) + object SubscriptionEstablished : PhaseListAttributeSubscriptionState() + } +class CurrentPhaseAttribute( + val value: UByte? + ) sealed class CurrentPhaseAttributeSubscriptionState { - data class Success(val value: UByte?) : CurrentPhaseAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : CurrentPhaseAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPhaseAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() - } - - class CountdownTimeAttribute(val value: UInt?) + object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() + } +class CountdownTimeAttribute( + val value: UInt? + ) sealed class CountdownTimeAttributeSubscriptionState { - data class Success(val value: UInt?) : CountdownTimeAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : CountdownTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : CountdownTimeAttributeSubscriptionState() - object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() - } - - class OperationalStateListAttribute( + object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() + } +class OperationalStateListAttribute( val value: List ) sealed class OperationalStateListAttributeSubscriptionState { - data class Success(val value: List) : - OperationalStateListAttributeSubscriptionState() - + data class Success( + val value: List + ) : OperationalStateListAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalStateListAttributeSubscriptionState() - object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() - } - - class OperationalErrorAttribute(val value: OvenCavityOperationalStateClusterErrorStateStruct) + object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() + } +class OperationalErrorAttribute( + val value: OvenCavityOperationalStateClusterErrorStateStruct + ) sealed class OperationalErrorAttributeSubscriptionState { - data class Success(val value: OvenCavityOperationalStateClusterErrorStateStruct) : - OperationalErrorAttributeSubscriptionState() - + data class Success( + val value: OvenCavityOperationalStateClusterErrorStateStruct + ) : OperationalErrorAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalErrorAttributeSubscriptionState() - object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun pause(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -163,32 +202,39 @@ class OvenCavityOperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } suspend fun stop(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -205,32 +251,39 @@ class OvenCavityOperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } suspend fun start(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -247,32 +300,39 @@ class OvenCavityOperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } suspend fun resume(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -289,66 +349,79 @@ class OvenCavityOperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } - - suspend fun readPhaseListAttribute(): PhaseListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Phaselist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Phaselist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null + val decodedValue: List? = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PhaseListAttribute(decodedValue) } @@ -358,96 +431,102 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PhaseListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PhaseListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Phaselist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Phaselist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PhaseListAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PhaseListAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PhaseListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentphase attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentphase attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentPhaseAttribute(decodedValue) } @@ -457,94 +536,100 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentPhaseAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentPhaseAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentphase attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentphase attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CurrentPhaseAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CurrentPhaseAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPhaseAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Countdowntime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Countdowntime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CountdownTimeAttribute(decodedValue) } @@ -554,97 +639,101 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CountdownTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CountdownTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Countdowntime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Countdowntime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CountdownTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CountdownTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CountdownTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader) - ) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return OperationalStateListAttribute(decodedValue) } @@ -654,55 +743,45 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OperationalStateListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OperationalStateListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(OperationalStateListAttributeSubscriptionState.Success(decodedValue)) } @@ -710,37 +789,44 @@ class OvenCavityOperationalStateCluster( emit(OperationalStateListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOperationalStateAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationalstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -749,38 +835,34 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -793,37 +875,43 @@ class OvenCavityOperationalStateCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationalerror attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = - OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + return OperationalErrorAttribute(decodedValue) } @@ -833,44 +921,39 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OperationalErrorAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OperationalErrorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = - OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) emit(OperationalErrorAttributeSubscriptionState.Success(decodedValue)) } @@ -878,43 +961,49 @@ class OvenCavityOperationalStateCluster( emit(OperationalErrorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -924,50 +1013,45 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -975,43 +1059,49 @@ class OvenCavityOperationalStateCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1021,50 +1111,45 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1072,43 +1157,49 @@ class OvenCavityOperationalStateCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1118,48 +1209,45 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1167,43 +1255,49 @@ class OvenCavityOperationalStateCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1213,48 +1307,45 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1262,37 +1353,44 @@ class OvenCavityOperationalStateCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1301,37 +1399,35 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1343,37 +1439,44 @@ class OvenCavityOperationalStateCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1382,38 +1485,34 @@ class OvenCavityOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1426,7 +1525,7 @@ class OvenCavityOperationalStateCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt index 8dcff4690b2aa5..072808ed1b0f75 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt @@ -17,117 +17,154 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class OvenModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse(val status: UByte, val statusText: String?) - - class SupportedModesAttribute(val value: List) + class ChangeToModeResponse( + val status: UByte, + val statusText: String? + ) +class SupportedModesAttribute( + val value: List + ) sealed class SupportedModesAttributeSubscriptionState { - data class Success(val value: List) : - SupportedModesAttributeSubscriptionState() - + data class Success( + val value: List + ) : SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } - - class StartUpModeAttribute(val value: UByte?) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } +class StartUpModeAttribute( + val value: UByte? + ) sealed class StartUpModeAttributeSubscriptionState { - data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } - - class OnModeAttribute(val value: UByte?) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } +class OnModeAttribute( + val value: UByte? + ) sealed class OnModeAttributeSubscriptionState { - data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeout: Duration? = null - ): ChangeToModeResponse { + suspend fun changeToMode(newMode: UByte + ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -144,77 +181,92 @@ class OvenModeCluster(private val controller: MatterController, private val endp tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { - statusText_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return ChangeToModeResponse(status_decoded, statusText_decoded) + return ChangeToModeResponse( + status_decoded, + statusText_decoded + ) } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return SupportedModesAttribute(decodedValue) } @@ -224,50 +276,45 @@ class OvenModeCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedModesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -275,37 +322,44 @@ class OvenModeCluster(private val controller: MatterController, private val endp emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -314,37 +368,35 @@ class OvenModeCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -356,66 +408,76 @@ class OvenModeCluster(private val controller: MatterController, private val endp emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStartUpModeAttribute(): StartUpModeAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Startupmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Startupmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -437,7 +499,7 @@ class OvenModeCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -445,118 +507,128 @@ class OvenModeCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StartUpModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Startupmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(StartUpModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOnModeAttribute(): OnModeAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Onmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Onmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -578,7 +650,7 @@ class OvenModeCluster(private val controller: MatterController, private val endp throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -586,95 +658,101 @@ class OvenModeCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OnModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Onmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OnModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -684,50 +762,45 @@ class OvenModeCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -735,43 +808,49 @@ class OvenModeCluster(private val controller: MatterController, private val endp emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -781,50 +860,45 @@ class OvenModeCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -832,43 +906,49 @@ class OvenModeCluster(private val controller: MatterController, private val endp emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -878,48 +958,45 @@ class OvenModeCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -927,43 +1004,49 @@ class OvenModeCluster(private val controller: MatterController, private val endp emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -973,48 +1056,45 @@ class OvenModeCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1022,37 +1102,44 @@ class OvenModeCluster(private val controller: MatterController, private val endp emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1061,37 +1148,35 @@ class OvenModeCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1103,37 +1188,44 @@ class OvenModeCluster(private val controller: MatterController, private val endp emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1142,38 +1234,34 @@ class OvenModeCluster(private val controller: MatterController, private val endp maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1186,7 +1274,7 @@ class OvenModeCluster(private val controller: MatterController, private val endp emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt index c660d89a0f566c..427cf896b35373 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt @@ -17,156 +17,209 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class OzoneConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) +class OzoneConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Float? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Float? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Float? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class PeakMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class PeakMeasuredValueAttribute( + val value: Float? + ) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } - - class AverageMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } +class AverageMeasuredValueAttribute( + val value: Float? + ) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -176,98 +229,104 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -277,100 +336,104 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -380,100 +443,104 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeakMeasuredValueAttribute(decodedValue) } @@ -483,95 +550,99 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeakMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -581,95 +652,99 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AverageMeasuredValueAttribute(decodedValue) } @@ -679,95 +754,99 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AverageMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -777,90 +856,94 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUncertaintyAttribute(): Float? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + return decodedValue } @@ -870,88 +953,94 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(FloatSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementUnitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -961,90 +1050,94 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementMediumAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1054,90 +1147,94 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLevelValueAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1147,90 +1244,96 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1240,50 +1343,45 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1291,43 +1389,49 @@ class OzoneConcentrationMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1337,50 +1441,45 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1388,43 +1487,49 @@ class OzoneConcentrationMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1434,48 +1539,45 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1483,43 +1585,49 @@ class OzoneConcentrationMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1529,48 +1637,45 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1578,37 +1683,44 @@ class OzoneConcentrationMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1617,37 +1729,35 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1659,37 +1769,44 @@ class OzoneConcentrationMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1698,38 +1815,34 @@ class OzoneConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1742,7 +1855,7 @@ class OzoneConcentrationMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt index d81ab6b7f6574d..0105d1d2a3b075 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt @@ -17,156 +17,209 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class Pm10ConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) +class Pm10ConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Float? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Float? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Float? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class PeakMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class PeakMeasuredValueAttribute( + val value: Float? + ) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } - - class AverageMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } +class AverageMeasuredValueAttribute( + val value: Float? + ) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -176,98 +229,104 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -277,100 +336,104 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -380,100 +443,104 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeakMeasuredValueAttribute(decodedValue) } @@ -483,95 +550,99 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeakMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -581,95 +652,99 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AverageMeasuredValueAttribute(decodedValue) } @@ -679,95 +754,99 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AverageMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -777,90 +856,94 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUncertaintyAttribute(): Float? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + return decodedValue } @@ -870,88 +953,94 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(FloatSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementUnitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -961,90 +1050,94 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementMediumAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1054,90 +1147,94 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLevelValueAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1147,90 +1244,96 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1240,50 +1343,45 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1291,43 +1389,49 @@ class Pm10ConcentrationMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1337,50 +1441,45 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1388,43 +1487,49 @@ class Pm10ConcentrationMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1434,48 +1539,45 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1483,43 +1585,49 @@ class Pm10ConcentrationMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1529,48 +1637,45 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1578,37 +1683,44 @@ class Pm10ConcentrationMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1617,37 +1729,35 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1659,37 +1769,44 @@ class Pm10ConcentrationMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1698,38 +1815,34 @@ class Pm10ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1742,7 +1855,7 @@ class Pm10ConcentrationMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt index 9f880bbbec52d7..56a19df1bc928d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt @@ -17,156 +17,209 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class Pm1ConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) +class Pm1ConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Float? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Float? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Float? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class PeakMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class PeakMeasuredValueAttribute( + val value: Float? + ) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } - - class AverageMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } +class AverageMeasuredValueAttribute( + val value: Float? + ) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -176,98 +229,104 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -277,100 +336,104 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -380,100 +443,104 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeakMeasuredValueAttribute(decodedValue) } @@ -483,95 +550,99 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeakMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -581,95 +652,99 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AverageMeasuredValueAttribute(decodedValue) } @@ -679,95 +754,99 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AverageMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -777,90 +856,94 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUncertaintyAttribute(): Float? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + return decodedValue } @@ -870,88 +953,94 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(FloatSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementUnitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -961,90 +1050,94 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementMediumAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1054,90 +1147,94 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLevelValueAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1147,90 +1244,96 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1240,50 +1343,45 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1291,43 +1389,49 @@ class Pm1ConcentrationMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1337,50 +1441,45 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1388,43 +1487,49 @@ class Pm1ConcentrationMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1434,48 +1539,45 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1483,43 +1585,49 @@ class Pm1ConcentrationMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1529,48 +1637,45 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1578,37 +1683,44 @@ class Pm1ConcentrationMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1617,37 +1729,35 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1659,37 +1769,44 @@ class Pm1ConcentrationMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1698,38 +1815,34 @@ class Pm1ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1742,7 +1855,7 @@ class Pm1ConcentrationMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt index cfd4cda6106049..090d17ca0c1584 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt @@ -17,156 +17,209 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class Pm25ConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) +class Pm25ConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Float? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Float? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Float? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class PeakMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class PeakMeasuredValueAttribute( + val value: Float? + ) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } - - class AverageMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } +class AverageMeasuredValueAttribute( + val value: Float? + ) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -176,98 +229,104 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -277,100 +336,104 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -380,100 +443,104 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeakMeasuredValueAttribute(decodedValue) } @@ -483,95 +550,99 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeakMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -581,95 +652,99 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AverageMeasuredValueAttribute(decodedValue) } @@ -679,95 +754,99 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AverageMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -777,90 +856,94 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUncertaintyAttribute(): Float? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + return decodedValue } @@ -870,88 +953,94 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(FloatSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementUnitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -961,90 +1050,94 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementMediumAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1054,90 +1147,94 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLevelValueAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1147,90 +1244,96 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1240,50 +1343,45 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1291,43 +1389,49 @@ class Pm25ConcentrationMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1337,50 +1441,45 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1388,43 +1487,49 @@ class Pm25ConcentrationMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1434,48 +1539,45 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1483,43 +1585,49 @@ class Pm25ConcentrationMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1529,48 +1637,45 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1578,37 +1683,44 @@ class Pm25ConcentrationMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1617,37 +1729,35 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1659,37 +1769,44 @@ class Pm25ConcentrationMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1698,38 +1815,34 @@ class Pm25ConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1742,7 +1855,7 @@ class Pm25ConcentrationMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt index e5df8e8e29a31d..835ea746f9a7d8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt @@ -17,218 +17,292 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class PowerSourceCluster(private val controller: MatterController, private val endpointId: UShort) { - class WiredAssessedInputVoltageAttribute(val value: UInt?) +class PowerSourceCluster(private val controller: MatterController, private val endpointId: UShort) {class WiredAssessedInputVoltageAttribute( + val value: UInt? + ) sealed class WiredAssessedInputVoltageAttributeSubscriptionState { - data class Success(val value: UInt?) : WiredAssessedInputVoltageAttributeSubscriptionState() - - data class Error(val exception: Exception) : - WiredAssessedInputVoltageAttributeSubscriptionState() - - object SubscriptionEstablished : WiredAssessedInputVoltageAttributeSubscriptionState() - } - - class WiredAssessedInputFrequencyAttribute(val value: UShort?) + data class Success( + val value: UInt? + ) : WiredAssessedInputVoltageAttributeSubscriptionState() + + data class Error(val exception: Exception) : WiredAssessedInputVoltageAttributeSubscriptionState() + + object SubscriptionEstablished : WiredAssessedInputVoltageAttributeSubscriptionState() + } +class WiredAssessedInputFrequencyAttribute( + val value: UShort? + ) sealed class WiredAssessedInputFrequencyAttributeSubscriptionState { - data class Success(val value: UShort?) : - WiredAssessedInputFrequencyAttributeSubscriptionState() - - data class Error(val exception: Exception) : - WiredAssessedInputFrequencyAttributeSubscriptionState() - - object SubscriptionEstablished : WiredAssessedInputFrequencyAttributeSubscriptionState() - } - - class WiredAssessedCurrentAttribute(val value: UInt?) + data class Success( + val value: UShort? + ) : WiredAssessedInputFrequencyAttributeSubscriptionState() + + data class Error(val exception: Exception) : WiredAssessedInputFrequencyAttributeSubscriptionState() + + object SubscriptionEstablished : WiredAssessedInputFrequencyAttributeSubscriptionState() + } +class WiredAssessedCurrentAttribute( + val value: UInt? + ) sealed class WiredAssessedCurrentAttributeSubscriptionState { - data class Success(val value: UInt?) : WiredAssessedCurrentAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : WiredAssessedCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : WiredAssessedCurrentAttributeSubscriptionState() - object SubscriptionEstablished : WiredAssessedCurrentAttributeSubscriptionState() - } - - class ActiveWiredFaultsAttribute(val value: List?) + object SubscriptionEstablished : WiredAssessedCurrentAttributeSubscriptionState() + } +class ActiveWiredFaultsAttribute( + val value: List? + ) sealed class ActiveWiredFaultsAttributeSubscriptionState { - data class Success(val value: List?) : ActiveWiredFaultsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : ActiveWiredFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveWiredFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveWiredFaultsAttributeSubscriptionState() - } - - class BatVoltageAttribute(val value: UInt?) + object SubscriptionEstablished : ActiveWiredFaultsAttributeSubscriptionState() + } +class BatVoltageAttribute( + val value: UInt? + ) sealed class BatVoltageAttributeSubscriptionState { - data class Success(val value: UInt?) : BatVoltageAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : BatVoltageAttributeSubscriptionState() + data class Error(val exception: Exception) : BatVoltageAttributeSubscriptionState() - object SubscriptionEstablished : BatVoltageAttributeSubscriptionState() - } - - class BatPercentRemainingAttribute(val value: UByte?) + object SubscriptionEstablished : BatVoltageAttributeSubscriptionState() + } +class BatPercentRemainingAttribute( + val value: UByte? + ) sealed class BatPercentRemainingAttributeSubscriptionState { - data class Success(val value: UByte?) : BatPercentRemainingAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : BatPercentRemainingAttributeSubscriptionState() + data class Error(val exception: Exception) : BatPercentRemainingAttributeSubscriptionState() - object SubscriptionEstablished : BatPercentRemainingAttributeSubscriptionState() - } - - class BatTimeRemainingAttribute(val value: UInt?) + object SubscriptionEstablished : BatPercentRemainingAttributeSubscriptionState() + } +class BatTimeRemainingAttribute( + val value: UInt? + ) sealed class BatTimeRemainingAttributeSubscriptionState { - data class Success(val value: UInt?) : BatTimeRemainingAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : BatTimeRemainingAttributeSubscriptionState() + data class Error(val exception: Exception) : BatTimeRemainingAttributeSubscriptionState() - object SubscriptionEstablished : BatTimeRemainingAttributeSubscriptionState() - } - - class ActiveBatFaultsAttribute(val value: List?) + object SubscriptionEstablished : BatTimeRemainingAttributeSubscriptionState() + } +class ActiveBatFaultsAttribute( + val value: List? + ) sealed class ActiveBatFaultsAttributeSubscriptionState { - data class Success(val value: List?) : ActiveBatFaultsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : ActiveBatFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveBatFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveBatFaultsAttributeSubscriptionState() - } - - class BatTimeToFullChargeAttribute(val value: UInt?) + object SubscriptionEstablished : ActiveBatFaultsAttributeSubscriptionState() + } +class BatTimeToFullChargeAttribute( + val value: UInt? + ) sealed class BatTimeToFullChargeAttributeSubscriptionState { - data class Success(val value: UInt?) : BatTimeToFullChargeAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : BatTimeToFullChargeAttributeSubscriptionState() + data class Error(val exception: Exception) : BatTimeToFullChargeAttributeSubscriptionState() - object SubscriptionEstablished : BatTimeToFullChargeAttributeSubscriptionState() - } - - class BatChargingCurrentAttribute(val value: UInt?) + object SubscriptionEstablished : BatTimeToFullChargeAttributeSubscriptionState() + } +class BatChargingCurrentAttribute( + val value: UInt? + ) sealed class BatChargingCurrentAttributeSubscriptionState { - data class Success(val value: UInt?) : BatChargingCurrentAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : BatChargingCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : BatChargingCurrentAttributeSubscriptionState() - object SubscriptionEstablished : BatChargingCurrentAttributeSubscriptionState() - } - - class ActiveBatChargeFaultsAttribute(val value: List?) + object SubscriptionEstablished : BatChargingCurrentAttributeSubscriptionState() + } +class ActiveBatChargeFaultsAttribute( + val value: List? + ) sealed class ActiveBatChargeFaultsAttributeSubscriptionState { - data class Success(val value: List?) : ActiveBatChargeFaultsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : ActiveBatChargeFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveBatChargeFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveBatChargeFaultsAttributeSubscriptionState() - } - - class EndpointListAttribute(val value: List) + object SubscriptionEstablished : ActiveBatChargeFaultsAttributeSubscriptionState() + } +class EndpointListAttribute( + val value: List + ) sealed class EndpointListAttributeSubscriptionState { - data class Success(val value: List) : EndpointListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EndpointListAttributeSubscriptionState() + data class Error(val exception: Exception) : EndpointListAttributeSubscriptionState() - object SubscriptionEstablished : EndpointListAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : EndpointListAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readStatusAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Status attribute not found in response" } + } + + requireNotNull(attributeData) { + "Status attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -237,37 +311,35 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Status attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Status attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -279,37 +351,44 @@ class PowerSourceCluster(private val controller: MatterController, private val e emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOrderAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - suspend fun readOrderAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Order attribute not found in response" } + } + + requireNotNull(attributeData) { + "Order attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -318,37 +397,35 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Order attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Order attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -360,37 +437,44 @@ class PowerSourceCluster(private val controller: MatterController, private val e emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 2u - suspend fun readDescriptionAttribute(): String { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Description attribute not found in response" } + } + + requireNotNull(attributeData) { + "Description attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } @@ -399,37 +483,35 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Description attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Description attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -441,46 +523,52 @@ class PowerSourceCluster(private val controller: MatterController, private val e emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWiredAssessedInputVoltageAttribute(): WiredAssessedInputVoltageAttribute {val ATTRIBUTE_ID: UInt = 3u - suspend fun readWiredAssessedInputVoltageAttribute(): WiredAssessedInputVoltageAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Wiredassessedinputvoltage attribute not found in response" } + } + + requireNotNull(attributeData) { + "Wiredassessedinputvoltage attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return WiredAssessedInputVoltageAttribute(decodedValue) } @@ -490,102 +578,104 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - WiredAssessedInputVoltageAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(WiredAssessedInputVoltageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Wiredassessedinputvoltage attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Wiredassessedinputvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(WiredAssessedInputVoltageAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(WiredAssessedInputVoltageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWiredAssessedInputFrequencyAttribute(): WiredAssessedInputFrequencyAttribute {val ATTRIBUTE_ID: UInt = 4u - suspend fun readWiredAssessedInputFrequencyAttribute(): WiredAssessedInputFrequencyAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Wiredassessedinputfrequency attribute not found in response" } + } + + requireNotNull(attributeData) { + "Wiredassessedinputfrequency attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return WiredAssessedInputFrequencyAttribute(decodedValue) } @@ -595,97 +685,99 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - WiredAssessedInputFrequencyAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(WiredAssessedInputFrequencyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Wiredassessedinputfrequency attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Wiredassessedinputfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(WiredAssessedInputFrequencyAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(WiredAssessedInputFrequencyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWiredCurrentTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u - suspend fun readWiredCurrentTypeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Wiredcurrenttype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Wiredcurrenttype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -695,95 +787,99 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Wiredcurrenttype attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Wiredcurrenttype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWiredAssessedCurrentAttribute(): WiredAssessedCurrentAttribute {val ATTRIBUTE_ID: UInt = 6u - suspend fun readWiredAssessedCurrentAttribute(): WiredAssessedCurrentAttribute { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Wiredassessedcurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Wiredassessedcurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return WiredAssessedCurrentAttribute(decodedValue) } @@ -793,95 +889,99 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - WiredAssessedCurrentAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(WiredAssessedCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Wiredassessedcurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Wiredassessedcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(WiredAssessedCurrentAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(WiredAssessedCurrentAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(WiredAssessedCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWiredNominalVoltageAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 7u - suspend fun readWiredNominalVoltageAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Wirednominalvoltage attribute not found in response" } + } + + requireNotNull(attributeData) { + "Wirednominalvoltage attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -891,90 +991,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Wirednominalvoltage attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Wirednominalvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWiredMaximumCurrentAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 8u - suspend fun readWiredMaximumCurrentAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Wiredmaximumcurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Wiredmaximumcurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -984,90 +1088,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Wiredmaximumcurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Wiredmaximumcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWiredPresentAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 9u - suspend fun readWiredPresentAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Wiredpresent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Wiredpresent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1077,94 +1185,100 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Wiredpresent attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Wiredpresent attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActiveWiredFaultsAttribute(): ActiveWiredFaultsAttribute {val ATTRIBUTE_ID: UInt = 10u - suspend fun readActiveWiredFaultsAttribute(): ActiveWiredFaultsAttribute { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activewiredfaults attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activewiredfaults attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return ActiveWiredFaultsAttribute(decodedValue) } @@ -1174,101 +1288,105 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveWiredFaultsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveWiredFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activewiredfaults attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activewiredfaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ActiveWiredFaultsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ActiveWiredFaultsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ActiveWiredFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatVoltageAttribute(): BatVoltageAttribute {val ATTRIBUTE_ID: UInt = 11u - suspend fun readBatVoltageAttribute(): BatVoltageAttribute { - val ATTRIBUTE_ID: UInt = 11u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batvoltage attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batvoltage attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return BatVoltageAttribute(decodedValue) } @@ -1278,98 +1396,104 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BatVoltageAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BatVoltageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Batvoltage attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batvoltage attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(BatVoltageAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(BatVoltageAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BatVoltageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatPercentRemainingAttribute(): BatPercentRemainingAttribute {val ATTRIBUTE_ID: UInt = 12u - suspend fun readBatPercentRemainingAttribute(): BatPercentRemainingAttribute { - val ATTRIBUTE_ID: UInt = 12u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batpercentremaining attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batpercentremaining attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return BatPercentRemainingAttribute(decodedValue) } @@ -1379,100 +1503,104 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BatPercentRemainingAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BatPercentRemainingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batpercentremaining attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batpercentremaining attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(BatPercentRemainingAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(BatPercentRemainingAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BatPercentRemainingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatTimeRemainingAttribute(): BatTimeRemainingAttribute {val ATTRIBUTE_ID: UInt = 13u - suspend fun readBatTimeRemainingAttribute(): BatTimeRemainingAttribute { - val ATTRIBUTE_ID: UInt = 13u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Battimeremaining attribute not found in response" } + } + + requireNotNull(attributeData) { + "Battimeremaining attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return BatTimeRemainingAttribute(decodedValue) } @@ -1482,95 +1610,99 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BatTimeRemainingAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BatTimeRemainingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Battimeremaining attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Battimeremaining attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(BatTimeRemainingAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(BatTimeRemainingAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BatTimeRemainingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatChargeLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 14u - suspend fun readBatChargeLevelAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 14u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batchargelevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batchargelevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1580,90 +1712,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batchargelevel attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batchargelevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatReplacementNeededAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 15u - suspend fun readBatReplacementNeededAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 15u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batreplacementneeded attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batreplacementneeded attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1673,90 +1809,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batreplacementneeded attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batreplacementneeded attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatReplaceabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16u - suspend fun readBatReplaceabilityAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batreplaceability attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batreplaceability attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1766,90 +1906,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batreplaceability attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batreplaceability attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatPresentAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 17u - suspend fun readBatPresentAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batpresent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batpresent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1859,94 +2003,100 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Batpresent attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batpresent attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActiveBatFaultsAttribute(): ActiveBatFaultsAttribute {val ATTRIBUTE_ID: UInt = 18u - suspend fun readActiveBatFaultsAttribute(): ActiveBatFaultsAttribute { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activebatfaults attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activebatfaults attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return ActiveBatFaultsAttribute(decodedValue) } @@ -1956,96 +2106,100 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveBatFaultsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveBatFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activebatfaults attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activebatfaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ActiveBatFaultsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ActiveBatFaultsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ActiveBatFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatReplacementDescriptionAttribute(): String? {val ATTRIBUTE_ID: UInt = 19u - suspend fun readBatReplacementDescriptionAttribute(): String? { - val ATTRIBUTE_ID: UInt = 19u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batreplacementdescription attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batreplacementdescription attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2055,90 +2209,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batreplacementdescription attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batreplacementdescription attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatCommonDesignationAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 20u - suspend fun readBatCommonDesignationAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 20u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batcommondesignation attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batcommondesignation attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2148,90 +2306,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batcommondesignation attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batcommondesignation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatANSIDesignationAttribute(): String? {val ATTRIBUTE_ID: UInt = 21u - suspend fun readBatANSIDesignationAttribute(): String? { - val ATTRIBUTE_ID: UInt = 21u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batansidesignation attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batansidesignation attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2241,90 +2403,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batansidesignation attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batansidesignation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatIECDesignationAttribute(): String? {val ATTRIBUTE_ID: UInt = 22u - suspend fun readBatIECDesignationAttribute(): String? { - val ATTRIBUTE_ID: UInt = 22u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batiecdesignation attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batiecdesignation attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2334,90 +2500,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batiecdesignation attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batiecdesignation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatApprovedChemistryAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 23u - suspend fun readBatApprovedChemistryAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 23u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batapprovedchemistry attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batapprovedchemistry attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2427,90 +2597,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batapprovedchemistry attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batapprovedchemistry attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatCapacityAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 24u - suspend fun readBatCapacityAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 24u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batcapacity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batcapacity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2520,88 +2694,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Batcapacity attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batcapacity attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatQuantityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 25u - suspend fun readBatQuantityAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 25u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batquantity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batquantity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2611,88 +2791,94 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Batquantity attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batquantity attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatChargeStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u - suspend fun readBatChargeStateAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 26u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batchargestate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batchargestate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2702,95 +2888,99 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batchargestate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batchargestate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatTimeToFullChargeAttribute(): BatTimeToFullChargeAttribute {val ATTRIBUTE_ID: UInt = 27u - suspend fun readBatTimeToFullChargeAttribute(): BatTimeToFullChargeAttribute { - val ATTRIBUTE_ID: UInt = 27u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Battimetofullcharge attribute not found in response" } + } + + requireNotNull(attributeData) { + "Battimetofullcharge attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return BatTimeToFullChargeAttribute(decodedValue) } @@ -2800,95 +2990,99 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BatTimeToFullChargeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BatTimeToFullChargeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Battimetofullcharge attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Battimetofullcharge attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(BatTimeToFullChargeAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(BatTimeToFullChargeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BatTimeToFullChargeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatFunctionalWhileChargingAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 28u - suspend fun readBatFunctionalWhileChargingAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 28u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batfunctionalwhilecharging attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batfunctionalwhilecharging attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2898,95 +3092,99 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batfunctionalwhilecharging attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batfunctionalwhilecharging attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBatChargingCurrentAttribute(): BatChargingCurrentAttribute {val ATTRIBUTE_ID: UInt = 29u - suspend fun readBatChargingCurrentAttribute(): BatChargingCurrentAttribute { - val ATTRIBUTE_ID: UInt = 29u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batchargingcurrent attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batchargingcurrent attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return BatChargingCurrentAttribute(decodedValue) } @@ -2996,101 +3194,105 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 29u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BatChargingCurrentAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BatChargingCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Batchargingcurrent attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batchargingcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(BatChargingCurrentAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(BatChargingCurrentAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BatChargingCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActiveBatChargeFaultsAttribute(): ActiveBatChargeFaultsAttribute {val ATTRIBUTE_ID: UInt = 30u - suspend fun readActiveBatChargeFaultsAttribute(): ActiveBatChargeFaultsAttribute { - val ATTRIBUTE_ID: UInt = 30u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activebatchargefaults attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activebatchargefaults attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return ActiveBatChargeFaultsAttribute(decodedValue) } @@ -3100,98 +3302,102 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveBatChargeFaultsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveBatChargeFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activebatchargefaults attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activebatchargefaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ActiveBatChargeFaultsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ActiveBatChargeFaultsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ActiveBatChargeFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEndpointListAttribute(): EndpointListAttribute {val ATTRIBUTE_ID: UInt = 31u - suspend fun readEndpointListAttribute(): EndpointListAttribute { - val ATTRIBUTE_ID: UInt = 31u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Endpointlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Endpointlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) } + tlvReader.exitContainer() + } + return EndpointListAttribute(decodedValue) } @@ -3201,48 +3407,45 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 31u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EndpointListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EndpointListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Endpointlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Endpointlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EndpointListAttributeSubscriptionState.Success(decodedValue)) } @@ -3250,43 +3453,49 @@ class PowerSourceCluster(private val controller: MatterController, private val e emit(EndpointListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -3296,50 +3505,45 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3347,43 +3551,49 @@ class PowerSourceCluster(private val controller: MatterController, private val e emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -3393,50 +3603,45 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3444,43 +3649,49 @@ class PowerSourceCluster(private val controller: MatterController, private val e emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -3490,48 +3701,45 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -3539,43 +3747,49 @@ class PowerSourceCluster(private val controller: MatterController, private val e emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -3585,48 +3799,45 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -3634,37 +3845,44 @@ class PowerSourceCluster(private val controller: MatterController, private val e emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -3673,37 +3891,35 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3715,37 +3931,44 @@ class PowerSourceCluster(private val controller: MatterController, private val e emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -3754,38 +3977,34 @@ class PowerSourceCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3798,7 +4017,7 @@ class PowerSourceCluster(private val controller: MatterController, private val e emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt index eb3b505f117912..59bfeff63ee455 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt @@ -17,111 +17,154 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class PowerSourceConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SourcesAttribute(val value: List) +class PowerSourceConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class SourcesAttribute( + val value: List + ) sealed class SourcesAttributeSubscriptionState { - data class Success(val value: List) : SourcesAttributeSubscriptionState() - + data class Success( + val value: List + ) : SourcesAttributeSubscriptionState() + data class Error(val exception: Exception) : SourcesAttributeSubscriptionState() - object SubscriptionEstablished : SourcesAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : SourcesAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readSourcesAttribute(): SourcesAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readSourcesAttribute(): SourcesAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Sources attribute not found in response" } + } + + requireNotNull(attributeData) { + "Sources attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) } + tlvReader.exitContainer() + } + return SourcesAttribute(decodedValue) } @@ -131,48 +174,45 @@ class PowerSourceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SourcesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SourcesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Sources attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Sources attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(SourcesAttributeSubscriptionState.Success(decodedValue)) } @@ -180,43 +220,49 @@ class PowerSourceConfigurationCluster( emit(SourcesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -226,50 +272,45 @@ class PowerSourceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -277,43 +318,49 @@ class PowerSourceConfigurationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -323,50 +370,45 @@ class PowerSourceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -374,43 +416,49 @@ class PowerSourceConfigurationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -420,48 +468,45 @@ class PowerSourceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -469,43 +514,49 @@ class PowerSourceConfigurationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -515,48 +566,45 @@ class PowerSourceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -564,37 +612,44 @@ class PowerSourceConfigurationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -603,37 +658,35 @@ class PowerSourceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -645,37 +698,44 @@ class PowerSourceConfigurationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -684,38 +744,34 @@ class PowerSourceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -728,7 +784,7 @@ class PowerSourceConfigurationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt index e374599a909987..e8726e5f3a3cac 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt @@ -17,161 +17,218 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.ByteSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class PressureMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Short?) +class PressureMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Short? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Short?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Short?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Short? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Short?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Short?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Short? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Short?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class ScaledValueAttribute(val value: Short?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class ScaledValueAttribute( + val value: Short? + ) sealed class ScaledValueAttributeSubscriptionState { - data class Success(val value: Short?) : ScaledValueAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : ScaledValueAttributeSubscriptionState() + data class Error(val exception: Exception) : ScaledValueAttributeSubscriptionState() - object SubscriptionEstablished : ScaledValueAttributeSubscriptionState() - } - - class MinScaledValueAttribute(val value: Short?) + object SubscriptionEstablished : ScaledValueAttributeSubscriptionState() + } +class MinScaledValueAttribute( + val value: Short? + ) sealed class MinScaledValueAttributeSubscriptionState { - data class Success(val value: Short?) : MinScaledValueAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MinScaledValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinScaledValueAttributeSubscriptionState() - object SubscriptionEstablished : MinScaledValueAttributeSubscriptionState() - } - - class MaxScaledValueAttribute(val value: Short?) + object SubscriptionEstablished : MinScaledValueAttributeSubscriptionState() + } +class MaxScaledValueAttribute( + val value: Short? + ) sealed class MaxScaledValueAttributeSubscriptionState { - data class Success(val value: Short?) : MaxScaledValueAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MaxScaledValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxScaledValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxScaledValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : MaxScaledValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -181,90 +238,96 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -274,92 +337,96 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -369,91 +436,95 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readToleranceAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Tolerance attribute not found in response" } + } + + requireNotNull(attributeData) { + "Tolerance attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -463,93 +534,99 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Tolerance attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readScaledValueAttribute(): ScaledValueAttribute { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readScaledValueAttribute(): ScaledValueAttribute {val ATTRIBUTE_ID: UInt = 16u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Scaledvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Scaledvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ScaledValueAttribute(decodedValue) } @@ -559,98 +636,104 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ScaledValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ScaledValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Scaledvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scaledvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ScaledValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ScaledValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ScaledValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinScaledValueAttribute(): MinScaledValueAttribute { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinScaledValueAttribute(): MinScaledValueAttribute {val ATTRIBUTE_ID: UInt = 17u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minscaledvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minscaledvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinScaledValueAttribute(decodedValue) } @@ -660,100 +743,104 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinScaledValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinScaledValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minscaledvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minscaledvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinScaledValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinScaledValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinScaledValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxScaledValueAttribute(): MaxScaledValueAttribute { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxScaledValueAttribute(): MaxScaledValueAttribute {val ATTRIBUTE_ID: UInt = 18u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxscaledvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxscaledvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxScaledValueAttribute(decodedValue) } @@ -763,95 +850,99 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxScaledValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxScaledValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxscaledvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxscaledvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxScaledValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxScaledValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxScaledValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readScaledToleranceAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 19u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readScaledToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Scaledtolerance attribute not found in response" } + } + + requireNotNull(attributeData) { + "Scaledtolerance attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -861,90 +952,94 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Scaledtolerance attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scaledtolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readScaleAttribute(): Byte? { - val ATTRIBUTE_ID: UInt = 20u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readScaleAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 20u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Scale attribute not found in response" } + } + + requireNotNull(attributeData) { + "Scale attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -954,90 +1049,96 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Scale attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scale attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1047,50 +1148,45 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1098,43 +1194,49 @@ class PressureMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1144,50 +1246,45 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1195,43 +1292,49 @@ class PressureMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1241,48 +1344,45 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1290,43 +1390,49 @@ class PressureMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1336,48 +1442,45 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1385,37 +1488,44 @@ class PressureMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1424,37 +1534,35 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1466,37 +1574,44 @@ class PressureMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1505,38 +1620,34 @@ class PressureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1549,7 +1660,7 @@ class PressureMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt index 5eb0f105ba47d1..b08df6933b9fd1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt @@ -17,101 +17,141 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class ProxyConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class ProxyConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -121,50 +161,45 @@ class ProxyConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -172,43 +207,49 @@ class ProxyConfigurationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -218,50 +259,45 @@ class ProxyConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -269,43 +305,49 @@ class ProxyConfigurationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -315,48 +357,45 @@ class ProxyConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -364,43 +403,49 @@ class ProxyConfigurationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -410,48 +455,45 @@ class ProxyConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -459,37 +501,44 @@ class ProxyConfigurationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -498,37 +547,35 @@ class ProxyConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -540,37 +587,44 @@ class ProxyConfigurationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -579,38 +633,34 @@ class ProxyConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -623,7 +673,7 @@ class ProxyConfigurationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt index 46ad79a25cd0c2..42d50e762f785c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt @@ -17,101 +17,141 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class ProxyDiscoveryCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class ProxyDiscoveryCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -121,50 +161,45 @@ class ProxyDiscoveryCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -172,43 +207,49 @@ class ProxyDiscoveryCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -218,50 +259,45 @@ class ProxyDiscoveryCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -269,43 +305,49 @@ class ProxyDiscoveryCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -315,48 +357,45 @@ class ProxyDiscoveryCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -364,43 +403,49 @@ class ProxyDiscoveryCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -410,48 +455,45 @@ class ProxyDiscoveryCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -459,37 +501,44 @@ class ProxyDiscoveryCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -498,37 +547,35 @@ class ProxyDiscoveryCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -540,37 +587,44 @@ class ProxyDiscoveryCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -579,38 +633,34 @@ class ProxyDiscoveryCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -623,7 +673,7 @@ class ProxyDiscoveryCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt index 96d846ad277cec..79217bb65e2c72 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt @@ -17,98 +17,141 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class ProxyValidCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) +class ProxyValidCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -118,50 +161,45 @@ class ProxyValidCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -169,43 +207,49 @@ class ProxyValidCluster(private val controller: MatterController, private val en emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -215,50 +259,45 @@ class ProxyValidCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -266,43 +305,49 @@ class ProxyValidCluster(private val controller: MatterController, private val en emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -312,48 +357,45 @@ class ProxyValidCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -361,43 +403,49 @@ class ProxyValidCluster(private val controller: MatterController, private val en emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -407,48 +455,45 @@ class ProxyValidCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -456,37 +501,44 @@ class ProxyValidCluster(private val controller: MatterController, private val en emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -495,37 +547,35 @@ class ProxyValidCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -537,37 +587,44 @@ class ProxyValidCluster(private val controller: MatterController, private val en emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -576,38 +633,34 @@ class ProxyValidCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -620,7 +673,7 @@ class ProxyValidCluster(private val controller: MatterController, private val en emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt index 0e2ffc820350d9..0ae147a5169862 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt @@ -17,101 +17,141 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class PulseWidthModulationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class PulseWidthModulationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -121,50 +161,45 @@ class PulseWidthModulationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -172,43 +207,49 @@ class PulseWidthModulationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -218,50 +259,45 @@ class PulseWidthModulationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -269,43 +305,49 @@ class PulseWidthModulationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -315,48 +357,45 @@ class PulseWidthModulationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -364,43 +403,49 @@ class PulseWidthModulationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -410,48 +455,45 @@ class PulseWidthModulationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -459,37 +501,44 @@ class PulseWidthModulationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -498,37 +547,35 @@ class PulseWidthModulationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -540,37 +587,44 @@ class PulseWidthModulationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -579,38 +633,34 @@ class PulseWidthModulationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -623,7 +673,7 @@ class PulseWidthModulationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt index 6620523d5be3fa..77f27057b0a555 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt @@ -17,285 +17,374 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PumpConfigurationAndControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MaxPressureAttribute(val value: Short?) +class PumpConfigurationAndControlCluster(private val controller: MatterController, private val endpointId: UShort) {class MaxPressureAttribute( + val value: Short? + ) sealed class MaxPressureAttributeSubscriptionState { - data class Success(val value: Short?) : MaxPressureAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MaxPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxPressureAttributeSubscriptionState() - object SubscriptionEstablished : MaxPressureAttributeSubscriptionState() - } - - class MaxSpeedAttribute(val value: UShort?) + object SubscriptionEstablished : MaxPressureAttributeSubscriptionState() + } +class MaxSpeedAttribute( + val value: UShort? + ) sealed class MaxSpeedAttributeSubscriptionState { - data class Success(val value: UShort?) : MaxSpeedAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MaxSpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxSpeedAttributeSubscriptionState() - object SubscriptionEstablished : MaxSpeedAttributeSubscriptionState() - } - - class MaxFlowAttribute(val value: UShort?) + object SubscriptionEstablished : MaxSpeedAttributeSubscriptionState() + } +class MaxFlowAttribute( + val value: UShort? + ) sealed class MaxFlowAttributeSubscriptionState { - data class Success(val value: UShort?) : MaxFlowAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MaxFlowAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxFlowAttributeSubscriptionState() - object SubscriptionEstablished : MaxFlowAttributeSubscriptionState() - } - - class MinConstPressureAttribute(val value: Short?) + object SubscriptionEstablished : MaxFlowAttributeSubscriptionState() + } +class MinConstPressureAttribute( + val value: Short? + ) sealed class MinConstPressureAttributeSubscriptionState { - data class Success(val value: Short?) : MinConstPressureAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MinConstPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstPressureAttributeSubscriptionState() - object SubscriptionEstablished : MinConstPressureAttributeSubscriptionState() - } - - class MaxConstPressureAttribute(val value: Short?) + object SubscriptionEstablished : MinConstPressureAttributeSubscriptionState() + } +class MaxConstPressureAttribute( + val value: Short? + ) sealed class MaxConstPressureAttributeSubscriptionState { - data class Success(val value: Short?) : MaxConstPressureAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MaxConstPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstPressureAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstPressureAttributeSubscriptionState() - } - - class MinCompPressureAttribute(val value: Short?) + object SubscriptionEstablished : MaxConstPressureAttributeSubscriptionState() + } +class MinCompPressureAttribute( + val value: Short? + ) sealed class MinCompPressureAttributeSubscriptionState { - data class Success(val value: Short?) : MinCompPressureAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MinCompPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MinCompPressureAttributeSubscriptionState() - object SubscriptionEstablished : MinCompPressureAttributeSubscriptionState() - } - - class MaxCompPressureAttribute(val value: Short?) + object SubscriptionEstablished : MinCompPressureAttributeSubscriptionState() + } +class MaxCompPressureAttribute( + val value: Short? + ) sealed class MaxCompPressureAttributeSubscriptionState { - data class Success(val value: Short?) : MaxCompPressureAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MaxCompPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxCompPressureAttributeSubscriptionState() - object SubscriptionEstablished : MaxCompPressureAttributeSubscriptionState() - } - - class MinConstSpeedAttribute(val value: UShort?) + object SubscriptionEstablished : MaxCompPressureAttributeSubscriptionState() + } +class MinConstSpeedAttribute( + val value: UShort? + ) sealed class MinConstSpeedAttributeSubscriptionState { - data class Success(val value: UShort?) : MinConstSpeedAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MinConstSpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstSpeedAttributeSubscriptionState() - object SubscriptionEstablished : MinConstSpeedAttributeSubscriptionState() - } - - class MaxConstSpeedAttribute(val value: UShort?) + object SubscriptionEstablished : MinConstSpeedAttributeSubscriptionState() + } +class MaxConstSpeedAttribute( + val value: UShort? + ) sealed class MaxConstSpeedAttributeSubscriptionState { - data class Success(val value: UShort?) : MaxConstSpeedAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MaxConstSpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstSpeedAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstSpeedAttributeSubscriptionState() - } - - class MinConstFlowAttribute(val value: UShort?) + object SubscriptionEstablished : MaxConstSpeedAttributeSubscriptionState() + } +class MinConstFlowAttribute( + val value: UShort? + ) sealed class MinConstFlowAttributeSubscriptionState { - data class Success(val value: UShort?) : MinConstFlowAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MinConstFlowAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstFlowAttributeSubscriptionState() - object SubscriptionEstablished : MinConstFlowAttributeSubscriptionState() - } - - class MaxConstFlowAttribute(val value: UShort?) + object SubscriptionEstablished : MinConstFlowAttributeSubscriptionState() + } +class MaxConstFlowAttribute( + val value: UShort? + ) sealed class MaxConstFlowAttributeSubscriptionState { - data class Success(val value: UShort?) : MaxConstFlowAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MaxConstFlowAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstFlowAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstFlowAttributeSubscriptionState() - } - - class MinConstTempAttribute(val value: Short?) + object SubscriptionEstablished : MaxConstFlowAttributeSubscriptionState() + } +class MinConstTempAttribute( + val value: Short? + ) sealed class MinConstTempAttributeSubscriptionState { - data class Success(val value: Short?) : MinConstTempAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MinConstTempAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstTempAttributeSubscriptionState() - object SubscriptionEstablished : MinConstTempAttributeSubscriptionState() - } - - class MaxConstTempAttribute(val value: Short?) + object SubscriptionEstablished : MinConstTempAttributeSubscriptionState() + } +class MaxConstTempAttribute( + val value: Short? + ) sealed class MaxConstTempAttributeSubscriptionState { - data class Success(val value: Short?) : MaxConstTempAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MaxConstTempAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstTempAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstTempAttributeSubscriptionState() - } - - class CapacityAttribute(val value: Short?) + object SubscriptionEstablished : MaxConstTempAttributeSubscriptionState() + } +class CapacityAttribute( + val value: Short? + ) sealed class CapacityAttributeSubscriptionState { - data class Success(val value: Short?) : CapacityAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : CapacityAttributeSubscriptionState() + data class Error(val exception: Exception) : CapacityAttributeSubscriptionState() - object SubscriptionEstablished : CapacityAttributeSubscriptionState() - } - - class SpeedAttribute(val value: UShort?) + object SubscriptionEstablished : CapacityAttributeSubscriptionState() + } +class SpeedAttribute( + val value: UShort? + ) sealed class SpeedAttributeSubscriptionState { - data class Success(val value: UShort?) : SpeedAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : SpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : SpeedAttributeSubscriptionState() - object SubscriptionEstablished : SpeedAttributeSubscriptionState() - } - - class LifetimeRunningHoursAttribute(val value: UInt?) + object SubscriptionEstablished : SpeedAttributeSubscriptionState() + } +class LifetimeRunningHoursAttribute( + val value: UInt? + ) sealed class LifetimeRunningHoursAttributeSubscriptionState { - data class Success(val value: UInt?) : LifetimeRunningHoursAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : LifetimeRunningHoursAttributeSubscriptionState() + data class Error(val exception: Exception) : LifetimeRunningHoursAttributeSubscriptionState() - object SubscriptionEstablished : LifetimeRunningHoursAttributeSubscriptionState() - } - - class PowerAttribute(val value: UInt?) + object SubscriptionEstablished : LifetimeRunningHoursAttributeSubscriptionState() + } +class PowerAttribute( + val value: UInt? + ) sealed class PowerAttributeSubscriptionState { - data class Success(val value: UInt?) : PowerAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : PowerAttributeSubscriptionState() + data class Error(val exception: Exception) : PowerAttributeSubscriptionState() - object SubscriptionEstablished : PowerAttributeSubscriptionState() - } - - class LifetimeEnergyConsumedAttribute(val value: UInt?) + object SubscriptionEstablished : PowerAttributeSubscriptionState() + } +class LifetimeEnergyConsumedAttribute( + val value: UInt? + ) sealed class LifetimeEnergyConsumedAttributeSubscriptionState { - data class Success(val value: UInt?) : LifetimeEnergyConsumedAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : LifetimeEnergyConsumedAttributeSubscriptionState() + data class Error(val exception: Exception) : LifetimeEnergyConsumedAttributeSubscriptionState() - object SubscriptionEstablished : LifetimeEnergyConsumedAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : LifetimeEnergyConsumedAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMaxPressureAttribute(): MaxPressureAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMaxPressureAttribute(): MaxPressureAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxpressure attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxpressure attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxPressureAttribute(decodedValue) } @@ -305,90 +394,96 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxPressureAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxpressure attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxpressure attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(MaxPressureAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(MaxPressureAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxSpeedAttribute(): MaxSpeedAttribute {val ATTRIBUTE_ID: UInt = 1u - suspend fun readMaxSpeedAttribute(): MaxSpeedAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxspeed attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxspeed attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxSpeedAttribute(decodedValue) } @@ -398,90 +493,96 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxSpeedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxSpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxspeed attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxspeed attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(MaxSpeedAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(MaxSpeedAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxSpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxFlowAttribute(): MaxFlowAttribute {val ATTRIBUTE_ID: UInt = 2u - suspend fun readMaxFlowAttribute(): MaxFlowAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxflow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxflow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxFlowAttribute(decodedValue) } @@ -491,94 +592,100 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxFlowAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxFlowAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxflow attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxflow attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(MaxFlowAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(MaxFlowAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxFlowAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinConstPressureAttribute(): MinConstPressureAttribute {val ATTRIBUTE_ID: UInt = 3u - suspend fun readMinConstPressureAttribute(): MinConstPressureAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minconstpressure attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minconstpressure attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinConstPressureAttribute(decodedValue) } @@ -588,100 +695,104 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinConstPressureAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinConstPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minconstpressure attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minconstpressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinConstPressureAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinConstPressureAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinConstPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxConstPressureAttribute(): MaxConstPressureAttribute {val ATTRIBUTE_ID: UInt = 4u - suspend fun readMaxConstPressureAttribute(): MaxConstPressureAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxconstpressure attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxconstpressure attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxConstPressureAttribute(decodedValue) } @@ -691,100 +802,104 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxConstPressureAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxConstPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxconstpressure attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxconstpressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxConstPressureAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxConstPressureAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinCompPressureAttribute(): MinCompPressureAttribute {val ATTRIBUTE_ID: UInt = 5u - suspend fun readMinCompPressureAttribute(): MinCompPressureAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Mincomppressure attribute not found in response" } + } + + requireNotNull(attributeData) { + "Mincomppressure attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinCompPressureAttribute(decodedValue) } @@ -794,100 +909,104 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinCompPressureAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinCompPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Mincomppressure attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Mincomppressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinCompPressureAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinCompPressureAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinCompPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxCompPressureAttribute(): MaxCompPressureAttribute {val ATTRIBUTE_ID: UInt = 6u - suspend fun readMaxCompPressureAttribute(): MaxCompPressureAttribute { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxcomppressure attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxcomppressure attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxCompPressureAttribute(decodedValue) } @@ -897,100 +1016,104 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxCompPressureAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxCompPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxcomppressure attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxcomppressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxCompPressureAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxCompPressureAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxCompPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinConstSpeedAttribute(): MinConstSpeedAttribute {val ATTRIBUTE_ID: UInt = 7u - suspend fun readMinConstSpeedAttribute(): MinConstSpeedAttribute { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minconstspeed attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minconstspeed attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinConstSpeedAttribute(decodedValue) } @@ -1000,98 +1123,104 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinConstSpeedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinConstSpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Minconstspeed attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minconstspeed attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinConstSpeedAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinConstSpeedAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinConstSpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxConstSpeedAttribute(): MaxConstSpeedAttribute {val ATTRIBUTE_ID: UInt = 8u - suspend fun readMaxConstSpeedAttribute(): MaxConstSpeedAttribute { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxconstspeed attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxconstspeed attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxConstSpeedAttribute(decodedValue) } @@ -1101,98 +1230,104 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxConstSpeedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxConstSpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxconstspeed attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxconstspeed attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxConstSpeedAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxConstSpeedAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstSpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinConstFlowAttribute(): MinConstFlowAttribute {val ATTRIBUTE_ID: UInt = 9u - suspend fun readMinConstFlowAttribute(): MinConstFlowAttribute { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minconstflow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minconstflow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinConstFlowAttribute(decodedValue) } @@ -1202,98 +1337,104 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinConstFlowAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinConstFlowAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Minconstflow attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minconstflow attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinConstFlowAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinConstFlowAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinConstFlowAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxConstFlowAttribute(): MaxConstFlowAttribute {val ATTRIBUTE_ID: UInt = 10u - suspend fun readMaxConstFlowAttribute(): MaxConstFlowAttribute { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxconstflow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxconstflow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxConstFlowAttribute(decodedValue) } @@ -1303,98 +1444,104 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxConstFlowAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxConstFlowAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxconstflow attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxconstflow attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxConstFlowAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxConstFlowAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstFlowAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinConstTempAttribute(): MinConstTempAttribute {val ATTRIBUTE_ID: UInt = 11u - suspend fun readMinConstTempAttribute(): MinConstTempAttribute { - val ATTRIBUTE_ID: UInt = 11u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minconsttemp attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minconsttemp attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinConstTempAttribute(decodedValue) } @@ -1404,98 +1551,104 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinConstTempAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinConstTempAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Minconsttemp attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minconsttemp attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinConstTempAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinConstTempAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinConstTempAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxConstTempAttribute(): MaxConstTempAttribute {val ATTRIBUTE_ID: UInt = 12u - suspend fun readMaxConstTempAttribute(): MaxConstTempAttribute { - val ATTRIBUTE_ID: UInt = 12u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxconsttemp attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxconsttemp attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxConstTempAttribute(decodedValue) } @@ -1505,93 +1658,99 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxConstTempAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxConstTempAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Maxconsttemp attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxconsttemp attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxConstTempAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxConstTempAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstTempAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPumpStatusAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - suspend fun readPumpStatusAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Pumpstatus attribute not found in response" } + } + + requireNotNull(attributeData) { + "Pumpstatus attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1601,84 +1760,91 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Pumpstatus attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Pumpstatus attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } - } - - suspend fun readEffectiveOperationModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + } + } +suspend fun readEffectiveOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Effectiveoperationmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Effectiveoperationmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -1687,38 +1853,34 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Effectiveoperationmode attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Effectiveoperationmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1731,37 +1893,44 @@ class PumpConfigurationAndControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEffectiveControlModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 18u - suspend fun readEffectiveControlModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Effectivecontrolmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Effectivecontrolmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -1770,38 +1939,34 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Effectivecontrolmode attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Effectivecontrolmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1814,42 +1979,48 @@ class PumpConfigurationAndControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCapacityAttribute(): CapacityAttribute {val ATTRIBUTE_ID: UInt = 19u - suspend fun readCapacityAttribute(): CapacityAttribute { - val ATTRIBUTE_ID: UInt = 19u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Capacity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Capacity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CapacityAttribute(decodedValue) } @@ -1859,94 +2030,100 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CapacityAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CapacityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Capacity attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Capacity attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(CapacityAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(CapacityAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CapacityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSpeedAttribute(): SpeedAttribute {val ATTRIBUTE_ID: UInt = 20u - suspend fun readSpeedAttribute(): SpeedAttribute { - val ATTRIBUTE_ID: UInt = 20u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Speed attribute not found in response" } + } + + requireNotNull(attributeData) { + "Speed attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SpeedAttribute(decodedValue) } @@ -1956,118 +2133,128 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SpeedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Speed attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Speed attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(SpeedAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(SpeedAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute {val ATTRIBUTE_ID: UInt = 21u - suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute { - val ATTRIBUTE_ID: UInt = 21u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lifetimerunninghours attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lifetimerunninghours attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LifetimeRunningHoursAttribute(decodedValue) } - suspend fun writeLifetimeRunningHoursAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeLifetimeRunningHoursAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2089,7 +2276,7 @@ class PumpConfigurationAndControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLifetimeRunningHoursAttribute( @@ -2097,100 +2284,104 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LifetimeRunningHoursAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LifetimeRunningHoursAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lifetimerunninghours attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lifetimerunninghours attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(LifetimeRunningHoursAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(LifetimeRunningHoursAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LifetimeRunningHoursAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPowerAttribute(): PowerAttribute {val ATTRIBUTE_ID: UInt = 22u - suspend fun readPowerAttribute(): PowerAttribute { - val ATTRIBUTE_ID: UInt = 22u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Power attribute not found in response" } + } + + requireNotNull(attributeData) { + "Power attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PowerAttribute(decodedValue) } @@ -2200,121 +2391,128 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PowerAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PowerAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Power attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Power attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PowerAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PowerAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PowerAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribute {val ATTRIBUTE_ID: UInt = 23u - suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribute { - val ATTRIBUTE_ID: UInt = 23u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lifetimeenergyconsumed attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lifetimeenergyconsumed attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LifetimeEnergyConsumedAttribute(decodedValue) } suspend fun writeLifetimeEnergyConsumedAttribute( value: UInt, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2336,7 +2534,7 @@ class PumpConfigurationAndControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLifetimeEnergyConsumedAttribute( @@ -2344,110 +2542,119 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LifetimeEnergyConsumedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LifetimeEnergyConsumedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lifetimeenergyconsumed attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lifetimeenergyconsumed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(LifetimeEnergyConsumedAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(LifetimeEnergyConsumedAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LifetimeEnergyConsumedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u - suspend fun readOperationModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 32u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeOperationModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOperationModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 32u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2469,7 +2676,7 @@ class PumpConfigurationAndControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOperationModeAttribute( @@ -2477,37 +2684,35 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Operationmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2519,61 +2724,71 @@ class PumpConfigurationAndControlCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readControlModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 33u - suspend fun readControlModeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 33u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Controlmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Controlmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeControlModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeControlModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2595,7 +2810,7 @@ class PumpConfigurationAndControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeControlModeAttribute( @@ -2603,90 +2818,96 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Controlmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Controlmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -2696,50 +2917,45 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2747,43 +2963,49 @@ class PumpConfigurationAndControlCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -2793,50 +3015,45 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2844,43 +3061,49 @@ class PumpConfigurationAndControlCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -2890,48 +3113,45 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2939,43 +3159,49 @@ class PumpConfigurationAndControlCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -2985,48 +3211,45 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -3034,37 +3257,44 @@ class PumpConfigurationAndControlCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -3073,37 +3303,35 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3115,37 +3343,44 @@ class PumpConfigurationAndControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -3154,38 +3389,34 @@ class PumpConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3198,7 +3429,7 @@ class PumpConfigurationAndControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt index d2d71369780de0..05e3ef50cbd96d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt @@ -17,156 +17,209 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class RadonConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) +class RadonConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Float? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Float? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Float? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class PeakMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class PeakMeasuredValueAttribute( + val value: Float? + ) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } - - class AverageMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } +class AverageMeasuredValueAttribute( + val value: Float? + ) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -176,98 +229,104 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -277,100 +336,104 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -380,100 +443,104 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeakMeasuredValueAttribute(decodedValue) } @@ -483,95 +550,99 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeakMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -581,95 +652,99 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AverageMeasuredValueAttribute(decodedValue) } @@ -679,95 +754,99 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AverageMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -777,90 +856,94 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUncertaintyAttribute(): Float? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + return decodedValue } @@ -870,88 +953,94 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(FloatSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementUnitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -961,90 +1050,94 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementMediumAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1054,90 +1147,94 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLevelValueAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1147,90 +1244,96 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1240,50 +1343,45 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1291,43 +1389,49 @@ class RadonConcentrationMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1337,50 +1441,45 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1388,43 +1487,49 @@ class RadonConcentrationMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1434,48 +1539,45 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1483,43 +1585,49 @@ class RadonConcentrationMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1529,48 +1637,45 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1578,37 +1683,44 @@ class RadonConcentrationMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1617,37 +1729,35 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1659,37 +1769,44 @@ class RadonConcentrationMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1698,38 +1815,34 @@ class RadonConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1742,7 +1855,7 @@ class RadonConcentrationMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt index 70eb72e6db7ec9..fc8ca10f3d18d2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt @@ -17,95 +17,136 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class RefrigeratorAlarmCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class RefrigeratorAlarmCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMaskAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Mask attribute not found in response" } + } + + requireNotNull(attributeData) { + "Mask attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -114,37 +155,35 @@ class RefrigeratorAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Mask attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Mask attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -156,37 +195,44 @@ class RefrigeratorAlarmCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStateAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "State attribute not found in response" } + } + + requireNotNull(attributeData) { + "State attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -195,37 +241,35 @@ class RefrigeratorAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "State attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "State attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -237,37 +281,44 @@ class RefrigeratorAlarmCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportedAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supported attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supported attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -276,37 +327,35 @@ class RefrigeratorAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Supported attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supported attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -318,43 +367,49 @@ class RefrigeratorAlarmCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -364,50 +419,45 @@ class RefrigeratorAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -415,43 +465,49 @@ class RefrigeratorAlarmCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -461,50 +517,45 @@ class RefrigeratorAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -512,43 +563,49 @@ class RefrigeratorAlarmCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -558,48 +615,45 @@ class RefrigeratorAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -607,43 +661,49 @@ class RefrigeratorAlarmCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -653,48 +713,45 @@ class RefrigeratorAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -702,37 +759,44 @@ class RefrigeratorAlarmCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -741,37 +805,35 @@ class RefrigeratorAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -783,37 +845,44 @@ class RefrigeratorAlarmCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -822,38 +891,34 @@ class RefrigeratorAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -866,7 +931,7 @@ class RefrigeratorAlarmCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt index 61898b4f3d849d..ce6565c3397935 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt @@ -17,123 +17,154 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RefrigeratorAndTemperatureControlledCabinetModeCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ChangeToModeResponse(val status: UByte, val statusText: String?) - - class SupportedModesAttribute( +class RefrigeratorAndTemperatureControlledCabinetModeCluster(private val controller: MatterController, private val endpointId: UShort) { + class ChangeToModeResponse( + val status: UByte, + val statusText: String? + ) +class SupportedModesAttribute( val value: List ) sealed class SupportedModesAttributeSubscriptionState { data class Success( - val value: List + val value: List ) : SupportedModesAttributeSubscriptionState() - + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } - - class StartUpModeAttribute(val value: UByte?) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } +class StartUpModeAttribute( + val value: UByte? + ) sealed class StartUpModeAttributeSubscriptionState { - data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } - - class OnModeAttribute(val value: UByte?) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } +class OnModeAttribute( + val value: UByte? + ) sealed class OnModeAttributeSubscriptionState { - data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeout: Duration? = null - ): ChangeToModeResponse { + suspend fun changeToMode(newMode: UByte + ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -150,82 +181,92 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { - statusText_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return ChangeToModeResponse(status_decoded, statusText_decoded) + return ChangeToModeResponse( + status_decoded, + statusText_decoded + ) } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return SupportedModesAttribute(decodedValue) } @@ -235,56 +276,45 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedModesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: - List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -292,37 +322,44 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -331,37 +368,35 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -373,66 +408,76 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStartUpModeAttribute(): StartUpModeAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Startupmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Startupmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -454,7 +499,7 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -462,118 +507,128 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StartUpModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Startupmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(StartUpModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOnModeAttribute(): OnModeAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Onmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Onmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -595,7 +650,7 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -603,95 +658,101 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OnModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Onmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OnModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -701,50 +762,45 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -752,43 +808,49 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -798,50 +860,45 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -849,43 +906,49 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -895,48 +958,45 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -944,43 +1004,49 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -990,48 +1056,45 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1039,37 +1102,44 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1078,37 +1148,35 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1120,37 +1188,44 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1159,38 +1234,34 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1203,12 +1274,11 @@ class RefrigeratorAndTemperatureControlledCabinetModeCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = - Logger.getLogger(RefrigeratorAndTemperatureControlledCabinetModeCluster::class.java.name) + private val logger = Logger.getLogger(RefrigeratorAndTemperatureControlledCabinetModeCluster::class.java.name) const val CLUSTER_ID: UInt = 82u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt index c8b35042a38183..c7f6f1f5cc66a8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt @@ -17,130 +17,179 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class RelativeHumidityMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: UShort?) +class RelativeHumidityMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: UShort? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: UShort?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: UShort?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: UShort? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: UShort?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: UShort?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: UShort? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: UShort?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -150,90 +199,96 @@ class RelativeHumidityMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -243,92 +298,96 @@ class RelativeHumidityMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -338,91 +397,95 @@ class RelativeHumidityMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readToleranceAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Tolerance attribute not found in response" } + } + + requireNotNull(attributeData) { + "Tolerance attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -432,90 +495,96 @@ class RelativeHumidityMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Tolerance attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -525,50 +594,45 @@ class RelativeHumidityMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -576,43 +640,49 @@ class RelativeHumidityMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -622,50 +692,45 @@ class RelativeHumidityMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -673,43 +738,49 @@ class RelativeHumidityMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -719,48 +790,45 @@ class RelativeHumidityMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -768,43 +836,49 @@ class RelativeHumidityMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -814,48 +888,45 @@ class RelativeHumidityMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -863,37 +934,44 @@ class RelativeHumidityMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -902,37 +980,35 @@ class RelativeHumidityMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -944,37 +1020,44 @@ class RelativeHumidityMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -983,38 +1066,34 @@ class RelativeHumidityMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1027,7 +1106,7 @@ class RelativeHumidityMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt index fc06787142bc87..4b5c4234e782ef 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt @@ -17,110 +17,141 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcCleanModeCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ChangeToModeResponse(val status: UByte, val statusText: String?) - - class SupportedModesAttribute(val value: List) +class RvcCleanModeCluster(private val controller: MatterController, private val endpointId: UShort) { + class ChangeToModeResponse( + val status: UByte, + val statusText: String? + ) +class SupportedModesAttribute( + val value: List + ) sealed class SupportedModesAttributeSubscriptionState { - data class Success(val value: List) : - SupportedModesAttributeSubscriptionState() - + data class Success( + val value: List + ) : SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } - - class OnModeAttribute(val value: UByte?) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } +class OnModeAttribute( + val value: UByte? + ) sealed class OnModeAttributeSubscriptionState { - data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeout: Duration? = null - ): ChangeToModeResponse { + suspend fun changeToMode(newMode: UByte + ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -137,77 +168,92 @@ class RvcCleanModeCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { - statusText_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return ChangeToModeResponse(status_decoded, statusText_decoded) + return ChangeToModeResponse( + status_decoded, + statusText_decoded + ) } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return SupportedModesAttribute(decodedValue) } @@ -217,50 +263,45 @@ class RvcCleanModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedModesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -268,37 +309,44 @@ class RvcCleanModeCluster( emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -307,37 +355,35 @@ class RvcCleanModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -349,66 +395,76 @@ class RvcCleanModeCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOnModeAttribute(): OnModeAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Onmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Onmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -430,7 +486,7 @@ class RvcCleanModeCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -438,95 +494,101 @@ class RvcCleanModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OnModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Onmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OnModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -536,50 +598,45 @@ class RvcCleanModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -587,43 +644,49 @@ class RvcCleanModeCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -633,50 +696,45 @@ class RvcCleanModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -684,43 +742,49 @@ class RvcCleanModeCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -730,48 +794,45 @@ class RvcCleanModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -779,43 +840,49 @@ class RvcCleanModeCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -825,48 +892,45 @@ class RvcCleanModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -874,37 +938,44 @@ class RvcCleanModeCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -913,37 +984,35 @@ class RvcCleanModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -955,37 +1024,44 @@ class RvcCleanModeCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -994,38 +1070,34 @@ class RvcCleanModeCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1038,7 +1110,7 @@ class RvcCleanModeCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt index d2a53548665600..15089a43d93b59 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt @@ -17,136 +17,175 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcOperationalStateCluster( - private val controller: MatterController, - private val endpointId: UShort -) { +class RvcOperationalStateCluster(private val controller: MatterController, private val endpointId: UShort) { class OperationalCommandResponse( val commandResponseState: RvcOperationalStateClusterErrorStateStruct ) - - class PhaseListAttribute(val value: List?) +class PhaseListAttribute( + val value: List? + ) sealed class PhaseListAttributeSubscriptionState { - data class Success(val value: List?) : PhaseListAttributeSubscriptionState() - + data class Success( + val value: List? + ) : PhaseListAttributeSubscriptionState() + data class Error(val exception: Exception) : PhaseListAttributeSubscriptionState() - object SubscriptionEstablished : PhaseListAttributeSubscriptionState() - } - - class CurrentPhaseAttribute(val value: UByte?) + object SubscriptionEstablished : PhaseListAttributeSubscriptionState() + } +class CurrentPhaseAttribute( + val value: UByte? + ) sealed class CurrentPhaseAttributeSubscriptionState { - data class Success(val value: UByte?) : CurrentPhaseAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : CurrentPhaseAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPhaseAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() - } - - class CountdownTimeAttribute(val value: UInt?) + object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() + } +class CountdownTimeAttribute( + val value: UInt? + ) sealed class CountdownTimeAttributeSubscriptionState { - data class Success(val value: UInt?) : CountdownTimeAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : CountdownTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : CountdownTimeAttributeSubscriptionState() - object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() - } - - class OperationalStateListAttribute( + object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() + } +class OperationalStateListAttribute( val value: List ) sealed class OperationalStateListAttributeSubscriptionState { - data class Success(val value: List) : - OperationalStateListAttributeSubscriptionState() - + data class Success( + val value: List + ) : OperationalStateListAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalStateListAttributeSubscriptionState() - object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() - } - - class OperationalErrorAttribute(val value: RvcOperationalStateClusterErrorStateStruct) + object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() + } +class OperationalErrorAttribute( + val value: RvcOperationalStateClusterErrorStateStruct + ) sealed class OperationalErrorAttributeSubscriptionState { - data class Success(val value: RvcOperationalStateClusterErrorStateStruct) : - OperationalErrorAttributeSubscriptionState() - + data class Success( + val value: RvcOperationalStateClusterErrorStateStruct + ) : OperationalErrorAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalErrorAttributeSubscriptionState() - object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun pause(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -163,32 +202,39 @@ class RvcOperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } suspend fun stop(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -205,32 +251,39 @@ class RvcOperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } suspend fun start(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -247,32 +300,39 @@ class RvcOperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } suspend fun resume(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -289,32 +349,39 @@ class RvcOperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } suspend fun goHome(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 128u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -331,66 +398,79 @@ class RvcOperationalStateCluster( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { - commandResponseState_decoded = - RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } + tlvReader.exitContainer() - return OperationalCommandResponse(commandResponseState_decoded) + return OperationalCommandResponse( + commandResponseState_decoded + ) } - - suspend fun readPhaseListAttribute(): PhaseListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Phaselist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Phaselist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null + val decodedValue: List? = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PhaseListAttribute(decodedValue) } @@ -400,96 +480,102 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PhaseListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PhaseListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Phaselist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Phaselist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PhaseListAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PhaseListAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PhaseListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentphase attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentphase attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentPhaseAttribute(decodedValue) } @@ -499,94 +585,100 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentPhaseAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentPhaseAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentphase attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentphase attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CurrentPhaseAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CurrentPhaseAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPhaseAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Countdowntime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Countdowntime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CountdownTimeAttribute(decodedValue) } @@ -596,95 +688,101 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CountdownTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CountdownTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Countdowntime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Countdowntime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CountdownTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CountdownTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CountdownTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return OperationalStateListAttribute(decodedValue) } @@ -694,52 +792,45 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OperationalStateListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OperationalStateListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader) - ) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(OperationalStateListAttributeSubscriptionState.Success(decodedValue)) } @@ -747,37 +838,44 @@ class RvcOperationalStateCluster( emit(OperationalStateListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOperationalStateAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationalstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -786,38 +884,34 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -830,37 +924,43 @@ class RvcOperationalStateCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationalerror attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: RvcOperationalStateClusterErrorStateStruct = - RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: RvcOperationalStateClusterErrorStateStruct = RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + return OperationalErrorAttribute(decodedValue) } @@ -870,44 +970,39 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OperationalErrorAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OperationalErrorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: RvcOperationalStateClusterErrorStateStruct = - RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: RvcOperationalStateClusterErrorStateStruct = RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) emit(OperationalErrorAttributeSubscriptionState.Success(decodedValue)) } @@ -915,43 +1010,49 @@ class RvcOperationalStateCluster( emit(OperationalErrorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -961,50 +1062,45 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1012,43 +1108,49 @@ class RvcOperationalStateCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1058,50 +1160,45 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1109,43 +1206,49 @@ class RvcOperationalStateCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1155,48 +1258,45 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1204,43 +1304,49 @@ class RvcOperationalStateCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1250,48 +1356,45 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1299,37 +1402,44 @@ class RvcOperationalStateCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1338,37 +1448,35 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1380,37 +1488,44 @@ class RvcOperationalStateCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1419,38 +1534,34 @@ class RvcOperationalStateCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1463,7 +1574,7 @@ class RvcOperationalStateCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt index 2297e2fb439d4e..a5a84c7128df14 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt @@ -17,107 +17,141 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class RvcRunModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse(val status: UByte, val statusText: String?) - - class SupportedModesAttribute(val value: List) + class ChangeToModeResponse( + val status: UByte, + val statusText: String? + ) +class SupportedModesAttribute( + val value: List + ) sealed class SupportedModesAttributeSubscriptionState { - data class Success(val value: List) : - SupportedModesAttributeSubscriptionState() - + data class Success( + val value: List + ) : SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } - - class OnModeAttribute(val value: UByte?) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } +class OnModeAttribute( + val value: UByte? + ) sealed class OnModeAttributeSubscriptionState { - data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode( - newMode: UByte, - timedInvokeTimeout: Duration? = null - ): ChangeToModeResponse { + suspend fun changeToMode(newMode: UByte + ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -134,77 +168,92 @@ class RvcRunModeCluster(private val controller: MatterController, private val en tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { - statusText_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return ChangeToModeResponse(status_decoded, statusText_decoded) + return ChangeToModeResponse( + status_decoded, + statusText_decoded + ) } - - suspend fun readSupportedModesAttribute(): SupportedModesAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return SupportedModesAttribute(decodedValue) } @@ -214,50 +263,45 @@ class RvcRunModeCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedModesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -265,37 +309,44 @@ class RvcRunModeCluster(private val controller: MatterController, private val en emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -304,37 +355,35 @@ class RvcRunModeCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -346,66 +395,76 @@ class RvcRunModeCluster(private val controller: MatterController, private val en emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOnModeAttribute(): OnModeAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Onmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Onmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -427,7 +486,7 @@ class RvcRunModeCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -435,95 +494,101 @@ class RvcRunModeCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OnModeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Onmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OnModeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -533,50 +598,45 @@ class RvcRunModeCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -584,43 +644,49 @@ class RvcRunModeCluster(private val controller: MatterController, private val en emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -630,50 +696,45 @@ class RvcRunModeCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -681,43 +742,49 @@ class RvcRunModeCluster(private val controller: MatterController, private val en emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -727,48 +794,45 @@ class RvcRunModeCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -776,43 +840,49 @@ class RvcRunModeCluster(private val controller: MatterController, private val en emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -822,48 +892,45 @@ class RvcRunModeCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -871,37 +938,44 @@ class RvcRunModeCluster(private val controller: MatterController, private val en emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -910,37 +984,35 @@ class RvcRunModeCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -952,37 +1024,44 @@ class RvcRunModeCluster(private val controller: MatterController, private val en emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -991,38 +1070,34 @@ class RvcRunModeCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1035,7 +1110,7 @@ class RvcRunModeCluster(private val controller: MatterController, private val en emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt index 4514121f33fa31..9d5b10e9a5a6ce 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt @@ -17,80 +17,110 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class SampleMeiCluster(private val controller: MatterController, private val endpointId: UShort) { - class AddArgumentsResponse(val returnValue: UByte) - - class GeneratedCommandListAttribute(val value: List) + class AddArgumentsResponse( + val returnValue: UByte + ) +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun ping(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -104,11 +134,9 @@ class SampleMeiCluster(private val controller: MatterController, private val end logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addArguments( - arg1: UByte, - arg2: UByte, - timedInvokeTimeout: Duration? = null - ): AddArgumentsResponse { + suspend fun addArguments(arg1: UByte + ,arg2: UByte + ,timedInvokeTimeout: Duration? = null): AddArgumentsResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -118,7 +146,7 @@ class SampleMeiCluster(private val controller: MatterController, private val end tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) val TAG_ARG2_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) tlvWriter.endStructure() val request: InvokeRequest = @@ -135,73 +163,92 @@ class SampleMeiCluster(private val controller: MatterController, private val end tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { - returnValue_decoded = tlvReader.getUByte(tag) - } else { + + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getUByte(tag)} + + + else { tlvReader.skipElement() } } + + if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } + tlvReader.exitContainer() - return AddArgumentsResponse(returnValue_decoded) + return AddArgumentsResponse( + returnValue_decoded + ) } - - suspend fun readFlipFlopAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFlipFlopAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Flipflop attribute not found in response" } + } + + requireNotNull(attributeData) { + "Flipflop attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } - suspend fun writeFlipFlopAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { + suspend fun writeFlipFlopAttribute( + value: Boolean, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -223,7 +270,7 @@ class SampleMeiCluster(private val controller: MatterController, private val end throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFlipFlopAttribute( @@ -231,37 +278,35 @@ class SampleMeiCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Flipflop attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Flipflop attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -273,43 +318,49 @@ class SampleMeiCluster(private val controller: MatterController, private val end emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -319,50 +370,45 @@ class SampleMeiCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -370,43 +416,49 @@ class SampleMeiCluster(private val controller: MatterController, private val end emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -416,50 +468,45 @@ class SampleMeiCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -467,43 +514,49 @@ class SampleMeiCluster(private val controller: MatterController, private val end emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -513,48 +566,45 @@ class SampleMeiCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -562,43 +612,49 @@ class SampleMeiCluster(private val controller: MatterController, private val end emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -608,48 +664,45 @@ class SampleMeiCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -657,37 +710,44 @@ class SampleMeiCluster(private val controller: MatterController, private val end emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -696,37 +756,35 @@ class SampleMeiCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -738,37 +796,44 @@ class SampleMeiCluster(private val controller: MatterController, private val end emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -777,38 +842,34 @@ class SampleMeiCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -821,7 +882,7 @@ class SampleMeiCluster(private val controller: MatterController, private val end emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt index a7c4b66d6ee5be..b74311f864c1cc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt @@ -17,144 +17,193 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ScenesManagementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class AddSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) +class ScenesManagementCluster(private val controller: MatterController, private val endpointId: UShort) { + class AddSceneResponse( + val status: UByte, + val groupID: UShort, + val sceneID: UByte + ) class ViewSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte, - val transitionTime: UShort?, - val sceneName: String?, + val status: UByte, + val groupID: UShort, + val sceneID: UByte, + val transitionTime: UShort?, + val sceneName: String?, val extensionFieldSets: List? ) - class RemoveSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) + class RemoveSceneResponse( + val status: UByte, + val groupID: UShort, + val sceneID: UByte + ) - class RemoveAllScenesResponse(val status: UByte, val groupID: UShort) + class RemoveAllScenesResponse( + val status: UByte, + val groupID: UShort + ) - class StoreSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) + class StoreSceneResponse( + val status: UByte, + val groupID: UShort, + val sceneID: UByte + ) class GetSceneMembershipResponse( - val status: UByte, - val capacity: UByte?, - val groupID: UShort, + val status: UByte, + val capacity: UByte?, + val groupID: UShort, val sceneList: List? ) - class EnhancedAddSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) + class EnhancedAddSceneResponse( + val status: UByte, + val groupID: UShort, + val sceneID: UByte + ) class EnhancedViewSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte, - val transitionTime: UShort?, - val sceneName: String?, + val status: UByte, + val groupID: UShort, + val sceneID: UByte, + val transitionTime: UShort?, + val sceneName: String?, val extensionFieldSets: List? ) class CopySceneResponse( - val status: UByte, - val groupIdentifierFrom: UShort, + val status: UByte, + val groupIdentifierFrom: UShort, val sceneIdentifierFrom: UByte ) - - class LastConfiguredByAttribute(val value: ULong?) +class LastConfiguredByAttribute( + val value: ULong? + ) sealed class LastConfiguredByAttributeSubscriptionState { - data class Success(val value: ULong?) : LastConfiguredByAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : LastConfiguredByAttributeSubscriptionState() + data class Error(val exception: Exception) : LastConfiguredByAttributeSubscriptionState() - object SubscriptionEstablished : LastConfiguredByAttributeSubscriptionState() - } - - class FabricSceneInfoAttribute(val value: List) + object SubscriptionEstablished : LastConfiguredByAttributeSubscriptionState() + } +class FabricSceneInfoAttribute( + val value: List + ) sealed class FabricSceneInfoAttributeSubscriptionState { - data class Success(val value: List) : - FabricSceneInfoAttributeSubscriptionState() - + data class Success( + val value: List + ) : FabricSceneInfoAttributeSubscriptionState() + data class Error(val exception: Exception) : FabricSceneInfoAttributeSubscriptionState() - object SubscriptionEstablished : FabricSceneInfoAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : FabricSceneInfoAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun addScene( - groupID: UShort, - sceneID: UByte, - transitionTime: UShort, - sceneName: String, - extensionFieldSets: List, - timedInvokeTimeout: Duration? = null - ): AddSceneResponse { + suspend fun addScene(groupID: UShort + ,sceneID: UByte + ,transitionTime: UShort + ,sceneName: String + ,extensionFieldSets: List + ,timedInvokeTimeout: Duration? = null): AddSceneResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -174,10 +223,10 @@ class ScenesManagementCluster( val TAG_EXTENSION_FIELD_SETS_REQ: Int = 4 tlvWriter.startArray(ContextSpecificTag(TAG_EXTENSION_FIELD_SETS_REQ)) - for (item in extensionFieldSets.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in extensionFieldSets.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -194,53 +243,59 @@ class ScenesManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} + - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { - groupID_decoded = tlvReader.getUShort(tag) - } - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { - sceneID_decoded = tlvReader.getUByte(tag) - } else { + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - + + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } + tlvReader.exitContainer() - return AddSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) + return AddSceneResponse( + status_decoded, + groupID_decoded, + sceneID_decoded + ) } - suspend fun viewScene( - groupID: UShort, - sceneID: UByte, - timedInvokeTimeout: Duration? = null - ): ViewSceneResponse { + suspend fun viewScene(groupID: UShort + ,sceneID: UByte + ,timedInvokeTimeout: Duration? = null): ViewSceneResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -250,7 +305,7 @@ class ScenesManagementCluster( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_SCENE_I_D_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) tlvWriter.endStructure() val request: InvokeRequest = @@ -267,99 +322,103 @@ class ScenesManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - + val TAG_TRANSITION_TIME: Int = 3 var transitionTime_decoded: UShort? = null - + val TAG_SCENE_NAME: Int = 4 var sceneName_decoded: String? = null - + val TAG_EXTENSION_FIELD_SETS: Int = 5 var extensionFieldSets_decoded: List? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { - groupID_decoded = tlvReader.getUShort(tag) - } - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { - sceneID_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) { - transitionTime_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) {transitionTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_SCENE_NAME)) { - sceneName_decoded = + tlvReader.getUShort(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_SCENE_NAME)) {sceneName_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) { - extensionFieldSets_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) {extensionFieldSets_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } - } else { + buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - + + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } + + + + + + + tlvReader.exitContainer() @@ -373,11 +432,9 @@ class ScenesManagementCluster( ) } - suspend fun removeScene( - groupID: UShort, - sceneID: UByte, - timedInvokeTimeout: Duration? = null - ): RemoveSceneResponse { + suspend fun removeScene(groupID: UShort + ,sceneID: UByte + ,timedInvokeTimeout: Duration? = null): RemoveSceneResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -387,7 +444,7 @@ class ScenesManagementCluster( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_SCENE_I_D_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) tlvWriter.endStructure() val request: InvokeRequest = @@ -404,59 +461,65 @@ class ScenesManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} + - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { - groupID_decoded = tlvReader.getUShort(tag) - } - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { - sceneID_decoded = tlvReader.getUByte(tag) - } else { + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - + + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } + tlvReader.exitContainer() - return RemoveSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) + return RemoveSceneResponse( + status_decoded, + groupID_decoded, + sceneID_decoded + ) } - suspend fun removeAllScenes( - groupID: UShort, - timedInvokeTimeout: Duration? = null - ): RemoveAllScenesResponse { + suspend fun removeAllScenes(groupID: UShort + ,timedInvokeTimeout: Duration? = null): RemoveAllScenesResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -473,42 +536,48 @@ class ScenesManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} + - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { - groupID_decoded = tlvReader.getUShort(tag) - } else { + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } + tlvReader.exitContainer() - return RemoveAllScenesResponse(status_decoded, groupID_decoded) + return RemoveAllScenesResponse( + status_decoded, + groupID_decoded + ) } - suspend fun storeScene( - groupID: UShort, - sceneID: UByte, - timedInvokeTimeout: Duration? = null - ): StoreSceneResponse { + suspend fun storeScene(groupID: UShort + ,sceneID: UByte + ,timedInvokeTimeout: Duration? = null): StoreSceneResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -518,7 +587,7 @@ class ScenesManagementCluster( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_SCENE_I_D_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) tlvWriter.endStructure() val request: InvokeRequest = @@ -535,54 +604,60 @@ class ScenesManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} + - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { - groupID_decoded = tlvReader.getUShort(tag) - } - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { - sceneID_decoded = tlvReader.getUByte(tag) - } else { + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - + + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } + tlvReader.exitContainer() - return StoreSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) + return StoreSceneResponse( + status_decoded, + groupID_decoded, + sceneID_decoded + ) } - suspend fun recallScene( - groupID: UShort, - sceneID: UByte, - transitionTime: UShort?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun recallScene(groupID: UShort + ,sceneID: UByte + ,transitionTime: UShort? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -597,7 +672,7 @@ class ScenesManagementCluster( val TAG_TRANSITION_TIME_REQ: Int = 2 transitionTime?.let { tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -611,17 +686,15 @@ class ScenesManagementCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getSceneMembership( - groupID: UShort, - timedInvokeTimeout: Duration? = null - ): GetSceneMembershipResponse { + suspend fun getSceneMembership(groupID: UShort + ,timedInvokeTimeout: Duration? = null): GetSceneMembershipResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -638,72 +711,77 @@ class ScenesManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_CAPACITY: Int = 1 var capacity_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 2 var groupID_decoded: UShort? = null - + val TAG_SCENE_LIST: Int = 3 var sceneList_decoded: List? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_CAPACITY)) { - capacity_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_CAPACITY)) {capacity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - } - } - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { - groupID_decoded = tlvReader.getUShort(tag) - } - - if (tag == ContextSpecificTag(TAG_SCENE_LIST)) { - sceneList_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + }} + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_SCENE_LIST)) {sceneList_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - } - } else { + buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + + + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } + + + tlvReader.exitContainer() @@ -715,14 +793,12 @@ class ScenesManagementCluster( ) } - suspend fun enhancedAddScene( - groupID: UShort, - sceneID: UByte, - transitionTime: UShort, - sceneName: String, - extensionFieldSets: List, - timedInvokeTimeout: Duration? = null - ): EnhancedAddSceneResponse { + suspend fun enhancedAddScene(groupID: UShort + ,sceneID: UByte + ,transitionTime: UShort + ,sceneName: String + ,extensionFieldSets: List + ,timedInvokeTimeout: Duration? = null): EnhancedAddSceneResponse { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -742,10 +818,10 @@ class ScenesManagementCluster( val TAG_EXTENSION_FIELD_SETS_REQ: Int = 4 tlvWriter.startArray(ContextSpecificTag(TAG_EXTENSION_FIELD_SETS_REQ)) - for (item in extensionFieldSets.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in extensionFieldSets.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -762,53 +838,59 @@ class ScenesManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { - groupID_decoded = tlvReader.getUShort(tag) - } + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} + - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { - sceneID_decoded = tlvReader.getUByte(tag) - } else { + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - + + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } + tlvReader.exitContainer() - return EnhancedAddSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) + return EnhancedAddSceneResponse( + status_decoded, + groupID_decoded, + sceneID_decoded + ) } - suspend fun enhancedViewScene( - groupID: UShort, - sceneID: UByte, - timedInvokeTimeout: Duration? = null - ): EnhancedViewSceneResponse { + suspend fun enhancedViewScene(groupID: UShort + ,sceneID: UByte + ,timedInvokeTimeout: Duration? = null): EnhancedViewSceneResponse { val commandId: UInt = 65u val tlvWriter = TlvWriter() @@ -818,7 +900,7 @@ class ScenesManagementCluster( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_SCENE_I_D_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) tlvWriter.endStructure() val request: InvokeRequest = @@ -835,99 +917,103 @@ class ScenesManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - + val TAG_TRANSITION_TIME: Int = 3 var transitionTime_decoded: UShort? = null - + val TAG_SCENE_NAME: Int = 4 var sceneName_decoded: String? = null - + val TAG_EXTENSION_FIELD_SETS: Int = 5 var extensionFieldSets_decoded: List? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { - groupID_decoded = tlvReader.getUShort(tag) - } - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { - sceneID_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) { - transitionTime_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) {transitionTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_SCENE_NAME)) { - sceneName_decoded = + tlvReader.getUShort(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_SCENE_NAME)) {sceneName_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) { - extensionFieldSets_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) {extensionFieldSets_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } - } else { + buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - + + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } + + + + + + + tlvReader.exitContainer() @@ -941,14 +1027,12 @@ class ScenesManagementCluster( ) } - suspend fun copyScene( - mode: UByte, - groupIdentifierFrom: UShort, - sceneIdentifierFrom: UByte, - groupIdentifierTo: UShort, - sceneIdentifierTo: UByte, - timedInvokeTimeout: Duration? = null - ): CopySceneResponse { + suspend fun copyScene(mode: UByte + ,groupIdentifierFrom: UShort + ,sceneIdentifierFrom: UByte + ,groupIdentifierTo: UShort + ,sceneIdentifierTo: UByte + ,timedInvokeTimeout: Duration? = null): CopySceneResponse { val commandId: UInt = 66u val tlvWriter = TlvWriter() @@ -967,7 +1051,7 @@ class ScenesManagementCluster( tlvWriter.put(ContextSpecificTag(TAG_GROUP_IDENTIFIER_TO_REQ), groupIdentifierTo) val TAG_SCENE_IDENTIFIER_TO_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_IDENTIFIER_TO_REQ), sceneIdentifierTo) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_IDENTIFIER_TO_REQ), sceneIdentifierTo) tlvWriter.endStructure() val request: InvokeRequest = @@ -984,42 +1068,46 @@ class ScenesManagementCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_IDENTIFIER_FROM: Int = 1 var groupIdentifierFrom_decoded: UShort? = null - + val TAG_SCENE_IDENTIFIER_FROM: Int = 2 var sceneIdentifierFrom_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_GROUP_IDENTIFIER_FROM)) { - groupIdentifierFrom_decoded = tlvReader.getUShort(tag) - } + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_GROUP_IDENTIFIER_FROM)) {groupIdentifierFrom_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_SCENE_IDENTIFIER_FROM)) {sceneIdentifierFrom_decoded = tlvReader.getUByte(tag)} + - if (tag == ContextSpecificTag(TAG_SCENE_IDENTIFIER_FROM)) { - sceneIdentifierFrom_decoded = tlvReader.getUByte(tag) - } else { + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - + + if (groupIdentifierFrom_decoded == null) { - throw IllegalStateException("groupIdentifierFrom not found in TLV") + throw IllegalStateException("groupIdentifierFrom not found in TLV") } - + + if (sceneIdentifierFrom_decoded == null) { - throw IllegalStateException("sceneIdentifierFrom not found in TLV") + throw IllegalStateException("sceneIdentifierFrom not found in TLV") } + tlvReader.exitContainer() @@ -1029,39 +1117,45 @@ class ScenesManagementCluster( sceneIdentifierFrom_decoded ) } +suspend fun readSceneCountAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - suspend fun readSceneCountAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Scenecount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Scenecount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1071,88 +1165,94 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Scenecount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scenecount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentSceneAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - suspend fun readCurrentSceneAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentscene attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentscene attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1162,88 +1262,94 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentscene attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentscene attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentGroupAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u - suspend fun readCurrentGroupAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentgroup attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentgroup attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1253,88 +1359,94 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentgroup attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentgroup attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSceneValidAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 3u - suspend fun readSceneValidAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Scenevalid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Scenevalid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1344,84 +1456,91 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Scenevalid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scenevalid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNameSupportAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u - suspend fun readNameSupportAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Namesupport attribute not found in response" } + } + + requireNotNull(attributeData) { + "Namesupport attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -1430,37 +1549,35 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Namesupport attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Namesupport attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1472,46 +1589,52 @@ class ScenesManagementCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLastConfiguredByAttribute(): LastConfiguredByAttribute {val ATTRIBUTE_ID: UInt = 5u - suspend fun readLastConfiguredByAttribute(): LastConfiguredByAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Lastconfiguredby attribute not found in response" } + } + + requireNotNull(attributeData) { + "Lastconfiguredby attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LastConfiguredByAttribute(decodedValue) } @@ -1521,91 +1644,96 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LastConfiguredByAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LastConfiguredByAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Lastconfiguredby attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Lastconfiguredby attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(LastConfiguredByAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(LastConfiguredByAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LastConfiguredByAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSceneTableSizeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u - suspend fun readSceneTableSizeAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Scenetablesize attribute not found in response" } + } + + requireNotNull(attributeData) { + "Scenetablesize attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1614,38 +1742,34 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Scenetablesize attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scenetablesize attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1658,43 +1782,49 @@ class ScenesManagementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute {val ATTRIBUTE_ID: UInt = 7u - suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Fabricsceneinfo attribute not found in response" } + } + + requireNotNull(attributeData) { + "Fabricsceneinfo attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return FabricSceneInfoAttribute(decodedValue) } @@ -1704,50 +1834,45 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FabricSceneInfoAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FabricSceneInfoAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Fabricsceneinfo attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Fabricsceneinfo attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(FabricSceneInfoAttributeSubscriptionState.Success(decodedValue)) } @@ -1755,43 +1880,49 @@ class ScenesManagementCluster( emit(FabricSceneInfoAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1801,50 +1932,45 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1852,43 +1978,49 @@ class ScenesManagementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1898,50 +2030,45 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1949,43 +2076,49 @@ class ScenesManagementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1995,48 +2128,45 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2044,43 +2174,49 @@ class ScenesManagementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -2090,48 +2226,45 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2139,37 +2272,44 @@ class ScenesManagementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -2178,37 +2318,35 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2220,37 +2358,44 @@ class ScenesManagementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2259,38 +2404,34 @@ class ScenesManagementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2303,7 +2444,7 @@ class ScenesManagementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt index 12a337827e4c2c..ec9ca8d0e7e65a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt @@ -17,81 +17,106 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class SmokeCoAlarmCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun selfTestRequest(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -104,35 +129,42 @@ class SmokeCoAlarmCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readExpressedStateAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readExpressedStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Expressedstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Expressedstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -141,38 +173,34 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Expressedstate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Expressedstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -185,41 +213,47 @@ class SmokeCoAlarmCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSmokeStateAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSmokeStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Smokestate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Smokestate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -229,88 +263,94 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Smokestate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Smokestate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCOStateAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCOStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Costate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Costate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -320,84 +360,91 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Costate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Costate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBatteryAlertAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBatteryAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Batteryalert attribute not found in response" } + } + + requireNotNull(attributeData) { + "Batteryalert attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -406,37 +453,35 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Batteryalert attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Batteryalert attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -448,41 +493,47 @@ class SmokeCoAlarmCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDeviceMutedAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDeviceMutedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Devicemuted attribute not found in response" } + } + + requireNotNull(attributeData) { + "Devicemuted attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -492,84 +543,91 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Devicemuted attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Devicemuted attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTestInProgressAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTestInProgressAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Testinprogress attribute not found in response" } + } + + requireNotNull(attributeData) { + "Testinprogress attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -578,38 +636,34 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Testinprogress attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Testinprogress attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -622,37 +676,44 @@ class SmokeCoAlarmCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readHardwareFaultAlertAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readHardwareFaultAlertAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Hardwarefaultalert attribute not found in response" } + } + + requireNotNull(attributeData) { + "Hardwarefaultalert attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } @@ -661,38 +722,34 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Hardwarefaultalert attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Hardwarefaultalert attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -705,37 +762,44 @@ class SmokeCoAlarmCluster( emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEndOfServiceAlertAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEndOfServiceAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Endofservicealert attribute not found in response" } + } + + requireNotNull(attributeData) { + "Endofservicealert attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -744,38 +808,34 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Endofservicealert attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Endofservicealert attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -788,41 +848,47 @@ class SmokeCoAlarmCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readInterconnectSmokeAlarmAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readInterconnectSmokeAlarmAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Interconnectsmokealarm attribute not found in response" } + } + + requireNotNull(attributeData) { + "Interconnectsmokealarm attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -832,90 +898,94 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Interconnectsmokealarm attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Interconnectsmokealarm attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readInterconnectCOAlarmAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readInterconnectCOAlarmAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Interconnectcoalarm attribute not found in response" } + } + + requireNotNull(attributeData) { + "Interconnectcoalarm attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -925,90 +995,94 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Interconnectcoalarm attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Interconnectcoalarm attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readContaminationStateAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readContaminationStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Contaminationstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Contaminationstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1018,113 +1092,118 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Contaminationstate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Contaminationstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSmokeSensitivityLevelAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 11u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSmokeSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Smokesensitivitylevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Smokesensitivitylevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeSmokeSensitivityLevelAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 11u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1146,7 +1225,7 @@ class SmokeCoAlarmCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSmokeSensitivityLevelAttribute( @@ -1154,90 +1233,94 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Smokesensitivitylevel attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Smokesensitivitylevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readExpiryDateAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 12u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readExpiryDateAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 12u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Expirydate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Expirydate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1247,90 +1330,96 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Expirydate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Expirydate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1340,50 +1429,45 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1391,43 +1475,49 @@ class SmokeCoAlarmCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1437,50 +1527,45 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1488,43 +1573,49 @@ class SmokeCoAlarmCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1534,48 +1625,45 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1583,43 +1671,49 @@ class SmokeCoAlarmCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1629,48 +1723,45 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1678,37 +1769,44 @@ class SmokeCoAlarmCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1717,37 +1815,35 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1759,37 +1855,44 @@ class SmokeCoAlarmCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1798,38 +1901,34 @@ class SmokeCoAlarmCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1842,7 +1941,7 @@ class SmokeCoAlarmCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt index c3568e5825e8fe..3e60be49a852ca 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt @@ -17,88 +17,119 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SoftwareDiagnosticsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ThreadMetricsAttribute(val value: List?) +class SoftwareDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class ThreadMetricsAttribute( + val value: List? + ) sealed class ThreadMetricsAttributeSubscriptionState { - data class Success(val value: List?) : - ThreadMetricsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : ThreadMetricsAttributeSubscriptionState() + data class Error(val exception: Exception) : ThreadMetricsAttributeSubscriptionState() - object SubscriptionEstablished : ThreadMetricsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : ThreadMetricsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetWatermarks(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -111,45 +142,51 @@ class SoftwareDiagnosticsCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readThreadMetricsAttribute(): ThreadMetricsAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readThreadMetricsAttribute(): ThreadMetricsAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Threadmetrics attribute not found in response" } + } + + requireNotNull(attributeData) { + "Threadmetrics attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return ThreadMetricsAttribute(decodedValue) } @@ -159,96 +196,100 @@ class SoftwareDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ThreadMetricsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ThreadMetricsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Threadmetrics attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Threadmetrics attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader) - ) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ThreadMetricsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ThreadMetricsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ThreadMetricsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentHeapFreeAttribute(): ULong? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentHeapFreeAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentheapfree attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentheapfree attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -258,90 +299,94 @@ class SoftwareDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentheapfree attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentheapfree attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ULongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentHeapUsedAttribute(): ULong? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentHeapUsedAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentheapused attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentheapused attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -351,90 +396,94 @@ class SoftwareDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentheapused attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentheapused attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ULongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentHeapHighWatermarkAttribute(): ULong? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentHeapHighWatermarkAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentheaphighwatermark attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentheaphighwatermark attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -444,92 +493,96 @@ class SoftwareDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentheaphighwatermark attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentheaphighwatermark attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ULongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -539,50 +592,45 @@ class SoftwareDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -590,43 +638,49 @@ class SoftwareDiagnosticsCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -636,50 +690,45 @@ class SoftwareDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -687,43 +736,49 @@ class SoftwareDiagnosticsCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -733,48 +788,45 @@ class SoftwareDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -782,43 +834,49 @@ class SoftwareDiagnosticsCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -828,48 +886,45 @@ class SoftwareDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -877,37 +932,44 @@ class SoftwareDiagnosticsCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -916,37 +978,35 @@ class SoftwareDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -958,37 +1018,44 @@ class SoftwareDiagnosticsCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -997,38 +1064,34 @@ class SoftwareDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1041,7 +1104,7 @@ class SoftwareDiagnosticsCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt index ec30f6aa7452e6..0462ac9b0c886c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt @@ -17,93 +17,136 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class SwitchCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) +class SwitchCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readNumberOfPositionsAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readNumberOfPositionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofpositions attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofpositions attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -112,38 +155,34 @@ class SwitchCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofpositions attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofpositions attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -156,37 +195,44 @@ class SwitchCluster(private val controller: MatterController, private val endpoi emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentPositionAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentposition attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentposition attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -195,38 +241,34 @@ class SwitchCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentposition attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -239,41 +281,47 @@ class SwitchCluster(private val controller: MatterController, private val endpoi emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMultiPressMaxAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMultiPressMaxAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Multipressmax attribute not found in response" } + } + + requireNotNull(attributeData) { + "Multipressmax attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -283,90 +331,96 @@ class SwitchCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Multipressmax attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Multipressmax attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -376,50 +430,45 @@ class SwitchCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -427,43 +476,49 @@ class SwitchCluster(private val controller: MatterController, private val endpoi emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -473,50 +528,45 @@ class SwitchCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -524,43 +574,49 @@ class SwitchCluster(private val controller: MatterController, private val endpoi emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -570,48 +626,45 @@ class SwitchCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -619,43 +672,49 @@ class SwitchCluster(private val controller: MatterController, private val endpoi emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -665,48 +724,45 @@ class SwitchCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -714,37 +770,44 @@ class SwitchCluster(private val controller: MatterController, private val endpoi emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -753,37 +816,35 @@ class SwitchCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -795,37 +856,44 @@ class SwitchCluster(private val controller: MatterController, private val endpoi emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -834,38 +902,34 @@ class SwitchCluster(private val controller: MatterController, private val endpoi maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -878,7 +942,7 @@ class SwitchCluster(private val controller: MatterController, private val endpoi emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt index aa48d2e32d4736..c7aee150c59e6c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt @@ -17,91 +17,122 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TargetNavigatorCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class NavigateTargetResponse(val status: UByte, val data: String?) - - class TargetListAttribute(val value: List) +class TargetNavigatorCluster(private val controller: MatterController, private val endpointId: UShort) { + class NavigateTargetResponse( + val status: UByte, + val data: String? + ) +class TargetListAttribute( + val value: List + ) sealed class TargetListAttributeSubscriptionState { - data class Success(val value: List) : - TargetListAttributeSubscriptionState() - + data class Success( + val value: List + ) : TargetListAttributeSubscriptionState() + data class Error(val exception: Exception) : TargetListAttributeSubscriptionState() - object SubscriptionEstablished : TargetListAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : TargetListAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun navigateTarget( - target: UByte, - data: String?, - timedInvokeTimeout: Duration? = null - ): NavigateTargetResponse { + suspend fun navigateTarget(target: UByte + ,data: String? + ,timedInvokeTimeout: Duration? = null): NavigateTargetResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -111,7 +142,9 @@ class TargetNavigatorCluster( tlvWriter.put(ContextSpecificTag(TAG_TARGET_REQ), target) val TAG_DATA_REQ: Int = 1 - data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } + data?.let { + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -128,77 +161,92 @@ class TargetNavigatorCluster( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_STATUS)) { - status_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DATA)) { - data_decoded = + + if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } else { + tlvReader.getString(tag) + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } + + + tlvReader.exitContainer() - return NavigateTargetResponse(status_decoded, data_decoded) + return NavigateTargetResponse( + status_decoded, + data_decoded + ) } - - suspend fun readTargetListAttribute(): TargetListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTargetListAttribute(): TargetListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Targetlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Targetlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return TargetListAttribute(decodedValue) } @@ -208,48 +256,45 @@ class TargetNavigatorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - TargetListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(TargetListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Targetlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Targetlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(TargetListAttributeSubscriptionState.Success(decodedValue)) } @@ -257,41 +302,47 @@ class TargetNavigatorCluster( emit(TargetListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentTargetAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentTargetAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currenttarget attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currenttarget attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -301,90 +352,96 @@ class TargetNavigatorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currenttarget attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currenttarget attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -394,50 +451,45 @@ class TargetNavigatorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -445,43 +497,49 @@ class TargetNavigatorCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -491,50 +549,45 @@ class TargetNavigatorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -542,43 +595,49 @@ class TargetNavigatorCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -588,48 +647,45 @@ class TargetNavigatorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -637,43 +693,49 @@ class TargetNavigatorCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -683,48 +745,45 @@ class TargetNavigatorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -732,37 +791,44 @@ class TargetNavigatorCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -771,37 +837,35 @@ class TargetNavigatorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -813,37 +877,44 @@ class TargetNavigatorCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -852,38 +923,34 @@ class TargetNavigatorCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -896,7 +963,7 @@ class TargetNavigatorCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt index ef8fa756028407..879479e9577967 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt @@ -17,91 +17,117 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.ShortSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TemperatureControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SupportedTemperatureLevelsAttribute(val value: List?) +class TemperatureControlCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedTemperatureLevelsAttribute( + val value: List? + ) sealed class SupportedTemperatureLevelsAttributeSubscriptionState { - data class Success(val value: List?) : - SupportedTemperatureLevelsAttributeSubscriptionState() - - data class Error(val exception: Exception) : - SupportedTemperatureLevelsAttributeSubscriptionState() - - object SubscriptionEstablished : SupportedTemperatureLevelsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + data class Success( + val value: List? + ) : SupportedTemperatureLevelsAttributeSubscriptionState() + + data class Error(val exception: Exception) : SupportedTemperatureLevelsAttributeSubscriptionState() + + object SubscriptionEstablished : SupportedTemperatureLevelsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setTemperature( - targetTemperature: Short?, - targetTemperatureLevel: UByte?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setTemperature(targetTemperature: Short? + ,targetTemperatureLevel: UByte? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -115,7 +141,7 @@ class TemperatureControlCluster( val TAG_TARGET_TEMPERATURE_LEVEL_REQ: Int = 1 targetTemperatureLevel?.let { tlvWriter.put(ContextSpecificTag(TAG_TARGET_TEMPERATURE_LEVEL_REQ), targetTemperatureLevel) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -128,39 +154,45 @@ class TemperatureControlCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readTemperatureSetpointAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTemperatureSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Temperaturesetpoint attribute not found in response" } + } + + requireNotNull(attributeData) { + "Temperaturesetpoint attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -170,90 +202,94 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Temperaturesetpoint attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Temperaturesetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinTemperatureAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinTemperatureAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Mintemperature attribute not found in response" } + } + + requireNotNull(attributeData) { + "Mintemperature attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -263,90 +299,94 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Mintemperature attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Mintemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxTemperatureAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxTemperatureAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxtemperature attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxtemperature attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -356,90 +396,94 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxtemperature attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxtemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readStepAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readStepAttribute(): Short? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Step attribute not found in response" } + } + + requireNotNull(attributeData) { + "Step attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -449,88 +493,94 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Step attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Step attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSelectedTemperatureLevelAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSelectedTemperatureLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Selectedtemperaturelevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Selectedtemperaturelevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -540,96 +590,100 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Selectedtemperaturelevel attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Selectedtemperaturelevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportedTemperatureLevelsAttribute(): SupportedTemperatureLevelsAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedTemperatureLevelsAttribute(): SupportedTemperatureLevelsAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedtemperaturelevels attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedtemperaturelevels attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return SupportedTemperatureLevelsAttribute(decodedValue) } @@ -639,100 +693,102 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedTemperatureLevelsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedTemperatureLevelsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedtemperaturelevels attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedtemperaturelevels attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { emit(SupportedTemperatureLevelsAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(SupportedTemperatureLevelsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -742,50 +798,45 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -793,43 +844,49 @@ class TemperatureControlCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -839,50 +896,45 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -890,43 +942,49 @@ class TemperatureControlCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -936,48 +994,45 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -985,43 +1040,49 @@ class TemperatureControlCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1031,48 +1092,45 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1080,37 +1138,44 @@ class TemperatureControlCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1119,37 +1184,35 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1161,37 +1224,44 @@ class TemperatureControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1200,38 +1270,34 @@ class TemperatureControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1244,7 +1310,7 @@ class TemperatureControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt index 5cd6ac3392242f..ef6d1043bbbf5b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt @@ -17,130 +17,179 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class TemperatureMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Short?) +class TemperatureMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Short? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Short?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Short?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Short? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Short?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Short?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Short? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Short?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -150,90 +199,96 @@ class TemperatureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -243,92 +298,96 @@ class TemperatureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -338,91 +397,95 @@ class TemperatureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readToleranceAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Tolerance attribute not found in response" } + } + + requireNotNull(attributeData) { + "Tolerance attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -432,90 +495,96 @@ class TemperatureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Tolerance attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -525,50 +594,45 @@ class TemperatureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -576,43 +640,49 @@ class TemperatureMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -622,50 +692,45 @@ class TemperatureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -673,43 +738,49 @@ class TemperatureMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -719,48 +790,45 @@ class TemperatureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -768,43 +836,49 @@ class TemperatureMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -814,48 +888,45 @@ class TemperatureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -863,37 +934,44 @@ class TemperatureMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -902,37 +980,35 @@ class TemperatureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -944,37 +1020,44 @@ class TemperatureMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -983,38 +1066,34 @@ class TemperatureMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1027,7 +1106,7 @@ class TemperatureMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt index 2fa28950db06cd..f64bc24d5bee34 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt @@ -17,294 +17,371 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.ShortSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class ThermostatCluster(private val controller: MatterController, private val endpointId: UShort) { class GetWeeklyScheduleResponse( - val numberOfTransitionsForSequence: UByte, - val dayOfWeekForSequence: UByte, - val modeForSequence: UByte, + val numberOfTransitionsForSequence: UByte, + val dayOfWeekForSequence: UByte, + val modeForSequence: UByte, val transitions: List ) - - class LocalTemperatureAttribute(val value: Short?) +class LocalTemperatureAttribute( + val value: Short? + ) sealed class LocalTemperatureAttributeSubscriptionState { - data class Success(val value: Short?) : LocalTemperatureAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : LocalTemperatureAttributeSubscriptionState() + data class Error(val exception: Exception) : LocalTemperatureAttributeSubscriptionState() - object SubscriptionEstablished : LocalTemperatureAttributeSubscriptionState() - } - - class OutdoorTemperatureAttribute(val value: Short?) + object SubscriptionEstablished : LocalTemperatureAttributeSubscriptionState() + } +class OutdoorTemperatureAttribute( + val value: Short? + ) sealed class OutdoorTemperatureAttributeSubscriptionState { - data class Success(val value: Short?) : OutdoorTemperatureAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : OutdoorTemperatureAttributeSubscriptionState() + data class Error(val exception: Exception) : OutdoorTemperatureAttributeSubscriptionState() - object SubscriptionEstablished : OutdoorTemperatureAttributeSubscriptionState() - } - - class TemperatureSetpointHoldDurationAttribute(val value: UShort?) + object SubscriptionEstablished : OutdoorTemperatureAttributeSubscriptionState() + } +class TemperatureSetpointHoldDurationAttribute( + val value: UShort? + ) sealed class TemperatureSetpointHoldDurationAttributeSubscriptionState { - data class Success(val value: UShort?) : - TemperatureSetpointHoldDurationAttributeSubscriptionState() - - data class Error(val exception: Exception) : - TemperatureSetpointHoldDurationAttributeSubscriptionState() - - object SubscriptionEstablished : TemperatureSetpointHoldDurationAttributeSubscriptionState() - } - - class SetpointChangeAmountAttribute(val value: Short?) + data class Success( + val value: UShort? + ) : TemperatureSetpointHoldDurationAttributeSubscriptionState() + + data class Error(val exception: Exception) : TemperatureSetpointHoldDurationAttributeSubscriptionState() + + object SubscriptionEstablished : TemperatureSetpointHoldDurationAttributeSubscriptionState() + } +class SetpointChangeAmountAttribute( + val value: Short? + ) sealed class SetpointChangeAmountAttributeSubscriptionState { - data class Success(val value: Short?) : SetpointChangeAmountAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : SetpointChangeAmountAttributeSubscriptionState() + data class Error(val exception: Exception) : SetpointChangeAmountAttributeSubscriptionState() - object SubscriptionEstablished : SetpointChangeAmountAttributeSubscriptionState() - } - - class OccupiedSetbackAttribute(val value: UByte?) + object SubscriptionEstablished : SetpointChangeAmountAttributeSubscriptionState() + } +class OccupiedSetbackAttribute( + val value: UByte? + ) sealed class OccupiedSetbackAttributeSubscriptionState { - data class Success(val value: UByte?) : OccupiedSetbackAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : OccupiedSetbackAttributeSubscriptionState() + data class Error(val exception: Exception) : OccupiedSetbackAttributeSubscriptionState() - object SubscriptionEstablished : OccupiedSetbackAttributeSubscriptionState() - } - - class OccupiedSetbackMinAttribute(val value: UByte?) + object SubscriptionEstablished : OccupiedSetbackAttributeSubscriptionState() + } +class OccupiedSetbackMinAttribute( + val value: UByte? + ) sealed class OccupiedSetbackMinAttributeSubscriptionState { - data class Success(val value: UByte?) : OccupiedSetbackMinAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : OccupiedSetbackMinAttributeSubscriptionState() + data class Error(val exception: Exception) : OccupiedSetbackMinAttributeSubscriptionState() - object SubscriptionEstablished : OccupiedSetbackMinAttributeSubscriptionState() - } - - class OccupiedSetbackMaxAttribute(val value: UByte?) + object SubscriptionEstablished : OccupiedSetbackMinAttributeSubscriptionState() + } +class OccupiedSetbackMaxAttribute( + val value: UByte? + ) sealed class OccupiedSetbackMaxAttributeSubscriptionState { - data class Success(val value: UByte?) : OccupiedSetbackMaxAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : OccupiedSetbackMaxAttributeSubscriptionState() + data class Error(val exception: Exception) : OccupiedSetbackMaxAttributeSubscriptionState() - object SubscriptionEstablished : OccupiedSetbackMaxAttributeSubscriptionState() - } - - class UnoccupiedSetbackAttribute(val value: UByte?) + object SubscriptionEstablished : OccupiedSetbackMaxAttributeSubscriptionState() + } +class UnoccupiedSetbackAttribute( + val value: UByte? + ) sealed class UnoccupiedSetbackAttributeSubscriptionState { - data class Success(val value: UByte?) : UnoccupiedSetbackAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : UnoccupiedSetbackAttributeSubscriptionState() + data class Error(val exception: Exception) : UnoccupiedSetbackAttributeSubscriptionState() - object SubscriptionEstablished : UnoccupiedSetbackAttributeSubscriptionState() - } - - class UnoccupiedSetbackMinAttribute(val value: UByte?) + object SubscriptionEstablished : UnoccupiedSetbackAttributeSubscriptionState() + } +class UnoccupiedSetbackMinAttribute( + val value: UByte? + ) sealed class UnoccupiedSetbackMinAttributeSubscriptionState { - data class Success(val value: UByte?) : UnoccupiedSetbackMinAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : UnoccupiedSetbackMinAttributeSubscriptionState() + data class Error(val exception: Exception) : UnoccupiedSetbackMinAttributeSubscriptionState() - object SubscriptionEstablished : UnoccupiedSetbackMinAttributeSubscriptionState() - } - - class UnoccupiedSetbackMaxAttribute(val value: UByte?) + object SubscriptionEstablished : UnoccupiedSetbackMinAttributeSubscriptionState() + } +class UnoccupiedSetbackMaxAttribute( + val value: UByte? + ) sealed class UnoccupiedSetbackMaxAttributeSubscriptionState { - data class Success(val value: UByte?) : UnoccupiedSetbackMaxAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : UnoccupiedSetbackMaxAttributeSubscriptionState() + data class Error(val exception: Exception) : UnoccupiedSetbackMaxAttributeSubscriptionState() - object SubscriptionEstablished : UnoccupiedSetbackMaxAttributeSubscriptionState() - } - - class ACCoilTemperatureAttribute(val value: Short?) + object SubscriptionEstablished : UnoccupiedSetbackMaxAttributeSubscriptionState() + } +class ACCoilTemperatureAttribute( + val value: Short? + ) sealed class ACCoilTemperatureAttributeSubscriptionState { - data class Success(val value: Short?) : ACCoilTemperatureAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : ACCoilTemperatureAttributeSubscriptionState() + data class Error(val exception: Exception) : ACCoilTemperatureAttributeSubscriptionState() - object SubscriptionEstablished : ACCoilTemperatureAttributeSubscriptionState() - } - - class PresetTypesAttribute(val value: List?) + object SubscriptionEstablished : ACCoilTemperatureAttributeSubscriptionState() + } +class PresetTypesAttribute( + val value: List? + ) sealed class PresetTypesAttributeSubscriptionState { - data class Success(val value: List?) : - PresetTypesAttributeSubscriptionState() - + data class Success( + val value: List? + ) : PresetTypesAttributeSubscriptionState() + data class Error(val exception: Exception) : PresetTypesAttributeSubscriptionState() - object SubscriptionEstablished : PresetTypesAttributeSubscriptionState() - } - - class ScheduleTypesAttribute(val value: List?) + object SubscriptionEstablished : PresetTypesAttributeSubscriptionState() + } +class ScheduleTypesAttribute( + val value: List? + ) sealed class ScheduleTypesAttributeSubscriptionState { - data class Success(val value: List?) : - ScheduleTypesAttributeSubscriptionState() - + data class Success( + val value: List? + ) : ScheduleTypesAttributeSubscriptionState() + data class Error(val exception: Exception) : ScheduleTypesAttributeSubscriptionState() - object SubscriptionEstablished : ScheduleTypesAttributeSubscriptionState() - } - - class NumberOfScheduleTransitionPerDayAttribute(val value: UByte?) + object SubscriptionEstablished : ScheduleTypesAttributeSubscriptionState() + } +class NumberOfScheduleTransitionPerDayAttribute( + val value: UByte? + ) sealed class NumberOfScheduleTransitionPerDayAttributeSubscriptionState { - data class Success(val value: UByte?) : - NumberOfScheduleTransitionPerDayAttributeSubscriptionState() - - data class Error(val exception: Exception) : - NumberOfScheduleTransitionPerDayAttributeSubscriptionState() - - object SubscriptionEstablished : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() - } - - class ActivePresetHandleAttribute(val value: ByteArray?) + data class Success( + val value: UByte? + ) : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() + + data class Error(val exception: Exception) : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() + + object SubscriptionEstablished : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() + } +class ActivePresetHandleAttribute( + val value: ByteArray? + ) sealed class ActivePresetHandleAttributeSubscriptionState { - data class Success(val value: ByteArray?) : ActivePresetHandleAttributeSubscriptionState() - + data class Success( + val value: ByteArray? + ) : ActivePresetHandleAttributeSubscriptionState() + data class Error(val exception: Exception) : ActivePresetHandleAttributeSubscriptionState() - object SubscriptionEstablished : ActivePresetHandleAttributeSubscriptionState() - } - - class ActiveScheduleHandleAttribute(val value: ByteArray?) + object SubscriptionEstablished : ActivePresetHandleAttributeSubscriptionState() + } +class ActiveScheduleHandleAttribute( + val value: ByteArray? + ) sealed class ActiveScheduleHandleAttributeSubscriptionState { - data class Success(val value: ByteArray?) : ActiveScheduleHandleAttributeSubscriptionState() - + data class Success( + val value: ByteArray? + ) : ActiveScheduleHandleAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveScheduleHandleAttributeSubscriptionState() - object SubscriptionEstablished : ActiveScheduleHandleAttributeSubscriptionState() - } - - class PresetsAttribute(val value: List?) + object SubscriptionEstablished : ActiveScheduleHandleAttributeSubscriptionState() + } +class PresetsAttribute( + val value: List? + ) sealed class PresetsAttributeSubscriptionState { - data class Success(val value: List?) : - PresetsAttributeSubscriptionState() - + data class Success( + val value: List? + ) : PresetsAttributeSubscriptionState() + data class Error(val exception: Exception) : PresetsAttributeSubscriptionState() - object SubscriptionEstablished : PresetsAttributeSubscriptionState() - } - - class SchedulesAttribute(val value: List?) + object SubscriptionEstablished : PresetsAttributeSubscriptionState() + } +class SchedulesAttribute( + val value: List? + ) sealed class SchedulesAttributeSubscriptionState { - data class Success(val value: List?) : - SchedulesAttributeSubscriptionState() - + data class Success( + val value: List? + ) : SchedulesAttributeSubscriptionState() + data class Error(val exception: Exception) : SchedulesAttributeSubscriptionState() - object SubscriptionEstablished : SchedulesAttributeSubscriptionState() - } - - class SetpointHoldExpiryTimestampAttribute(val value: UInt?) + object SubscriptionEstablished : SchedulesAttributeSubscriptionState() + } +class SetpointHoldExpiryTimestampAttribute( + val value: UInt? + ) sealed class SetpointHoldExpiryTimestampAttributeSubscriptionState { - data class Success(val value: UInt?) : SetpointHoldExpiryTimestampAttributeSubscriptionState() - - data class Error(val exception: Exception) : - SetpointHoldExpiryTimestampAttributeSubscriptionState() - - object SubscriptionEstablished : SetpointHoldExpiryTimestampAttributeSubscriptionState() - } - - class QueuedPresetAttribute(val value: ThermostatClusterQueuedPresetStruct?) + data class Success( + val value: UInt? + ) : SetpointHoldExpiryTimestampAttributeSubscriptionState() + + data class Error(val exception: Exception) : SetpointHoldExpiryTimestampAttributeSubscriptionState() + + object SubscriptionEstablished : SetpointHoldExpiryTimestampAttributeSubscriptionState() + } +class QueuedPresetAttribute( + val value: ThermostatClusterQueuedPresetStruct? + ) sealed class QueuedPresetAttributeSubscriptionState { - data class Success(val value: ThermostatClusterQueuedPresetStruct?) : - QueuedPresetAttributeSubscriptionState() - + data class Success( + val value: ThermostatClusterQueuedPresetStruct? + ) : QueuedPresetAttributeSubscriptionState() + data class Error(val exception: Exception) : QueuedPresetAttributeSubscriptionState() - object SubscriptionEstablished : QueuedPresetAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : QueuedPresetAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setpointRaiseLower(mode: UByte, amount: Byte, timedInvokeTimeout: Duration? = null) { + suspend fun setpointRaiseLower(mode: UByte + ,amount: Byte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -314,7 +391,7 @@ class ThermostatCluster(private val controller: MatterController, private val en tlvWriter.put(ContextSpecificTag(TAG_MODE_REQ), mode) val TAG_AMOUNT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_AMOUNT_REQ), amount) + tlvWriter.put(ContextSpecificTag(TAG_AMOUNT_REQ), amount) tlvWriter.endStructure() val request: InvokeRequest = @@ -328,23 +405,18 @@ class ThermostatCluster(private val controller: MatterController, private val en logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setWeeklySchedule( - numberOfTransitionsForSequence: UByte, - dayOfWeekForSequence: UByte, - modeForSequence: UByte, - transitions: List, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setWeeklySchedule(numberOfTransitionsForSequence: UByte + ,dayOfWeekForSequence: UByte + ,modeForSequence: UByte + ,transitions: List + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE_REQ: Int = 0 - tlvWriter.put( - ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE_REQ), - numberOfTransitionsForSequence - ) + tlvWriter.put(ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE_REQ), numberOfTransitionsForSequence) val TAG_DAY_OF_WEEK_FOR_SEQUENCE_REQ: Int = 1 tlvWriter.put(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE_REQ), dayOfWeekForSequence) @@ -354,10 +426,10 @@ class ThermostatCluster(private val controller: MatterController, private val en val TAG_TRANSITIONS_REQ: Int = 3 tlvWriter.startArray(ContextSpecificTag(TAG_TRANSITIONS_REQ)) - for (item in transitions.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in transitions.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -371,11 +443,9 @@ class ThermostatCluster(private val controller: MatterController, private val en logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getWeeklySchedule( - daysToReturn: UByte, - modeToReturn: UByte, - timedInvokeTimeout: Duration? = null - ): GetWeeklyScheduleResponse { + suspend fun getWeeklySchedule(daysToReturn: UByte + ,modeToReturn: UByte + ,timedInvokeTimeout: Duration? = null): GetWeeklyScheduleResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -385,7 +455,7 @@ class ThermostatCluster(private val controller: MatterController, private val en tlvWriter.put(ContextSpecificTag(TAG_DAYS_TO_RETURN_REQ), daysToReturn) val TAG_MODE_TO_RETURN_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_MODE_TO_RETURN_REQ), modeToReturn) + tlvWriter.put(ContextSpecificTag(TAG_MODE_TO_RETURN_REQ), modeToReturn) tlvWriter.endStructure() val request: InvokeRequest = @@ -402,60 +472,62 @@ class ThermostatCluster(private val controller: MatterController, private val en tlvReader.enterStructure(AnonymousTag) val TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE: Int = 0 var numberOfTransitionsForSequence_decoded: UByte? = null - + val TAG_DAY_OF_WEEK_FOR_SEQUENCE: Int = 1 var dayOfWeekForSequence_decoded: UByte? = null - + val TAG_MODE_FOR_SEQUENCE: Int = 2 var modeForSequence_decoded: UByte? = null - + val TAG_TRANSITIONS: Int = 3 var transitions_decoded: List? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE)) { - numberOfTransitionsForSequence_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) { - dayOfWeekForSequence_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_MODE_FOR_SEQUENCE)) { - modeForSequence_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_TRANSITIONS)) { - transitions_decoded = - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(ThermostatClusterWeeklyScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { + + if (tag == ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE)) {numberOfTransitionsForSequence_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) {dayOfWeekForSequence_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_MODE_FOR_SEQUENCE)) {modeForSequence_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_TRANSITIONS)) {transitions_decoded = buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(ThermostatClusterWeeklyScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }} + + + else { tlvReader.skipElement() } } + + if (numberOfTransitionsForSequence_decoded == null) { - throw IllegalStateException("numberOfTransitionsForSequence not found in TLV") + throw IllegalStateException("numberOfTransitionsForSequence not found in TLV") } - + + if (dayOfWeekForSequence_decoded == null) { - throw IllegalStateException("dayOfWeekForSequence not found in TLV") + throw IllegalStateException("dayOfWeekForSequence not found in TLV") } - + + if (modeForSequence_decoded == null) { - throw IllegalStateException("modeForSequence not found in TLV") + throw IllegalStateException("modeForSequence not found in TLV") } - + + if (transitions_decoded == null) { - throw IllegalStateException("transitions not found in TLV") + throw IllegalStateException("transitions not found in TLV") } + tlvReader.exitContainer() @@ -471,7 +543,7 @@ class ThermostatCluster(private val controller: MatterController, private val en val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -485,17 +557,15 @@ class ThermostatCluster(private val controller: MatterController, private val en logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setActiveScheduleRequest( - scheduleHandle: ByteArray, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setActiveScheduleRequest(scheduleHandle: ByteArray + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SCHEDULE_HANDLE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_SCHEDULE_HANDLE_REQ), scheduleHandle) + tlvWriter.put(ContextSpecificTag(TAG_SCHEDULE_HANDLE_REQ), scheduleHandle) tlvWriter.endStructure() val request: InvokeRequest = @@ -509,11 +579,9 @@ class ThermostatCluster(private val controller: MatterController, private val en logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setActivePresetRequest( - presetHandle: ByteArray, - delayMinutes: UShort?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setActivePresetRequest(presetHandle: ByteArray + ,delayMinutes: UShort? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -523,7 +591,9 @@ class ThermostatCluster(private val controller: MatterController, private val en tlvWriter.put(ContextSpecificTag(TAG_PRESET_HANDLE_REQ), presetHandle) val TAG_DELAY_MINUTES_REQ: Int = 1 - delayMinutes?.let { tlvWriter.put(ContextSpecificTag(TAG_DELAY_MINUTES_REQ), delayMinutes) } + delayMinutes?.let { + tlvWriter.put(ContextSpecificTag(TAG_DELAY_MINUTES_REQ), delayMinutes) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -537,17 +607,15 @@ class ThermostatCluster(private val controller: MatterController, private val en logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startPresetsSchedulesEditRequest( - timeoutSeconds: UShort, - timedInvokeTimeout: Duration? = null - ) { + suspend fun startPresetsSchedulesEditRequest(timeoutSeconds: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 7u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TIMEOUT_SECONDS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TIMEOUT_SECONDS_REQ), timeoutSeconds) + tlvWriter.put(ContextSpecificTag(TAG_TIMEOUT_SECONDS_REQ), timeoutSeconds) tlvWriter.endStructure() val request: InvokeRequest = @@ -565,7 +633,7 @@ class ThermostatCluster(private val controller: MatterController, private val en val commandId: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -583,7 +651,7 @@ class ThermostatCluster(private val controller: MatterController, private val en val commandId: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -601,7 +669,7 @@ class ThermostatCluster(private val controller: MatterController, private val en val commandId: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -615,20 +683,15 @@ class ThermostatCluster(private val controller: MatterController, private val en logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTemperatureSetpointHoldPolicy( - temperatureSetpointHoldPolicy: UByte, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setTemperatureSetpointHoldPolicy(temperatureSetpointHoldPolicy: UByte + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TEMPERATURE_SETPOINT_HOLD_POLICY_REQ: Int = 0 - tlvWriter.put( - ContextSpecificTag(TAG_TEMPERATURE_SETPOINT_HOLD_POLICY_REQ), - temperatureSetpointHoldPolicy - ) + tlvWriter.put(ContextSpecificTag(TAG_TEMPERATURE_SETPOINT_HOLD_POLICY_REQ), temperatureSetpointHoldPolicy) tlvWriter.endStructure() val request: InvokeRequest = @@ -641,40 +704,46 @@ class ThermostatCluster(private val controller: MatterController, private val en val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } +suspend fun readLocalTemperatureAttribute(): LocalTemperatureAttribute {val ATTRIBUTE_ID: UInt = 0u - suspend fun readLocalTemperatureAttribute(): LocalTemperatureAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Localtemperature attribute not found in response" } + } + + requireNotNull(attributeData) { + "Localtemperature attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LocalTemperatureAttribute(decodedValue) } @@ -684,96 +753,100 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LocalTemperatureAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LocalTemperatureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Localtemperature attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Localtemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(LocalTemperatureAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(LocalTemperatureAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LocalTemperatureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOutdoorTemperatureAttribute(): OutdoorTemperatureAttribute {val ATTRIBUTE_ID: UInt = 1u - suspend fun readOutdoorTemperatureAttribute(): OutdoorTemperatureAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Outdoortemperature attribute not found in response" } + } + + requireNotNull(attributeData) { + "Outdoortemperature attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OutdoorTemperatureAttribute(decodedValue) } @@ -783,95 +856,99 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OutdoorTemperatureAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OutdoorTemperatureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Outdoortemperature attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Outdoortemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OutdoorTemperatureAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OutdoorTemperatureAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OutdoorTemperatureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOccupancyAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - suspend fun readOccupancyAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Occupancy attribute not found in response" } + } + + requireNotNull(attributeData) { + "Occupancy attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -881,88 +958,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Occupancy attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Occupancy attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAbsMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 3u - suspend fun readAbsMinHeatSetpointLimitAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Absminheatsetpointlimit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Absminheatsetpointlimit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -972,90 +1055,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Absminheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Absminheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAbsMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 4u - suspend fun readAbsMaxHeatSetpointLimitAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Absmaxheatsetpointlimit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Absmaxheatsetpointlimit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1065,90 +1152,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Absmaxheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Absmaxheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAbsMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 5u - suspend fun readAbsMinCoolSetpointLimitAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Absmincoolsetpointlimit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Absmincoolsetpointlimit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1158,90 +1249,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Absmincoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Absmincoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAbsMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 6u - suspend fun readAbsMaxCoolSetpointLimitAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Absmaxcoolsetpointlimit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Absmaxcoolsetpointlimit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1251,90 +1346,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Absmaxcoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Absmaxcoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPICoolingDemandAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u - suspend fun readPICoolingDemandAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Picoolingdemand attribute not found in response" } + } + + requireNotNull(attributeData) { + "Picoolingdemand attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1344,90 +1443,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Picoolingdemand attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Picoolingdemand attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPIHeatingDemandAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - suspend fun readPIHeatingDemandAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Piheatingdemand attribute not found in response" } + } + + requireNotNull(attributeData) { + "Piheatingdemand attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1437,113 +1540,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Piheatingdemand attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Piheatingdemand attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readHVACSystemTypeConfigurationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - suspend fun readHVACSystemTypeConfigurationAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Hvacsystemtypeconfiguration attribute not found in response" } + } + + requireNotNull(attributeData) { + "Hvacsystemtypeconfiguration attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeHVACSystemTypeConfigurationAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1565,7 +1673,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeHVACSystemTypeConfigurationAttribute( @@ -1573,113 +1681,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Hvacsystemtypeconfiguration attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Hvacsystemtypeconfiguration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLocalTemperatureCalibrationAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 16u - suspend fun readLocalTemperatureCalibrationAttribute(): Byte? { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Localtemperaturecalibration attribute not found in response" } + } + + requireNotNull(attributeData) { + "Localtemperaturecalibration attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeLocalTemperatureCalibrationAttribute( value: Byte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1701,7 +1814,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocalTemperatureCalibrationAttribute( @@ -1709,113 +1822,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Localtemperaturecalibration attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Localtemperaturecalibration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 17u - suspend fun readOccupiedCoolingSetpointAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Occupiedcoolingsetpoint attribute not found in response" } + } + + requireNotNull(attributeData) { + "Occupiedcoolingsetpoint attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeOccupiedCoolingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1837,7 +1955,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOccupiedCoolingSetpointAttribute( @@ -1845,113 +1963,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Occupiedcoolingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Occupiedcoolingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 18u - suspend fun readOccupiedHeatingSetpointAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Occupiedheatingsetpoint attribute not found in response" } + } + + requireNotNull(attributeData) { + "Occupiedheatingsetpoint attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeOccupiedHeatingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1973,7 +2096,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOccupiedHeatingSetpointAttribute( @@ -1981,113 +2104,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Occupiedheatingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Occupiedheatingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readUnoccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 19u - suspend fun readUnoccupiedCoolingSetpointAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 19u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Unoccupiedcoolingsetpoint attribute not found in response" } + } + + requireNotNull(attributeData) { + "Unoccupiedcoolingsetpoint attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeUnoccupiedCoolingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 19u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2109,7 +2237,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnoccupiedCoolingSetpointAttribute( @@ -2117,113 +2245,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Unoccupiedcoolingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Unoccupiedcoolingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readUnoccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 20u - suspend fun readUnoccupiedHeatingSetpointAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 20u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Unoccupiedheatingsetpoint attribute not found in response" } + } + + requireNotNull(attributeData) { + "Unoccupiedheatingsetpoint attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeUnoccupiedHeatingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2245,7 +2378,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnoccupiedHeatingSetpointAttribute( @@ -2253,113 +2386,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Unoccupiedheatingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Unoccupiedheatingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 21u - suspend fun readMinHeatSetpointLimitAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 21u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minheatsetpointlimit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minheatsetpointlimit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeMinHeatSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2381,7 +2519,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinHeatSetpointLimitAttribute( @@ -2389,113 +2527,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 22u - suspend fun readMaxHeatSetpointLimitAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 22u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxheatsetpointlimit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxheatsetpointlimit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeMaxHeatSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 22u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2517,7 +2660,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMaxHeatSetpointLimitAttribute( @@ -2525,113 +2668,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 23u - suspend fun readMinCoolSetpointLimitAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 23u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Mincoolsetpointlimit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Mincoolsetpointlimit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeMinCoolSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2653,7 +2801,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinCoolSetpointLimitAttribute( @@ -2661,113 +2809,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Mincoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Mincoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 24u - suspend fun readMaxCoolSetpointLimitAttribute(): Short? { - val ATTRIBUTE_ID: UInt = 24u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxcoolsetpointlimit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxcoolsetpointlimit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeMaxCoolSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 24u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2789,7 +2942,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMaxCoolSetpointLimitAttribute( @@ -2797,110 +2950,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxcoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxcoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMinSetpointDeadBandAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 25u - suspend fun readMinSetpointDeadBandAttribute(): Byte? { - val ATTRIBUTE_ID: UInt = 25u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minsetpointdeadband attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minsetpointdeadband attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeMinSetpointDeadBandAttribute(value: Byte, timedWriteTimeout: Duration? = null) { + suspend fun writeMinSetpointDeadBandAttribute( + value: Byte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 25u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2922,7 +3083,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinSetpointDeadBandAttribute( @@ -2930,110 +3091,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minsetpointdeadband attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minsetpointdeadband attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRemoteSensingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u - suspend fun readRemoteSensingAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 26u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Remotesensing attribute not found in response" } + } + + requireNotNull(attributeData) { + "Remotesensing attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeRemoteSensingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeRemoteSensingAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 26u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3055,7 +3224,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRemoteSensingAttribute( @@ -3063,106 +3232,114 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Remotesensing attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Remotesensing attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readControlSequenceOfOperationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 27u - suspend fun readControlSequenceOfOperationAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 27u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Controlsequenceofoperation attribute not found in response" } + } + + requireNotNull(attributeData) { + "Controlsequenceofoperation attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } suspend fun writeControlSequenceOfOperationAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 27u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3184,7 +3361,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeControlSequenceOfOperationAttribute( @@ -3192,38 +3369,34 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Controlsequenceofoperation attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Controlsequenceofoperation attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3236,56 +3409,67 @@ class ThermostatCluster(private val controller: MatterController, private val en emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSystemModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 28u - suspend fun readSystemModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 28u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Systemmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Systemmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeSystemModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeSystemModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 28u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3307,7 +3491,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSystemModeAttribute( @@ -3315,37 +3499,35 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Systemmode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Systemmode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3357,41 +3539,47 @@ class ThermostatCluster(private val controller: MatterController, private val en emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readThermostatRunningModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 30u - suspend fun readThermostatRunningModeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 30u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Thermostatrunningmode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Thermostatrunningmode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3401,90 +3589,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Thermostatrunningmode attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Thermostatrunningmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readStartOfWeekAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 32u - suspend fun readStartOfWeekAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 32u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Startofweek attribute not found in response" } + } + + requireNotNull(attributeData) { + "Startofweek attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3494,88 +3686,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Startofweek attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Startofweek attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfWeeklyTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 33u - suspend fun readNumberOfWeeklyTransitionsAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 33u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofweeklytransitions attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofweeklytransitions attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3585,90 +3783,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofweeklytransitions attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofweeklytransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfDailyTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u - suspend fun readNumberOfDailyTransitionsAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 34u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofdailytransitions attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofdailytransitions attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3678,113 +3880,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofdailytransitions attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofdailytransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTemperatureSetpointHoldAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 35u - suspend fun readTemperatureSetpointHoldAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 35u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Temperaturesetpointhold attribute not found in response" } + } + + requireNotNull(attributeData) { + "Temperaturesetpointhold attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeTemperatureSetpointHoldAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 35u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3806,7 +4013,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureSetpointHoldAttribute( @@ -3814,121 +4021,123 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Temperaturesetpointhold attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Temperaturesetpointhold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTemperatureSetpointHoldDurationAttribute(): TemperatureSetpointHoldDurationAttribute {val ATTRIBUTE_ID: UInt = 36u - suspend fun readTemperatureSetpointHoldDurationAttribute(): - TemperatureSetpointHoldDurationAttribute { - val ATTRIBUTE_ID: UInt = 36u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointholdduration attribute not found in response" + } + + requireNotNull(attributeData) { + "Temperaturesetpointholdduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return TemperatureSetpointHoldDurationAttribute(decodedValue) } suspend fun writeTemperatureSetpointHoldDurationAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 36u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3950,7 +4159,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureSetpointHoldDurationAttribute( @@ -3958,122 +4167,123 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - TemperatureSetpointHoldDurationAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(TemperatureSetpointHoldDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Temperaturesetpointholdduration attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Temperaturesetpointholdduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(TemperatureSetpointHoldDurationAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(TemperatureSetpointHoldDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readThermostatProgrammingOperationModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 37u - suspend fun readThermostatProgrammingOperationModeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 37u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatprogrammingoperationmode attribute not found in response" + } + + requireNotNull(attributeData) { + "Thermostatprogrammingoperationmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeThermostatProgrammingOperationModeAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 37u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4095,7 +4305,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeThermostatProgrammingOperationModeAttribute( @@ -4103,90 +4313,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Thermostatprogrammingoperationmode attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Thermostatprogrammingoperationmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readThermostatRunningStateAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 41u - suspend fun readThermostatRunningStateAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 41u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Thermostatrunningstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Thermostatrunningstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4196,90 +4410,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Thermostatrunningstate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Thermostatrunningstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSetpointChangeSourceAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 48u - suspend fun readSetpointChangeSourceAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 48u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Setpointchangesource attribute not found in response" } + } + + requireNotNull(attributeData) { + "Setpointchangesource attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4289,95 +4507,99 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Setpointchangesource attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Setpointchangesource attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSetpointChangeAmountAttribute(): SetpointChangeAmountAttribute {val ATTRIBUTE_ID: UInt = 49u - suspend fun readSetpointChangeAmountAttribute(): SetpointChangeAmountAttribute { - val ATTRIBUTE_ID: UInt = 49u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Setpointchangeamount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Setpointchangeamount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SetpointChangeAmountAttribute(decodedValue) } @@ -4387,97 +4609,99 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SetpointChangeAmountAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SetpointChangeAmountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Setpointchangeamount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Setpointchangeamount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(SetpointChangeAmountAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(SetpointChangeAmountAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SetpointChangeAmountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSetpointChangeSourceTimestampAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 50u - suspend fun readSetpointChangeSourceTimestampAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 50u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangesourcetimestamp attribute not found in response" + } + + requireNotNull(attributeData) { + "Setpointchangesourcetimestamp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4487,115 +4711,123 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Setpointchangesourcetimestamp attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Setpointchangesourcetimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute {val ATTRIBUTE_ID: UInt = 52u - suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute { - val ATTRIBUTE_ID: UInt = 52u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Occupiedsetback attribute not found in response" } + } + + requireNotNull(attributeData) { + "Occupiedsetback attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OccupiedSetbackAttribute(decodedValue) } - suspend fun writeOccupiedSetbackAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeOccupiedSetbackAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 52u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4617,7 +4849,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOccupiedSetbackAttribute( @@ -4625,100 +4857,104 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OccupiedSetbackAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OccupiedSetbackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Occupiedsetback attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Occupiedsetback attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OccupiedSetbackAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OccupiedSetbackAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OccupiedSetbackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOccupiedSetbackMinAttribute(): OccupiedSetbackMinAttribute {val ATTRIBUTE_ID: UInt = 53u - suspend fun readOccupiedSetbackMinAttribute(): OccupiedSetbackMinAttribute { - val ATTRIBUTE_ID: UInt = 53u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Occupiedsetbackmin attribute not found in response" } + } + + requireNotNull(attributeData) { + "Occupiedsetbackmin attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OccupiedSetbackMinAttribute(decodedValue) } @@ -4728,100 +4964,104 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OccupiedSetbackMinAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OccupiedSetbackMinAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Occupiedsetbackmin attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Occupiedsetbackmin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OccupiedSetbackMinAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OccupiedSetbackMinAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OccupiedSetbackMinAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOccupiedSetbackMaxAttribute(): OccupiedSetbackMaxAttribute {val ATTRIBUTE_ID: UInt = 54u - suspend fun readOccupiedSetbackMaxAttribute(): OccupiedSetbackMaxAttribute { - val ATTRIBUTE_ID: UInt = 54u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Occupiedsetbackmax attribute not found in response" } + } + + requireNotNull(attributeData) { + "Occupiedsetbackmax attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OccupiedSetbackMaxAttribute(decodedValue) } @@ -4831,120 +5071,128 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 54u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OccupiedSetbackMaxAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OccupiedSetbackMaxAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Occupiedsetbackmax attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Occupiedsetbackmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OccupiedSetbackMaxAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OccupiedSetbackMaxAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OccupiedSetbackMaxAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute {val ATTRIBUTE_ID: UInt = 55u - suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute { - val ATTRIBUTE_ID: UInt = 55u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Unoccupiedsetback attribute not found in response" } + } + + requireNotNull(attributeData) { + "Unoccupiedsetback attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return UnoccupiedSetbackAttribute(decodedValue) } - suspend fun writeUnoccupiedSetbackAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeUnoccupiedSetbackAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 55u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4966,7 +5214,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnoccupiedSetbackAttribute( @@ -4974,100 +5222,104 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 55u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UnoccupiedSetbackAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UnoccupiedSetbackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Unoccupiedsetback attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Unoccupiedsetback attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(UnoccupiedSetbackAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(UnoccupiedSetbackAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UnoccupiedSetbackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readUnoccupiedSetbackMinAttribute(): UnoccupiedSetbackMinAttribute {val ATTRIBUTE_ID: UInt = 56u - suspend fun readUnoccupiedSetbackMinAttribute(): UnoccupiedSetbackMinAttribute { - val ATTRIBUTE_ID: UInt = 56u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Unoccupiedsetbackmin attribute not found in response" } + } + + requireNotNull(attributeData) { + "Unoccupiedsetbackmin attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return UnoccupiedSetbackMinAttribute(decodedValue) } @@ -5077,100 +5329,104 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 56u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UnoccupiedSetbackMinAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UnoccupiedSetbackMinAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Unoccupiedsetbackmin attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Unoccupiedsetbackmin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(UnoccupiedSetbackMinAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(UnoccupiedSetbackMinAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UnoccupiedSetbackMinAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readUnoccupiedSetbackMaxAttribute(): UnoccupiedSetbackMaxAttribute {val ATTRIBUTE_ID: UInt = 57u - suspend fun readUnoccupiedSetbackMaxAttribute(): UnoccupiedSetbackMaxAttribute { - val ATTRIBUTE_ID: UInt = 57u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Unoccupiedsetbackmax attribute not found in response" } + } + + requireNotNull(attributeData) { + "Unoccupiedsetbackmax attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return UnoccupiedSetbackMaxAttribute(decodedValue) } @@ -5180,115 +5436,123 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 57u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UnoccupiedSetbackMaxAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UnoccupiedSetbackMaxAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Unoccupiedsetbackmax attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Unoccupiedsetbackmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(UnoccupiedSetbackMaxAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(UnoccupiedSetbackMaxAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UnoccupiedSetbackMaxAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEmergencyHeatDeltaAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 58u - suspend fun readEmergencyHeatDeltaAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 58u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Emergencyheatdelta attribute not found in response" } + } + + requireNotNull(attributeData) { + "Emergencyheatdelta attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeEmergencyHeatDeltaAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeEmergencyHeatDeltaAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 58u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5310,7 +5574,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEmergencyHeatDeltaAttribute( @@ -5318,110 +5582,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 58u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Emergencyheatdelta attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Emergencyheatdelta attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readACTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 64u - suspend fun readACTypeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 64u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Actype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Actype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeACTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeACTypeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 64u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5443,7 +5715,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACTypeAttribute( @@ -5451,108 +5723,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 64u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Actype attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Actype attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readACCapacityAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 65u - suspend fun readACCapacityAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 65u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Accapacity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Accapacity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeACCapacityAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeACCapacityAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 65u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5574,7 +5856,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACCapacityAttribute( @@ -5582,108 +5864,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Accapacity attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Accapacity attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readACRefrigerantTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 66u - suspend fun readACRefrigerantTypeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 66u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acrefrigeranttype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acrefrigeranttype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeACRefrigerantTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeACRefrigerantTypeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 66u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5705,7 +5997,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACRefrigerantTypeAttribute( @@ -5713,110 +6005,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 66u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acrefrigeranttype attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acrefrigeranttype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readACCompressorTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 67u - suspend fun readACCompressorTypeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 67u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Accompressortype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Accompressortype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeACCompressorTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeACCompressorTypeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 67u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5838,7 +6138,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACCompressorTypeAttribute( @@ -5846,110 +6146,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 67u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Accompressortype attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Accompressortype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readACErrorCodeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 68u - suspend fun readACErrorCodeAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 68u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acerrorcode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acerrorcode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeACErrorCodeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeACErrorCodeAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 68u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5971,7 +6279,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACErrorCodeAttribute( @@ -5979,108 +6287,118 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 68u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Acerrorcode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acerrorcode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readACLouverPositionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 69u - suspend fun readACLouverPositionAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 69u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Aclouverposition attribute not found in response" } + } + + requireNotNull(attributeData) { + "Aclouverposition attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeACLouverPositionAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeACLouverPositionAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 69u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6102,7 +6420,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACLouverPositionAttribute( @@ -6110,96 +6428,100 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 69u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Aclouverposition attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Aclouverposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readACCoilTemperatureAttribute(): ACCoilTemperatureAttribute {val ATTRIBUTE_ID: UInt = 70u - suspend fun readACCoilTemperatureAttribute(): ACCoilTemperatureAttribute { - val ATTRIBUTE_ID: UInt = 70u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Accoiltemperature attribute not found in response" } + } + + requireNotNull(attributeData) { + "Accoiltemperature attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + return ACCoilTemperatureAttribute(decodedValue) } @@ -6208,115 +6530,123 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 70u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ACCoilTemperatureAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ACCoilTemperatureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Accoiltemperature attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Accoiltemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ACCoilTemperatureAttributeSubscriptionState.Success(it)) } + val decodedValue: Short? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ACCoilTemperatureAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ACCoilTemperatureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readACCapacityformatAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 71u - suspend fun readACCapacityformatAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 71u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Accapacityformat attribute not found in response" } + } + + requireNotNull(attributeData) { + "Accapacityformat attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeACCapacityformatAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeACCapacityformatAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 71u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6338,7 +6668,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACCapacityformatAttribute( @@ -6346,96 +6676,100 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 71u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Accapacityformat attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Accapacityformat attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPresetTypesAttribute(): PresetTypesAttribute {val ATTRIBUTE_ID: UInt = 72u - suspend fun readPresetTypesAttribute(): PresetTypesAttribute { - val ATTRIBUTE_ID: UInt = 72u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Presettypes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Presettypes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return PresetTypesAttribute(decodedValue) } @@ -6445,100 +6779,106 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 72u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PresetTypesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PresetTypesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Presettypes attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Presettypes attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(PresetTypesAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(PresetTypesAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PresetTypesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readScheduleTypesAttribute(): ScheduleTypesAttribute {val ATTRIBUTE_ID: UInt = 73u - suspend fun readScheduleTypesAttribute(): ScheduleTypesAttribute { - val ATTRIBUTE_ID: UInt = 73u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Scheduletypes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Scheduletypes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return ScheduleTypesAttribute(decodedValue) } @@ -6548,94 +6888,100 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 73u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ScheduleTypesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ScheduleTypesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Scheduletypes attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scheduletypes attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(ScheduleTypesAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(ScheduleTypesAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ScheduleTypesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfPresetsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 74u - suspend fun readNumberOfPresetsAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 74u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofpresets attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofpresets attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6645,90 +6991,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 74u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofpresets attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofpresets attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfSchedulesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 75u - suspend fun readNumberOfSchedulesAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 75u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofschedules attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofschedules attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6738,90 +7088,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 75u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofschedules attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofschedules attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfScheduleTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 76u - suspend fun readNumberOfScheduleTransitionsAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 76u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofscheduletransitions attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofscheduletransitions attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -6831,98 +7185,99 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 76u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofscheduletransitions attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofscheduletransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfScheduleTransitionPerDayAttribute(): NumberOfScheduleTransitionPerDayAttribute {val ATTRIBUTE_ID: UInt = 77u - suspend fun readNumberOfScheduleTransitionPerDayAttribute(): - NumberOfScheduleTransitionPerDayAttribute { - val ATTRIBUTE_ID: UInt = 77u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofscheduletransitionperday attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofscheduletransitionperday attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NumberOfScheduleTransitionPerDayAttribute(decodedValue) } @@ -6932,102 +7287,104 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 77u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NumberOfScheduleTransitionPerDayAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NumberOfScheduleTransitionPerDayAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofscheduletransitionperday attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofscheduletransitionperday attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NumberOfScheduleTransitionPerDayAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(NumberOfScheduleTransitionPerDayAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActivePresetHandleAttribute(): ActivePresetHandleAttribute {val ATTRIBUTE_ID: UInt = 78u - suspend fun readActivePresetHandleAttribute(): ActivePresetHandleAttribute { - val ATTRIBUTE_ID: UInt = 78u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activepresethandle attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activepresethandle attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ActivePresetHandleAttribute(decodedValue) } @@ -7037,100 +7394,104 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 78u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActivePresetHandleAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActivePresetHandleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activepresethandle attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activepresethandle attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ActivePresetHandleAttributeSubscriptionState.Success(it)) } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ActivePresetHandleAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ActivePresetHandleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActiveScheduleHandleAttribute(): ActiveScheduleHandleAttribute {val ATTRIBUTE_ID: UInt = 79u - suspend fun readActiveScheduleHandleAttribute(): ActiveScheduleHandleAttribute { - val ATTRIBUTE_ID: UInt = 79u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activeschedulehandle attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activeschedulehandle attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ActiveScheduleHandleAttribute(decodedValue) } @@ -7140,128 +7501,133 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 79u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveScheduleHandleAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveScheduleHandleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activeschedulehandle attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activeschedulehandle attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ActiveScheduleHandleAttributeSubscriptionState.Success(it)) } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ActiveScheduleHandleAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ActiveScheduleHandleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPresetsAttribute(): PresetsAttribute {val ATTRIBUTE_ID: UInt = 80u - suspend fun readPresetsAttribute(): PresetsAttribute { - val ATTRIBUTE_ID: UInt = 80u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Presets attribute not found in response" } + } + + requireNotNull(attributeData) { + "Presets attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return PresetsAttribute(decodedValue) } suspend fun writePresetsAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 80u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7283,7 +7649,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePresetsAttribute( @@ -7291,127 +7657,134 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 80u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PresetsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PresetsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Presets attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Presets attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(PresetsAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(PresetsAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PresetsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSchedulesAttribute(): SchedulesAttribute {val ATTRIBUTE_ID: UInt = 81u - suspend fun readSchedulesAttribute(): SchedulesAttribute { - val ATTRIBUTE_ID: UInt = 81u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Schedules attribute not found in response" } + } + + requireNotNull(attributeData) { + "Schedules attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return SchedulesAttribute(decodedValue) } suspend fun writeSchedulesAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 81u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7433,7 +7806,7 @@ class ThermostatCluster(private val controller: MatterController, private val en throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSchedulesAttribute( @@ -7441,94 +7814,100 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 81u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SchedulesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SchedulesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Schedules attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Schedules attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(SchedulesAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(SchedulesAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SchedulesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPresetsSchedulesEditableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 82u - suspend fun readPresetsSchedulesEditableAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 82u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Presetsscheduleseditable attribute not found in response" } + } + + requireNotNull(attributeData) { + "Presetsscheduleseditable attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -7538,92 +7917,94 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 82u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Presetsscheduleseditable attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Presetsscheduleseditable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTemperatureSetpointHoldPolicyAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 83u - suspend fun readTemperatureSetpointHoldPolicyAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 83u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointholdpolicy attribute not found in response" + } + + requireNotNull(attributeData) { + "Temperaturesetpointholdpolicy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -7633,95 +8014,99 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 83u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Temperaturesetpointholdpolicy attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Temperaturesetpointholdpolicy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSetpointHoldExpiryTimestampAttribute(): SetpointHoldExpiryTimestampAttribute {val ATTRIBUTE_ID: UInt = 84u - suspend fun readSetpointHoldExpiryTimestampAttribute(): SetpointHoldExpiryTimestampAttribute { - val ATTRIBUTE_ID: UInt = 84u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Setpointholdexpirytimestamp attribute not found in response" } + } + + requireNotNull(attributeData) { + "Setpointholdexpirytimestamp attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SetpointHoldExpiryTimestampAttribute(decodedValue) } @@ -7731,102 +8116,104 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 84u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SetpointHoldExpiryTimestampAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SetpointHoldExpiryTimestampAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Setpointholdexpirytimestamp attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Setpointholdexpirytimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(SetpointHoldExpiryTimestampAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(SetpointHoldExpiryTimestampAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readQueuedPresetAttribute(): QueuedPresetAttribute {val ATTRIBUTE_ID: UInt = 85u - suspend fun readQueuedPresetAttribute(): QueuedPresetAttribute { - val ATTRIBUTE_ID: UInt = 85u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Queuedpreset attribute not found in response" } + } + + requireNotNull(attributeData) { + "Queuedpreset attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThermostatClusterQueuedPresetStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ThermostatClusterQueuedPresetStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return QueuedPresetAttribute(decodedValue) } @@ -7836,95 +8223,101 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 85u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - QueuedPresetAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(QueuedPresetAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Queuedpreset attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Queuedpreset attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThermostatClusterQueuedPresetStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(QueuedPresetAttributeSubscriptionState.Success(it)) } + val decodedValue: ThermostatClusterQueuedPresetStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(QueuedPresetAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(QueuedPresetAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -7934,50 +8327,45 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -7985,43 +8373,49 @@ class ThermostatCluster(private val controller: MatterController, private val en emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -8031,50 +8425,45 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -8082,43 +8471,49 @@ class ThermostatCluster(private val controller: MatterController, private val en emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -8128,48 +8523,45 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -8177,43 +8569,49 @@ class ThermostatCluster(private val controller: MatterController, private val en emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -8223,48 +8621,45 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -8272,37 +8667,44 @@ class ThermostatCluster(private val controller: MatterController, private val en emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -8311,37 +8713,35 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -8353,37 +8753,44 @@ class ThermostatCluster(private val controller: MatterController, private val en emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -8392,38 +8799,34 @@ class ThermostatCluster(private val controller: MatterController, private val en maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8436,7 +8839,7 @@ class ThermostatCluster(private val controller: MatterController, private val en emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt index 1f5a0777fcb41f..f766146a4a3b89 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt @@ -17,122 +17,159 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThermostatUserInterfaceConfigurationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class ThermostatUserInterfaceConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readTemperatureDisplayModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readTemperatureDisplayModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Temperaturedisplaymode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Temperaturedisplaymode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } suspend fun writeTemperatureDisplayModeAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -154,7 +191,7 @@ class ThermostatUserInterfaceConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureDisplayModeAttribute( @@ -162,38 +199,34 @@ class ThermostatUserInterfaceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Temperaturedisplaymode attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Temperaturedisplaymode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -206,56 +239,67 @@ class ThermostatUserInterfaceConfigurationCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readKeypadLockoutAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readKeypadLockoutAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Keypadlockout attribute not found in response" } + } + + requireNotNull(attributeData) { + "Keypadlockout attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeKeypadLockoutAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeKeypadLockoutAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -277,7 +321,7 @@ class ThermostatUserInterfaceConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeKeypadLockoutAttribute( @@ -285,37 +329,35 @@ class ThermostatUserInterfaceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Keypadlockout attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Keypadlockout attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -327,66 +369,71 @@ class ThermostatUserInterfaceConfigurationCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readScheduleProgrammingVisibilityAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readScheduleProgrammingVisibilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduleprogrammingvisibility attribute not found in response" + } + + requireNotNull(attributeData) { + "Scheduleprogrammingvisibility attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } suspend fun writeScheduleProgrammingVisibilityAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -408,7 +455,7 @@ class ThermostatUserInterfaceConfigurationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeScheduleProgrammingVisibilityAttribute( @@ -416,92 +463,96 @@ class ThermostatUserInterfaceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Scheduleprogrammingvisibility attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Scheduleprogrammingvisibility attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -511,50 +562,45 @@ class ThermostatUserInterfaceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -562,43 +608,49 @@ class ThermostatUserInterfaceConfigurationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -608,50 +660,45 @@ class ThermostatUserInterfaceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -659,43 +706,49 @@ class ThermostatUserInterfaceConfigurationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -705,48 +758,45 @@ class ThermostatUserInterfaceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -754,43 +804,49 @@ class ThermostatUserInterfaceConfigurationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -800,48 +856,45 @@ class ThermostatUserInterfaceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -849,37 +902,44 @@ class ThermostatUserInterfaceConfigurationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -888,37 +948,35 @@ class ThermostatUserInterfaceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -930,37 +988,44 @@ class ThermostatUserInterfaceConfigurationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -969,38 +1034,34 @@ class ThermostatUserInterfaceConfigurationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1013,12 +1074,11 @@ class ThermostatUserInterfaceConfigurationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = - Logger.getLogger(ThermostatUserInterfaceConfigurationCluster::class.java.name) + private val logger = Logger.getLogger(ThermostatUserInterfaceConfigurationCluster::class.java.name) const val CLUSTER_ID: UInt = 516u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt index d4949cb4df2bf6..865e7b62d0545d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt @@ -17,286 +17,366 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class ChannelAttribute(val value: UShort?) +class ThreadNetworkDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class ChannelAttribute( + val value: UShort? + ) sealed class ChannelAttributeSubscriptionState { - data class Success(val value: UShort?) : ChannelAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : ChannelAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelAttributeSubscriptionState() - object SubscriptionEstablished : ChannelAttributeSubscriptionState() - } - - class RoutingRoleAttribute(val value: UByte?) + object SubscriptionEstablished : ChannelAttributeSubscriptionState() + } +class RoutingRoleAttribute( + val value: UByte? + ) sealed class RoutingRoleAttributeSubscriptionState { - data class Success(val value: UByte?) : RoutingRoleAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : RoutingRoleAttributeSubscriptionState() + data class Error(val exception: Exception) : RoutingRoleAttributeSubscriptionState() - object SubscriptionEstablished : RoutingRoleAttributeSubscriptionState() - } - - class NetworkNameAttribute(val value: String?) + object SubscriptionEstablished : RoutingRoleAttributeSubscriptionState() + } +class NetworkNameAttribute( + val value: String? + ) sealed class NetworkNameAttributeSubscriptionState { - data class Success(val value: String?) : NetworkNameAttributeSubscriptionState() - + data class Success( + val value: String? + ) : NetworkNameAttributeSubscriptionState() + data class Error(val exception: Exception) : NetworkNameAttributeSubscriptionState() - object SubscriptionEstablished : NetworkNameAttributeSubscriptionState() - } - - class PanIdAttribute(val value: UShort?) + object SubscriptionEstablished : NetworkNameAttributeSubscriptionState() + } +class PanIdAttribute( + val value: UShort? + ) sealed class PanIdAttributeSubscriptionState { - data class Success(val value: UShort?) : PanIdAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : PanIdAttributeSubscriptionState() + data class Error(val exception: Exception) : PanIdAttributeSubscriptionState() - object SubscriptionEstablished : PanIdAttributeSubscriptionState() - } - - class ExtendedPanIdAttribute(val value: ULong?) + object SubscriptionEstablished : PanIdAttributeSubscriptionState() + } +class ExtendedPanIdAttribute( + val value: ULong? + ) sealed class ExtendedPanIdAttributeSubscriptionState { - data class Success(val value: ULong?) : ExtendedPanIdAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : ExtendedPanIdAttributeSubscriptionState() + data class Error(val exception: Exception) : ExtendedPanIdAttributeSubscriptionState() - object SubscriptionEstablished : ExtendedPanIdAttributeSubscriptionState() - } - - class MeshLocalPrefixAttribute(val value: ByteArray?) + object SubscriptionEstablished : ExtendedPanIdAttributeSubscriptionState() + } +class MeshLocalPrefixAttribute( + val value: ByteArray? + ) sealed class MeshLocalPrefixAttributeSubscriptionState { - data class Success(val value: ByteArray?) : MeshLocalPrefixAttributeSubscriptionState() - + data class Success( + val value: ByteArray? + ) : MeshLocalPrefixAttributeSubscriptionState() + data class Error(val exception: Exception) : MeshLocalPrefixAttributeSubscriptionState() - object SubscriptionEstablished : MeshLocalPrefixAttributeSubscriptionState() - } - - class NeighborTableAttribute(val value: List) + object SubscriptionEstablished : MeshLocalPrefixAttributeSubscriptionState() + } +class NeighborTableAttribute( + val value: List + ) sealed class NeighborTableAttributeSubscriptionState { - data class Success(val value: List) : - NeighborTableAttributeSubscriptionState() - + data class Success( + val value: List + ) : NeighborTableAttributeSubscriptionState() + data class Error(val exception: Exception) : NeighborTableAttributeSubscriptionState() - object SubscriptionEstablished : NeighborTableAttributeSubscriptionState() - } - - class RouteTableAttribute(val value: List) + object SubscriptionEstablished : NeighborTableAttributeSubscriptionState() + } +class RouteTableAttribute( + val value: List + ) sealed class RouteTableAttributeSubscriptionState { - data class Success(val value: List) : - RouteTableAttributeSubscriptionState() - + data class Success( + val value: List + ) : RouteTableAttributeSubscriptionState() + data class Error(val exception: Exception) : RouteTableAttributeSubscriptionState() - object SubscriptionEstablished : RouteTableAttributeSubscriptionState() - } - - class PartitionIdAttribute(val value: UInt?) + object SubscriptionEstablished : RouteTableAttributeSubscriptionState() + } +class PartitionIdAttribute( + val value: UInt? + ) sealed class PartitionIdAttributeSubscriptionState { - data class Success(val value: UInt?) : PartitionIdAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : PartitionIdAttributeSubscriptionState() + data class Error(val exception: Exception) : PartitionIdAttributeSubscriptionState() - object SubscriptionEstablished : PartitionIdAttributeSubscriptionState() - } - - class WeightingAttribute(val value: UShort?) + object SubscriptionEstablished : PartitionIdAttributeSubscriptionState() + } +class WeightingAttribute( + val value: UShort? + ) sealed class WeightingAttributeSubscriptionState { - data class Success(val value: UShort?) : WeightingAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : WeightingAttributeSubscriptionState() + data class Error(val exception: Exception) : WeightingAttributeSubscriptionState() - object SubscriptionEstablished : WeightingAttributeSubscriptionState() - } - - class DataVersionAttribute(val value: UShort?) + object SubscriptionEstablished : WeightingAttributeSubscriptionState() + } +class DataVersionAttribute( + val value: UShort? + ) sealed class DataVersionAttributeSubscriptionState { - data class Success(val value: UShort?) : DataVersionAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : DataVersionAttributeSubscriptionState() + data class Error(val exception: Exception) : DataVersionAttributeSubscriptionState() - object SubscriptionEstablished : DataVersionAttributeSubscriptionState() - } - - class StableDataVersionAttribute(val value: UShort?) + object SubscriptionEstablished : DataVersionAttributeSubscriptionState() + } +class StableDataVersionAttribute( + val value: UShort? + ) sealed class StableDataVersionAttributeSubscriptionState { - data class Success(val value: UShort?) : StableDataVersionAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : StableDataVersionAttributeSubscriptionState() + data class Error(val exception: Exception) : StableDataVersionAttributeSubscriptionState() - object SubscriptionEstablished : StableDataVersionAttributeSubscriptionState() - } - - class LeaderRouterIdAttribute(val value: UByte?) + object SubscriptionEstablished : StableDataVersionAttributeSubscriptionState() + } +class LeaderRouterIdAttribute( + val value: UByte? + ) sealed class LeaderRouterIdAttributeSubscriptionState { - data class Success(val value: UByte?) : LeaderRouterIdAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : LeaderRouterIdAttributeSubscriptionState() + data class Error(val exception: Exception) : LeaderRouterIdAttributeSubscriptionState() - object SubscriptionEstablished : LeaderRouterIdAttributeSubscriptionState() - } - - class ActiveTimestampAttribute(val value: ULong?) + object SubscriptionEstablished : LeaderRouterIdAttributeSubscriptionState() + } +class ActiveTimestampAttribute( + val value: ULong? + ) sealed class ActiveTimestampAttributeSubscriptionState { - data class Success(val value: ULong?) : ActiveTimestampAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : ActiveTimestampAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveTimestampAttributeSubscriptionState() - object SubscriptionEstablished : ActiveTimestampAttributeSubscriptionState() - } - - class PendingTimestampAttribute(val value: ULong?) + object SubscriptionEstablished : ActiveTimestampAttributeSubscriptionState() + } +class PendingTimestampAttribute( + val value: ULong? + ) sealed class PendingTimestampAttributeSubscriptionState { - data class Success(val value: ULong?) : PendingTimestampAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : PendingTimestampAttributeSubscriptionState() + data class Error(val exception: Exception) : PendingTimestampAttributeSubscriptionState() - object SubscriptionEstablished : PendingTimestampAttributeSubscriptionState() - } - - class DelayAttribute(val value: UInt?) + object SubscriptionEstablished : PendingTimestampAttributeSubscriptionState() + } +class DelayAttribute( + val value: UInt? + ) sealed class DelayAttributeSubscriptionState { - data class Success(val value: UInt?) : DelayAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : DelayAttributeSubscriptionState() + data class Error(val exception: Exception) : DelayAttributeSubscriptionState() - object SubscriptionEstablished : DelayAttributeSubscriptionState() - } - - class SecurityPolicyAttribute(val value: ThreadNetworkDiagnosticsClusterSecurityPolicy?) + object SubscriptionEstablished : DelayAttributeSubscriptionState() + } +class SecurityPolicyAttribute( + val value: ThreadNetworkDiagnosticsClusterSecurityPolicy? + ) sealed class SecurityPolicyAttributeSubscriptionState { - data class Success(val value: ThreadNetworkDiagnosticsClusterSecurityPolicy?) : - SecurityPolicyAttributeSubscriptionState() - + data class Success( + val value: ThreadNetworkDiagnosticsClusterSecurityPolicy? + ) : SecurityPolicyAttributeSubscriptionState() + data class Error(val exception: Exception) : SecurityPolicyAttributeSubscriptionState() - object SubscriptionEstablished : SecurityPolicyAttributeSubscriptionState() - } - - class ChannelPage0MaskAttribute(val value: ByteArray?) + object SubscriptionEstablished : SecurityPolicyAttributeSubscriptionState() + } +class ChannelPage0MaskAttribute( + val value: ByteArray? + ) sealed class ChannelPage0MaskAttributeSubscriptionState { - data class Success(val value: ByteArray?) : ChannelPage0MaskAttributeSubscriptionState() - + data class Success( + val value: ByteArray? + ) : ChannelPage0MaskAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelPage0MaskAttributeSubscriptionState() - object SubscriptionEstablished : ChannelPage0MaskAttributeSubscriptionState() - } - - class OperationalDatasetComponentsAttribute( + object SubscriptionEstablished : ChannelPage0MaskAttributeSubscriptionState() + } +class OperationalDatasetComponentsAttribute( val value: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? ) sealed class OperationalDatasetComponentsAttributeSubscriptionState { - data class Success(val value: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents?) : - OperationalDatasetComponentsAttributeSubscriptionState() - - data class Error(val exception: Exception) : - OperationalDatasetComponentsAttributeSubscriptionState() - - object SubscriptionEstablished : OperationalDatasetComponentsAttributeSubscriptionState() - } - - class ActiveNetworkFaultsListAttribute(val value: List) + data class Success( + val value: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? + ) : OperationalDatasetComponentsAttributeSubscriptionState() + + data class Error(val exception: Exception) : OperationalDatasetComponentsAttributeSubscriptionState() + + object SubscriptionEstablished : OperationalDatasetComponentsAttributeSubscriptionState() + } +class ActiveNetworkFaultsListAttribute( + val value: List + ) sealed class ActiveNetworkFaultsListAttributeSubscriptionState { - data class Success(val value: List) : - ActiveNetworkFaultsListAttributeSubscriptionState() - - data class Error(val exception: Exception) : - ActiveNetworkFaultsListAttributeSubscriptionState() - - object SubscriptionEstablished : ActiveNetworkFaultsListAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + data class Success( + val value: List + ) : ActiveNetworkFaultsListAttributeSubscriptionState() + + data class Error(val exception: Exception) : ActiveNetworkFaultsListAttributeSubscriptionState() + + object SubscriptionEstablished : ActiveNetworkFaultsListAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCounts(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -309,40 +389,46 @@ class ThreadNetworkDiagnosticsCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } +suspend fun readChannelAttribute(): ChannelAttribute {val ATTRIBUTE_ID: UInt = 0u - suspend fun readChannelAttribute(): ChannelAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Channel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Channel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ChannelAttribute(decodedValue) } @@ -352,90 +438,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ChannelAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ChannelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Channel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Channel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(ChannelAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ChannelAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ChannelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRoutingRoleAttribute(): RoutingRoleAttribute {val ATTRIBUTE_ID: UInt = 1u - suspend fun readRoutingRoleAttribute(): RoutingRoleAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Routingrole attribute not found in response" } + } + + requireNotNull(attributeData) { + "Routingrole attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return RoutingRoleAttribute(decodedValue) } @@ -445,90 +537,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - RoutingRoleAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(RoutingRoleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Routingrole attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Routingrole attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(RoutingRoleAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(RoutingRoleAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(RoutingRoleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNetworkNameAttribute(): NetworkNameAttribute {val ATTRIBUTE_ID: UInt = 2u - suspend fun readNetworkNameAttribute(): NetworkNameAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Networkname attribute not found in response" } + } + + requireNotNull(attributeData) { + "Networkname attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: String? = if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NetworkNameAttribute(decodedValue) } @@ -538,90 +636,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NetworkNameAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NetworkNameAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Networkname attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Networkname attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: String? = if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NetworkNameAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NetworkNameAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NetworkNameAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPanIdAttribute(): PanIdAttribute {val ATTRIBUTE_ID: UInt = 3u - suspend fun readPanIdAttribute(): PanIdAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Panid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Panid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PanIdAttribute(decodedValue) } @@ -631,90 +735,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PanIdAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PanIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Panid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Panid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(PanIdAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(PanIdAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PanIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readExtendedPanIdAttribute(): ExtendedPanIdAttribute {val ATTRIBUTE_ID: UInt = 4u - suspend fun readExtendedPanIdAttribute(): ExtendedPanIdAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Extendedpanid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Extendedpanid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ExtendedPanIdAttribute(decodedValue) } @@ -724,90 +834,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ExtendedPanIdAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ExtendedPanIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Extendedpanid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Extendedpanid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(ExtendedPanIdAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ExtendedPanIdAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ExtendedPanIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readMeshLocalPrefixAttribute(): MeshLocalPrefixAttribute {val ATTRIBUTE_ID: UInt = 5u - suspend fun readMeshLocalPrefixAttribute(): MeshLocalPrefixAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Meshlocalprefix attribute not found in response" } + } + + requireNotNull(attributeData) { + "Meshlocalprefix attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeshLocalPrefixAttribute(decodedValue) } @@ -817,91 +933,95 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeshLocalPrefixAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeshLocalPrefixAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Meshlocalprefix attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Meshlocalprefix attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(MeshLocalPrefixAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(MeshLocalPrefixAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeshLocalPrefixAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOverrunCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 6u - suspend fun readOverrunCountAttribute(): ULong? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Overruncount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Overruncount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + return decodedValue } @@ -911,90 +1031,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Overruncount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Overruncount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ULongSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNeighborTableAttribute(): NeighborTableAttribute {val ATTRIBUTE_ID: UInt = 7u - suspend fun readNeighborTableAttribute(): NeighborTableAttribute { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Neighbortable attribute not found in response" } + } + + requireNotNull(attributeData) { + "Neighbortable attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return NeighborTableAttribute(decodedValue) } @@ -1004,53 +1130,45 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NeighborTableAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NeighborTableAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Neighbortable attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Neighbortable attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(NeighborTableAttributeSubscriptionState.Success(decodedValue)) } @@ -1058,43 +1176,49 @@ class ThreadNetworkDiagnosticsCluster( emit(NeighborTableAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRouteTableAttribute(): RouteTableAttribute {val ATTRIBUTE_ID: UInt = 8u - suspend fun readRouteTableAttribute(): RouteTableAttribute { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Routetable attribute not found in response" } + } + + requireNotNull(attributeData) { + "Routetable attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return RouteTableAttribute(decodedValue) } @@ -1104,50 +1228,45 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - RouteTableAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(RouteTableAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Routetable attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Routetable attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add( - ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader) - ) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(RouteTableAttributeSubscriptionState.Success(decodedValue)) } @@ -1155,42 +1274,48 @@ class ThreadNetworkDiagnosticsCluster( emit(RouteTableAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPartitionIdAttribute(): PartitionIdAttribute {val ATTRIBUTE_ID: UInt = 9u - suspend fun readPartitionIdAttribute(): PartitionIdAttribute { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Partitionid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Partitionid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PartitionIdAttribute(decodedValue) } @@ -1200,90 +1325,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PartitionIdAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PartitionIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Partitionid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Partitionid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(PartitionIdAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(PartitionIdAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PartitionIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWeightingAttribute(): WeightingAttribute {val ATTRIBUTE_ID: UInt = 10u - suspend fun readWeightingAttribute(): WeightingAttribute { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Weighting attribute not found in response" } + } + + requireNotNull(attributeData) { + "Weighting attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return WeightingAttribute(decodedValue) } @@ -1293,90 +1424,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - WeightingAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(WeightingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Weighting attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Weighting attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(WeightingAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(WeightingAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(WeightingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDataVersionAttribute(): DataVersionAttribute {val ATTRIBUTE_ID: UInt = 11u - suspend fun readDataVersionAttribute(): DataVersionAttribute { - val ATTRIBUTE_ID: UInt = 11u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dataversion attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dataversion attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return DataVersionAttribute(decodedValue) } @@ -1386,90 +1523,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DataVersionAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DataVersionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Dataversion attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dataversion attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(DataVersionAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(DataVersionAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(DataVersionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readStableDataVersionAttribute(): StableDataVersionAttribute {val ATTRIBUTE_ID: UInt = 12u - suspend fun readStableDataVersionAttribute(): StableDataVersionAttribute { - val ATTRIBUTE_ID: UInt = 12u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Stabledataversion attribute not found in response" } + } + + requireNotNull(attributeData) { + "Stabledataversion attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return StableDataVersionAttribute(decodedValue) } @@ -1479,92 +1622,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StableDataVersionAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StableDataVersionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Stabledataversion attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Stabledataversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(StableDataVersionAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(StableDataVersionAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StableDataVersionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLeaderRouterIdAttribute(): LeaderRouterIdAttribute {val ATTRIBUTE_ID: UInt = 13u - suspend fun readLeaderRouterIdAttribute(): LeaderRouterIdAttribute { - val ATTRIBUTE_ID: UInt = 13u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Leaderrouterid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Leaderrouterid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LeaderRouterIdAttribute(decodedValue) } @@ -1574,91 +1721,95 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LeaderRouterIdAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LeaderRouterIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Leaderrouterid attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Leaderrouterid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(LeaderRouterIdAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(LeaderRouterIdAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LeaderRouterIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDetachedRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 14u - suspend fun readDetachedRoleCountAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 14u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Detachedrolecount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Detachedrolecount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1668,90 +1819,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Detachedrolecount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Detachedrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readChildRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 15u - suspend fun readChildRoleCountAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 15u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Childrolecount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Childrolecount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1761,90 +1916,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Childrolecount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Childrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRouterRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - suspend fun readRouterRoleCountAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Routerrolecount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Routerrolecount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1854,90 +2013,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Routerrolecount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Routerrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLeaderRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - suspend fun readLeaderRoleCountAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Leaderrolecount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Leaderrolecount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1947,90 +2110,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Leaderrolecount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Leaderrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttachAttemptCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - suspend fun readAttachAttemptCountAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attachattemptcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attachattemptcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2040,90 +2207,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Attachattemptcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attachattemptcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPartitionIdChangeCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u - suspend fun readPartitionIdChangeCountAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 19u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Partitionidchangecount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Partitionidchangecount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2133,92 +2304,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Partitionidchangecount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Partitionidchangecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBetterPartitionAttachAttemptCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 20u - suspend fun readBetterPartitionAttachAttemptCountAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 20u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Betterpartitionattachattemptcount attribute not found in response" + } + + requireNotNull(attributeData) { + "Betterpartitionattachattemptcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2228,90 +2401,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Betterpartitionattachattemptcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Betterpartitionattachattemptcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readParentChangeCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 21u - suspend fun readParentChangeCountAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 21u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Parentchangecount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Parentchangecount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2321,90 +2498,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Parentchangecount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Parentchangecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxTotalCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 22u - suspend fun readTxTotalCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 22u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txtotalcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txtotalcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2414,88 +2595,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Txtotalcount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txtotalcount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxUnicastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 23u - suspend fun readTxUnicastCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 23u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txunicastcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txunicastcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2505,90 +2692,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Txunicastcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txunicastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxBroadcastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 24u - suspend fun readTxBroadcastCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 24u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txbroadcastcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txbroadcastcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2598,90 +2789,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Txbroadcastcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txbroadcastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxAckRequestedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 25u - suspend fun readTxAckRequestedCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 25u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txackrequestedcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txackrequestedcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2691,90 +2886,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Txackrequestedcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txackrequestedcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxAckedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 26u - suspend fun readTxAckedCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 26u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txackedcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txackedcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2784,88 +2983,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Txackedcount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txackedcount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxNoAckRequestedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 27u - suspend fun readTxNoAckRequestedCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 27u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txnoackrequestedcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txnoackrequestedcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2875,90 +3080,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Txnoackrequestedcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txnoackrequestedcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxDataCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 28u - suspend fun readTxDataCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 28u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txdatacount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txdatacount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2968,88 +3177,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Txdatacount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txdatacount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxDataPollCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 29u - suspend fun readTxDataPollCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 29u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txdatapollcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txdatapollcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3059,90 +3274,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 29u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Txdatapollcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txdatapollcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxBeaconCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 30u - suspend fun readTxBeaconCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 30u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txbeaconcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txbeaconcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3152,88 +3371,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Txbeaconcount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txbeaconcount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxBeaconRequestCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 31u - suspend fun readTxBeaconRequestCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 31u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txbeaconrequestcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txbeaconrequestcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3243,90 +3468,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 31u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Txbeaconrequestcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txbeaconrequestcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 32u - suspend fun readTxOtherCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 32u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txothercount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txothercount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3336,88 +3565,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Txothercount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txothercount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxRetryCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 33u - suspend fun readTxRetryCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 33u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txretrycount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txretrycount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3427,88 +3662,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Txretrycount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txretrycount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxDirectMaxRetryExpiryCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 34u - suspend fun readTxDirectMaxRetryExpiryCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 34u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txdirectmaxretryexpirycount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txdirectmaxretryexpirycount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3518,92 +3759,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Txdirectmaxretryexpirycount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txdirectmaxretryexpirycount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxIndirectMaxRetryExpiryCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 35u - suspend fun readTxIndirectMaxRetryExpiryCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 35u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txindirectmaxretryexpirycount attribute not found in response" + } + + requireNotNull(attributeData) { + "Txindirectmaxretryexpirycount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3613,90 +3856,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Txindirectmaxretryexpirycount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txindirectmaxretryexpirycount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxErrCcaCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 36u - suspend fun readTxErrCcaCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 36u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txerrccacount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txerrccacount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3706,88 +3953,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Txerrccacount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txerrccacount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxErrAbortCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 37u - suspend fun readTxErrAbortCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 37u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txerrabortcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txerrabortcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3797,90 +4050,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Txerrabortcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txerrabortcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTxErrBusyChannelCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 38u - suspend fun readTxErrBusyChannelCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 38u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Txerrbusychannelcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Txerrbusychannelcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3890,90 +4147,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Txerrbusychannelcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Txerrbusychannelcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxTotalCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 39u - suspend fun readRxTotalCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 39u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxtotalcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxtotalcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -3983,88 +4244,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rxtotalcount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxtotalcount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxUnicastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 40u - suspend fun readRxUnicastCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 40u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxunicastcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxunicastcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4074,90 +4341,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rxunicastcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxunicastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxBroadcastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 41u - suspend fun readRxBroadcastCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 41u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxbroadcastcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxbroadcastcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4167,90 +4438,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rxbroadcastcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxbroadcastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxDataCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 42u - suspend fun readRxDataCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 42u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxdatacount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxdatacount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4260,88 +4535,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rxdatacount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxdatacount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxDataPollCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 43u - suspend fun readRxDataPollCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 43u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxdatapollcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxdatapollcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4351,90 +4632,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 43u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rxdatapollcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxdatapollcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxBeaconCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 44u - suspend fun readRxBeaconCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 44u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxbeaconcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxbeaconcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4444,88 +4729,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 44u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rxbeaconcount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxbeaconcount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxBeaconRequestCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 45u - suspend fun readRxBeaconRequestCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 45u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxbeaconrequestcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxbeaconrequestcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4535,90 +4826,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 45u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rxbeaconrequestcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxbeaconrequestcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 46u - suspend fun readRxOtherCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 46u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxothercount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxothercount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4628,88 +4923,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 46u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rxothercount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxothercount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxAddressFilteredCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 47u - suspend fun readRxAddressFilteredCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 47u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxaddressfilteredcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxaddressfilteredcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4719,90 +5020,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 47u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rxaddressfilteredcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxaddressfilteredcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxDestAddrFilteredCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 48u - suspend fun readRxDestAddrFilteredCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 48u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxdestaddrfilteredcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxdestaddrfilteredcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4812,90 +5117,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rxdestaddrfilteredcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxdestaddrfilteredcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxDuplicatedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 49u - suspend fun readRxDuplicatedCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 49u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxduplicatedcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxduplicatedcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4905,90 +5214,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rxduplicatedcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxduplicatedcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxErrNoFrameCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 50u - suspend fun readRxErrNoFrameCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 50u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxerrnoframecount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxerrnoframecount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -4998,90 +5311,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rxerrnoframecount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxerrnoframecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxErrUnknownNeighborCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 51u - suspend fun readRxErrUnknownNeighborCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 51u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxerrunknownneighborcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxerrunknownneighborcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5091,90 +5408,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rxerrunknownneighborcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxerrunknownneighborcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxErrInvalidSrcAddrCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 52u - suspend fun readRxErrInvalidSrcAddrCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 52u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxerrinvalidsrcaddrcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxerrinvalidsrcaddrcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5184,90 +5505,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rxerrinvalidsrcaddrcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxerrinvalidsrcaddrcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxErrSecCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 53u - suspend fun readRxErrSecCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 53u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxerrseccount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxerrseccount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5277,88 +5602,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rxerrseccount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxerrseccount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxErrFcsCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 54u - suspend fun readRxErrFcsCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 54u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxerrfcscount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxerrfcscount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5368,88 +5699,94 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 54u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rxerrfcscount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxerrfcscount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRxErrOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 55u - suspend fun readRxErrOtherCountAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 55u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rxerrothercount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rxerrothercount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -5459,95 +5796,99 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 55u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rxerrothercount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rxerrothercount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActiveTimestampAttribute(): ActiveTimestampAttribute {val ATTRIBUTE_ID: UInt = 56u - suspend fun readActiveTimestampAttribute(): ActiveTimestampAttribute { - val ATTRIBUTE_ID: UInt = 56u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activetimestamp attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activetimestamp attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ActiveTimestampAttribute(decodedValue) } @@ -5557,100 +5898,104 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 56u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveTimestampAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveTimestampAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activetimestamp attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activetimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ActiveTimestampAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ActiveTimestampAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ActiveTimestampAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPendingTimestampAttribute(): PendingTimestampAttribute {val ATTRIBUTE_ID: UInt = 57u - suspend fun readPendingTimestampAttribute(): PendingTimestampAttribute { - val ATTRIBUTE_ID: UInt = 57u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Pendingtimestamp attribute not found in response" } + } + + requireNotNull(attributeData) { + "Pendingtimestamp attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PendingTimestampAttribute(decodedValue) } @@ -5660,100 +6005,104 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 57u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PendingTimestampAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PendingTimestampAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Pendingtimestamp attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Pendingtimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PendingTimestampAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PendingTimestampAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PendingTimestampAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readDelayAttribute(): DelayAttribute {val ATTRIBUTE_ID: UInt = 58u - suspend fun readDelayAttribute(): DelayAttribute { - val ATTRIBUTE_ID: UInt = 58u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Delay attribute not found in response" } + } + + requireNotNull(attributeData) { + "Delay attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return DelayAttribute(decodedValue) } @@ -5763,94 +6112,100 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 58u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DelayAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DelayAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Delay attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Delay attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(DelayAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(DelayAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(DelayAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSecurityPolicyAttribute(): SecurityPolicyAttribute {val ATTRIBUTE_ID: UInt = 59u - suspend fun readSecurityPolicyAttribute(): SecurityPolicyAttribute { - val ATTRIBUTE_ID: UInt = 59u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Securitypolicy attribute not found in response" } + } + + requireNotNull(attributeData) { + "Securitypolicy attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = - if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SecurityPolicyAttribute(decodedValue) } @@ -5860,92 +6215,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 59u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SecurityPolicyAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SecurityPolicyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Securitypolicy attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Securitypolicy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = - if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(SecurityPolicyAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(SecurityPolicyAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SecurityPolicyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readChannelPage0MaskAttribute(): ChannelPage0MaskAttribute {val ATTRIBUTE_ID: UInt = 60u - suspend fun readChannelPage0MaskAttribute(): ChannelPage0MaskAttribute { - val ATTRIBUTE_ID: UInt = 60u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Channelpage0mask attribute not found in response" } + } + + requireNotNull(attributeData) { + "Channelpage0mask attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ChannelPage0MaskAttribute(decodedValue) } @@ -5955,92 +6314,96 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 60u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ChannelPage0MaskAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ChannelPage0MaskAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Channelpage0mask attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Channelpage0mask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(ChannelPage0MaskAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(ChannelPage0MaskAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ChannelPage0MaskAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOperationalDatasetComponentsAttribute(): OperationalDatasetComponentsAttribute {val ATTRIBUTE_ID: UInt = 61u - suspend fun readOperationalDatasetComponentsAttribute(): OperationalDatasetComponentsAttribute { - val ATTRIBUTE_ID: UInt = 61u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationaldatasetcomponents attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationaldatasetcomponents attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = - if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OperationalDatasetComponentsAttribute(decodedValue) } @@ -6050,98 +6413,97 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 61u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OperationalDatasetComponentsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OperationalDatasetComponentsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Operationaldatasetcomponents attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationaldatasetcomponents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = - if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv( - AnonymousTag, - tlvReader - ) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(OperationalDatasetComponentsAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(OperationalDatasetComponentsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttribute {val ATTRIBUTE_ID: UInt = 62u - suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttribute { - val ATTRIBUTE_ID: UInt = 62u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activenetworkfaultslist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activenetworkfaultslist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + return ActiveNetworkFaultsListAttribute(decodedValue) } @@ -6151,50 +6513,45 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 62u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ActiveNetworkFaultsListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ActiveNetworkFaultsListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activenetworkfaultslist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activenetworkfaultslist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ActiveNetworkFaultsListAttributeSubscriptionState.Success(decodedValue)) } @@ -6202,43 +6559,49 @@ class ThreadNetworkDiagnosticsCluster( emit(ActiveNetworkFaultsListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -6248,50 +6611,45 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6299,43 +6657,49 @@ class ThreadNetworkDiagnosticsCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -6345,50 +6709,45 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6396,43 +6755,49 @@ class ThreadNetworkDiagnosticsCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -6442,48 +6807,45 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -6491,43 +6853,49 @@ class ThreadNetworkDiagnosticsCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -6537,48 +6905,45 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -6586,37 +6951,44 @@ class ThreadNetworkDiagnosticsCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -6625,37 +6997,35 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6667,37 +7037,44 @@ class ThreadNetworkDiagnosticsCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -6706,38 +7083,34 @@ class ThreadNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -6750,7 +7123,7 @@ class ThreadNetworkDiagnosticsCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt index c16c37cdb0d766..0a6b84266fe5f8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt @@ -17,130 +17,172 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeFormatLocalizationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SupportedCalendarTypesAttribute(val value: List?) +class TimeFormatLocalizationCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedCalendarTypesAttribute( + val value: List? + ) sealed class SupportedCalendarTypesAttributeSubscriptionState { - data class Success(val value: List?) : - SupportedCalendarTypesAttributeSubscriptionState() - + data class Success( + val value: List? + ) : SupportedCalendarTypesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedCalendarTypesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedCalendarTypesAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : SupportedCalendarTypesAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readHourFormatAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readHourFormatAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Hourformat attribute not found in response" } + } + + requireNotNull(attributeData) { + "Hourformat attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeHourFormatAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeHourFormatAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -162,7 +204,7 @@ class TimeFormatLocalizationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeHourFormatAttribute( @@ -170,37 +212,35 @@ class TimeFormatLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Hourformat attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Hourformat attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -212,61 +252,71 @@ class TimeFormatLocalizationCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readActiveCalendarTypeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readActiveCalendarTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Activecalendartype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Activecalendartype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeActiveCalendarTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeActiveCalendarTypeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -288,7 +338,7 @@ class TimeFormatLocalizationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeActiveCalendarTypeAttribute( @@ -296,96 +346,100 @@ class TimeFormatLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Activecalendartype attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Activecalendartype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportedCalendarTypesAttribute(): SupportedCalendarTypesAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportedCalendarTypesAttribute(): SupportedCalendarTypesAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportedcalendartypes attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportedcalendartypes attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + } else { + null + } + return SupportedCalendarTypesAttribute(decodedValue) } @@ -395,98 +449,102 @@ class TimeFormatLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SupportedCalendarTypesAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SupportedCalendarTypesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportedcalendartypes attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportedcalendartypes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(SupportedCalendarTypesAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(SupportedCalendarTypesAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SupportedCalendarTypesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -496,50 +554,45 @@ class TimeFormatLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -547,43 +600,49 @@ class TimeFormatLocalizationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -593,50 +652,45 @@ class TimeFormatLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -644,43 +698,49 @@ class TimeFormatLocalizationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -690,48 +750,45 @@ class TimeFormatLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -739,43 +796,49 @@ class TimeFormatLocalizationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -785,48 +848,45 @@ class TimeFormatLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -834,37 +894,44 @@ class TimeFormatLocalizationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -873,37 +940,35 @@ class TimeFormatLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -915,37 +980,44 @@ class TimeFormatLocalizationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -954,38 +1026,34 @@ class TimeFormatLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -998,7 +1066,7 @@ class TimeFormatLocalizationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt index 13edfff80a046d..6310128a0314e5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt @@ -17,145 +17,187 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class SetTimeZoneResponse(val DSTOffsetRequired: Boolean) - - class UTCTimeAttribute(val value: ULong?) +class TimeSynchronizationCluster(private val controller: MatterController, private val endpointId: UShort) { + class SetTimeZoneResponse( + val DSTOffsetRequired: Boolean + ) +class UTCTimeAttribute( + val value: ULong? + ) sealed class UTCTimeAttributeSubscriptionState { - data class Success(val value: ULong?) : UTCTimeAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : UTCTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : UTCTimeAttributeSubscriptionState() - object SubscriptionEstablished : UTCTimeAttributeSubscriptionState() - } - - class TrustedTimeSourceAttribute(val value: TimeSynchronizationClusterTrustedTimeSourceStruct?) + object SubscriptionEstablished : UTCTimeAttributeSubscriptionState() + } +class TrustedTimeSourceAttribute( + val value: TimeSynchronizationClusterTrustedTimeSourceStruct? + ) sealed class TrustedTimeSourceAttributeSubscriptionState { - data class Success(val value: TimeSynchronizationClusterTrustedTimeSourceStruct?) : - TrustedTimeSourceAttributeSubscriptionState() - + data class Success( + val value: TimeSynchronizationClusterTrustedTimeSourceStruct? + ) : TrustedTimeSourceAttributeSubscriptionState() + data class Error(val exception: Exception) : TrustedTimeSourceAttributeSubscriptionState() - object SubscriptionEstablished : TrustedTimeSourceAttributeSubscriptionState() - } - - class DefaultNTPAttribute(val value: String?) + object SubscriptionEstablished : TrustedTimeSourceAttributeSubscriptionState() + } +class DefaultNTPAttribute( + val value: String? + ) sealed class DefaultNTPAttributeSubscriptionState { - data class Success(val value: String?) : DefaultNTPAttributeSubscriptionState() - + data class Success( + val value: String? + ) : DefaultNTPAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultNTPAttributeSubscriptionState() - object SubscriptionEstablished : DefaultNTPAttributeSubscriptionState() - } - - class TimeZoneAttribute(val value: List?) + object SubscriptionEstablished : DefaultNTPAttributeSubscriptionState() + } +class TimeZoneAttribute( + val value: List? + ) sealed class TimeZoneAttributeSubscriptionState { - data class Success(val value: List?) : - TimeZoneAttributeSubscriptionState() - + data class Success( + val value: List? + ) : TimeZoneAttributeSubscriptionState() + data class Error(val exception: Exception) : TimeZoneAttributeSubscriptionState() - object SubscriptionEstablished : TimeZoneAttributeSubscriptionState() - } - - class DSTOffsetAttribute(val value: List?) + object SubscriptionEstablished : TimeZoneAttributeSubscriptionState() + } +class DSTOffsetAttribute( + val value: List? + ) sealed class DSTOffsetAttributeSubscriptionState { - data class Success(val value: List?) : - DSTOffsetAttributeSubscriptionState() - + data class Success( + val value: List? + ) : DSTOffsetAttributeSubscriptionState() + data class Error(val exception: Exception) : DSTOffsetAttributeSubscriptionState() - object SubscriptionEstablished : DSTOffsetAttributeSubscriptionState() - } - - class LocalTimeAttribute(val value: ULong?) + object SubscriptionEstablished : DSTOffsetAttributeSubscriptionState() + } +class LocalTimeAttribute( + val value: ULong? + ) sealed class LocalTimeAttributeSubscriptionState { - data class Success(val value: ULong?) : LocalTimeAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : LocalTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : LocalTimeAttributeSubscriptionState() - object SubscriptionEstablished : LocalTimeAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : LocalTimeAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setUTCTime( - UTCTime: ULong, - granularity: UByte, - timeSource: UByte?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setUTCTime(UTCTime: ULong + ,granularity: UByte + ,timeSource: UByte? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -168,7 +210,9 @@ class TimeSynchronizationCluster( tlvWriter.put(ContextSpecificTag(TAG_GRANULARITY_REQ), granularity) val TAG_TIME_SOURCE_REQ: Int = 2 - timeSource?.let { tlvWriter.put(ContextSpecificTag(TAG_TIME_SOURCE_REQ), timeSource) } + timeSource?.let { + tlvWriter.put(ContextSpecificTag(TAG_TIME_SOURCE_REQ), timeSource) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -182,10 +226,8 @@ class TimeSynchronizationCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTrustedTimeSource( - trustedTimeSource: TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setTrustedTimeSource(trustedTimeSource: TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -194,7 +236,7 @@ class TimeSynchronizationCluster( val TAG_TRUSTED_TIME_SOURCE_REQ: Int = 0 trustedTimeSource?.let { trustedTimeSource.toTlv(ContextSpecificTag(TAG_TRUSTED_TIME_SOURCE_REQ), tlvWriter) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -208,10 +250,8 @@ class TimeSynchronizationCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTimeZone( - timeZone: List, - timedInvokeTimeout: Duration? = null - ): SetTimeZoneResponse { + suspend fun setTimeZone(timeZone: List + ,timedInvokeTimeout: Duration? = null): SetTimeZoneResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -219,10 +259,10 @@ class TimeSynchronizationCluster( val TAG_TIME_ZONE_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_TIME_ZONE_REQ)) - for (item in timeZone.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in timeZone.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -239,30 +279,36 @@ class TimeSynchronizationCluster( tlvReader.enterStructure(AnonymousTag) val TAG_D_S_T_OFFSET_REQUIRED: Int = 0 var DSTOffsetRequired_decoded: Boolean? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_D_S_T_OFFSET_REQUIRED)) { - DSTOffsetRequired_decoded = tlvReader.getBoolean(tag) - } else { + + if (tag == ContextSpecificTag(TAG_D_S_T_OFFSET_REQUIRED)) {DSTOffsetRequired_decoded = tlvReader.getBoolean(tag)} + + + else { tlvReader.skipElement() } } + + if (DSTOffsetRequired_decoded == null) { - throw IllegalStateException("DSTOffsetRequired not found in TLV") + throw IllegalStateException("DSTOffsetRequired not found in TLV") } + tlvReader.exitContainer() - return SetTimeZoneResponse(DSTOffsetRequired_decoded) + return SetTimeZoneResponse( + DSTOffsetRequired_decoded + ) } - suspend fun setDSTOffset( - DSTOffset: List, - timedInvokeTimeout: Duration? = null - ) { + suspend fun setDSTOffset(DSTOffset: List + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -270,10 +316,10 @@ class TimeSynchronizationCluster( val TAG_D_S_T_OFFSET_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_D_S_T_OFFSET_REQ)) - for (item in DSTOffset.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in DSTOffset.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -287,14 +333,17 @@ class TimeSynchronizationCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setDefaultNTP(defaultNTP: String?, timedInvokeTimeout: Duration? = null) { + suspend fun setDefaultNTP(defaultNTP: String? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DEFAULT_N_T_P_REQ: Int = 0 - defaultNTP?.let { tlvWriter.put(ContextSpecificTag(TAG_DEFAULT_N_T_P_REQ), defaultNTP) } + defaultNTP?.let { + tlvWriter.put(ContextSpecificTag(TAG_DEFAULT_N_T_P_REQ), defaultNTP) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -307,40 +356,46 @@ class TimeSynchronizationCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readUTCTimeAttribute(): UTCTimeAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUTCTimeAttribute(): UTCTimeAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Utctime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Utctime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return UTCTimeAttribute(decodedValue) } @@ -350,85 +405,92 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UTCTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UTCTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Utctime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Utctime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(UTCTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(UTCTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UTCTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGranularityAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGranularityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Granularity attribute not found in response" } + } + + requireNotNull(attributeData) { + "Granularity attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -437,37 +499,35 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Granularity attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Granularity attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -479,41 +539,47 @@ class TimeSynchronizationCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTimeSourceAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTimeSourceAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Timesource attribute not found in response" } + } + + requireNotNull(attributeData) { + "Timesource attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -523,93 +589,99 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Timesource attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Timesource attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTrustedTimeSourceAttribute(): TrustedTimeSourceAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTrustedTimeSourceAttribute(): TrustedTimeSourceAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Trustedtimesource attribute not found in response" } + } + + requireNotNull(attributeData) { + "Trustedtimesource attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return TrustedTimeSourceAttribute(decodedValue) } @@ -619,100 +691,104 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - TrustedTimeSourceAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(TrustedTimeSourceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Trustedtimesource attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Trustedtimesource attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(TrustedTimeSourceAttributeSubscriptionState.Success(it)) } + val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(TrustedTimeSourceAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(TrustedTimeSourceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDefaultNTPAttribute(): DefaultNTPAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDefaultNTPAttribute(): DefaultNTPAttribute {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Defaultntp attribute not found in response" } + } + + requireNotNull(attributeData) { + "Defaultntp attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: String? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return DefaultNTPAttribute(decodedValue) } @@ -722,99 +798,105 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DefaultNTPAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DefaultNTPAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Defaultntp attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Defaultntp attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(DefaultNTPAttributeSubscriptionState.Success(it)) } + val decodedValue: String? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(DefaultNTPAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(DefaultNTPAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTimeZoneAttribute(): TimeZoneAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTimeZoneAttribute(): TimeZoneAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Timezone attribute not found in response" } + } + + requireNotNull(attributeData) { + "Timezone attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return TimeZoneAttribute(decodedValue) } @@ -824,100 +906,106 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - TimeZoneAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(TimeZoneAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Timezone attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Timezone attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(TimeZoneAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(TimeZoneAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(TimeZoneAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDSTOffsetAttribute(): DSTOffsetAttribute { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDSTOffsetAttribute(): DSTOffsetAttribute {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dstoffset attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dstoffset attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + } else { + null + } + return DSTOffsetAttribute(decodedValue) } @@ -927,99 +1015,105 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DSTOffsetAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DSTOffsetAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Dstoffset attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dstoffset attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { emit(DSTOffsetAttributeSubscriptionState.Success(it)) } + val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { + emit(DSTOffsetAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(DSTOffsetAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLocalTimeAttribute(): LocalTimeAttribute { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLocalTimeAttribute(): LocalTimeAttribute {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Localtime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Localtime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return LocalTimeAttribute(decodedValue) } @@ -1029,93 +1123,99 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LocalTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LocalTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Localtime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Localtime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(LocalTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(LocalTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(LocalTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTimeZoneDatabaseAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTimeZoneDatabaseAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Timezonedatabase attribute not found in response" } + } + + requireNotNull(attributeData) { + "Timezonedatabase attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1125,90 +1225,94 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Timezonedatabase attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Timezonedatabase attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readNTPServerAvailableAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readNTPServerAvailableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Ntpserveravailable attribute not found in response" } + } + + requireNotNull(attributeData) { + "Ntpserveravailable attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1218,90 +1322,94 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Ntpserveravailable attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Ntpserveravailable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTimeZoneListMaxSizeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTimeZoneListMaxSizeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Timezonelistmaxsize attribute not found in response" } + } + + requireNotNull(attributeData) { + "Timezonelistmaxsize attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1311,90 +1419,94 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Timezonelistmaxsize attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Timezonelistmaxsize attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDSTOffsetListMaxSizeAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 11u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDSTOffsetListMaxSizeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Dstoffsetlistmaxsize attribute not found in response" } + } + + requireNotNull(attributeData) { + "Dstoffsetlistmaxsize attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1404,90 +1516,94 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Dstoffsetlistmaxsize attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Dstoffsetlistmaxsize attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSupportsDNSResolveAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 12u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSupportsDNSResolveAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 12u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Supportsdnsresolve attribute not found in response" } + } + + requireNotNull(attributeData) { + "Supportsdnsresolve attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1497,92 +1613,96 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Supportsdnsresolve attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Supportsdnsresolve attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1592,50 +1712,45 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1643,43 +1758,49 @@ class TimeSynchronizationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1689,50 +1810,45 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1740,43 +1856,49 @@ class TimeSynchronizationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1786,48 +1908,45 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1835,43 +1954,49 @@ class TimeSynchronizationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1881,48 +2006,45 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1930,37 +2052,44 @@ class TimeSynchronizationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1969,37 +2098,35 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2011,37 +2138,44 @@ class TimeSynchronizationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2050,38 +2184,34 @@ class TimeSynchronizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2094,7 +2224,7 @@ class TimeSynchronizationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt index c019d26a8a29bf..e974a2ed351918 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt @@ -17,78 +17,110 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimerCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) +class TimerCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setTimer(newTime: UInt, timedInvokeTimeout: Duration? = null) { + suspend fun setTimer(newTime: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_TIME_REQ), newTime) + tlvWriter.put(ContextSpecificTag(TAG_NEW_TIME_REQ), newTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -106,7 +138,7 @@ class TimerCluster(private val controller: MatterController, private val endpoin val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -120,14 +152,15 @@ class TimerCluster(private val controller: MatterController, private val endpoin logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addTime(additionalTime: UInt, timedInvokeTimeout: Duration? = null) { + suspend fun addTime(additionalTime: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ADDITIONAL_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ADDITIONAL_TIME_REQ), additionalTime) + tlvWriter.put(ContextSpecificTag(TAG_ADDITIONAL_TIME_REQ), additionalTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -141,14 +174,15 @@ class TimerCluster(private val controller: MatterController, private val endpoin logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun reduceTime(timeReduction: UInt, timedInvokeTimeout: Duration? = null) { + suspend fun reduceTime(timeReduction: UInt + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TIME_REDUCTION_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TIME_REDUCTION_REQ), timeReduction) + tlvWriter.put(ContextSpecificTag(TAG_TIME_REDUCTION_REQ), timeReduction) tlvWriter.endStructure() val request: InvokeRequest = @@ -161,35 +195,42 @@ class TimerCluster(private val controller: MatterController, private val endpoin val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readSetTimeAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSetTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Settime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Settime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -198,37 +239,35 @@ class TimerCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Settime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Settime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -240,37 +279,44 @@ class TimerCluster(private val controller: MatterController, private val endpoin emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTimeRemainingAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTimeRemainingAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Timeremaining attribute not found in response" } + } + + requireNotNull(attributeData) { + "Timeremaining attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -279,37 +325,35 @@ class TimerCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Timeremaining attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Timeremaining attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -321,37 +365,44 @@ class TimerCluster(private val controller: MatterController, private val endpoin emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTimerStateAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTimerStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Timerstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Timerstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -360,37 +411,35 @@ class TimerCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Timerstate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Timerstate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -402,43 +451,49 @@ class TimerCluster(private val controller: MatterController, private val endpoin emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -448,50 +503,45 @@ class TimerCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -499,43 +549,49 @@ class TimerCluster(private val controller: MatterController, private val endpoin emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -545,50 +601,45 @@ class TimerCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -596,43 +647,49 @@ class TimerCluster(private val controller: MatterController, private val endpoin emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -642,48 +699,45 @@ class TimerCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -691,43 +745,49 @@ class TimerCluster(private val controller: MatterController, private val endpoin emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -737,48 +797,45 @@ class TimerCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -786,37 +843,44 @@ class TimerCluster(private val controller: MatterController, private val endpoin emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -825,37 +889,35 @@ class TimerCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -867,37 +929,44 @@ class TimerCluster(private val controller: MatterController, private val endpoin emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -906,38 +975,34 @@ class TimerCluster(private val controller: MatterController, private val endpoin maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -950,7 +1015,7 @@ class TimerCluster(private val controller: MatterController, private val endpoin emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt index 5ff5251fad8295..acddad214ee5bc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt @@ -17,156 +17,209 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class MeasuredValueAttribute(val value: Float?) +class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( + val value: Float? + ) sealed class MeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } - - class MinMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } +class MinMeasuredValueAttribute( + val value: Float? + ) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } - - class MaxMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } +class MaxMeasuredValueAttribute( + val value: Float? + ) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } - - class PeakMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } +class PeakMeasuredValueAttribute( + val value: Float? + ) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } - - class AverageMeasuredValueAttribute(val value: Float?) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } +class AverageMeasuredValueAttribute( + val value: Float? + ) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MeasuredValueAttribute(decodedValue) } @@ -176,98 +229,104 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measuredvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MinMeasuredValueAttribute(decodedValue) } @@ -277,100 +336,104 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MinMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return MaxMeasuredValueAttribute(decodedValue) } @@ -380,100 +443,104 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - MaxMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PeakMeasuredValueAttribute(decodedValue) } @@ -483,95 +550,99 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PeakMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -581,95 +652,99 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AverageMeasuredValueAttribute(decodedValue) } @@ -679,95 +754,99 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AverageMeasuredValueAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } + val decodedValue: Float? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + return decodedValue } @@ -777,90 +856,94 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UIntSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readUncertaintyAttribute(): Float? { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Uncertainty attribute not found in response" } + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + return decodedValue } @@ -870,88 +953,94 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Uncertainty attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } + val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(FloatSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementUnitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementunit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -961,90 +1050,94 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readMeasurementMediumAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1054,90 +1147,94 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLevelValueAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Levelvalue attribute not found in response" } + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1147,90 +1244,96 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Levelvalue attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1240,50 +1343,45 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1291,43 +1389,49 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1337,50 +1441,45 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1388,43 +1487,49 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1434,48 +1539,45 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1483,43 +1585,49 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1529,48 +1637,45 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1578,37 +1683,44 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1617,37 +1729,35 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1659,37 +1769,44 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1698,38 +1815,34 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1742,14 +1855,11 @@ class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = - Logger.getLogger( - TotalVolatileOrganicCompoundsConcentrationMeasurementCluster::class.java.name - ) + private val logger = Logger.getLogger(TotalVolatileOrganicCompoundsConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1070u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt index 36c750385a9bd6..7d5cb6ca7abba9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt @@ -17,124 +17,163 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitLocalizationCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class GeneratedCommandListAttribute(val value: List) +class UnitLocalizationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readTemperatureUnitAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readTemperatureUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Temperatureunit attribute not found in response" } + } + + requireNotNull(attributeData) { + "Temperatureunit attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeTemperatureUnitAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeTemperatureUnitAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -156,7 +195,7 @@ class UnitLocalizationCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureUnitAttribute( @@ -164,92 +203,96 @@ class UnitLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Temperatureunit attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Temperatureunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -259,50 +302,45 @@ class UnitLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -310,43 +348,49 @@ class UnitLocalizationCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -356,50 +400,45 @@ class UnitLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -407,43 +446,49 @@ class UnitLocalizationCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -453,48 +498,45 @@ class UnitLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -502,43 +544,49 @@ class UnitLocalizationCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -548,48 +596,45 @@ class UnitLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -597,37 +642,44 @@ class UnitLocalizationCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -636,37 +688,35 @@ class UnitLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -678,37 +728,44 @@ class UnitLocalizationCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -717,38 +774,34 @@ class UnitLocalizationCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -761,7 +814,7 @@ class UnitLocalizationCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt index 468d4e4b310802..cfc1bf1fe749aa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt @@ -17,571 +17,714 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.BooleanSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.LongSubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.ShortSubscriptionState -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.UShortSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class UnitTestingCluster(private val controller: MatterController, private val endpointId: UShort) { - class TestSpecificResponse(val returnValue: UByte) + class TestSpecificResponse( + val returnValue: UByte + ) - class TestAddArgumentsResponse(val returnValue: UByte) + class TestAddArgumentsResponse( + val returnValue: UByte + ) - class TestSimpleArgumentResponse(val returnValue: Boolean) + class TestSimpleArgumentResponse( + val returnValue: Boolean + ) class TestStructArrayArgumentResponse( - val arg1: List, - val arg2: List, - val arg3: List, - val arg4: List, - val arg5: UByte, + val arg1: List, + val arg2: List, + val arg3: List, + val arg4: List, + val arg5: UByte, val arg6: Boolean ) - class BooleanResponse(val value: Boolean) + class BooleanResponse( + val value: Boolean + ) - class TestListInt8UReverseResponse(val arg1: List) + class TestListInt8UReverseResponse( + val arg1: List + ) - class TestEnumsResponse(val arg1: UShort, val arg2: UByte) + class TestEnumsResponse( + val arg1: UShort, + val arg2: UByte + ) class TestNullableOptionalResponse( - val wasPresent: Boolean, - val wasNull: Boolean?, - val value: UByte?, + val wasPresent: Boolean, + val wasNull: Boolean?, + val value: UByte?, val originalValue: UByte? ) class TestComplexNullableOptionalResponse( - val nullableIntWasNull: Boolean, - val nullableIntValue: UShort?, - val optionalIntWasPresent: Boolean, - val optionalIntValue: UShort?, - val nullableOptionalIntWasPresent: Boolean, - val nullableOptionalIntWasNull: Boolean?, - val nullableOptionalIntValue: UShort?, - val nullableStringWasNull: Boolean, - val nullableStringValue: String?, - val optionalStringWasPresent: Boolean, - val optionalStringValue: String?, - val nullableOptionalStringWasPresent: Boolean, - val nullableOptionalStringWasNull: Boolean?, - val nullableOptionalStringValue: String?, - val nullableStructWasNull: Boolean, - val nullableStructValue: UnitTestingClusterSimpleStruct?, - val optionalStructWasPresent: Boolean, - val optionalStructValue: UnitTestingClusterSimpleStruct?, - val nullableOptionalStructWasPresent: Boolean, - val nullableOptionalStructWasNull: Boolean?, - val nullableOptionalStructValue: UnitTestingClusterSimpleStruct?, - val nullableListWasNull: Boolean, - val nullableListValue: List?, - val optionalListWasPresent: Boolean, - val optionalListValue: List?, - val nullableOptionalListWasPresent: Boolean, - val nullableOptionalListWasNull: Boolean?, + val nullableIntWasNull: Boolean, + val nullableIntValue: UShort?, + val optionalIntWasPresent: Boolean, + val optionalIntValue: UShort?, + val nullableOptionalIntWasPresent: Boolean, + val nullableOptionalIntWasNull: Boolean?, + val nullableOptionalIntValue: UShort?, + val nullableStringWasNull: Boolean, + val nullableStringValue: String?, + val optionalStringWasPresent: Boolean, + val optionalStringValue: String?, + val nullableOptionalStringWasPresent: Boolean, + val nullableOptionalStringWasNull: Boolean?, + val nullableOptionalStringValue: String?, + val nullableStructWasNull: Boolean, + val nullableStructValue: UnitTestingClusterSimpleStruct?, + val optionalStructWasPresent: Boolean, + val optionalStructValue: UnitTestingClusterSimpleStruct?, + val nullableOptionalStructWasPresent: Boolean, + val nullableOptionalStructWasNull: Boolean?, + val nullableOptionalStructValue: UnitTestingClusterSimpleStruct?, + val nullableListWasNull: Boolean, + val nullableListValue: List?, + val optionalListWasPresent: Boolean, + val optionalListValue: List?, + val nullableOptionalListWasPresent: Boolean, + val nullableOptionalListWasNull: Boolean?, val nullableOptionalListValue: List? ) - class SimpleStructResponse(val arg1: UnitTestingClusterSimpleStruct) - - class TestEmitTestEventResponse(val value: ULong) + class SimpleStructResponse( + val arg1: UnitTestingClusterSimpleStruct + ) - class TestEmitTestFabricScopedEventResponse(val value: ULong) + class TestEmitTestEventResponse( + val value: ULong + ) - class TestBatchHelperResponse(val buffer: ByteArray) + class TestEmitTestFabricScopedEventResponse( + val value: ULong + ) - class ListInt8uAttribute(val value: List) + class TestBatchHelperResponse( + val buffer: ByteArray + ) +class ListInt8uAttribute( + val value: List + ) sealed class ListInt8uAttributeSubscriptionState { - data class Success(val value: List) : ListInt8uAttributeSubscriptionState() - + data class Success( + val value: List + ) : ListInt8uAttributeSubscriptionState() + data class Error(val exception: Exception) : ListInt8uAttributeSubscriptionState() - object SubscriptionEstablished : ListInt8uAttributeSubscriptionState() - } - - class ListOctetStringAttribute(val value: List) + object SubscriptionEstablished : ListInt8uAttributeSubscriptionState() + } +class ListOctetStringAttribute( + val value: List + ) sealed class ListOctetStringAttributeSubscriptionState { - data class Success(val value: List) : ListOctetStringAttributeSubscriptionState() - + data class Success( + val value: List + ) : ListOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : ListOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : ListOctetStringAttributeSubscriptionState() - } - - class ListStructOctetStringAttribute(val value: List) + object SubscriptionEstablished : ListOctetStringAttributeSubscriptionState() + } +class ListStructOctetStringAttribute( + val value: List + ) sealed class ListStructOctetStringAttributeSubscriptionState { - data class Success(val value: List) : - ListStructOctetStringAttributeSubscriptionState() - + data class Success( + val value: List + ) : ListStructOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : ListStructOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : ListStructOctetStringAttributeSubscriptionState() - } - - class ListNullablesAndOptionalsStructAttribute( + object SubscriptionEstablished : ListStructOctetStringAttributeSubscriptionState() + } +class ListNullablesAndOptionalsStructAttribute( val value: List ) sealed class ListNullablesAndOptionalsStructAttributeSubscriptionState { - data class Success(val value: List) : - ListNullablesAndOptionalsStructAttributeSubscriptionState() - - data class Error(val exception: Exception) : - ListNullablesAndOptionalsStructAttributeSubscriptionState() - - object SubscriptionEstablished : ListNullablesAndOptionalsStructAttributeSubscriptionState() - } - - class StructAttrAttribute(val value: UnitTestingClusterSimpleStruct) + data class Success( + val value: List + ) : ListNullablesAndOptionalsStructAttributeSubscriptionState() + + data class Error(val exception: Exception) : ListNullablesAndOptionalsStructAttributeSubscriptionState() + + object SubscriptionEstablished : ListNullablesAndOptionalsStructAttributeSubscriptionState() + } +class StructAttrAttribute( + val value: UnitTestingClusterSimpleStruct + ) sealed class StructAttrAttributeSubscriptionState { - data class Success(val value: UnitTestingClusterSimpleStruct) : - StructAttrAttributeSubscriptionState() - + data class Success( + val value: UnitTestingClusterSimpleStruct + ) : StructAttrAttributeSubscriptionState() + data class Error(val exception: Exception) : StructAttrAttributeSubscriptionState() - object SubscriptionEstablished : StructAttrAttributeSubscriptionState() - } - - class ListLongOctetStringAttribute(val value: List) + object SubscriptionEstablished : StructAttrAttributeSubscriptionState() + } +class ListLongOctetStringAttribute( + val value: List + ) sealed class ListLongOctetStringAttributeSubscriptionState { - data class Success(val value: List) : - ListLongOctetStringAttributeSubscriptionState() - + data class Success( + val value: List + ) : ListLongOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : ListLongOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : ListLongOctetStringAttributeSubscriptionState() - } - - class ListFabricScopedAttribute(val value: List) + object SubscriptionEstablished : ListLongOctetStringAttributeSubscriptionState() + } +class ListFabricScopedAttribute( + val value: List + ) sealed class ListFabricScopedAttributeSubscriptionState { - data class Success(val value: List) : - ListFabricScopedAttributeSubscriptionState() - + data class Success( + val value: List + ) : ListFabricScopedAttributeSubscriptionState() + data class Error(val exception: Exception) : ListFabricScopedAttributeSubscriptionState() - object SubscriptionEstablished : ListFabricScopedAttributeSubscriptionState() - } - - class NullableBooleanAttribute(val value: Boolean?) + object SubscriptionEstablished : ListFabricScopedAttributeSubscriptionState() + } +class NullableBooleanAttribute( + val value: Boolean? + ) sealed class NullableBooleanAttributeSubscriptionState { - data class Success(val value: Boolean?) : NullableBooleanAttributeSubscriptionState() - + data class Success( + val value: Boolean? + ) : NullableBooleanAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBooleanAttributeSubscriptionState() - object SubscriptionEstablished : NullableBooleanAttributeSubscriptionState() - } - - class NullableBitmap8Attribute(val value: UByte?) + object SubscriptionEstablished : NullableBooleanAttributeSubscriptionState() + } +class NullableBitmap8Attribute( + val value: UByte? + ) sealed class NullableBitmap8AttributeSubscriptionState { - data class Success(val value: UByte?) : NullableBitmap8AttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : NullableBitmap8AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap8AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap8AttributeSubscriptionState() - } - - class NullableBitmap16Attribute(val value: UShort?) + object SubscriptionEstablished : NullableBitmap8AttributeSubscriptionState() + } +class NullableBitmap16Attribute( + val value: UShort? + ) sealed class NullableBitmap16AttributeSubscriptionState { - data class Success(val value: UShort?) : NullableBitmap16AttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : NullableBitmap16AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap16AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap16AttributeSubscriptionState() - } - - class NullableBitmap32Attribute(val value: UInt?) + object SubscriptionEstablished : NullableBitmap16AttributeSubscriptionState() + } +class NullableBitmap32Attribute( + val value: UInt? + ) sealed class NullableBitmap32AttributeSubscriptionState { - data class Success(val value: UInt?) : NullableBitmap32AttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : NullableBitmap32AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap32AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap32AttributeSubscriptionState() - } - - class NullableBitmap64Attribute(val value: ULong?) + object SubscriptionEstablished : NullableBitmap32AttributeSubscriptionState() + } +class NullableBitmap64Attribute( + val value: ULong? + ) sealed class NullableBitmap64AttributeSubscriptionState { - data class Success(val value: ULong?) : NullableBitmap64AttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : NullableBitmap64AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap64AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap64AttributeSubscriptionState() - } - - class NullableInt8uAttribute(val value: UByte?) + object SubscriptionEstablished : NullableBitmap64AttributeSubscriptionState() + } +class NullableInt8uAttribute( + val value: UByte? + ) sealed class NullableInt8uAttributeSubscriptionState { - data class Success(val value: UByte?) : NullableInt8uAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : NullableInt8uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt8uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt8uAttributeSubscriptionState() - } - - class NullableInt16uAttribute(val value: UShort?) + object SubscriptionEstablished : NullableInt8uAttributeSubscriptionState() + } +class NullableInt16uAttribute( + val value: UShort? + ) sealed class NullableInt16uAttributeSubscriptionState { - data class Success(val value: UShort?) : NullableInt16uAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : NullableInt16uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt16uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt16uAttributeSubscriptionState() - } - - class NullableInt24uAttribute(val value: UInt?) + object SubscriptionEstablished : NullableInt16uAttributeSubscriptionState() + } +class NullableInt24uAttribute( + val value: UInt? + ) sealed class NullableInt24uAttributeSubscriptionState { - data class Success(val value: UInt?) : NullableInt24uAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : NullableInt24uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt24uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt24uAttributeSubscriptionState() - } - - class NullableInt32uAttribute(val value: UInt?) + object SubscriptionEstablished : NullableInt24uAttributeSubscriptionState() + } +class NullableInt32uAttribute( + val value: UInt? + ) sealed class NullableInt32uAttributeSubscriptionState { - data class Success(val value: UInt?) : NullableInt32uAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : NullableInt32uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt32uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt32uAttributeSubscriptionState() - } - - class NullableInt40uAttribute(val value: ULong?) + object SubscriptionEstablished : NullableInt32uAttributeSubscriptionState() + } +class NullableInt40uAttribute( + val value: ULong? + ) sealed class NullableInt40uAttributeSubscriptionState { - data class Success(val value: ULong?) : NullableInt40uAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : NullableInt40uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt40uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt40uAttributeSubscriptionState() - } - - class NullableInt48uAttribute(val value: ULong?) + object SubscriptionEstablished : NullableInt40uAttributeSubscriptionState() + } +class NullableInt48uAttribute( + val value: ULong? + ) sealed class NullableInt48uAttributeSubscriptionState { - data class Success(val value: ULong?) : NullableInt48uAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : NullableInt48uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt48uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt48uAttributeSubscriptionState() - } - - class NullableInt56uAttribute(val value: ULong?) + object SubscriptionEstablished : NullableInt48uAttributeSubscriptionState() + } +class NullableInt56uAttribute( + val value: ULong? + ) sealed class NullableInt56uAttributeSubscriptionState { - data class Success(val value: ULong?) : NullableInt56uAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : NullableInt56uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt56uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt56uAttributeSubscriptionState() - } - - class NullableInt64uAttribute(val value: ULong?) + object SubscriptionEstablished : NullableInt56uAttributeSubscriptionState() + } +class NullableInt64uAttribute( + val value: ULong? + ) sealed class NullableInt64uAttributeSubscriptionState { - data class Success(val value: ULong?) : NullableInt64uAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : NullableInt64uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt64uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt64uAttributeSubscriptionState() - } - - class NullableInt8sAttribute(val value: Byte?) + object SubscriptionEstablished : NullableInt64uAttributeSubscriptionState() + } +class NullableInt8sAttribute( + val value: Byte? + ) sealed class NullableInt8sAttributeSubscriptionState { - data class Success(val value: Byte?) : NullableInt8sAttributeSubscriptionState() - + data class Success( + val value: Byte? + ) : NullableInt8sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt8sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt8sAttributeSubscriptionState() - } - - class NullableInt16sAttribute(val value: Short?) + object SubscriptionEstablished : NullableInt8sAttributeSubscriptionState() + } +class NullableInt16sAttribute( + val value: Short? + ) sealed class NullableInt16sAttributeSubscriptionState { - data class Success(val value: Short?) : NullableInt16sAttributeSubscriptionState() - + data class Success( + val value: Short? + ) : NullableInt16sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt16sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt16sAttributeSubscriptionState() - } - - class NullableInt24sAttribute(val value: Int?) + object SubscriptionEstablished : NullableInt16sAttributeSubscriptionState() + } +class NullableInt24sAttribute( + val value: Int? + ) sealed class NullableInt24sAttributeSubscriptionState { - data class Success(val value: Int?) : NullableInt24sAttributeSubscriptionState() - + data class Success( + val value: Int? + ) : NullableInt24sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt24sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt24sAttributeSubscriptionState() - } - - class NullableInt32sAttribute(val value: Int?) + object SubscriptionEstablished : NullableInt24sAttributeSubscriptionState() + } +class NullableInt32sAttribute( + val value: Int? + ) sealed class NullableInt32sAttributeSubscriptionState { - data class Success(val value: Int?) : NullableInt32sAttributeSubscriptionState() - + data class Success( + val value: Int? + ) : NullableInt32sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt32sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt32sAttributeSubscriptionState() - } - - class NullableInt40sAttribute(val value: Long?) + object SubscriptionEstablished : NullableInt32sAttributeSubscriptionState() + } +class NullableInt40sAttribute( + val value: Long? + ) sealed class NullableInt40sAttributeSubscriptionState { - data class Success(val value: Long?) : NullableInt40sAttributeSubscriptionState() - + data class Success( + val value: Long? + ) : NullableInt40sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt40sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt40sAttributeSubscriptionState() - } - - class NullableInt48sAttribute(val value: Long?) + object SubscriptionEstablished : NullableInt40sAttributeSubscriptionState() + } +class NullableInt48sAttribute( + val value: Long? + ) sealed class NullableInt48sAttributeSubscriptionState { - data class Success(val value: Long?) : NullableInt48sAttributeSubscriptionState() - + data class Success( + val value: Long? + ) : NullableInt48sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt48sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt48sAttributeSubscriptionState() - } - - class NullableInt56sAttribute(val value: Long?) + object SubscriptionEstablished : NullableInt48sAttributeSubscriptionState() + } +class NullableInt56sAttribute( + val value: Long? + ) sealed class NullableInt56sAttributeSubscriptionState { - data class Success(val value: Long?) : NullableInt56sAttributeSubscriptionState() - + data class Success( + val value: Long? + ) : NullableInt56sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt56sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt56sAttributeSubscriptionState() - } - - class NullableInt64sAttribute(val value: Long?) + object SubscriptionEstablished : NullableInt56sAttributeSubscriptionState() + } +class NullableInt64sAttribute( + val value: Long? + ) sealed class NullableInt64sAttributeSubscriptionState { - data class Success(val value: Long?) : NullableInt64sAttributeSubscriptionState() - + data class Success( + val value: Long? + ) : NullableInt64sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt64sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt64sAttributeSubscriptionState() - } - - class NullableEnum8Attribute(val value: UByte?) + object SubscriptionEstablished : NullableInt64sAttributeSubscriptionState() + } +class NullableEnum8Attribute( + val value: UByte? + ) sealed class NullableEnum8AttributeSubscriptionState { - data class Success(val value: UByte?) : NullableEnum8AttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : NullableEnum8AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableEnum8AttributeSubscriptionState() - object SubscriptionEstablished : NullableEnum8AttributeSubscriptionState() - } - - class NullableEnum16Attribute(val value: UShort?) + object SubscriptionEstablished : NullableEnum8AttributeSubscriptionState() + } +class NullableEnum16Attribute( + val value: UShort? + ) sealed class NullableEnum16AttributeSubscriptionState { - data class Success(val value: UShort?) : NullableEnum16AttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : NullableEnum16AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableEnum16AttributeSubscriptionState() - object SubscriptionEstablished : NullableEnum16AttributeSubscriptionState() - } - - class NullableFloatSingleAttribute(val value: Float?) + object SubscriptionEstablished : NullableEnum16AttributeSubscriptionState() + } +class NullableFloatSingleAttribute( + val value: Float? + ) sealed class NullableFloatSingleAttributeSubscriptionState { - data class Success(val value: Float?) : NullableFloatSingleAttributeSubscriptionState() - + data class Success( + val value: Float? + ) : NullableFloatSingleAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableFloatSingleAttributeSubscriptionState() - object SubscriptionEstablished : NullableFloatSingleAttributeSubscriptionState() - } - - class NullableFloatDoubleAttribute(val value: Double?) + object SubscriptionEstablished : NullableFloatSingleAttributeSubscriptionState() + } +class NullableFloatDoubleAttribute( + val value: Double? + ) sealed class NullableFloatDoubleAttributeSubscriptionState { - data class Success(val value: Double?) : NullableFloatDoubleAttributeSubscriptionState() - + data class Success( + val value: Double? + ) : NullableFloatDoubleAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableFloatDoubleAttributeSubscriptionState() - object SubscriptionEstablished : NullableFloatDoubleAttributeSubscriptionState() - } - - class NullableOctetStringAttribute(val value: ByteArray?) + object SubscriptionEstablished : NullableFloatDoubleAttributeSubscriptionState() + } +class NullableOctetStringAttribute( + val value: ByteArray? + ) sealed class NullableOctetStringAttributeSubscriptionState { - data class Success(val value: ByteArray?) : NullableOctetStringAttributeSubscriptionState() - + data class Success( + val value: ByteArray? + ) : NullableOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : NullableOctetStringAttributeSubscriptionState() - } - - class NullableCharStringAttribute(val value: String?) + object SubscriptionEstablished : NullableOctetStringAttributeSubscriptionState() + } +class NullableCharStringAttribute( + val value: String? + ) sealed class NullableCharStringAttributeSubscriptionState { - data class Success(val value: String?) : NullableCharStringAttributeSubscriptionState() - + data class Success( + val value: String? + ) : NullableCharStringAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableCharStringAttributeSubscriptionState() - object SubscriptionEstablished : NullableCharStringAttributeSubscriptionState() - } - - class NullableEnumAttrAttribute(val value: UByte?) + object SubscriptionEstablished : NullableCharStringAttributeSubscriptionState() + } +class NullableEnumAttrAttribute( + val value: UByte? + ) sealed class NullableEnumAttrAttributeSubscriptionState { - data class Success(val value: UByte?) : NullableEnumAttrAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : NullableEnumAttrAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableEnumAttrAttributeSubscriptionState() - object SubscriptionEstablished : NullableEnumAttrAttributeSubscriptionState() - } - - class NullableStructAttribute(val value: UnitTestingClusterSimpleStruct?) + object SubscriptionEstablished : NullableEnumAttrAttributeSubscriptionState() + } +class NullableStructAttribute( + val value: UnitTestingClusterSimpleStruct? + ) sealed class NullableStructAttributeSubscriptionState { - data class Success(val value: UnitTestingClusterSimpleStruct?) : - NullableStructAttributeSubscriptionState() - + data class Success( + val value: UnitTestingClusterSimpleStruct? + ) : NullableStructAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableStructAttributeSubscriptionState() - object SubscriptionEstablished : NullableStructAttributeSubscriptionState() - } - - class NullableRangeRestrictedInt8uAttribute(val value: UByte?) + object SubscriptionEstablished : NullableStructAttributeSubscriptionState() + } +class NullableRangeRestrictedInt8uAttribute( + val value: UByte? + ) sealed class NullableRangeRestrictedInt8uAttributeSubscriptionState { - data class Success(val value: UByte?) : - NullableRangeRestrictedInt8uAttributeSubscriptionState() - - data class Error(val exception: Exception) : - NullableRangeRestrictedInt8uAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt8uAttributeSubscriptionState() - } - - class NullableRangeRestrictedInt8sAttribute(val value: Byte?) + data class Success( + val value: UByte? + ) : NullableRangeRestrictedInt8uAttributeSubscriptionState() + + data class Error(val exception: Exception) : NullableRangeRestrictedInt8uAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt8uAttributeSubscriptionState() + } +class NullableRangeRestrictedInt8sAttribute( + val value: Byte? + ) sealed class NullableRangeRestrictedInt8sAttributeSubscriptionState { - data class Success(val value: Byte?) : NullableRangeRestrictedInt8sAttributeSubscriptionState() - - data class Error(val exception: Exception) : - NullableRangeRestrictedInt8sAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt8sAttributeSubscriptionState() - } - - class NullableRangeRestrictedInt16uAttribute(val value: UShort?) + data class Success( + val value: Byte? + ) : NullableRangeRestrictedInt8sAttributeSubscriptionState() + + data class Error(val exception: Exception) : NullableRangeRestrictedInt8sAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt8sAttributeSubscriptionState() + } +class NullableRangeRestrictedInt16uAttribute( + val value: UShort? + ) sealed class NullableRangeRestrictedInt16uAttributeSubscriptionState { - data class Success(val value: UShort?) : - NullableRangeRestrictedInt16uAttributeSubscriptionState() - - data class Error(val exception: Exception) : - NullableRangeRestrictedInt16uAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt16uAttributeSubscriptionState() - } - - class NullableRangeRestrictedInt16sAttribute(val value: Short?) + data class Success( + val value: UShort? + ) : NullableRangeRestrictedInt16uAttributeSubscriptionState() + + data class Error(val exception: Exception) : NullableRangeRestrictedInt16uAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt16uAttributeSubscriptionState() + } +class NullableRangeRestrictedInt16sAttribute( + val value: Short? + ) sealed class NullableRangeRestrictedInt16sAttributeSubscriptionState { - data class Success(val value: Short?) : - NullableRangeRestrictedInt16sAttributeSubscriptionState() - - data class Error(val exception: Exception) : - NullableRangeRestrictedInt16sAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt16sAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + data class Success( + val value: Short? + ) : NullableRangeRestrictedInt16sAttributeSubscriptionState() + + data class Error(val exception: Exception) : NullableRangeRestrictedInt16sAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt16sAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun test(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -599,7 +742,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -617,7 +760,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -634,31 +777,39 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { - returnValue_decoded = tlvReader.getUByte(tag) - } else { + + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getUByte(tag)} + + + else { tlvReader.skipElement() } } + + if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } + tlvReader.exitContainer() - return TestSpecificResponse(returnValue_decoded) + return TestSpecificResponse( + returnValue_decoded + ) } suspend fun testUnknownCommand(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -672,11 +823,9 @@ class UnitTestingCluster(private val controller: MatterController, private val e logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun testAddArguments( - arg1: UByte, - arg2: UByte, - timedInvokeTimeout: Duration? = null - ): TestAddArgumentsResponse { + suspend fun testAddArguments(arg1: UByte + ,arg2: UByte + ,timedInvokeTimeout: Duration? = null): TestAddArgumentsResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -686,7 +835,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) val TAG_ARG2_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) tlvWriter.endStructure() val request: InvokeRequest = @@ -703,37 +852,43 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { - returnValue_decoded = tlvReader.getUByte(tag) - } else { + + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getUByte(tag)} + + + else { tlvReader.skipElement() } } + + if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } + tlvReader.exitContainer() - return TestAddArgumentsResponse(returnValue_decoded) + return TestAddArgumentsResponse( + returnValue_decoded + ) } - suspend fun testSimpleArgumentRequest( - arg1: Boolean, - timedInvokeTimeout: Duration? = null - ): TestSimpleArgumentResponse { + suspend fun testSimpleArgumentRequest(arg1: Boolean + ,timedInvokeTimeout: Duration? = null): TestSimpleArgumentResponse { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) tlvWriter.endStructure() val request: InvokeRequest = @@ -750,35 +905,41 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: Boolean? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { - returnValue_decoded = tlvReader.getBoolean(tag) - } else { + + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getBoolean(tag)} + + + else { tlvReader.skipElement() } } + + if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } + tlvReader.exitContainer() - return TestSimpleArgumentResponse(returnValue_decoded) + return TestSimpleArgumentResponse( + returnValue_decoded + ) } - suspend fun testStructArrayArgumentRequest( - arg1: List, - arg2: List, - arg3: List, - arg4: List, - arg5: UByte, - arg6: Boolean, - timedInvokeTimeout: Duration? = null - ): TestStructArrayArgumentResponse { + suspend fun testStructArrayArgumentRequest(arg1: List + ,arg2: List + ,arg3: List + ,arg4: List + ,arg5: UByte + ,arg6: Boolean + ,timedInvokeTimeout: Duration? = null): TestStructArrayArgumentResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -786,37 +947,37 @@ class UnitTestingCluster(private val controller: MatterController, private val e val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_ARG2_REQ: Int = 1 tlvWriter.startArray(ContextSpecificTag(TAG_ARG2_REQ)) - for (item in arg2.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg2.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_ARG3_REQ: Int = 2 tlvWriter.startArray(ContextSpecificTag(TAG_ARG3_REQ)) - for (item in arg3.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg3.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val TAG_ARG4_REQ: Int = 3 tlvWriter.startArray(ContextSpecificTag(TAG_ARG4_REQ)) - for (item in arg4.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg4.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val TAG_ARG5_REQ: Int = 4 tlvWriter.put(ContextSpecificTag(TAG_ARG5_REQ), arg5) val TAG_ARG6_REQ: Int = 5 - tlvWriter.put(ContextSpecificTag(TAG_ARG6_REQ), arg6) + tlvWriter.put(ContextSpecificTag(TAG_ARG6_REQ), arg6) tlvWriter.endStructure() val request: InvokeRequest = @@ -833,103 +994,100 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: List? = null - + val TAG_ARG2: Int = 1 var arg2_decoded: List? = null - + val TAG_ARG3: Int = 2 var arg3_decoded: List? = null - + val TAG_ARG4: Int = 3 var arg4_decoded: List? = null - + val TAG_ARG5: Int = 4 var arg5_decoded: UByte? = null - + val TAG_ARG6: Int = 5 var arg6_decoded: Boolean? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_ARG1)) { - arg1_decoded = - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } - - if (tag == ContextSpecificTag(TAG_ARG2)) { - arg2_decoded = - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } - - if (tag == ContextSpecificTag(TAG_ARG3)) { - arg3_decoded = - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } - - if (tag == ContextSpecificTag(TAG_ARG4)) { - arg4_decoded = - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getBoolean(AnonymousTag)) - } - tlvReader.exitContainer() - } - } - - if (tag == ContextSpecificTag(TAG_ARG5)) { - arg5_decoded = tlvReader.getUByte(tag) - } - - if (tag == ContextSpecificTag(TAG_ARG6)) { - arg6_decoded = tlvReader.getBoolean(tag) - } else { + + if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }} + + if (tag == ContextSpecificTag(TAG_ARG2)) {arg2_decoded = buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }} + + if (tag == ContextSpecificTag(TAG_ARG3)) {arg3_decoded = buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + }} + + if (tag == ContextSpecificTag(TAG_ARG4)) {arg4_decoded = buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getBoolean(AnonymousTag)) + } + tlvReader.exitContainer() + }} + + if (tag == ContextSpecificTag(TAG_ARG5)) {arg5_decoded = tlvReader.getUByte(tag)} + + if (tag == ContextSpecificTag(TAG_ARG6)) {arg6_decoded = tlvReader.getBoolean(tag)} + + + else { tlvReader.skipElement() } } + + if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } - + + if (arg2_decoded == null) { - throw IllegalStateException("arg2 not found in TLV") + throw IllegalStateException("arg2 not found in TLV") } - + + if (arg3_decoded == null) { - throw IllegalStateException("arg3 not found in TLV") + throw IllegalStateException("arg3 not found in TLV") } - + + if (arg4_decoded == null) { - throw IllegalStateException("arg4 not found in TLV") + throw IllegalStateException("arg4 not found in TLV") } - + + if (arg5_decoded == null) { - throw IllegalStateException("arg5 not found in TLV") + throw IllegalStateException("arg5 not found in TLV") } - + + if (arg6_decoded == null) { - throw IllegalStateException("arg6 not found in TLV") + throw IllegalStateException("arg6 not found in TLV") } + tlvReader.exitContainer() @@ -943,17 +1101,15 @@ class UnitTestingCluster(private val controller: MatterController, private val e ) } - suspend fun testStructArgumentRequest( - arg1: UnitTestingClusterSimpleStruct, - timedInvokeTimeout: Duration? = null - ): BooleanResponse { + suspend fun testStructArgumentRequest(arg1: UnitTestingClusterSimpleStruct + ,timedInvokeTimeout: Duration? = null): BooleanResponse { val commandId: UInt = 7u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -970,37 +1126,43 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_VALUE)) { - value_decoded = tlvReader.getBoolean(tag) - } else { + + if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} + + + else { tlvReader.skipElement() } } + + if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } + tlvReader.exitContainer() - return BooleanResponse(value_decoded) + return BooleanResponse( + value_decoded + ) } - suspend fun testNestedStructArgumentRequest( - arg1: UnitTestingClusterNestedStruct, - timedInvokeTimeout: Duration? = null - ): BooleanResponse { + suspend fun testNestedStructArgumentRequest(arg1: UnitTestingClusterNestedStruct + ,timedInvokeTimeout: Duration? = null): BooleanResponse { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -1017,30 +1179,36 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_VALUE)) { - value_decoded = tlvReader.getBoolean(tag) - } else { + + if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} + + + else { tlvReader.skipElement() } } + + if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } + tlvReader.exitContainer() - return BooleanResponse(value_decoded) + return BooleanResponse( + value_decoded + ) } - suspend fun testListStructArgumentRequest( - arg1: List, - timedInvokeTimeout: Duration? = null - ): BooleanResponse { + suspend fun testListStructArgumentRequest(arg1: List + ,timedInvokeTimeout: Duration? = null): BooleanResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -1048,10 +1216,10 @@ class UnitTestingCluster(private val controller: MatterController, private val e val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1068,30 +1236,36 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_VALUE)) { - value_decoded = tlvReader.getBoolean(tag) - } else { + + if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} + + + else { tlvReader.skipElement() } } + + if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } + tlvReader.exitContainer() - return BooleanResponse(value_decoded) + return BooleanResponse( + value_decoded + ) } - suspend fun testListInt8UArgumentRequest( - arg1: List, - timedInvokeTimeout: Duration? = null - ): BooleanResponse { + suspend fun testListInt8UArgumentRequest(arg1: List + ,timedInvokeTimeout: Duration? = null): BooleanResponse { val commandId: UInt = 10u val tlvWriter = TlvWriter() @@ -1099,10 +1273,10 @@ class UnitTestingCluster(private val controller: MatterController, private val e val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1119,37 +1293,43 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_VALUE)) { - value_decoded = tlvReader.getBoolean(tag) - } else { + + if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} + + + else { tlvReader.skipElement() } } + + if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } + tlvReader.exitContainer() - return BooleanResponse(value_decoded) + return BooleanResponse( + value_decoded + ) } - suspend fun testNestedStructListArgumentRequest( - arg1: UnitTestingClusterNestedStructList, - timedInvokeTimeout: Duration? = null - ): BooleanResponse { + suspend fun testNestedStructListArgumentRequest(arg1: UnitTestingClusterNestedStructList + ,timedInvokeTimeout: Duration? = null): BooleanResponse { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -1166,30 +1346,36 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_VALUE)) { - value_decoded = tlvReader.getBoolean(tag) - } else { + + if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} + + + else { tlvReader.skipElement() } } + + if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } + tlvReader.exitContainer() - return BooleanResponse(value_decoded) + return BooleanResponse( + value_decoded + ) } - suspend fun testListNestedStructListArgumentRequest( - arg1: List, - timedInvokeTimeout: Duration? = null - ): BooleanResponse { + suspend fun testListNestedStructListArgumentRequest(arg1: List + ,timedInvokeTimeout: Duration? = null): BooleanResponse { val commandId: UInt = 12u val tlvWriter = TlvWriter() @@ -1197,10 +1383,10 @@ class UnitTestingCluster(private val controller: MatterController, private val e val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1217,30 +1403,36 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_VALUE)) { - value_decoded = tlvReader.getBoolean(tag) - } else { + + if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} + + + else { tlvReader.skipElement() } } + + if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } + tlvReader.exitContainer() - return BooleanResponse(value_decoded) + return BooleanResponse( + value_decoded + ) } - suspend fun testListInt8UReverseRequest( - arg1: List, - timedInvokeTimeout: Duration? = null - ): TestListInt8UReverseResponse { + suspend fun testListInt8UReverseRequest(arg1: List + ,timedInvokeTimeout: Duration? = null): TestListInt8UReverseResponse { val commandId: UInt = 13u val tlvWriter = TlvWriter() @@ -1248,10 +1440,10 @@ class UnitTestingCluster(private val controller: MatterController, private val e val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1268,38 +1460,43 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: List? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_ARG1)) { - arg1_decoded = - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { + + if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + }} + + + else { tlvReader.skipElement() } } + + if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } + tlvReader.exitContainer() - return TestListInt8UReverseResponse(arg1_decoded) + return TestListInt8UReverseResponse( + arg1_decoded + ) } - suspend fun testEnumsRequest( - arg1: UShort, - arg2: UByte, - timedInvokeTimeout: Duration? = null - ): TestEnumsResponse { + suspend fun testEnumsRequest(arg1: UShort + ,arg2: UByte + ,timedInvokeTimeout: Duration? = null): TestEnumsResponse { val commandId: UInt = 14u val tlvWriter = TlvWriter() @@ -1309,7 +1506,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) val TAG_ARG2_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) tlvWriter.endStructure() val request: InvokeRequest = @@ -1326,48 +1523,56 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: UShort? = null - + val TAG_ARG2: Int = 1 var arg2_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_ARG1)) { - arg1_decoded = tlvReader.getUShort(tag) - } + + if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = tlvReader.getUShort(tag)} + + if (tag == ContextSpecificTag(TAG_ARG2)) {arg2_decoded = tlvReader.getUByte(tag)} + - if (tag == ContextSpecificTag(TAG_ARG2)) { - arg2_decoded = tlvReader.getUByte(tag) - } else { + else { tlvReader.skipElement() } } + + if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } - + + if (arg2_decoded == null) { - throw IllegalStateException("arg2 not found in TLV") + throw IllegalStateException("arg2 not found in TLV") } + tlvReader.exitContainer() - return TestEnumsResponse(arg1_decoded, arg2_decoded) + return TestEnumsResponse( + arg1_decoded, + arg2_decoded + ) } - suspend fun testNullableOptionalRequest( - arg1: UByte?, - timedInvokeTimeout: Duration? = null - ): TestNullableOptionalResponse { + suspend fun testNullableOptionalRequest(arg1: UByte? + ,timedInvokeTimeout: Duration? = null): TestNullableOptionalResponse { val commandId: UInt = 15u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1?.let { tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) } + arg1?.let { + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1384,76 +1589,82 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_WAS_PRESENT: Int = 0 var wasPresent_decoded: Boolean? = null - + val TAG_WAS_NULL: Int = 1 var wasNull_decoded: Boolean? = null - + val TAG_VALUE: Int = 2 var value_decoded: UByte? = null - + val TAG_ORIGINAL_VALUE: Int = 3 var originalValue_decoded: UByte? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_WAS_PRESENT)) { - wasPresent_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_WAS_NULL)) { - wasNull_decoded = + + if (tag == ContextSpecificTag(TAG_WAS_PRESENT)) {wasPresent_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_WAS_NULL)) {wasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_VALUE)) { - value_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_ORIGINAL_VALUE)) { - originalValue_decoded = + tlvReader.getUByte(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_ORIGINAL_VALUE)) {originalValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } else { - tlvReader.getNull(tag) - null - } - } - } else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } else { + tlvReader.getNull(tag) + null + } + }} + + + else { tlvReader.skipElement() } } + + if (wasPresent_decoded == null) { - throw IllegalStateException("wasPresent not found in TLV") + throw IllegalStateException("wasPresent not found in TLV") } + + + + + + + tlvReader.exitContainer() @@ -1465,31 +1676,33 @@ class UnitTestingCluster(private val controller: MatterController, private val e ) } - suspend fun testComplexNullableOptionalRequest( - nullableInt: UShort?, - optionalInt: UShort?, - nullableOptionalInt: UShort?, - nullableString: String?, - optionalString: String?, - nullableOptionalString: String?, - nullableStruct: UnitTestingClusterSimpleStruct?, - optionalStruct: UnitTestingClusterSimpleStruct?, - nullableOptionalStruct: UnitTestingClusterSimpleStruct?, - nullableList: List?, - optionalList: List?, - nullableOptionalList: List?, - timedInvokeTimeout: Duration? = null - ): TestComplexNullableOptionalResponse { + suspend fun testComplexNullableOptionalRequest(nullableInt: UShort? + ,optionalInt: UShort? + ,nullableOptionalInt: UShort? + ,nullableString: String? + ,optionalString: String? + ,nullableOptionalString: String? + ,nullableStruct: UnitTestingClusterSimpleStruct? + ,optionalStruct: UnitTestingClusterSimpleStruct? + ,nullableOptionalStruct: UnitTestingClusterSimpleStruct? + ,nullableList: List? + ,optionalList: List? + ,nullableOptionalList: List? + ,timedInvokeTimeout: Duration? = null): TestComplexNullableOptionalResponse { val commandId: UInt = 16u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NULLABLE_INT_REQ: Int = 0 - nullableInt?.let { tlvWriter.put(ContextSpecificTag(TAG_NULLABLE_INT_REQ), nullableInt) } + nullableInt?.let { + tlvWriter.put(ContextSpecificTag(TAG_NULLABLE_INT_REQ), nullableInt) + } val TAG_OPTIONAL_INT_REQ: Int = 1 - optionalInt?.let { tlvWriter.put(ContextSpecificTag(TAG_OPTIONAL_INT_REQ), optionalInt) } + optionalInt?.let { + tlvWriter.put(ContextSpecificTag(TAG_OPTIONAL_INT_REQ), optionalInt) + } val TAG_NULLABLE_OPTIONAL_INT_REQ: Int = 2 nullableOptionalInt?.let { @@ -1551,7 +1764,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvWriter.put(AnonymousTag, item) } tlvWriter.endArray() - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1568,431 +1781,426 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_NULLABLE_INT_WAS_NULL: Int = 0 var nullableIntWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_INT_VALUE: Int = 1 var nullableIntValue_decoded: UShort? = null - + val TAG_OPTIONAL_INT_WAS_PRESENT: Int = 2 var optionalIntWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_INT_VALUE: Int = 3 var optionalIntValue_decoded: UShort? = null - + val TAG_NULLABLE_OPTIONAL_INT_WAS_PRESENT: Int = 4 var nullableOptionalIntWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_INT_WAS_NULL: Int = 5 var nullableOptionalIntWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_INT_VALUE: Int = 6 var nullableOptionalIntValue_decoded: UShort? = null - + val TAG_NULLABLE_STRING_WAS_NULL: Int = 7 var nullableStringWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_STRING_VALUE: Int = 8 var nullableStringValue_decoded: String? = null - + val TAG_OPTIONAL_STRING_WAS_PRESENT: Int = 9 var optionalStringWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_STRING_VALUE: Int = 10 var optionalStringValue_decoded: String? = null - + val TAG_NULLABLE_OPTIONAL_STRING_WAS_PRESENT: Int = 11 var nullableOptionalStringWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRING_WAS_NULL: Int = 12 var nullableOptionalStringWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRING_VALUE: Int = 13 var nullableOptionalStringValue_decoded: String? = null - + val TAG_NULLABLE_STRUCT_WAS_NULL: Int = 14 var nullableStructWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_STRUCT_VALUE: Int = 15 var nullableStructValue_decoded: UnitTestingClusterSimpleStruct? = null - + val TAG_OPTIONAL_STRUCT_WAS_PRESENT: Int = 16 var optionalStructWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_STRUCT_VALUE: Int = 17 var optionalStructValue_decoded: UnitTestingClusterSimpleStruct? = null - + val TAG_NULLABLE_OPTIONAL_STRUCT_WAS_PRESENT: Int = 18 var nullableOptionalStructWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRUCT_WAS_NULL: Int = 19 var nullableOptionalStructWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRUCT_VALUE: Int = 20 var nullableOptionalStructValue_decoded: UnitTestingClusterSimpleStruct? = null - + val TAG_NULLABLE_LIST_WAS_NULL: Int = 21 var nullableListWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_LIST_VALUE: Int = 22 var nullableListValue_decoded: List? = null - + val TAG_OPTIONAL_LIST_WAS_PRESENT: Int = 23 var optionalListWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_LIST_VALUE: Int = 24 var optionalListValue_decoded: List? = null - + val TAG_NULLABLE_OPTIONAL_LIST_WAS_PRESENT: Int = 25 var nullableOptionalListWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_LIST_WAS_NULL: Int = 26 var nullableOptionalListWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_LIST_VALUE: Int = 27 var nullableOptionalListValue_decoded: List? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_NULLABLE_INT_WAS_NULL)) { - nullableIntWasNull_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_INT_VALUE)) { - nullableIntValue_decoded = + + if (tag == ContextSpecificTag(TAG_NULLABLE_INT_WAS_NULL)) {nullableIntWasNull_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_NULLABLE_INT_VALUE)) {nullableIntValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_WAS_PRESENT)) { - optionalIntWasPresent_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_VALUE)) { - optionalIntValue_decoded = + tlvReader.getUShort(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_WAS_PRESENT)) {optionalIntWasPresent_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_VALUE)) {optionalIntValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_PRESENT)) { - nullableOptionalIntWasPresent_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_NULL)) { - nullableOptionalIntWasNull_decoded = + tlvReader.getUShort(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_PRESENT)) {nullableOptionalIntWasPresent_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_NULL)) {nullableOptionalIntWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_VALUE)) { - nullableOptionalIntValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_VALUE)) {nullableOptionalIntValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_WAS_NULL)) { - nullableStringWasNull_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_VALUE)) { - nullableStringValue_decoded = + tlvReader.getUShort(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_WAS_NULL)) {nullableStringWasNull_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_VALUE)) {nullableStringValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_WAS_PRESENT)) { - optionalStringWasPresent_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_VALUE)) { - optionalStringValue_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_WAS_PRESENT)) {optionalStringWasPresent_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_VALUE)) {optionalStringValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_PRESENT)) { - nullableOptionalStringWasPresent_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_NULL)) { - nullableOptionalStringWasNull_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_PRESENT)) {nullableOptionalStringWasPresent_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_NULL)) {nullableOptionalStringWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_VALUE)) { - nullableOptionalStringValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_VALUE)) {nullableOptionalStringValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_WAS_NULL)) { - nullableStructWasNull_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_VALUE)) { - nullableStructValue_decoded = + tlvReader.getString(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_WAS_NULL)) {nullableStructWasNull_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_VALUE)) {nullableStructValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_WAS_PRESENT)) { - optionalStructWasPresent_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_VALUE)) { - optionalStructValue_decoded = + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_WAS_PRESENT)) {optionalStructWasPresent_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_VALUE)) {optionalStructValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_PRESENT)) { - nullableOptionalStructWasPresent_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_NULL)) { - nullableOptionalStructWasNull_decoded = + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_PRESENT)) {nullableOptionalStructWasPresent_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_NULL)) {nullableOptionalStructWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_VALUE)) { - nullableOptionalStructValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_VALUE)) {nullableOptionalStructValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_WAS_NULL)) { - nullableListWasNull_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_VALUE)) { - nullableListValue_decoded = + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_WAS_NULL)) {nullableListWasNull_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_VALUE)) {nullableListValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_WAS_PRESENT)) { - optionalListWasPresent_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_VALUE)) { - optionalListValue_decoded = + buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_WAS_PRESENT)) {optionalListWasPresent_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_VALUE)) {optionalListValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_PRESENT)) { - nullableOptionalListWasPresent_decoded = tlvReader.getBoolean(tag) - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_NULL)) { - nullableOptionalListWasNull_decoded = + buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_PRESENT)) {nullableOptionalListWasPresent_decoded = tlvReader.getBoolean(tag)} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_NULL)) {nullableOptionalListWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - } - } - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_VALUE)) { - nullableOptionalListValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + }} + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_VALUE)) {nullableOptionalListValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - } - } else { + buildList { + tlvReader.enterArray(tag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + }} + + + else { tlvReader.skipElement() } } + + if (nullableIntWasNull_decoded == null) { - throw IllegalStateException("nullableIntWasNull not found in TLV") + throw IllegalStateException("nullableIntWasNull not found in TLV") } - + + + + if (optionalIntWasPresent_decoded == null) { - throw IllegalStateException("optionalIntWasPresent not found in TLV") + throw IllegalStateException("optionalIntWasPresent not found in TLV") } - + + + + if (nullableOptionalIntWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalIntWasPresent not found in TLV") - } - + throw IllegalStateException("nullableOptionalIntWasPresent not found in TLV") + } + + + + + + if (nullableStringWasNull_decoded == null) { - throw IllegalStateException("nullableStringWasNull not found in TLV") + throw IllegalStateException("nullableStringWasNull not found in TLV") } - + + + + if (optionalStringWasPresent_decoded == null) { - throw IllegalStateException("optionalStringWasPresent not found in TLV") + throw IllegalStateException("optionalStringWasPresent not found in TLV") } - + + + + if (nullableOptionalStringWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalStringWasPresent not found in TLV") - } - + throw IllegalStateException("nullableOptionalStringWasPresent not found in TLV") + } + + + + + + if (nullableStructWasNull_decoded == null) { - throw IllegalStateException("nullableStructWasNull not found in TLV") + throw IllegalStateException("nullableStructWasNull not found in TLV") } - + + + + if (optionalStructWasPresent_decoded == null) { - throw IllegalStateException("optionalStructWasPresent not found in TLV") + throw IllegalStateException("optionalStructWasPresent not found in TLV") } - + + + + if (nullableOptionalStructWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalStructWasPresent not found in TLV") - } - + throw IllegalStateException("nullableOptionalStructWasPresent not found in TLV") + } + + + + + + if (nullableListWasNull_decoded == null) { - throw IllegalStateException("nullableListWasNull not found in TLV") + throw IllegalStateException("nullableListWasNull not found in TLV") } - + + + + if (optionalListWasPresent_decoded == null) { - throw IllegalStateException("optionalListWasPresent not found in TLV") + throw IllegalStateException("optionalListWasPresent not found in TLV") } - + + + + if (nullableOptionalListWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalListWasPresent not found in TLV") + throw IllegalStateException("nullableOptionalListWasPresent not found in TLV") } + + + + + tlvReader.exitContainer() @@ -2028,17 +2236,15 @@ class UnitTestingCluster(private val controller: MatterController, private val e ) } - suspend fun simpleStructEchoRequest( - arg1: UnitTestingClusterSimpleStruct, - timedInvokeTimeout: Duration? = null - ): SimpleStructResponse { + suspend fun simpleStructEchoRequest(arg1: UnitTestingClusterSimpleStruct + ,timedInvokeTimeout: Duration? = null): SimpleStructResponse { val commandId: UInt = 17u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -2055,31 +2261,39 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: UnitTestingClusterSimpleStruct? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_ARG1)) { - arg1_decoded = UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) - } else { + + if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader)} + + + else { tlvReader.skipElement() } } + + if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } + tlvReader.exitContainer() - return SimpleStructResponse(arg1_decoded) + return SimpleStructResponse( + arg1_decoded + ) } suspend fun timedInvokeRequest(timedInvokeTimeout: Duration) { val commandId: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -2093,17 +2307,17 @@ class UnitTestingCluster(private val controller: MatterController, private val e logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun testSimpleOptionalArgumentRequest( - arg1: Boolean?, - timedInvokeTimeout: Duration? = null - ) { + suspend fun testSimpleOptionalArgumentRequest(arg1: Boolean? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 19u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1?.let { tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) } + arg1?.let { + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -2117,12 +2331,10 @@ class UnitTestingCluster(private val controller: MatterController, private val e logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun testEmitTestEventRequest( - arg1: UByte, - arg2: UByte, - arg3: Boolean, - timedInvokeTimeout: Duration? = null - ): TestEmitTestEventResponse { + suspend fun testEmitTestEventRequest(arg1: UByte + ,arg2: UByte + ,arg3: Boolean + ,timedInvokeTimeout: Duration? = null): TestEmitTestEventResponse { val commandId: UInt = 20u val tlvWriter = TlvWriter() @@ -2135,7 +2347,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) val TAG_ARG3_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_ARG3_REQ), arg3) + tlvWriter.put(ContextSpecificTag(TAG_ARG3_REQ), arg3) tlvWriter.endStructure() val request: InvokeRequest = @@ -2152,37 +2364,43 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: ULong? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_VALUE)) { - value_decoded = tlvReader.getULong(tag) - } else { + + if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getULong(tag)} + + + else { tlvReader.skipElement() } } + + if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } + tlvReader.exitContainer() - return TestEmitTestEventResponse(value_decoded) + return TestEmitTestEventResponse( + value_decoded + ) } - suspend fun testEmitTestFabricScopedEventRequest( - arg1: UByte, - timedInvokeTimeout: Duration? = null - ): TestEmitTestFabricScopedEventResponse { + suspend fun testEmitTestFabricScopedEventRequest(arg1: UByte + ,timedInvokeTimeout: Duration? = null): TestEmitTestFabricScopedEventResponse { val commandId: UInt = 21u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) tlvWriter.endStructure() val request: InvokeRequest = @@ -2199,48 +2417,51 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: ULong? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_VALUE)) { - value_decoded = tlvReader.getULong(tag) - } else { + + if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getULong(tag)} + + + else { tlvReader.skipElement() } } + + if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } + tlvReader.exitContainer() - return TestEmitTestFabricScopedEventResponse(value_decoded) + return TestEmitTestFabricScopedEventResponse( + value_decoded + ) } - suspend fun testBatchHelperRequest( - sleepBeforeResponseTimeMs: UShort, - sizeOfResponseBuffer: UShort, - fillCharacter: UByte, - timedInvokeTimeout: Duration? = null - ): TestBatchHelperResponse { + suspend fun testBatchHelperRequest(sleepBeforeResponseTimeMs: UShort + ,sizeOfResponseBuffer: UShort + ,fillCharacter: UByte + ,timedInvokeTimeout: Duration? = null): TestBatchHelperResponse { val commandId: UInt = 22u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ: Int = 0 - tlvWriter.put( - ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), - sleepBeforeResponseTimeMs - ) + tlvWriter.put(ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), sleepBeforeResponseTimeMs) val TAG_SIZE_OF_RESPONSE_BUFFER_REQ: Int = 1 tlvWriter.put(ContextSpecificTag(TAG_SIZE_OF_RESPONSE_BUFFER_REQ), sizeOfResponseBuffer) val TAG_FILL_CHARACTER_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) + tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) tlvWriter.endStructure() val request: InvokeRequest = @@ -2257,48 +2478,51 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_BUFFER: Int = 0 var buffer_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_BUFFER)) { - buffer_decoded = tlvReader.getByteArray(tag) - } else { + + if (tag == ContextSpecificTag(TAG_BUFFER)) {buffer_decoded = tlvReader.getByteArray(tag)} + + + else { tlvReader.skipElement() } } + + if (buffer_decoded == null) { - throw IllegalStateException("buffer not found in TLV") + throw IllegalStateException("buffer not found in TLV") } + tlvReader.exitContainer() - return TestBatchHelperResponse(buffer_decoded) + return TestBatchHelperResponse( + buffer_decoded + ) } - suspend fun testSecondBatchHelperRequest( - sleepBeforeResponseTimeMs: UShort, - sizeOfResponseBuffer: UShort, - fillCharacter: UByte, - timedInvokeTimeout: Duration? = null - ): TestBatchHelperResponse { + suspend fun testSecondBatchHelperRequest(sleepBeforeResponseTimeMs: UShort + ,sizeOfResponseBuffer: UShort + ,fillCharacter: UByte + ,timedInvokeTimeout: Duration? = null): TestBatchHelperResponse { val commandId: UInt = 23u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ: Int = 0 - tlvWriter.put( - ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), - sleepBeforeResponseTimeMs - ) + tlvWriter.put(ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), sleepBeforeResponseTimeMs) val TAG_SIZE_OF_RESPONSE_BUFFER_REQ: Int = 1 tlvWriter.put(ContextSpecificTag(TAG_SIZE_OF_RESPONSE_BUFFER_REQ), sizeOfResponseBuffer) val TAG_FILL_CHARACTER_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) + tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) tlvWriter.endStructure() val request: InvokeRequest = @@ -2315,73 +2539,92 @@ class UnitTestingCluster(private val controller: MatterController, private val e tlvReader.enterStructure(AnonymousTag) val TAG_BUFFER: Int = 0 var buffer_decoded: ByteArray? = null + while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - if (tag == ContextSpecificTag(TAG_BUFFER)) { - buffer_decoded = tlvReader.getByteArray(tag) - } else { + + if (tag == ContextSpecificTag(TAG_BUFFER)) {buffer_decoded = tlvReader.getByteArray(tag)} + + + else { tlvReader.skipElement() } } + + if (buffer_decoded == null) { - throw IllegalStateException("buffer not found in TLV") + throw IllegalStateException("buffer not found in TLV") } + tlvReader.exitContainer() - return TestBatchHelperResponse(buffer_decoded) + return TestBatchHelperResponse( + buffer_decoded + ) } +suspend fun readBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u - suspend fun readBooleanAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Boolean attribute not found in response" } + } + + requireNotNull(attributeData) { + "Boolean attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } - suspend fun writeBooleanAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { + suspend fun writeBooleanAttribute( + value: Boolean, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2403,7 +2646,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBooleanAttribute( @@ -2411,37 +2654,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Boolean attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Boolean attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2453,56 +2694,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBitmap8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - suspend fun readBitmap8Attribute(): UByte { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Bitmap8 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Bitmap8 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeBitmap8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap8Attribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2524,7 +2776,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap8Attribute( @@ -2532,37 +2784,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Bitmap8 attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Bitmap8 attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2574,56 +2824,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBitmap16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - suspend fun readBitmap16Attribute(): UShort { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Bitmap16 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Bitmap16 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } - suspend fun writeBitmap16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap16Attribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2645,7 +2906,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap16Attribute( @@ -2653,37 +2914,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Bitmap16 attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Bitmap16 attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2695,56 +2954,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBitmap32Attribute(): UInt {val ATTRIBUTE_ID: UInt = 3u - suspend fun readBitmap32Attribute(): UInt { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Bitmap32 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Bitmap32 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } - suspend fun writeBitmap32Attribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap32Attribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2766,7 +3036,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap32Attribute( @@ -2774,37 +3044,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Bitmap32 attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Bitmap32 attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2816,56 +3084,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readBitmap64Attribute(): ULong {val ATTRIBUTE_ID: UInt = 4u - suspend fun readBitmap64Attribute(): ULong { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Bitmap64 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Bitmap64 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + return decodedValue } - suspend fun writeBitmap64Attribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap64Attribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2887,7 +3166,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap64Attribute( @@ -2895,37 +3174,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Bitmap64 attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Bitmap64 attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2937,56 +3214,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u - suspend fun readInt8uAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int8u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int8u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeInt8uAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeInt8uAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3008,7 +3296,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt8uAttribute( @@ -3016,37 +3304,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int8u attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int8u attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3058,56 +3344,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u - suspend fun readInt16uAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int16u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int16u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } - suspend fun writeInt16uAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeInt16uAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3129,7 +3426,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt16uAttribute( @@ -3137,37 +3434,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int16u attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int16u attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3179,56 +3474,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt24uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 7u - suspend fun readInt24uAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int24u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int24u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } - suspend fun writeInt24uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeInt24uAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3250,7 +3556,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt24uAttribute( @@ -3258,37 +3564,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int24u attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int24u attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3300,56 +3604,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt32uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 8u - suspend fun readInt32uAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int32u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int32u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } - suspend fun writeInt32uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeInt32uAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3371,7 +3686,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt32uAttribute( @@ -3379,37 +3694,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int32u attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int32u attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3421,56 +3734,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt40uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 9u - suspend fun readInt40uAttribute(): ULong { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int40u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int40u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + return decodedValue } - suspend fun writeInt40uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeInt40uAttribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3492,7 +3816,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt40uAttribute( @@ -3500,37 +3824,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int40u attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int40u attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3542,56 +3864,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt48uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 10u - suspend fun readInt48uAttribute(): ULong { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int48u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int48u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + return decodedValue } - suspend fun writeInt48uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeInt48uAttribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3613,7 +3946,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt48uAttribute( @@ -3621,37 +3954,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int48u attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int48u attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3663,56 +3994,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt56uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 11u - suspend fun readInt56uAttribute(): ULong { - val ATTRIBUTE_ID: UInt = 11u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int56u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int56u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + return decodedValue } - suspend fun writeInt56uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeInt56uAttribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 11u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3734,7 +4076,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt56uAttribute( @@ -3742,37 +4084,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int56u attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int56u attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3784,56 +4124,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt64uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 12u - suspend fun readInt64uAttribute(): ULong { - val ATTRIBUTE_ID: UInt = 12u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int64u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int64u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + return decodedValue } - suspend fun writeInt64uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeInt64uAttribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 12u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3855,7 +4206,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt64uAttribute( @@ -3863,37 +4214,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int64u attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int64u attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3905,56 +4254,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 13u - suspend fun readInt8sAttribute(): Byte { - val ATTRIBUTE_ID: UInt = 13u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int8s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int8s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Byte = tlvReader.getByte(AnonymousTag) + return decodedValue } - suspend fun writeInt8sAttribute(value: Byte, timedWriteTimeout: Duration? = null) { + suspend fun writeInt8sAttribute( + value: Byte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 13u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3976,7 +4336,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt8sAttribute( @@ -3984,37 +4344,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int8s attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int8s attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4026,56 +4384,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 14u - suspend fun readInt16sAttribute(): Short { - val ATTRIBUTE_ID: UInt = 14u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int16s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int16s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Short = tlvReader.getShort(AnonymousTag) + return decodedValue } - suspend fun writeInt16sAttribute(value: Short, timedWriteTimeout: Duration? = null) { + suspend fun writeInt16sAttribute( + value: Short, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 14u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4097,7 +4466,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt16sAttribute( @@ -4105,37 +4474,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int16s attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int16s attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4147,56 +4514,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt24sAttribute(): Int {val ATTRIBUTE_ID: UInt = 15u - suspend fun readInt24sAttribute(): Int { - val ATTRIBUTE_ID: UInt = 15u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int24s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int24s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Int = tlvReader.getInt(AnonymousTag) + return decodedValue } - suspend fun writeInt24sAttribute(value: Int, timedWriteTimeout: Duration? = null) { + suspend fun writeInt24sAttribute( + value: Int, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 15u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4218,7 +4596,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt24sAttribute( @@ -4226,37 +4604,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - IntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int24s attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int24s attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4268,56 +4644,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt32sAttribute(): Int {val ATTRIBUTE_ID: UInt = 16u - suspend fun readInt32sAttribute(): Int { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int32s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int32s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Int = tlvReader.getInt(AnonymousTag) + return decodedValue } - suspend fun writeInt32sAttribute(value: Int, timedWriteTimeout: Duration? = null) { + suspend fun writeInt32sAttribute( + value: Int, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4339,7 +4726,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt32sAttribute( @@ -4347,37 +4734,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - IntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int32s attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int32s attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4389,56 +4774,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt40sAttribute(): Long {val ATTRIBUTE_ID: UInt = 17u - suspend fun readInt40sAttribute(): Long { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int40s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int40s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) + return decodedValue } - suspend fun writeInt40sAttribute(value: Long, timedWriteTimeout: Duration? = null) { + suspend fun writeInt40sAttribute( + value: Long, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4460,7 +4856,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt40sAttribute( @@ -4468,37 +4864,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int40s attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int40s attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4510,56 +4904,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt48sAttribute(): Long {val ATTRIBUTE_ID: UInt = 18u - suspend fun readInt48sAttribute(): Long { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int48s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int48s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) + return decodedValue } - suspend fun writeInt48sAttribute(value: Long, timedWriteTimeout: Duration? = null) { + suspend fun writeInt48sAttribute( + value: Long, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4581,7 +4986,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt48sAttribute( @@ -4589,37 +4994,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int48s attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int48s attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4631,56 +5034,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt56sAttribute(): Long {val ATTRIBUTE_ID: UInt = 19u - suspend fun readInt56sAttribute(): Long { - val ATTRIBUTE_ID: UInt = 19u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int56s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int56s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) + return decodedValue } - suspend fun writeInt56sAttribute(value: Long, timedWriteTimeout: Duration? = null) { + suspend fun writeInt56sAttribute( + value: Long, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 19u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4702,7 +5116,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt56sAttribute( @@ -4710,37 +5124,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int56s attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int56s attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4752,56 +5164,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInt64sAttribute(): Long {val ATTRIBUTE_ID: UInt = 20u - suspend fun readInt64sAttribute(): Long { - val ATTRIBUTE_ID: UInt = 20u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Int64s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Int64s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) + return decodedValue } - suspend fun writeInt64sAttribute(value: Long, timedWriteTimeout: Duration? = null) { + suspend fun writeInt64sAttribute( + value: Long, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4823,7 +5246,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt64sAttribute( @@ -4831,37 +5254,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Int64s attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Int64s attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4873,56 +5294,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEnum8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 21u - suspend fun readEnum8Attribute(): UByte { - val ATTRIBUTE_ID: UInt = 21u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Enum8 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Enum8 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeEnum8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeEnum8Attribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4944,7 +5376,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnum8Attribute( @@ -4952,37 +5384,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Enum8 attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Enum8 attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4994,56 +5424,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEnum16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 22u - suspend fun readEnum16Attribute(): UShort { - val ATTRIBUTE_ID: UInt = 22u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Enum16 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Enum16 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } - suspend fun writeEnum16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeEnum16Attribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 22u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5065,7 +5506,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnum16Attribute( @@ -5073,37 +5514,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Enum16 attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Enum16 attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5115,56 +5554,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFloatSingleAttribute(): Float {val ATTRIBUTE_ID: UInt = 23u - suspend fun readFloatSingleAttribute(): Float { - val ATTRIBUTE_ID: UInt = 23u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Floatsingle attribute not found in response" } + } + + requireNotNull(attributeData) { + "Floatsingle attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Float = tlvReader.getFloat(AnonymousTag) + return decodedValue } - suspend fun writeFloatSingleAttribute(value: Float, timedWriteTimeout: Duration? = null) { + suspend fun writeFloatSingleAttribute( + value: Float, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5186,7 +5636,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFloatSingleAttribute( @@ -5194,37 +5644,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - FloatSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Floatsingle attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Floatsingle attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5236,56 +5684,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFloatDoubleAttribute(): Double {val ATTRIBUTE_ID: UInt = 24u - suspend fun readFloatDoubleAttribute(): Double { - val ATTRIBUTE_ID: UInt = 24u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Floatdouble attribute not found in response" } + } + + requireNotNull(attributeData) { + "Floatdouble attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Double = tlvReader.getDouble(AnonymousTag) + return decodedValue } - suspend fun writeFloatDoubleAttribute(value: Double, timedWriteTimeout: Duration? = null) { + suspend fun writeFloatDoubleAttribute( + value: Double, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 24u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5307,7 +5766,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFloatDoubleAttribute( @@ -5315,37 +5774,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DoubleSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DoubleSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Floatdouble attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Floatdouble attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5357,56 +5814,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(DoubleSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 25u - suspend fun readOctetStringAttribute(): ByteArray { - val ATTRIBUTE_ID: UInt = 25u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Octetstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Octetstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ByteArray = tlvReader.getByteArray(AnonymousTag) + return decodedValue } - suspend fun writeOctetStringAttribute(value: ByteArray, timedWriteTimeout: Duration? = null) { + suspend fun writeOctetStringAttribute( + value: ByteArray, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 25u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5428,7 +5896,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOctetStringAttribute( @@ -5436,37 +5904,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteArraySubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Octetstring attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Octetstring attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5478,67 +5944,77 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readListInt8uAttribute(): ListInt8uAttribute {val ATTRIBUTE_ID: UInt = 26u - suspend fun readListInt8uAttribute(): ListInt8uAttribute { - val ATTRIBUTE_ID: UInt = 26u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Listint8u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Listint8u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) } + tlvReader.exitContainer() + } + return ListInt8uAttribute(decodedValue) } - suspend fun writeListInt8uAttribute(value: List, timedWriteTimeout: Duration? = null) { + suspend fun writeListInt8uAttribute( + value: List, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 26u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5560,7 +6036,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListInt8uAttribute( @@ -5568,48 +6044,45 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ListInt8uAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ListInt8uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Listint8u attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Listint8u attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ListInt8uAttributeSubscriptionState.Success(decodedValue)) } @@ -5617,70 +6090,77 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ListInt8uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readListOctetStringAttribute(): ListOctetStringAttribute {val ATTRIBUTE_ID: UInt = 27u - suspend fun readListOctetStringAttribute(): ListOctetStringAttribute { - val ATTRIBUTE_ID: UInt = 27u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Listoctetstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Listoctetstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) } + tlvReader.exitContainer() + } + return ListOctetStringAttribute(decodedValue) } suspend fun writeListOctetStringAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 27u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5702,7 +6182,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListOctetStringAttribute( @@ -5710,50 +6190,45 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ListOctetStringAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ListOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Listoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Listoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ListOctetStringAttributeSubscriptionState.Success(decodedValue)) } @@ -5761,70 +6236,77 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ListOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute {val ATTRIBUTE_ID: UInt = 28u - suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute { - val ATTRIBUTE_ID: UInt = 28u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Liststructoctetstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Liststructoctetstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return ListStructOctetStringAttribute(decodedValue) } suspend fun writeListStructOctetStringAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 28u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5846,7 +6328,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListStructOctetStringAttribute( @@ -5854,50 +6336,45 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ListStructOctetStringAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ListStructOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Liststructoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Liststructoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ListStructOctetStringAttributeSubscriptionState.Success(decodedValue)) } @@ -5905,56 +6382,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ListStructOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLongOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 29u - suspend fun readLongOctetStringAttribute(): ByteArray { - val ATTRIBUTE_ID: UInt = 29u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Longoctetstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Longoctetstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ByteArray = tlvReader.getByteArray(AnonymousTag) + return decodedValue } - suspend fun writeLongOctetStringAttribute(value: ByteArray, timedWriteTimeout: Duration? = null) { + suspend fun writeLongOctetStringAttribute( + value: ByteArray, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 29u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5976,7 +6464,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLongOctetStringAttribute( @@ -5984,38 +6472,34 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 29u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteArraySubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Longoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Longoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -6028,56 +6512,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 30u - suspend fun readCharStringAttribute(): String { - val ATTRIBUTE_ID: UInt = 30u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Charstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Charstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } - suspend fun writeCharStringAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeCharStringAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 30u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6099,7 +6594,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCharStringAttribute( @@ -6107,37 +6602,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Charstring attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Charstring attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6149,56 +6642,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readLongCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 31u - suspend fun readLongCharStringAttribute(): String { - val ATTRIBUTE_ID: UInt = 31u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Longcharstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Longcharstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) + return decodedValue } - suspend fun writeLongCharStringAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeLongCharStringAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 31u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6220,7 +6724,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLongCharStringAttribute( @@ -6228,38 +6732,34 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 31u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Longcharstring attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Longcharstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -6272,56 +6772,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEpochUsAttribute(): ULong {val ATTRIBUTE_ID: UInt = 32u - suspend fun readEpochUsAttribute(): ULong { - val ATTRIBUTE_ID: UInt = 32u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Epochus attribute not found in response" } + } + + requireNotNull(attributeData) { + "Epochus attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) + return decodedValue } - suspend fun writeEpochUsAttribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeEpochUsAttribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 32u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6343,7 +6854,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEpochUsAttribute( @@ -6351,37 +6862,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ULongSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Epochus attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Epochus attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6393,56 +6902,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEpochSAttribute(): UInt {val ATTRIBUTE_ID: UInt = 33u - suspend fun readEpochSAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 33u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Epochs attribute not found in response" } + } + + requireNotNull(attributeData) { + "Epochs attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } - suspend fun writeEpochSAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeEpochSAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6464,7 +6984,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEpochSAttribute( @@ -6472,37 +6992,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Epochs attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Epochs attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6514,56 +7032,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readVendorIdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 34u - suspend fun readVendorIdAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 34u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Vendorid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Vendorid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } - suspend fun writeVendorIdAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeVendorIdAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 34u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6585,7 +7114,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeVendorIdAttribute( @@ -6593,37 +7122,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Vendorid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6635,73 +7162,77 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readListNullablesAndOptionalsStructAttribute(): ListNullablesAndOptionalsStructAttribute {val ATTRIBUTE_ID: UInt = 35u - suspend fun readListNullablesAndOptionalsStructAttribute(): - ListNullablesAndOptionalsStructAttribute { - val ATTRIBUTE_ID: UInt = 35u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listnullablesandoptionalsstruct attribute not found in response" + } + + requireNotNull(attributeData) { + "Listnullablesandoptionalsstruct attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return ListNullablesAndOptionalsStructAttribute(decodedValue) } suspend fun writeListNullablesAndOptionalsStructAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 35u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6723,7 +7254,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListNullablesAndOptionalsStructAttribute( @@ -6731,50 +7262,45 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ListNullablesAndOptionalsStructAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ListNullablesAndOptionalsStructAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Listnullablesandoptionalsstruct attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Listnullablesandoptionalsstruct attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ListNullablesAndOptionalsStructAttributeSubscriptionState.Success(decodedValue)) } @@ -6782,56 +7308,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ListNullablesAndOptionalsStructAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEnumAttrAttribute(): UByte {val ATTRIBUTE_ID: UInt = 36u - suspend fun readEnumAttrAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 36u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Enumattr attribute not found in response" } + } + + requireNotNull(attributeData) { + "Enumattr attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeEnumAttrAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeEnumAttrAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 36u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6853,7 +7390,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnumAttrAttribute( @@ -6861,37 +7398,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Enumattr attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Enumattr attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6903,60 +7438,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readStructAttrAttribute(): StructAttrAttribute {val ATTRIBUTE_ID: UInt = 37u - suspend fun readStructAttrAttribute(): StructAttrAttribute { - val ATTRIBUTE_ID: UInt = 37u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Structattr attribute not found in response" } + } + + requireNotNull(attributeData) { + "Structattr attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct = - UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: UnitTestingClusterSimpleStruct = UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + return StructAttrAttribute(decodedValue) } suspend fun writeStructAttrAttribute( value: UnitTestingClusterSimpleStruct, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 37u val tlvWriter = TlvWriter() - value.toTlv(AnonymousTag, tlvWriter) + value.toTlv(AnonymousTag, tlvWriter) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6978,7 +7520,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStructAttrAttribute( @@ -6986,42 +7528,39 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StructAttrAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StructAttrAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Structattr attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Structattr attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct = - UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: UnitTestingClusterSimpleStruct = UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) emit(StructAttrAttributeSubscriptionState.Success(decodedValue)) } @@ -7029,59 +7568,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(StructAttrAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRangeRestrictedInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 38u - suspend fun readRangeRestrictedInt8uAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 38u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rangerestrictedint8u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rangerestrictedint8u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } suspend fun writeRangeRestrictedInt8uAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 38u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7103,7 +7650,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt8uAttribute( @@ -7111,38 +7658,34 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rangerestrictedint8u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rangerestrictedint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7155,56 +7698,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRangeRestrictedInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 39u - suspend fun readRangeRestrictedInt8sAttribute(): Byte { - val ATTRIBUTE_ID: UInt = 39u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rangerestrictedint8s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rangerestrictedint8s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Byte = tlvReader.getByte(AnonymousTag) + return decodedValue } - suspend fun writeRangeRestrictedInt8sAttribute(value: Byte, timedWriteTimeout: Duration? = null) { + suspend fun writeRangeRestrictedInt8sAttribute( + value: Byte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 39u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7226,7 +7780,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt8sAttribute( @@ -7234,38 +7788,34 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rangerestrictedint8s attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rangerestrictedint8s attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7278,59 +7828,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRangeRestrictedInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 40u - suspend fun readRangeRestrictedInt16uAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 40u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rangerestrictedint16u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rangerestrictedint16u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } suspend fun writeRangeRestrictedInt16uAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 40u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7352,7 +7910,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt16uAttribute( @@ -7360,38 +7918,34 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rangerestrictedint16u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rangerestrictedint16u attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7404,59 +7958,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readRangeRestrictedInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 41u - suspend fun readRangeRestrictedInt16sAttribute(): Short { - val ATTRIBUTE_ID: UInt = 41u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rangerestrictedint16s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rangerestrictedint16s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Short = tlvReader.getShort(AnonymousTag) + return decodedValue } suspend fun writeRangeRestrictedInt16sAttribute( value: Short, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 41u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7478,7 +8040,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt16sAttribute( @@ -7486,38 +8048,34 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Rangerestrictedint16s attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rangerestrictedint16s attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7530,70 +8088,77 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute {val ATTRIBUTE_ID: UInt = 42u - suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute { - val ATTRIBUTE_ID: UInt = 42u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Listlongoctetstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Listlongoctetstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) } + tlvReader.exitContainer() + } + return ListLongOctetStringAttribute(decodedValue) } suspend fun writeListLongOctetStringAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 42u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7615,7 +8180,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListLongOctetStringAttribute( @@ -7623,50 +8188,45 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ListLongOctetStringAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ListLongOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Listlongoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Listlongoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ListLongOctetStringAttributeSubscriptionState.Success(decodedValue)) } @@ -7674,70 +8234,77 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ListLongOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute {val ATTRIBUTE_ID: UInt = 43u - suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute { - val ATTRIBUTE_ID: UInt = 43u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Listfabricscoped attribute not found in response" } + } + + requireNotNull(attributeData) { + "Listfabricscoped attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return ListFabricScopedAttribute(decodedValue) } suspend fun writeListFabricScopedAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 43u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7759,7 +8326,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListFabricScopedAttribute( @@ -7767,50 +8334,45 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 43u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ListFabricScopedAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ListFabricScopedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Listfabricscoped attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Listfabricscoped attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ListFabricScopedAttributeSubscriptionState.Success(decodedValue)) } @@ -7818,56 +8380,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(ListFabricScopedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTimedWriteBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 48u - suspend fun readTimedWriteBooleanAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 48u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Timedwriteboolean attribute not found in response" } + } + + requireNotNull(attributeData) { + "Timedwriteboolean attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } - suspend fun writeTimedWriteBooleanAttribute(value: Boolean, timedWriteTimeout: Duration) { + suspend fun writeTimedWriteBooleanAttribute( + value: Boolean, + timedWriteTimeout: Duration) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7889,7 +8462,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTimedWriteBooleanAttribute( @@ -7897,38 +8470,34 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Timedwriteboolean attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Timedwriteboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7941,59 +8510,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneralErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 49u - suspend fun readGeneralErrorBooleanAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 49u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generalerrorboolean attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generalerrorboolean attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } suspend fun writeGeneralErrorBooleanAttribute( value: Boolean, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8015,7 +8592,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeGeneralErrorBooleanAttribute( @@ -8023,38 +8600,34 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generalerrorboolean attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generalerrorboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8067,59 +8640,67 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 50u - suspend fun readClusterErrorBooleanAttribute(): Boolean { - val ATTRIBUTE_ID: UInt = 50u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clustererrorboolean attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clustererrorboolean attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) + return decodedValue } suspend fun writeClusterErrorBooleanAttribute( value: Boolean, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8141,7 +8722,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeClusterErrorBooleanAttribute( @@ -8149,38 +8730,34 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clustererrorboolean attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clustererrorboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8193,61 +8770,71 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readUnsupportedAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 255u - suspend fun readUnsupportedAttribute(): Boolean? { - val ATTRIBUTE_ID: UInt = 255u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Unsupported attribute not found in response" } + } + + requireNotNull(attributeData) { + "Unsupported attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeUnsupportedAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { + suspend fun writeUnsupportedAttribute( + value: Boolean, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 255u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8269,7 +8856,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnsupportedAttribute( @@ -8277,109 +8864,119 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 255u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BooleanSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Unsupported attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Unsupported attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } + decodedValue?.let { + emit(BooleanSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute {val ATTRIBUTE_ID: UInt = 16384u - suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute { - val ATTRIBUTE_ID: UInt = 16384u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableboolean attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableboolean attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (!tlvReader.isNull()) { - tlvReader.getBoolean(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Boolean? = if (!tlvReader.isNull()) { + tlvReader.getBoolean(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableBooleanAttribute(decodedValue) } - suspend fun writeNullableBooleanAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBooleanAttribute( + value: Boolean, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16384u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8401,7 +8998,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBooleanAttribute( @@ -8409,112 +9006,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableBooleanAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableBooleanAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableboolean attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = - if (!tlvReader.isNull()) { - tlvReader.getBoolean(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Boolean? = if (!tlvReader.isNull()) { + tlvReader.getBoolean(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableBooleanAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableBooleanAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableBooleanAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute {val ATTRIBUTE_ID: UInt = 16385u - suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute { - val ATTRIBUTE_ID: UInt = 16385u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullablebitmap8 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullablebitmap8 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableBitmap8Attribute(decodedValue) } - suspend fun writeNullableBitmap8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap8Attribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16385u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8536,7 +9141,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap8Attribute( @@ -8544,112 +9149,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16385u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableBitmap8AttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableBitmap8AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablebitmap8 attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablebitmap8 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableBitmap8AttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableBitmap8AttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap8AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute {val ATTRIBUTE_ID: UInt = 16386u - suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute { - val ATTRIBUTE_ID: UInt = 16386u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullablebitmap16 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullablebitmap16 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableBitmap16Attribute(decodedValue) } - suspend fun writeNullableBitmap16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap16Attribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16386u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8671,7 +9284,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap16Attribute( @@ -8679,112 +9292,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16386u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableBitmap16AttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableBitmap16AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablebitmap16 attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablebitmap16 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableBitmap16AttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableBitmap16AttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap16AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute {val ATTRIBUTE_ID: UInt = 16387u - suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute { - val ATTRIBUTE_ID: UInt = 16387u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullablebitmap32 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullablebitmap32 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableBitmap32Attribute(decodedValue) } - suspend fun writeNullableBitmap32Attribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap32Attribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16387u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8806,7 +9427,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap32Attribute( @@ -8814,112 +9435,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16387u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableBitmap32AttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableBitmap32AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablebitmap32 attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablebitmap32 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableBitmap32AttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableBitmap32AttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap32AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute {val ATTRIBUTE_ID: UInt = 16388u - suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute { - val ATTRIBUTE_ID: UInt = 16388u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullablebitmap64 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullablebitmap64 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableBitmap64Attribute(decodedValue) } - suspend fun writeNullableBitmap64Attribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap64Attribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16388u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8941,7 +9570,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap64Attribute( @@ -8949,112 +9578,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16388u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableBitmap64AttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableBitmap64AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablebitmap64 attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablebitmap64 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableBitmap64AttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableBitmap64AttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap64AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute {val ATTRIBUTE_ID: UInt = 16389u - suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute { - val ATTRIBUTE_ID: UInt = 16389u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint8u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint8u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt8uAttribute(decodedValue) } - suspend fun writeNullableInt8uAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt8uAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16389u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9076,7 +9713,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt8uAttribute( @@ -9084,110 +9721,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16389u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt8uAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt8uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Nullableint8u attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint8u attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt8uAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt8uAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt8uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute {val ATTRIBUTE_ID: UInt = 16390u - suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute { - val ATTRIBUTE_ID: UInt = 16390u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint16u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint16u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt16uAttribute(decodedValue) } - suspend fun writeNullableInt16uAttribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt16uAttribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16390u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9209,7 +9856,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt16uAttribute( @@ -9217,112 +9864,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16390u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt16uAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt16uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint16u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint16u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt16uAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt16uAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt16uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute {val ATTRIBUTE_ID: UInt = 16391u - suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute { - val ATTRIBUTE_ID: UInt = 16391u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint24u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint24u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt24uAttribute(decodedValue) } - suspend fun writeNullableInt24uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt24uAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16391u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9344,7 +9999,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt24uAttribute( @@ -9352,112 +10007,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16391u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt24uAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt24uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint24u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint24u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt24uAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt24uAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt24uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute {val ATTRIBUTE_ID: UInt = 16392u - suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute { - val ATTRIBUTE_ID: UInt = 16392u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint32u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint32u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt32uAttribute(decodedValue) } - suspend fun writeNullableInt32uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt32uAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16392u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9479,7 +10142,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt32uAttribute( @@ -9487,112 +10150,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16392u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt32uAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt32uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint32u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint32u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt32uAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt32uAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt32uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute {val ATTRIBUTE_ID: UInt = 16393u - suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute { - val ATTRIBUTE_ID: UInt = 16393u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint40u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint40u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt40uAttribute(decodedValue) } - suspend fun writeNullableInt40uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt40uAttribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16393u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9614,7 +10285,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt40uAttribute( @@ -9622,112 +10293,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16393u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt40uAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt40uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint40u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint40u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt40uAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt40uAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt40uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute {val ATTRIBUTE_ID: UInt = 16394u - suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute { - val ATTRIBUTE_ID: UInt = 16394u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint48u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint48u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt48uAttribute(decodedValue) } - suspend fun writeNullableInt48uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt48uAttribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16394u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9749,7 +10428,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt48uAttribute( @@ -9757,112 +10436,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16394u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt48uAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt48uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint48u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint48u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt48uAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt48uAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt48uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute {val ATTRIBUTE_ID: UInt = 16395u - suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute { - val ATTRIBUTE_ID: UInt = 16395u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint56u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint56u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt56uAttribute(decodedValue) } - suspend fun writeNullableInt56uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt56uAttribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16395u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9884,7 +10571,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt56uAttribute( @@ -9892,112 +10579,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16395u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt56uAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt56uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint56u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint56u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt56uAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt56uAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt56uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute {val ATTRIBUTE_ID: UInt = 16396u - suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute { - val ATTRIBUTE_ID: UInt = 16396u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint64u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint64u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt64uAttribute(decodedValue) } - suspend fun writeNullableInt64uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt64uAttribute( + value: ULong, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16396u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10019,7 +10714,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt64uAttribute( @@ -10027,112 +10722,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16396u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt64uAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt64uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint64u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint64u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt64uAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt64uAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt64uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute {val ATTRIBUTE_ID: UInt = 16397u - suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute { - val ATTRIBUTE_ID: UInt = 16397u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint8s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint8s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Byte? = if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt8sAttribute(decodedValue) } - suspend fun writeNullableInt8sAttribute(value: Byte, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt8sAttribute( + value: Byte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16397u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10154,7 +10857,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt8sAttribute( @@ -10162,110 +10865,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16397u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt8sAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt8sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Nullableint8s attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint8s attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Byte? = if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt8sAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt8sAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt8sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute {val ATTRIBUTE_ID: UInt = 16398u - suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute { - val ATTRIBUTE_ID: UInt = 16398u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint16s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint16s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt16sAttribute(decodedValue) } - suspend fun writeNullableInt16sAttribute(value: Short, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt16sAttribute( + value: Short, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16398u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10287,7 +11000,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt16sAttribute( @@ -10295,112 +11008,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16398u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt16sAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt16sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint16s attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint16s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt16sAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt16sAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt16sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute {val ATTRIBUTE_ID: UInt = 16399u - suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute { - val ATTRIBUTE_ID: UInt = 16399u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint24s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint24s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = - if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt24sAttribute(decodedValue) } - suspend fun writeNullableInt24sAttribute(value: Int, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt24sAttribute( + value: Int, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16399u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10422,7 +11143,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt24sAttribute( @@ -10430,112 +11151,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16399u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt24sAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt24sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint24s attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint24s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = - if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt24sAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt24sAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt24sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute {val ATTRIBUTE_ID: UInt = 16400u - suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute { - val ATTRIBUTE_ID: UInt = 16400u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint32s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint32s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = - if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt32sAttribute(decodedValue) } - suspend fun writeNullableInt32sAttribute(value: Int, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt32sAttribute( + value: Int, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16400u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10557,7 +11286,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt32sAttribute( @@ -10565,112 +11294,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16400u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt32sAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt32sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint32s attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint32s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = - if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt32sAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt32sAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt32sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute {val ATTRIBUTE_ID: UInt = 16401u - suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute { - val ATTRIBUTE_ID: UInt = 16401u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint40s attribute not found in response" } + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint40s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt40sAttribute(decodedValue) } - suspend fun writeNullableInt40sAttribute(value: Long, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt40sAttribute( + value: Long, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16401u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10692,7 +11429,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt40sAttribute( @@ -10700,112 +11437,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16401u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt40sAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt40sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint40s attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint40s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt40sAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt40sAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt40sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute {val ATTRIBUTE_ID: UInt = 16402u - suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute { - val ATTRIBUTE_ID: UInt = 16402u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint48s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint48s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt48sAttribute(decodedValue) } - suspend fun writeNullableInt48sAttribute(value: Long, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt48sAttribute( + value: Long, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16402u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10827,7 +11572,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt48sAttribute( @@ -10835,112 +11580,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16402u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt48sAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt48sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint48s attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint48s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt48sAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt48sAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt48sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute {val ATTRIBUTE_ID: UInt = 16403u - suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute { - val ATTRIBUTE_ID: UInt = 16403u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint56s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint56s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt56sAttribute(decodedValue) } - suspend fun writeNullableInt56sAttribute(value: Long, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt56sAttribute( + value: Long, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16403u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10962,7 +11715,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt56sAttribute( @@ -10970,112 +11723,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16403u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt56sAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt56sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint56s attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint56s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt56sAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt56sAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt56sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute {val ATTRIBUTE_ID: UInt = 16404u - suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute { - val ATTRIBUTE_ID: UInt = 16404u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableint64s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableint64s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableInt64sAttribute(decodedValue) } - suspend fun writeNullableInt64sAttribute(value: Long, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt64sAttribute( + value: Long, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16404u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11097,7 +11858,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt64sAttribute( @@ -11105,112 +11866,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16404u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableInt64sAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableInt64sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableint64s attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableint64s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = - if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableInt64sAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableInt64sAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt64sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute {val ATTRIBUTE_ID: UInt = 16405u - suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute { - val ATTRIBUTE_ID: UInt = 16405u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableenum8 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableenum8 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableEnum8Attribute(decodedValue) } - suspend fun writeNullableEnum8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableEnum8Attribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16405u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11232,7 +12001,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableEnum8Attribute( @@ -11240,110 +12009,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16405u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableEnum8AttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableEnum8AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Nullableenum8 attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableenum8 attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableEnum8AttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableEnum8AttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableEnum8AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute {val ATTRIBUTE_ID: UInt = 16406u - suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute { - val ATTRIBUTE_ID: UInt = 16406u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableenum16 attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableenum16 attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableEnum16Attribute(decodedValue) } - suspend fun writeNullableEnum16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableEnum16Attribute( + value: UShort, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16406u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11365,7 +12144,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableEnum16Attribute( @@ -11373,112 +12152,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16406u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableEnum16AttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableEnum16AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableenum16 attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableenum16 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableEnum16AttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableEnum16AttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableEnum16AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute {val ATTRIBUTE_ID: UInt = 16407u - suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute { - val ATTRIBUTE_ID: UInt = 16407u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullablefloatsingle attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullablefloatsingle attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - tlvReader.getFloat(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + tlvReader.getFloat(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableFloatSingleAttribute(decodedValue) } - suspend fun writeNullableFloatSingleAttribute(value: Float, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableFloatSingleAttribute( + value: Float, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16407u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11500,7 +12287,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableFloatSingleAttribute( @@ -11508,115 +12295,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16407u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableFloatSingleAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableFloatSingleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablefloatsingle attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablefloatsingle attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = - if (!tlvReader.isNull()) { - tlvReader.getFloat(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = if (!tlvReader.isNull()) { + tlvReader.getFloat(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableFloatSingleAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableFloatSingleAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableFloatSingleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute {val ATTRIBUTE_ID: UInt = 16408u - suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute { - val ATTRIBUTE_ID: UInt = 16408u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullablefloatdouble attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullablefloatdouble attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Double? = - if (!tlvReader.isNull()) { - tlvReader.getDouble(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Double? = if (!tlvReader.isNull()) { + tlvReader.getDouble(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableFloatDoubleAttribute(decodedValue) } suspend fun writeNullableFloatDoubleAttribute( value: Double, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16408u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11638,7 +12430,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableFloatDoubleAttribute( @@ -11646,115 +12438,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16408u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableFloatDoubleAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableFloatDoubleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablefloatdouble attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablefloatdouble attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Double? = - if (!tlvReader.isNull()) { - tlvReader.getDouble(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Double? = if (!tlvReader.isNull()) { + tlvReader.getDouble(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableFloatDoubleAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableFloatDoubleAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableFloatDoubleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute {val ATTRIBUTE_ID: UInt = 16409u - suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute { - val ATTRIBUTE_ID: UInt = 16409u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableoctetstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableoctetstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableOctetStringAttribute(decodedValue) } suspend fun writeNullableOctetStringAttribute( value: ByteArray, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16409u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11776,7 +12573,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableOctetStringAttribute( @@ -11784,112 +12581,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16409u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableOctetStringAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableOctetStringAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableOctetStringAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute {val ATTRIBUTE_ID: UInt = 16414u - suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute { - val ATTRIBUTE_ID: UInt = 16414u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullablecharstring attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullablecharstring attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: String? = if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableCharStringAttribute(decodedValue) } - suspend fun writeNullableCharStringAttribute(value: String, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableCharStringAttribute( + value: String, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16414u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11911,7 +12716,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableCharStringAttribute( @@ -11919,112 +12724,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16414u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableCharStringAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableCharStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablecharstring attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablecharstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: String? = if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableCharStringAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableCharStringAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableCharStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute {val ATTRIBUTE_ID: UInt = 16420u - suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute { - val ATTRIBUTE_ID: UInt = 16420u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullableenumattr attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullableenumattr attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableEnumAttrAttribute(decodedValue) } - suspend fun writeNullableEnumAttrAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeNullableEnumAttrAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16420u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12046,7 +12859,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableEnumAttrAttribute( @@ -12054,115 +12867,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16420u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableEnumAttrAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableEnumAttrAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullableenumattr attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullableenumattr attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableEnumAttrAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableEnumAttrAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableEnumAttrAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableStructAttribute(): NullableStructAttribute {val ATTRIBUTE_ID: UInt = 16421u - suspend fun readNullableStructAttribute(): NullableStructAttribute { - val ATTRIBUTE_ID: UInt = 16421u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullablestruct attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullablestruct attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct? = - if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UnitTestingClusterSimpleStruct? = if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableStructAttribute(decodedValue) } suspend fun writeNullableStructAttribute( value: UnitTestingClusterSimpleStruct, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16421u val tlvWriter = TlvWriter() - value.toTlv(AnonymousTag, tlvWriter) + value.toTlv(AnonymousTag, tlvWriter) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12184,7 +13002,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableStructAttribute( @@ -12192,115 +13010,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16421u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableStructAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableStructAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablestruct attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablestruct attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct? = - if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UnitTestingClusterSimpleStruct? = if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { emit(NullableStructAttributeSubscriptionState.Success(it)) } + decodedValue?.let { + emit(NullableStructAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableStructAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestrictedInt8uAttribute {val ATTRIBUTE_ID: UInt = 16422u - suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestrictedInt8uAttribute { - val ATTRIBUTE_ID: UInt = 16422u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullablerangerestrictedint8u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint8u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableRangeRestrictedInt8uAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt8uAttribute( value: UByte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16422u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12322,7 +13145,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt8uAttribute( @@ -12330,117 +13153,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16422u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableRangeRestrictedInt8uAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableRangeRestrictedInt8uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint8u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt8uAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt8uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestrictedInt8sAttribute {val ATTRIBUTE_ID: UInt = 16423u - suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestrictedInt8sAttribute { - val ATTRIBUTE_ID: UInt = 16423u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Nullablerangerestrictedint8s attribute not found in response" } + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint8s attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Byte? = if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableRangeRestrictedInt8sAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt8sAttribute( value: Byte, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16423u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12462,7 +13288,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt8sAttribute( @@ -12470,119 +13296,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16423u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableRangeRestrictedInt8sAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableRangeRestrictedInt8sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint8s attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint8s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Byte? = if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt8sAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt8sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestrictedInt16uAttribute {val ATTRIBUTE_ID: UInt = 16424u - suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestrictedInt16uAttribute { - val ATTRIBUTE_ID: UInt = 16424u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16u attribute not found in response" + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableRangeRestrictedInt16uAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt16uAttribute( value: UShort, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16424u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12604,7 +13431,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt16uAttribute( @@ -12612,119 +13439,120 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16424u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableRangeRestrictedInt16uAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableRangeRestrictedInt16uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt16uAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt16uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestrictedInt16sAttribute {val ATTRIBUTE_ID: UInt = 16425u - suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestrictedInt16sAttribute { - val ATTRIBUTE_ID: UInt = 16425u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16s attribute not found in response" + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return NullableRangeRestrictedInt16sAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt16sAttribute( value: Short, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16425u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12746,7 +13574,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt16sAttribute( @@ -12754,113 +13582,119 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16425u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - NullableRangeRestrictedInt16sAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(NullableRangeRestrictedInt16sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16s attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = - if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt16sAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt16sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readWriteOnlyInt8uAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16426u - suspend fun readWriteOnlyInt8uAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 16426u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Writeonlyint8u attribute not found in response" } + } + + requireNotNull(attributeData) { + "Writeonlyint8u attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeWriteOnlyInt8uAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeWriteOnlyInt8uAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16426u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12882,7 +13716,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWriteOnlyInt8uAttribute( @@ -12890,92 +13724,96 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16426u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Writeonlyint8u attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Writeonlyint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -12985,50 +13823,45 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -13036,43 +13869,49 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -13082,50 +13921,45 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -13133,43 +13967,49 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -13179,48 +14019,45 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -13228,43 +14065,49 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -13274,48 +14117,45 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -13323,37 +14163,44 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -13362,37 +14209,35 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -13404,37 +14249,44 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -13443,38 +14295,34 @@ class UnitTestingCluster(private val controller: MatterController, private val e maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -13487,7 +14335,7 @@ class UnitTestingCluster(private val controller: MatterController, private val e emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt index df0867a6902b61..b7fb44b39973dc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt @@ -17,140 +17,182 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UserLabelCluster(private val controller: MatterController, private val endpointId: UShort) { - class LabelListAttribute(val value: List) +class UserLabelCluster(private val controller: MatterController, private val endpointId: UShort) {class LabelListAttribute( + val value: List + ) sealed class LabelListAttributeSubscriptionState { - data class Success(val value: List) : - LabelListAttributeSubscriptionState() - + data class Success( + val value: List + ) : LabelListAttributeSubscriptionState() + data class Error(val exception: Exception) : LabelListAttributeSubscriptionState() - object SubscriptionEstablished : LabelListAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : LabelListAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readLabelListAttribute(): LabelListAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Labellist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Labellist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } + return LabelListAttribute(decodedValue) } suspend fun writeLabelListAttribute( value: List, - timedWriteTimeout: Duration? = null - ) { + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -172,7 +214,7 @@ class UserLabelCluster(private val controller: MatterController, private val end throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLabelListAttribute( @@ -180,48 +222,45 @@ class UserLabelCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - LabelListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(LabelListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Labellist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Labellist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(LabelListAttributeSubscriptionState.Success(decodedValue)) } @@ -229,43 +268,49 @@ class UserLabelCluster(private val controller: MatterController, private val end emit(LabelListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -275,50 +320,45 @@ class UserLabelCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -326,43 +366,49 @@ class UserLabelCluster(private val controller: MatterController, private val end emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -372,50 +418,45 @@ class UserLabelCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -423,43 +464,49 @@ class UserLabelCluster(private val controller: MatterController, private val end emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -469,48 +516,45 @@ class UserLabelCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -518,43 +562,49 @@ class UserLabelCluster(private val controller: MatterController, private val end emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -564,48 +614,45 @@ class UserLabelCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -613,37 +660,44 @@ class UserLabelCluster(private val controller: MatterController, private val end emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -652,37 +706,35 @@ class UserLabelCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -694,37 +746,44 @@ class UserLabelCluster(private val controller: MatterController, private val end emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -733,38 +792,34 @@ class UserLabelCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -777,7 +832,7 @@ class UserLabelCluster(private val controller: MatterController, private val end emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt index 6160dd924179e6..b4b18cde045376 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt @@ -17,167 +17,222 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ValveConfigurationAndControlCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class OpenDurationAttribute(val value: UInt?) +class ValveConfigurationAndControlCluster(private val controller: MatterController, private val endpointId: UShort) {class OpenDurationAttribute( + val value: UInt? + ) sealed class OpenDurationAttributeSubscriptionState { - data class Success(val value: UInt?) : OpenDurationAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : OpenDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : OpenDurationAttributeSubscriptionState() - object SubscriptionEstablished : OpenDurationAttributeSubscriptionState() - } - - class DefaultOpenDurationAttribute(val value: UInt?) + object SubscriptionEstablished : OpenDurationAttributeSubscriptionState() + } +class DefaultOpenDurationAttribute( + val value: UInt? + ) sealed class DefaultOpenDurationAttributeSubscriptionState { - data class Success(val value: UInt?) : DefaultOpenDurationAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : DefaultOpenDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultOpenDurationAttributeSubscriptionState() - object SubscriptionEstablished : DefaultOpenDurationAttributeSubscriptionState() - } - - class AutoCloseTimeAttribute(val value: ULong?) + object SubscriptionEstablished : DefaultOpenDurationAttributeSubscriptionState() + } +class AutoCloseTimeAttribute( + val value: ULong? + ) sealed class AutoCloseTimeAttributeSubscriptionState { - data class Success(val value: ULong?) : AutoCloseTimeAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : AutoCloseTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : AutoCloseTimeAttributeSubscriptionState() - object SubscriptionEstablished : AutoCloseTimeAttributeSubscriptionState() - } - - class RemainingDurationAttribute(val value: UInt?) + object SubscriptionEstablished : AutoCloseTimeAttributeSubscriptionState() + } +class RemainingDurationAttribute( + val value: UInt? + ) sealed class RemainingDurationAttributeSubscriptionState { - data class Success(val value: UInt?) : RemainingDurationAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : RemainingDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : RemainingDurationAttributeSubscriptionState() - object SubscriptionEstablished : RemainingDurationAttributeSubscriptionState() - } - - class CurrentStateAttribute(val value: UByte?) + object SubscriptionEstablished : RemainingDurationAttributeSubscriptionState() + } +class CurrentStateAttribute( + val value: UByte? + ) sealed class CurrentStateAttributeSubscriptionState { - data class Success(val value: UByte?) : CurrentStateAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : CurrentStateAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentStateAttributeSubscriptionState() - object SubscriptionEstablished : CurrentStateAttributeSubscriptionState() - } - - class TargetStateAttribute(val value: UByte?) + object SubscriptionEstablished : CurrentStateAttributeSubscriptionState() + } +class TargetStateAttribute( + val value: UByte? + ) sealed class TargetStateAttributeSubscriptionState { - data class Success(val value: UByte?) : TargetStateAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : TargetStateAttributeSubscriptionState() + data class Error(val exception: Exception) : TargetStateAttributeSubscriptionState() - object SubscriptionEstablished : TargetStateAttributeSubscriptionState() - } - - class CurrentLevelAttribute(val value: UByte?) + object SubscriptionEstablished : TargetStateAttributeSubscriptionState() + } +class CurrentLevelAttribute( + val value: UByte? + ) sealed class CurrentLevelAttributeSubscriptionState { - data class Success(val value: UByte?) : CurrentLevelAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : CurrentLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentLevelAttributeSubscriptionState() - object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() - } - - class TargetLevelAttribute(val value: UByte?) + object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() + } +class TargetLevelAttribute( + val value: UByte? + ) sealed class TargetLevelAttributeSubscriptionState { - data class Success(val value: UByte?) : TargetLevelAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : TargetLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : TargetLevelAttributeSubscriptionState() - object SubscriptionEstablished : TargetLevelAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : TargetLevelAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun open(openDuration: UInt?, targetLevel: UByte?, timedInvokeTimeout: Duration? = null) { + suspend fun open(openDuration: UInt? + ,targetLevel: UByte? + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_OPEN_DURATION_REQ: Int = 0 - openDuration?.let { tlvWriter.put(ContextSpecificTag(TAG_OPEN_DURATION_REQ), openDuration) } + openDuration?.let { + tlvWriter.put(ContextSpecificTag(TAG_OPEN_DURATION_REQ), openDuration) + } val TAG_TARGET_LEVEL_REQ: Int = 1 - targetLevel?.let { tlvWriter.put(ContextSpecificTag(TAG_TARGET_LEVEL_REQ), targetLevel) } + targetLevel?.let { + tlvWriter.put(ContextSpecificTag(TAG_TARGET_LEVEL_REQ), targetLevel) + } tlvWriter.endStructure() val request: InvokeRequest = @@ -195,7 +250,7 @@ class ValveConfigurationAndControlCluster( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -208,40 +263,46 @@ class ValveConfigurationAndControlCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readOpenDurationAttribute(): OpenDurationAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOpenDurationAttribute(): OpenDurationAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Openduration attribute not found in response" } + } + + requireNotNull(attributeData) { + "Openduration attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OpenDurationAttribute(decodedValue) } @@ -251,110 +312,120 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OpenDurationAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OpenDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Openduration attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Openduration attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OpenDurationAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OpenDurationAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OpenDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDefaultOpenDurationAttribute(): DefaultOpenDurationAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDefaultOpenDurationAttribute(): DefaultOpenDurationAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Defaultopenduration attribute not found in response" } + } + + requireNotNull(attributeData) { + "Defaultopenduration attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return DefaultOpenDurationAttribute(decodedValue) } - suspend fun writeDefaultOpenDurationAttribute(value: UInt, timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultOpenDurationAttribute( + value: UInt, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -376,7 +447,7 @@ class ValveConfigurationAndControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultOpenDurationAttribute( @@ -384,96 +455,100 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - DefaultOpenDurationAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(DefaultOpenDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Defaultopenduration attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Defaultopenduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(DefaultOpenDurationAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(DefaultOpenDurationAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(DefaultOpenDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAutoCloseTimeAttribute(): AutoCloseTimeAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAutoCloseTimeAttribute(): AutoCloseTimeAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Autoclosetime attribute not found in response" } + } + + requireNotNull(attributeData) { + "Autoclosetime attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return AutoCloseTimeAttribute(decodedValue) } @@ -483,94 +558,100 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AutoCloseTimeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AutoCloseTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Autoclosetime attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Autoclosetime attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(AutoCloseTimeAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(AutoCloseTimeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(AutoCloseTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readRemainingDurationAttribute(): RemainingDurationAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readRemainingDurationAttribute(): RemainingDurationAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Remainingduration attribute not found in response" } + } + + requireNotNull(attributeData) { + "Remainingduration attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return RemainingDurationAttribute(decodedValue) } @@ -580,92 +661,96 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - RemainingDurationAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(RemainingDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Remainingduration attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Remainingduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(RemainingDurationAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(RemainingDurationAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(RemainingDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentStateAttribute(): CurrentStateAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentStateAttribute(): CurrentStateAttribute {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentStateAttribute(decodedValue) } @@ -675,90 +760,96 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentStateAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentstate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentstate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CurrentStateAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CurrentStateAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTargetStateAttribute(): TargetStateAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTargetStateAttribute(): TargetStateAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Targetstate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Targetstate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return TargetStateAttribute(decodedValue) } @@ -768,94 +859,100 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - TargetStateAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(TargetStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Targetstate attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Targetstate attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(TargetStateAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(TargetStateAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(TargetStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentLevelAttribute(decodedValue) } @@ -865,98 +962,104 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentLevelAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Currentlevel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentlevel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CurrentLevelAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CurrentLevelAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readTargetLevelAttribute(): TargetLevelAttribute { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readTargetLevelAttribute(): TargetLevelAttribute {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Targetlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Targetlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return TargetLevelAttribute(decodedValue) } @@ -966,113 +1069,123 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - TargetLevelAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(TargetLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Targetlevel attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Targetlevel attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(TargetLevelAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(TargetLevelAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(TargetLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readDefaultOpenLevelAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readDefaultOpenLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Defaultopenlevel attribute not found in response" } + } + + requireNotNull(attributeData) { + "Defaultopenlevel attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } - suspend fun writeDefaultOpenLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultOpenLevelAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1094,7 +1207,7 @@ class ValveConfigurationAndControlCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultOpenLevelAttribute( @@ -1102,90 +1215,94 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Defaultopenlevel attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Defaultopenlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readValveFaultAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readValveFaultAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Valvefault attribute not found in response" } + } + + requireNotNull(attributeData) { + "Valvefault attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1195,88 +1312,94 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Valvefault attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Valvefault attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLevelStepAttribute(): UByte? { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLevelStepAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Levelstep attribute not found in response" } + } + + requireNotNull(attributeData) { + "Levelstep attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1286,90 +1409,96 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Levelstep attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Levelstep attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(UByteSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1379,50 +1508,45 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1430,43 +1554,49 @@ class ValveConfigurationAndControlCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1476,50 +1606,45 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1527,43 +1652,49 @@ class ValveConfigurationAndControlCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1573,48 +1704,45 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1622,43 +1750,49 @@ class ValveConfigurationAndControlCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1668,48 +1802,45 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1717,37 +1848,44 @@ class ValveConfigurationAndControlCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1756,37 +1894,35 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1798,37 +1934,44 @@ class ValveConfigurationAndControlCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -1837,38 +1980,34 @@ class ValveConfigurationAndControlCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1881,7 +2020,7 @@ class ValveConfigurationAndControlCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt index b29d8ae7c59bd6..18d648654b3557 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt @@ -17,98 +17,139 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.ByteArraySubscriptionState import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest -import matter.controller.StringSubscriptionState +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath +import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader +import matter.tlv.TlvWriter -class WakeOnLanCluster(private val controller: MatterController, private val endpointId: UShort) { - class GeneratedCommandListAttribute(val value: List) +class WakeOnLanCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun readMACAddressAttribute(): String? { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } +suspend fun readMACAddressAttribute(): String? {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Macaddress attribute not found in response" } + } + + requireNotNull(attributeData) { + "Macaddress attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + return decodedValue } @@ -118,88 +159,94 @@ class WakeOnLanCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - StringSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Macaddress attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Macaddress attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(StringSubscriptionState.Success(it)) } + val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(StringSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readLinkLocalAddressAttribute(): ByteArray? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readLinkLocalAddressAttribute(): ByteArray? {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Linklocaladdress attribute not found in response" } + } + + requireNotNull(attributeData) { + "Linklocaladdress attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } + val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + return decodedValue } @@ -209,92 +256,96 @@ class WakeOnLanCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ByteArraySubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Linklocaladdress attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Linklocaladdress attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - - decodedValue?.let { emit(ByteArraySubscriptionState.Success(it)) } + val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + + decodedValue?.let { + emit(ByteArraySubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -304,50 +355,45 @@ class WakeOnLanCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -355,43 +401,49 @@ class WakeOnLanCluster(private val controller: MatterController, private val end emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -401,50 +453,45 @@ class WakeOnLanCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -452,43 +499,49 @@ class WakeOnLanCluster(private val controller: MatterController, private val end emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -498,48 +551,45 @@ class WakeOnLanCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -547,43 +597,49 @@ class WakeOnLanCluster(private val controller: MatterController, private val end emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -593,48 +649,45 @@ class WakeOnLanCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -642,37 +695,44 @@ class WakeOnLanCluster(private val controller: MatterController, private val end emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -681,37 +741,35 @@ class WakeOnLanCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -723,37 +781,44 @@ class WakeOnLanCluster(private val controller: MatterController, private val end emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -762,38 +827,34 @@ class WakeOnLanCluster(private val controller: MatterController, private val end maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -806,7 +867,7 @@ class WakeOnLanCluster(private val controller: MatterController, private val end emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt index a5a3c4300e4829..a863a7bdcbe2f5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt @@ -17,206 +17,275 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.UIntSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState +import matter.controller.UByteSubscriptionState import matter.controller.UShortSubscriptionState -import matter.controller.cluster.structs.* +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.WriteRequest +import matter.controller.WriteRequests +import matter.controller.WriteResponse +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag +import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class BssidAttribute(val value: ByteArray?) +class WiFiNetworkDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class BssidAttribute( + val value: ByteArray? + ) sealed class BssidAttributeSubscriptionState { - data class Success(val value: ByteArray?) : BssidAttributeSubscriptionState() - + data class Success( + val value: ByteArray? + ) : BssidAttributeSubscriptionState() + data class Error(val exception: Exception) : BssidAttributeSubscriptionState() - object SubscriptionEstablished : BssidAttributeSubscriptionState() - } - - class SecurityTypeAttribute(val value: UByte?) + object SubscriptionEstablished : BssidAttributeSubscriptionState() + } +class SecurityTypeAttribute( + val value: UByte? + ) sealed class SecurityTypeAttributeSubscriptionState { - data class Success(val value: UByte?) : SecurityTypeAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : SecurityTypeAttributeSubscriptionState() + data class Error(val exception: Exception) : SecurityTypeAttributeSubscriptionState() - object SubscriptionEstablished : SecurityTypeAttributeSubscriptionState() - } - - class WiFiVersionAttribute(val value: UByte?) + object SubscriptionEstablished : SecurityTypeAttributeSubscriptionState() + } +class WiFiVersionAttribute( + val value: UByte? + ) sealed class WiFiVersionAttributeSubscriptionState { - data class Success(val value: UByte?) : WiFiVersionAttributeSubscriptionState() - + data class Success( + val value: UByte? + ) : WiFiVersionAttributeSubscriptionState() + data class Error(val exception: Exception) : WiFiVersionAttributeSubscriptionState() - object SubscriptionEstablished : WiFiVersionAttributeSubscriptionState() - } - - class ChannelNumberAttribute(val value: UShort?) + object SubscriptionEstablished : WiFiVersionAttributeSubscriptionState() + } +class ChannelNumberAttribute( + val value: UShort? + ) sealed class ChannelNumberAttributeSubscriptionState { - data class Success(val value: UShort?) : ChannelNumberAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : ChannelNumberAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelNumberAttributeSubscriptionState() - object SubscriptionEstablished : ChannelNumberAttributeSubscriptionState() - } - - class RssiAttribute(val value: Byte?) + object SubscriptionEstablished : ChannelNumberAttributeSubscriptionState() + } +class RssiAttribute( + val value: Byte? + ) sealed class RssiAttributeSubscriptionState { - data class Success(val value: Byte?) : RssiAttributeSubscriptionState() - + data class Success( + val value: Byte? + ) : RssiAttributeSubscriptionState() + data class Error(val exception: Exception) : RssiAttributeSubscriptionState() - object SubscriptionEstablished : RssiAttributeSubscriptionState() - } - - class BeaconLostCountAttribute(val value: UInt?) + object SubscriptionEstablished : RssiAttributeSubscriptionState() + } +class BeaconLostCountAttribute( + val value: UInt? + ) sealed class BeaconLostCountAttributeSubscriptionState { - data class Success(val value: UInt?) : BeaconLostCountAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : BeaconLostCountAttributeSubscriptionState() + data class Error(val exception: Exception) : BeaconLostCountAttributeSubscriptionState() - object SubscriptionEstablished : BeaconLostCountAttributeSubscriptionState() - } - - class BeaconRxCountAttribute(val value: UInt?) + object SubscriptionEstablished : BeaconLostCountAttributeSubscriptionState() + } +class BeaconRxCountAttribute( + val value: UInt? + ) sealed class BeaconRxCountAttributeSubscriptionState { - data class Success(val value: UInt?) : BeaconRxCountAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : BeaconRxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : BeaconRxCountAttributeSubscriptionState() - object SubscriptionEstablished : BeaconRxCountAttributeSubscriptionState() - } - - class PacketMulticastRxCountAttribute(val value: UInt?) + object SubscriptionEstablished : BeaconRxCountAttributeSubscriptionState() + } +class PacketMulticastRxCountAttribute( + val value: UInt? + ) sealed class PacketMulticastRxCountAttributeSubscriptionState { - data class Success(val value: UInt?) : PacketMulticastRxCountAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : PacketMulticastRxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketMulticastRxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketMulticastRxCountAttributeSubscriptionState() - } - - class PacketMulticastTxCountAttribute(val value: UInt?) + object SubscriptionEstablished : PacketMulticastRxCountAttributeSubscriptionState() + } +class PacketMulticastTxCountAttribute( + val value: UInt? + ) sealed class PacketMulticastTxCountAttributeSubscriptionState { - data class Success(val value: UInt?) : PacketMulticastTxCountAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : PacketMulticastTxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketMulticastTxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketMulticastTxCountAttributeSubscriptionState() - } - - class PacketUnicastRxCountAttribute(val value: UInt?) + object SubscriptionEstablished : PacketMulticastTxCountAttributeSubscriptionState() + } +class PacketUnicastRxCountAttribute( + val value: UInt? + ) sealed class PacketUnicastRxCountAttributeSubscriptionState { - data class Success(val value: UInt?) : PacketUnicastRxCountAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : PacketUnicastRxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketUnicastRxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketUnicastRxCountAttributeSubscriptionState() - } - - class PacketUnicastTxCountAttribute(val value: UInt?) + object SubscriptionEstablished : PacketUnicastRxCountAttributeSubscriptionState() + } +class PacketUnicastTxCountAttribute( + val value: UInt? + ) sealed class PacketUnicastTxCountAttributeSubscriptionState { - data class Success(val value: UInt?) : PacketUnicastTxCountAttributeSubscriptionState() - + data class Success( + val value: UInt? + ) : PacketUnicastTxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketUnicastTxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketUnicastTxCountAttributeSubscriptionState() - } - - class CurrentMaxRateAttribute(val value: ULong?) + object SubscriptionEstablished : PacketUnicastTxCountAttributeSubscriptionState() + } +class CurrentMaxRateAttribute( + val value: ULong? + ) sealed class CurrentMaxRateAttributeSubscriptionState { - data class Success(val value: ULong?) : CurrentMaxRateAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : CurrentMaxRateAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentMaxRateAttributeSubscriptionState() - object SubscriptionEstablished : CurrentMaxRateAttributeSubscriptionState() - } - - class OverrunCountAttribute(val value: ULong?) + object SubscriptionEstablished : CurrentMaxRateAttributeSubscriptionState() + } +class OverrunCountAttribute( + val value: ULong? + ) sealed class OverrunCountAttributeSubscriptionState { - data class Success(val value: ULong?) : OverrunCountAttributeSubscriptionState() - + data class Success( + val value: ULong? + ) : OverrunCountAttributeSubscriptionState() + data class Error(val exception: Exception) : OverrunCountAttributeSubscriptionState() - object SubscriptionEstablished : OverrunCountAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + object SubscriptionEstablished : OverrunCountAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCounts(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -229,40 +298,46 @@ class WiFiNetworkDiagnosticsCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - - suspend fun readBssidAttribute(): BssidAttribute { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBssidAttribute(): BssidAttribute {val ATTRIBUTE_ID: UInt = 0u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Bssid attribute not found in response" } + } + + requireNotNull(attributeData) { + "Bssid attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return BssidAttribute(decodedValue) } @@ -272,90 +347,96 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BssidAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BssidAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Bssid attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Bssid attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(BssidAttributeSubscriptionState.Success(it)) } + val decodedValue: ByteArray? = if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(BssidAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BssidAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readSecurityTypeAttribute(): SecurityTypeAttribute { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readSecurityTypeAttribute(): SecurityTypeAttribute {val ATTRIBUTE_ID: UInt = 1u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Securitytype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Securitytype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return SecurityTypeAttribute(decodedValue) } @@ -365,90 +446,96 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - SecurityTypeAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(SecurityTypeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Securitytype attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Securitytype attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(SecurityTypeAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(SecurityTypeAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(SecurityTypeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readWiFiVersionAttribute(): WiFiVersionAttribute { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readWiFiVersionAttribute(): WiFiVersionAttribute {val ATTRIBUTE_ID: UInt = 2u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Wifiversion attribute not found in response" } + } + + requireNotNull(attributeData) { + "Wifiversion attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return WiFiVersionAttribute(decodedValue) } @@ -458,90 +545,96 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - WiFiVersionAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(WiFiVersionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Wifiversion attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Wifiversion attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(WiFiVersionAttributeSubscriptionState.Success(it)) } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(WiFiVersionAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(WiFiVersionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readChannelNumberAttribute(): ChannelNumberAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readChannelNumberAttribute(): ChannelNumberAttribute {val ATTRIBUTE_ID: UInt = 3u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Channelnumber attribute not found in response" } + } + + requireNotNull(attributeData) { + "Channelnumber attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return ChannelNumberAttribute(decodedValue) } @@ -551,90 +644,96 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - ChannelNumberAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(ChannelNumberAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Channelnumber attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Channelnumber attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(ChannelNumberAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(ChannelNumberAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(ChannelNumberAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readRssiAttribute(): RssiAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readRssiAttribute(): RssiAttribute {val ATTRIBUTE_ID: UInt = 4u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Rssi attribute not found in response" } + } + + requireNotNull(attributeData) { + "Rssi attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Byte? = if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + return RssiAttribute(decodedValue) } @@ -644,94 +743,100 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - RssiAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(RssiAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Rssi attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Rssi attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = - if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(RssiAttributeSubscriptionState.Success(it)) } + val decodedValue: Byte? = if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(RssiAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(RssiAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBeaconLostCountAttribute(): BeaconLostCountAttribute { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBeaconLostCountAttribute(): BeaconLostCountAttribute {val ATTRIBUTE_ID: UInt = 5u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Beaconlostcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Beaconlostcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return BeaconLostCountAttribute(decodedValue) } @@ -741,100 +846,104 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BeaconLostCountAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BeaconLostCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Beaconlostcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Beaconlostcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(BeaconLostCountAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(BeaconLostCountAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BeaconLostCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readBeaconRxCountAttribute(): BeaconRxCountAttribute { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readBeaconRxCountAttribute(): BeaconRxCountAttribute {val ATTRIBUTE_ID: UInt = 6u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Beaconrxcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Beaconrxcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return BeaconRxCountAttribute(decodedValue) } @@ -844,98 +953,104 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - BeaconRxCountAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(BeaconRxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Beaconrxcount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Beaconrxcount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(BeaconRxCountAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(BeaconRxCountAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(BeaconRxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPacketMulticastRxCountAttribute(): PacketMulticastRxCountAttribute { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPacketMulticastRxCountAttribute(): PacketMulticastRxCountAttribute {val ATTRIBUTE_ID: UInt = 7u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Packetmulticastrxcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Packetmulticastrxcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PacketMulticastRxCountAttribute(decodedValue) } @@ -945,100 +1060,104 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PacketMulticastRxCountAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PacketMulticastRxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Packetmulticastrxcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Packetmulticastrxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PacketMulticastRxCountAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PacketMulticastRxCountAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PacketMulticastRxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPacketMulticastTxCountAttribute(): PacketMulticastTxCountAttribute { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPacketMulticastTxCountAttribute(): PacketMulticastTxCountAttribute {val ATTRIBUTE_ID: UInt = 8u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Packetmulticasttxcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Packetmulticasttxcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PacketMulticastTxCountAttribute(decodedValue) } @@ -1048,100 +1167,104 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PacketMulticastTxCountAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PacketMulticastTxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Packetmulticasttxcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Packetmulticasttxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PacketMulticastTxCountAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PacketMulticastTxCountAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PacketMulticastTxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPacketUnicastRxCountAttribute(): PacketUnicastRxCountAttribute { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPacketUnicastRxCountAttribute(): PacketUnicastRxCountAttribute {val ATTRIBUTE_ID: UInt = 9u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Packetunicastrxcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Packetunicastrxcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PacketUnicastRxCountAttribute(decodedValue) } @@ -1151,100 +1274,104 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PacketUnicastRxCountAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PacketUnicastRxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Packetunicastrxcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Packetunicastrxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PacketUnicastRxCountAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PacketUnicastRxCountAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PacketUnicastRxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readPacketUnicastTxCountAttribute(): PacketUnicastTxCountAttribute { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readPacketUnicastTxCountAttribute(): PacketUnicastTxCountAttribute {val ATTRIBUTE_ID: UInt = 10u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Packetunicasttxcount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Packetunicasttxcount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return PacketUnicastTxCountAttribute(decodedValue) } @@ -1254,100 +1381,104 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - PacketUnicastTxCountAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(PacketUnicastTxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Packetunicasttxcount attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Packetunicasttxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(PacketUnicastTxCountAttributeSubscriptionState.Success(it)) } + val decodedValue: UInt? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(PacketUnicastTxCountAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(PacketUnicastTxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readCurrentMaxRateAttribute(): CurrentMaxRateAttribute { - val ATTRIBUTE_ID: UInt = 11u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readCurrentMaxRateAttribute(): CurrentMaxRateAttribute {val ATTRIBUTE_ID: UInt = 11u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentmaxrate attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentmaxrate attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentMaxRateAttribute(decodedValue) } @@ -1357,100 +1488,104 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentMaxRateAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentMaxRateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentmaxrate attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentmaxrate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CurrentMaxRateAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CurrentMaxRateAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentMaxRateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readOverrunCountAttribute(): OverrunCountAttribute { - val ATTRIBUTE_ID: UInt = 12u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readOverrunCountAttribute(): OverrunCountAttribute {val ATTRIBUTE_ID: UInt = 12u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Overruncount attribute not found in response" } + } + + requireNotNull(attributeData) { + "Overruncount attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return OverrunCountAttribute(decodedValue) } @@ -1460,95 +1595,101 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - OverrunCountAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(OverrunCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Overruncount attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Overruncount attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(OverrunCountAttributeSubscriptionState.Success(it)) } + val decodedValue: ULong? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(OverrunCountAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(OverrunCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -1558,50 +1699,45 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1609,43 +1745,49 @@ class WiFiNetworkDiagnosticsCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -1655,50 +1797,45 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1706,43 +1843,49 @@ class WiFiNetworkDiagnosticsCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -1752,48 +1895,45 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1801,43 +1941,49 @@ class WiFiNetworkDiagnosticsCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -1847,48 +1993,45 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1896,37 +2039,44 @@ class WiFiNetworkDiagnosticsCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -1935,37 +2085,35 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1977,37 +2125,44 @@ class WiFiNetworkDiagnosticsCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } - - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2016,38 +2171,34 @@ class WiFiNetworkDiagnosticsCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2060,7 +2211,7 @@ class WiFiNetworkDiagnosticsCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt index 7fb2facd9cc45b..d47645e5b75dca 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt @@ -17,173 +17,210 @@ package matter.controller.cluster.clusters -import java.time.Duration import java.util.logging.Level import java.util.logging.Logger +import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadData import matter.controller.ReadRequest +import matter.controller.ReadData +import matter.controller.ReadFailure +import matter.controller.ReadResponse import matter.controller.SubscribeRequest import matter.controller.SubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.ShortSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.LongSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.CharSubscriptionState +import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UIntSubscriptionState import matter.controller.UShortSubscriptionState +import matter.controller.UIntSubscriptionState +import matter.controller.ULongSubscriptionState +import matter.controller.StringSubscriptionState +import matter.controller.ByteArraySubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.cluster.structs.* +import matter.controller.AttributeWriteError +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.model.AttributePath import matter.controller.model.CommandPath +import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag +import matter.tlv.Tag +import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WindowCoveringCluster( - private val controller: MatterController, - private val endpointId: UShort -) { - class CurrentPositionLiftAttribute(val value: UShort?) +class WindowCoveringCluster(private val controller: MatterController, private val endpointId: UShort) {class CurrentPositionLiftAttribute( + val value: UShort? + ) sealed class CurrentPositionLiftAttributeSubscriptionState { - data class Success(val value: UShort?) : CurrentPositionLiftAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : CurrentPositionLiftAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPositionLiftAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPositionLiftAttributeSubscriptionState() - } - - class CurrentPositionTiltAttribute(val value: UShort?) + object SubscriptionEstablished : CurrentPositionLiftAttributeSubscriptionState() + } +class CurrentPositionTiltAttribute( + val value: UShort? + ) sealed class CurrentPositionTiltAttributeSubscriptionState { - data class Success(val value: UShort?) : CurrentPositionTiltAttributeSubscriptionState() - + data class Success( + val value: UShort? + ) : CurrentPositionTiltAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPositionTiltAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPositionTiltAttributeSubscriptionState() - } - - class CurrentPositionLiftPercentageAttribute(val value: UByte?) + object SubscriptionEstablished : CurrentPositionTiltAttributeSubscriptionState() + } +class CurrentPositionLiftPercentageAttribute( + val value: UByte? + ) sealed class CurrentPositionLiftPercentageAttributeSubscriptionState { - data class Success(val value: UByte?) : - CurrentPositionLiftPercentageAttributeSubscriptionState() - - data class Error(val exception: Exception) : - CurrentPositionLiftPercentageAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionLiftPercentageAttributeSubscriptionState() - } - - class CurrentPositionTiltPercentageAttribute(val value: UByte?) + data class Success( + val value: UByte? + ) : CurrentPositionLiftPercentageAttributeSubscriptionState() + + data class Error(val exception: Exception) : CurrentPositionLiftPercentageAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionLiftPercentageAttributeSubscriptionState() + } +class CurrentPositionTiltPercentageAttribute( + val value: UByte? + ) sealed class CurrentPositionTiltPercentageAttributeSubscriptionState { - data class Success(val value: UByte?) : - CurrentPositionTiltPercentageAttributeSubscriptionState() - - data class Error(val exception: Exception) : - CurrentPositionTiltPercentageAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionTiltPercentageAttributeSubscriptionState() - } - - class TargetPositionLiftPercent100thsAttribute(val value: UShort?) + data class Success( + val value: UByte? + ) : CurrentPositionTiltPercentageAttributeSubscriptionState() + + data class Error(val exception: Exception) : CurrentPositionTiltPercentageAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionTiltPercentageAttributeSubscriptionState() + } +class TargetPositionLiftPercent100thsAttribute( + val value: UShort? + ) sealed class TargetPositionLiftPercent100thsAttributeSubscriptionState { - data class Success(val value: UShort?) : - TargetPositionLiftPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : - TargetPositionLiftPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : TargetPositionLiftPercent100thsAttributeSubscriptionState() - } - - class TargetPositionTiltPercent100thsAttribute(val value: UShort?) + data class Success( + val value: UShort? + ) : TargetPositionLiftPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : TargetPositionLiftPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : TargetPositionLiftPercent100thsAttributeSubscriptionState() + } +class TargetPositionTiltPercent100thsAttribute( + val value: UShort? + ) sealed class TargetPositionTiltPercent100thsAttributeSubscriptionState { - data class Success(val value: UShort?) : - TargetPositionTiltPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : - TargetPositionTiltPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : TargetPositionTiltPercent100thsAttributeSubscriptionState() - } - - class CurrentPositionLiftPercent100thsAttribute(val value: UShort?) + data class Success( + val value: UShort? + ) : TargetPositionTiltPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : TargetPositionTiltPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : TargetPositionTiltPercent100thsAttributeSubscriptionState() + } +class CurrentPositionLiftPercent100thsAttribute( + val value: UShort? + ) sealed class CurrentPositionLiftPercent100thsAttributeSubscriptionState { - data class Success(val value: UShort?) : - CurrentPositionLiftPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : - CurrentPositionLiftPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionLiftPercent100thsAttributeSubscriptionState() - } - - class CurrentPositionTiltPercent100thsAttribute(val value: UShort?) + data class Success( + val value: UShort? + ) : CurrentPositionLiftPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : CurrentPositionLiftPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionLiftPercent100thsAttributeSubscriptionState() + } +class CurrentPositionTiltPercent100thsAttribute( + val value: UShort? + ) sealed class CurrentPositionTiltPercent100thsAttributeSubscriptionState { - data class Success(val value: UShort?) : - CurrentPositionTiltPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : - CurrentPositionTiltPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionTiltPercent100thsAttributeSubscriptionState() - } - - class GeneratedCommandListAttribute(val value: List) + data class Success( + val value: UShort? + ) : CurrentPositionTiltPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : CurrentPositionTiltPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionTiltPercent100thsAttributeSubscriptionState() + } +class GeneratedCommandListAttribute( + val value: List + ) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } - - class AcceptedCommandListAttribute(val value: List) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } +class AcceptedCommandListAttribute( + val value: List + ) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } - - class EventListAttribute(val value: List) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } +class EventListAttribute( + val value: List + ) sealed class EventListAttributeSubscriptionState { - data class Success(val value: List) : EventListAttributeSubscriptionState() - + data class Success( + val value: List + ) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } - - class AttributeListAttribute(val value: List) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } +class AttributeListAttribute( + val value: List + ) sealed class AttributeListAttributeSubscriptionState { - data class Success(val value: List) : AttributeListAttributeSubscriptionState() - + data class Success( + val value: List + ) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun upOrOpen(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -201,7 +238,7 @@ class WindowCoveringCluster( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -219,7 +256,7 @@ class WindowCoveringCluster( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -233,14 +270,15 @@ class WindowCoveringCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToLiftValue(liftValue: UShort, timedInvokeTimeout: Duration? = null) { + suspend fun goToLiftValue(liftValue: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LIFT_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LIFT_VALUE_REQ), liftValue) + tlvWriter.put(ContextSpecificTag(TAG_LIFT_VALUE_REQ), liftValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -254,17 +292,15 @@ class WindowCoveringCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToLiftPercentage( - liftPercent100thsValue: UShort, - timedInvokeTimeout: Duration? = null - ) { + suspend fun goToLiftPercentage(liftPercent100thsValue: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LIFT_PERCENT100THS_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LIFT_PERCENT100THS_VALUE_REQ), liftPercent100thsValue) + tlvWriter.put(ContextSpecificTag(TAG_LIFT_PERCENT100THS_VALUE_REQ), liftPercent100thsValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -278,14 +314,15 @@ class WindowCoveringCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToTiltValue(tiltValue: UShort, timedInvokeTimeout: Duration? = null) { + suspend fun goToTiltValue(tiltValue: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 7u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TILT_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TILT_VALUE_REQ), tiltValue) + tlvWriter.put(ContextSpecificTag(TAG_TILT_VALUE_REQ), tiltValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -299,17 +336,15 @@ class WindowCoveringCluster( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToTiltPercentage( - tiltPercent100thsValue: UShort, - timedInvokeTimeout: Duration? = null - ) { + suspend fun goToTiltPercentage(tiltPercent100thsValue: UShort + ,timedInvokeTimeout: Duration? = null) { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TILT_PERCENT100THS_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TILT_PERCENT100THS_VALUE_REQ), tiltPercent100thsValue) + tlvWriter.put(ContextSpecificTag(TAG_TILT_PERCENT100THS_VALUE_REQ), tiltPercent100thsValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -322,35 +357,42 @@ class WindowCoveringCluster( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } +suspend fun readTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - suspend fun readTypeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 0u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Type attribute not found in response" } + } + + requireNotNull(attributeData) { + "Type attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -359,37 +401,35 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Type attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Type attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -401,41 +441,47 @@ class WindowCoveringCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPhysicalClosedLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u - suspend fun readPhysicalClosedLimitLiftAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 1u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Physicalclosedlimitlift attribute not found in response" } + } + + requireNotNull(attributeData) { + "Physicalclosedlimitlift attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -445,90 +491,94 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Physicalclosedlimitlift attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Physicalclosedlimitlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readPhysicalClosedLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u - suspend fun readPhysicalClosedLimitTiltAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 2u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Physicalclosedlimittilt attribute not found in response" } + } + + requireNotNull(attributeData) { + "Physicalclosedlimittilt attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -538,95 +588,99 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Physicalclosedlimittilt attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Physicalclosedlimittilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentPositionLiftAttribute(): CurrentPositionLiftAttribute {val ATTRIBUTE_ID: UInt = 3u - suspend fun readCurrentPositionLiftAttribute(): CurrentPositionLiftAttribute { - val ATTRIBUTE_ID: UInt = 3u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentpositionlift attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentpositionlift attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentPositionLiftAttribute(decodedValue) } @@ -636,100 +690,104 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentPositionLiftAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentPositionLiftAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentpositionlift attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentpositionlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CurrentPositionLiftAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CurrentPositionLiftAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionLiftAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentPositionTiltAttribute(): CurrentPositionTiltAttribute {val ATTRIBUTE_ID: UInt = 4u - suspend fun readCurrentPositionTiltAttribute(): CurrentPositionTiltAttribute { - val ATTRIBUTE_ID: UInt = 4u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Currentpositiontilt attribute not found in response" } + } + + requireNotNull(attributeData) { + "Currentpositiontilt attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentPositionTiltAttribute(decodedValue) } @@ -739,95 +797,99 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentPositionTiltAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentPositionTiltAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentpositiontilt attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentpositiontilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { emit(CurrentPositionTiltAttributeSubscriptionState.Success(it)) } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { + emit(CurrentPositionTiltAttributeSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionTiltAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfActuationsLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u - suspend fun readNumberOfActuationsLiftAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 5u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofactuationslift attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofactuationslift attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -837,90 +899,94 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofactuationslift attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofactuationslift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readNumberOfActuationsTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u - suspend fun readNumberOfActuationsTiltAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 6u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Numberofactuationstilt attribute not found in response" } + } + + requireNotNull(attributeData) { + "Numberofactuationstilt attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -930,86 +996,91 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Numberofactuationstilt attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Numberofactuationstilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readConfigStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u - suspend fun readConfigStatusAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 7u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Configstatus attribute not found in response" } + } + + requireNotNull(attributeData) { + "Configstatus attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -1018,37 +1089,35 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Configstatus attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Configstatus attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1060,48 +1129,52 @@ class WindowCoveringCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentPositionLiftPercentageAttribute(): CurrentPositionLiftPercentageAttribute {val ATTRIBUTE_ID: UInt = 8u - suspend fun readCurrentPositionLiftPercentageAttribute(): CurrentPositionLiftPercentageAttribute { - val ATTRIBUTE_ID: UInt = 8u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionliftpercentage attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositionliftpercentage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentPositionLiftPercentageAttribute(decodedValue) } @@ -1111,104 +1184,104 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentPositionLiftPercentageAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentPositionLiftPercentageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentpositionliftpercentage attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentpositionliftpercentage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionLiftPercentageAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionLiftPercentageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentPositionTiltPercentageAttribute(): CurrentPositionTiltPercentageAttribute {val ATTRIBUTE_ID: UInt = 9u - suspend fun readCurrentPositionTiltPercentageAttribute(): CurrentPositionTiltPercentageAttribute { - val ATTRIBUTE_ID: UInt = 9u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontiltpercentage attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositiontiltpercentage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentPositionTiltPercentageAttribute(decodedValue) } @@ -1218,93 +1291,96 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentPositionTiltPercentageAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentPositionTiltPercentageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentpositiontiltpercentage attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentpositiontiltpercentage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionTiltPercentageAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionTiltPercentageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readOperationalStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10u - suspend fun readOperationalStatusAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 10u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Operationalstatus attribute not found in response" } + } + + requireNotNull(attributeData) { + "Operationalstatus attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -1313,38 +1389,34 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Operationalstatus attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Operationalstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1357,49 +1429,52 @@ class WindowCoveringCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTargetPositionLiftPercent100thsAttribute(): TargetPositionLiftPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 11u - suspend fun readTargetPositionLiftPercent100thsAttribute(): - TargetPositionLiftPercent100thsAttribute { - val ATTRIBUTE_ID: UInt = 11u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetpositionliftpercent100ths attribute not found in response" + } + + requireNotNull(attributeData) { + "Targetpositionliftpercent100ths attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return TargetPositionLiftPercent100thsAttribute(decodedValue) } @@ -1409,105 +1484,104 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - TargetPositionLiftPercent100thsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(TargetPositionLiftPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Targetpositionliftpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Targetpositionliftpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(TargetPositionLiftPercent100thsAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(TargetPositionLiftPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readTargetPositionTiltPercent100thsAttribute(): TargetPositionTiltPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 12u - suspend fun readTargetPositionTiltPercent100thsAttribute(): - TargetPositionTiltPercent100thsAttribute { - val ATTRIBUTE_ID: UInt = 12u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } + } + + requireNotNull(attributeData) { + "Targetpositiontiltpercent100ths attribute not found in response" + } - requireNotNull(attributeData) { - "Targetpositiontiltpercent100ths attribute not found in response" + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null } - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } return TargetPositionTiltPercent100thsAttribute(decodedValue) } @@ -1517,93 +1591,96 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - TargetPositionTiltPercent100thsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(TargetPositionTiltPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Targetpositiontiltpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Targetpositiontiltpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(TargetPositionTiltPercent100thsAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(TargetPositionTiltPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEndProductTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 13u - suspend fun readEndProductTypeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 13u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Endproducttype attribute not found in response" } + } + + requireNotNull(attributeData) { + "Endproducttype attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } @@ -1612,38 +1689,34 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Endproducttype attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Endproducttype attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1656,49 +1729,52 @@ class WindowCoveringCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentPositionLiftPercent100thsAttribute(): CurrentPositionLiftPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 14u - suspend fun readCurrentPositionLiftPercent100thsAttribute(): - CurrentPositionLiftPercent100thsAttribute { - val ATTRIBUTE_ID: UInt = 14u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionliftpercent100ths attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositionliftpercent100ths attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentPositionLiftPercent100thsAttribute(decodedValue) } @@ -1708,105 +1784,104 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentPositionLiftPercent100thsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentPositionLiftPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentpositionliftpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentpositionliftpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionLiftPercent100thsAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionLiftPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readCurrentPositionTiltPercent100thsAttribute(): CurrentPositionTiltPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 15u - suspend fun readCurrentPositionTiltPercent100thsAttribute(): - CurrentPositionTiltPercent100thsAttribute { - val ATTRIBUTE_ID: UInt = 15u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontiltpercent100ths attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositiontiltpercent100ths attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + return CurrentPositionTiltPercent100thsAttribute(decodedValue) } @@ -1816,97 +1891,99 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - CurrentPositionTiltPercent100thsAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(CurrentPositionTiltPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Currentpositiontiltpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Currentpositiontiltpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionTiltPercent100thsAttributeSubscriptionState.Success(it)) } + } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionTiltPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInstalledOpenLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - suspend fun readInstalledOpenLimitLiftAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 16u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Installedopenlimitlift attribute not found in response" } + } + + requireNotNull(attributeData) { + "Installedopenlimitlift attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -1916,90 +1993,94 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Installedopenlimitlift attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Installedopenlimitlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInstalledClosedLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - suspend fun readInstalledClosedLimitLiftAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 17u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Installedclosedlimitlift attribute not found in response" } + } + + requireNotNull(attributeData) { + "Installedclosedlimitlift attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2009,90 +2090,94 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Installedclosedlimitlift attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Installedclosedlimitlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInstalledOpenLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - suspend fun readInstalledOpenLimitTiltAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 18u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Installedopenlimittilt attribute not found in response" } + } + + requireNotNull(attributeData) { + "Installedopenlimittilt attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2102,90 +2187,94 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Installedopenlimittilt attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Installedopenlimittilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readInstalledClosedLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u - suspend fun readInstalledClosedLimitTiltAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 19u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Installedclosedlimittilt attribute not found in response" } + } + + requireNotNull(attributeData) { + "Installedclosedlimittilt attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2195,105 +2284,114 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Installedclosedlimittilt attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Installedclosedlimittilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 23u - suspend fun readModeAttribute(): UByte { - val ATTRIBUTE_ID: UInt = 23u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Mode attribute not found in response" } + } + + requireNotNull(attributeData) { + "Mode attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) + return decodedValue } - suspend fun writeModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { + suspend fun writeModeAttribute( + value: UByte, + timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = - listOf( - WriteRequest( - attributePath = - AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = listOf( + WriteRequest( + attributePath = AttributePath( + endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2315,7 +2413,7 @@ class WindowCoveringCluster( throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeModeAttribute( @@ -2323,37 +2421,35 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UByteSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Mode attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Mode attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2365,41 +2461,47 @@ class WindowCoveringCluster( emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readSafetyStatusAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 26u - suspend fun readSafetyStatusAttribute(): UShort? { - val ATTRIBUTE_ID: UInt = 26u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Safetystatus attribute not found in response" } + } + + requireNotNull(attributeData) { + "Safetystatus attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + return decodedValue } @@ -2409,90 +2511,96 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Safetystatus attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Safetystatus attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } + decodedValue?.let { + emit(UShortSubscriptionState.Success(it)) + } + } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return GeneratedCommandListAttribute(decodedValue) } @@ -2502,50 +2610,45 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - GeneratedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2553,43 +2656,49 @@ class WindowCoveringCluster( emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { - val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AcceptedCommandListAttribute(decodedValue) } @@ -2599,50 +2708,45 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AcceptedCommandListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2650,43 +2754,49 @@ class WindowCoveringCluster( emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - suspend fun readEventListAttribute(): EventListAttribute { - val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Eventlist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return EventListAttribute(decodedValue) } @@ -2696,48 +2806,45 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - EventListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Eventlist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2745,43 +2852,49 @@ class WindowCoveringCluster( emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - suspend fun readAttributeListAttribute(): AttributeListAttribute { - val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Attributelist attribute not found in response" } + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) } + tlvReader.exitContainer() + } + return AttributeListAttribute(decodedValue) } @@ -2791,48 +2904,45 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - AttributeListAttributeSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Attributelist attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = - buildList { - tlvReader.enterArray(AnonymousTag) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = buildList { + tlvReader.enterArray(AnonymousTag) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2840,37 +2950,44 @@ class WindowCoveringCluster( emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - suspend fun readFeatureMapAttribute(): UInt { - val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Featuremap attribute not found in response" } + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) + return decodedValue } @@ -2879,37 +2996,35 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UIntSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Featuremap attribute not found in Node State update" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2921,37 +3036,44 @@ class WindowCoveringCluster( emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } +suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - suspend fun readClusterRevisionAttribute(): UShort { - val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) - - val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val attributePath = AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID + ) + val readRequest = ReadRequest( + eventPaths = emptyList(), + attributePaths = listOf(attributePath) + ) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in response" + } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) + return decodedValue } @@ -2960,38 +3082,34 @@ class WindowCoveringCluster( maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = - listOf( - AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + val attributePaths = listOf( + AttributePath( + endpointId = endpointId, + clusterId = CLUSTER_ID, + attributeId = ATTRIBUTE_ID ) + ) - val subscribeRequest: SubscribeRequest = - SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit( - UShortSubscriptionState.Error( - Exception( - "Subscription terminated with error code: ${subscriptionState.terminationCause}" - ) - ) - ) + emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes - .filterIsInstance() - .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes.filterIsInstance().firstOrNull { + it.path.attributeId == ATTRIBUTE_ID + } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3004,7 +3122,7 @@ class WindowCoveringCluster( emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt index bd0e6187f24cb5..391c1c223d35b1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -70,47 +72,32 @@ class AccessControlClusterAccessControlEntryChangedEvent( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): AccessControlClusterAccessControlEntryChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlEntryChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = - if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUByte(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = - if (!tlvReader.isNull()) { - matter.controller.cluster.structs.AccessControlClusterAccessControlEntryStruct.fromTlv( - ContextSpecificTag(TAG_LATEST_VALUE), - tlvReader - ) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = if (!tlvReader.isNull()) { + matter.controller.cluster.structs.AccessControlClusterAccessControlEntryStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryChangedEvent( - adminNodeID, - adminPasscodeID, - changeType, - latestValue, - fabricIndex - ) + return AccessControlClusterAccessControlEntryChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt index aa38ea414d325f..dafa1269b8e4c2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -26,8 +28,7 @@ class AccessControlClusterAccessControlExtensionChangedEvent( val adminNodeID: ULong?, val adminPasscodeID: UShort?, val changeType: UByte, - val latestValue: - matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, + val latestValue: matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, val fabricIndex: UByte ) { override fun toString(): String = buildString { @@ -71,45 +72,32 @@ class AccessControlClusterAccessControlExtensionChangedEvent( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): AccessControlClusterAccessControlExtensionChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlExtensionChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = - if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUByte(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = - if (!tlvReader.isNull()) { - matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct - .fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = if (!tlvReader.isNull()) { + matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlExtensionChangedEvent( - adminNodeID, - adminPasscodeID, - changeType, - latestValue, - fabricIndex - ) + return AccessControlClusterAccessControlExtensionChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt index 81e55baf4fe4f7..4adc0b113c8e01 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt @@ -18,12 +18,15 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccountLoginClusterLoggedOutEvent(val node: Optional) { +class AccountLoginClusterLoggedOutEvent( + val node: Optional +) { override fun toString(): String = buildString { append("AccountLoginClusterLoggedOutEvent {\n") append("\tnode : $node\n") @@ -44,15 +47,14 @@ class AccountLoginClusterLoggedOutEvent(val node: Optional) { companion object { private const val TAG_NODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccountLoginClusterLoggedOutEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccountLoginClusterLoggedOutEvent { tlvReader.enterStructure(tlvTag) - val node = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - + val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return AccountLoginClusterLoggedOutEvent(node) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt index c1c26f5dc71c4a..90612b49fdd1d2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -54,13 +56,13 @@ class ActionsClusterActionFailedEvent( private const val TAG_NEW_STATE = 2 private const val TAG_ERROR = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterActionFailedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterActionFailedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUShort(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getUInt(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) val error = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR)) - + tlvReader.exitContainer() return ActionsClusterActionFailedEvent(actionID, invokeID, newState, error) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt index 25fdc842bf0af1..2cf57936d0421c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,12 +52,12 @@ class ActionsClusterStateChangedEvent( private const val TAG_INVOKE_I_D = 1 private const val TAG_NEW_STATE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUShort(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getUInt(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) - + tlvReader.exitContainer() return ActionsClusterStateChangedEvent(actionID, invokeID, newState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt index ea0e7e1e1004c4..2b909a62b20b6f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterLeaveEvent(val fabricIndex: UByte) { +class BasicInformationClusterLeaveEvent( + val fabricIndex: UByte +) { override fun toString(): String = buildString { append("BasicInformationClusterLeaveEvent {\n") append("\tfabricIndex : $fabricIndex\n") @@ -40,10 +44,10 @@ class BasicInformationClusterLeaveEvent(val fabricIndex: UByte) { companion object { private const val TAG_FABRIC_INDEX = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterLeaveEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterLeaveEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BasicInformationClusterLeaveEvent(fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt index a6924b859aa024..4bacfa94d86ef9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { +class BasicInformationClusterReachableChangedEvent( + val reachableNewValue: Boolean +) { override fun toString(): String = buildString { append("BasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") @@ -40,10 +44,10 @@ class BasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolea companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterReachableChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt index fff1d76a1fa86e..949ae5f92688a0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterStartUpEvent(val softwareVersion: UInt) { +class BasicInformationClusterStartUpEvent( + val softwareVersion: UInt +) { override fun toString(): String = buildString { append("BasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") @@ -40,10 +44,10 @@ class BasicInformationClusterStartUpEvent(val softwareVersion: UInt) { companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterStartUpEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt index 82db9ecdb2a8f4..50b4494eebdc0d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateClusterStateChangeEvent(val stateValue: Boolean) { +class BooleanStateClusterStateChangeEvent( + val stateValue: Boolean +) { override fun toString(): String = buildString { append("BooleanStateClusterStateChangeEvent {\n") append("\tstateValue : $stateValue\n") @@ -40,10 +44,10 @@ class BooleanStateClusterStateChangeEvent(val stateValue: Boolean) { companion object { private const val TAG_STATE_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BooleanStateClusterStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateClusterStateChangeEvent { tlvReader.enterStructure(tlvTag) val stateValue = tlvReader.getBoolean(ContextSpecificTag(TAG_STATE_VALUE)) - + tlvReader.exitContainer() return BooleanStateClusterStateChangeEvent(stateValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt index f6777c819c9a57..14d64045516493 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,19 +51,15 @@ class BooleanStateConfigurationClusterAlarmsStateChangedEvent( private const val TAG_ALARMS_ACTIVE = 0 private const val TAG_ALARMS_SUPPRESSED = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): BooleanStateConfigurationClusterAlarmsStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterAlarmsStateChangedEvent { tlvReader.enterStructure(tlvTag) val alarmsActive = tlvReader.getUByte(ContextSpecificTag(TAG_ALARMS_ACTIVE)) - val alarmsSuppressed = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) - } else { - Optional.empty() - } - + val alarmsSuppressed = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return BooleanStateConfigurationClusterAlarmsStateChangedEvent(alarmsActive, alarmsSuppressed) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt index d29696d04cc3bf..750d449968ba98 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateConfigurationClusterSensorFaultEvent(val sensorFault: UShort) { +class BooleanStateConfigurationClusterSensorFaultEvent( + val sensorFault: UShort +) { override fun toString(): String = buildString { append("BooleanStateConfigurationClusterSensorFaultEvent {\n") append("\tsensorFault : $sensorFault\n") @@ -40,13 +44,10 @@ class BooleanStateConfigurationClusterSensorFaultEvent(val sensorFault: UShort) companion object { private const val TAG_SENSOR_FAULT = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): BooleanStateConfigurationClusterSensorFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterSensorFaultEvent { tlvReader.enterStructure(tlvTag) val sensorFault = tlvReader.getUShort(ContextSpecificTag(TAG_SENSOR_FAULT)) - + tlvReader.exitContainer() return BooleanStateConfigurationClusterSensorFaultEvent(sensorFault) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt index 2bdca2fbfb016e..5bd65929e12bdc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { +class BridgedDeviceBasicInformationClusterReachableChangedEvent( + val reachableNewValue: Boolean +) { override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") @@ -40,13 +44,10 @@ class BridgedDeviceBasicInformationClusterReachableChangedEvent(val reachableNew companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): BridgedDeviceBasicInformationClusterReachableChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt index e812711dad48f2..67aa89e3788154 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationClusterStartUpEvent(val softwareVersion: UInt) { +class BridgedDeviceBasicInformationClusterStartUpEvent( + val softwareVersion: UInt +) { override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") @@ -40,13 +44,10 @@ class BridgedDeviceBasicInformationClusterStartUpEvent(val softwareVersion: UInt companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): BridgedDeviceBasicInformationClusterStartUpEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt index 21b147d7ffb931..fe72fb0963a739 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -29,26 +30,11 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( val status: UByte, val criticality: UByte, val control: UShort, - val temperatureControl: - Optional< - matter.controller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct - >?, - val averageLoadControl: - Optional< - matter.controller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct - >?, - val dutyCycleControl: - Optional< - matter.controller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct - >?, - val powerSavingsControl: - Optional< - matter.controller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct - >?, - val heatingSourceControl: - Optional< - matter.controller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct - >? + val temperatureControl: Optional?, + val averageLoadControl: Optional?, + val dutyCycleControl: Optional?, + val powerSavingsControl: Optional?, + val heatingSourceControl: Optional? ) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent {\n") @@ -79,41 +65,41 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( put(ContextSpecificTag(TAG_CONTROL), control) if (temperatureControl != null) { if (temperatureControl.isPresent) { - val opttemperatureControl = temperatureControl.get() - opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) - } + val opttemperatureControl = temperatureControl.get() + opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) } if (averageLoadControl != null) { if (averageLoadControl.isPresent) { - val optaverageLoadControl = averageLoadControl.get() - optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) - } + val optaverageLoadControl = averageLoadControl.get() + optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) } if (dutyCycleControl != null) { if (dutyCycleControl.isPresent) { - val optdutyCycleControl = dutyCycleControl.get() - optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) - } + val optdutyCycleControl = dutyCycleControl.get() + optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) } if (powerSavingsControl != null) { if (powerSavingsControl.isPresent) { - val optpowerSavingsControl = powerSavingsControl.get() - optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) - } + val optpowerSavingsControl = powerSavingsControl.get() + optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) } if (heatingSourceControl != null) { if (heatingSourceControl.isPresent) { - val optheatingSourceControl = heatingSourceControl.get() - optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) - } + val optheatingSourceControl = heatingSourceControl.get() + optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) } @@ -133,112 +119,72 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( private const val TAG_POWER_SAVINGS_CONTROL = 8 private const val TAG_HEATING_SOURCE_CONTROL = 9 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val transitionIndex = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_TRANSITION_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) - null - } + val transitionIndex = if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_TRANSITION_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) + null + } val status = tlvReader.getUByte(ContextSpecificTag(TAG_STATUS)) val criticality = tlvReader.getUByte(ContextSpecificTag(TAG_CRITICALITY)) val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of( - matter.controller.cluster.structs - .DemandResponseLoadControlClusterTemperatureControlStruct - .fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) - null - } - val averageLoadControl = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of( - matter.controller.cluster.structs - .DemandResponseLoadControlClusterAverageLoadControlStruct - .fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) - null - } - val dutyCycleControl = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of( - matter.controller.cluster.structs - .DemandResponseLoadControlClusterDutyCycleControlStruct - .fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) - null - } - val powerSavingsControl = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of( - matter.controller.cluster.structs - .DemandResponseLoadControlClusterPowerSavingsControlStruct - .fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) - null - } - val heatingSourceControl = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of( - matter.controller.cluster.structs - .DemandResponseLoadControlClusterHeatingSourceControlStruct - .fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) - null - } - + val temperatureControl = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) + null + } + val averageLoadControl = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) + null + } + val dutyCycleControl = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) + null + } + val powerSavingsControl = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) + null + } + val heatingSourceControl = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( - eventID, - transitionIndex, - status, - criticality, - control, - temperatureControl, - averageLoadControl, - dutyCycleControl, - powerSavingsControl, - heatingSourceControl - ) + return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent(eventID, transitionIndex, status, criticality, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt index 10bda0f46af030..e05ca8e86ba704 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,15 +52,12 @@ class DeviceEnergyManagementClusterPowerAdjustEndEvent( private const val TAG_DURATION = 1 private const val TAG_ENERGY_USE = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DeviceEnergyManagementClusterPowerAdjustEndEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterPowerAdjustEndEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUByte(ContextSpecificTag(TAG_CAUSE)) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) val energyUse = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_USE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterPowerAdjustEndEvent(cause, duration, energyUse) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt index db5219f72dba0e..8d103f74e33de4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementClusterResumedEvent(val cause: UByte) { +class DeviceEnergyManagementClusterResumedEvent( + val cause: UByte +) { override fun toString(): String = buildString { append("DeviceEnergyManagementClusterResumedEvent {\n") append("\tcause : $cause\n") @@ -40,10 +44,10 @@ class DeviceEnergyManagementClusterResumedEvent(val cause: UByte) { companion object { private const val TAG_CAUSE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterResumedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterResumedEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUByte(ContextSpecificTag(TAG_CAUSE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterResumedEvent(cause) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt index d6a5d9227ec845..e17f43ed147ae0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -54,13 +56,13 @@ class DishwasherAlarmClusterNotifyEvent( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getUInt(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getUInt(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return DishwasherAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt index 233130a2371a2e..a04df8246a437e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterDoorLockAlarmEvent(val alarmCode: UByte) { +class DoorLockClusterDoorLockAlarmEvent( + val alarmCode: UByte +) { override fun toString(): String = buildString { append("DoorLockClusterDoorLockAlarmEvent {\n") append("\talarmCode : $alarmCode\n") @@ -40,10 +44,10 @@ class DoorLockClusterDoorLockAlarmEvent(val alarmCode: UByte) { companion object { private const val TAG_ALARM_CODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorLockAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorLockAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmCode = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_CODE)) - + tlvReader.exitContainer() return DoorLockClusterDoorLockAlarmEvent(alarmCode) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt index 92d04f6662dffe..c0dd0441ac3010 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterDoorStateChangeEvent(val doorState: UByte) { +class DoorLockClusterDoorStateChangeEvent( + val doorState: UByte +) { override fun toString(): String = buildString { append("DoorLockClusterDoorStateChangeEvent {\n") append("\tdoorState : $doorState\n") @@ -40,10 +44,10 @@ class DoorLockClusterDoorStateChangeEvent(val doorState: UByte) { companion object { private const val TAG_DOOR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorStateChangeEvent { tlvReader.enterStructure(tlvTag) val doorState = tlvReader.getUByte(ContextSpecificTag(TAG_DOOR_STATE)) - + tlvReader.exitContainer() return DoorLockClusterDoorStateChangeEvent(doorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt index 0834fde8914a0d..af031bad313f8f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt @@ -31,8 +31,7 @@ class DoorLockClusterLockOperationErrorEvent( val userIndex: UShort?, val fabricIndex: UByte?, val sourceNode: ULong?, - val credentials: - Optional>? + val credentials: Optional>? ) { override fun toString(): String = buildString { append("DoorLockClusterLockOperationErrorEvent {\n") @@ -69,13 +68,13 @@ class DoorLockClusterLockOperationErrorEvent( } if (credentials != null) { if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() - } + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } } else { putNull(ContextSpecificTag(TAG_CREDENTIALS)) } @@ -92,68 +91,49 @@ class DoorLockClusterLockOperationErrorEvent( private const val TAG_SOURCE_NODE = 5 private const val TAG_CREDENTIALS = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationErrorEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) val operationError = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_ERROR)) - val userIndex = - if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while (!tlvReader.isEndOfContainer()) { - this.add( - matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null + val userIndex = if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while(!tlvReader.isEndOfContainer()) { + this.add(matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) } - + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationErrorEvent( - lockOperationType, - operationSource, - operationError, - userIndex, - fabricIndex, - sourceNode, - credentials - ) + return DoorLockClusterLockOperationErrorEvent(lockOperationType, operationSource, operationError, userIndex, fabricIndex, sourceNode, credentials) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt index c063f08d6d1e64..d47734e612adc8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt @@ -30,8 +30,7 @@ class DoorLockClusterLockOperationEvent( val userIndex: UShort?, val fabricIndex: UByte?, val sourceNode: ULong?, - val credentials: - Optional>? + val credentials: Optional>? ) { override fun toString(): String = buildString { append("DoorLockClusterLockOperationEvent {\n") @@ -66,13 +65,13 @@ class DoorLockClusterLockOperationEvent( } if (credentials != null) { if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() - } + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } } else { putNull(ContextSpecificTag(TAG_CREDENTIALS)) } @@ -88,66 +87,48 @@ class DoorLockClusterLockOperationEvent( private const val TAG_SOURCE_NODE = 4 private const val TAG_CREDENTIALS = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = - if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while (!tlvReader.isEndOfContainer()) { - this.add( - matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null + val userIndex = if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while(!tlvReader.isEndOfContainer()) { + this.add(matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) } - + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationEvent( - lockOperationType, - operationSource, - userIndex, - fabricIndex, - sourceNode, - credentials - ) + return DoorLockClusterLockOperationEvent(lockOperationType, operationSource, userIndex, fabricIndex, sourceNode, credentials) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt index 3d3cd635977b85..bb39257e80cd71 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -82,51 +84,39 @@ class DoorLockClusterLockUserChangeEvent( private const val TAG_SOURCE_NODE = 5 private const val TAG_DATA_INDEX = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockUserChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockUserChangeEvent { tlvReader.enterStructure(tlvTag) val lockDataType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_DATA_TYPE)) val dataOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_DATA_OPERATION_TYPE)) val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = - if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val dataIndex = - if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_DATA_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) - null - } - + val userIndex = if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val dataIndex = if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_DATA_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockUserChangeEvent( - lockDataType, - dataOperationType, - operationSource, - userIndex, - fabricIndex, - sourceNode, - dataIndex - ) + return DoorLockClusterLockUserChangeEvent(lockDataType, dataOperationType, operationSource, userIndex, fabricIndex, sourceNode, dataIndex) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt index 2533881132950b..8fecbdd04a6da1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt @@ -18,20 +18,15 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( - val energyImported: - Optional< - matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - >, - val energyExported: - Optional< - matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - > + val energyImported: Optional, + val energyExported: Optional ) { override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent {\n") @@ -59,38 +54,22 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of( - matter.controller.cluster.structs - .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) - ) - } else { - Optional.empty() - } - val energyExported = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of( - matter.controller.cluster.structs - .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) - ) - } else { - Optional.empty() - } - + val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) + } else { + Optional.empty() + } + val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( - energyImported, - energyExported - ) + return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent(energyImported, energyExported) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt index 17194fbe3f7d84..65f3e9e1dc1ba1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt @@ -18,20 +18,15 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( - val energyImported: - Optional< - matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - >, - val energyExported: - Optional< - matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - > + val energyImported: Optional, + val energyExported: Optional ) { override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent {\n") @@ -59,38 +54,22 @@ class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of( - matter.controller.cluster.structs - .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) - ) - } else { - Optional.empty() - } - val energyExported = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of( - matter.controller.cluster.structs - .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct - .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) - ) - } else { - Optional.empty() - } - + val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) + } else { + Optional.empty() + } + val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( - energyImported, - energyExported - ) + return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent(energyImported, energyExported) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt index a0770e7e82af07..6cc387e2e019e1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterEVConnectedEvent(val sessionID: UInt) { +class EnergyEvseClusterEVConnectedEvent( + val sessionID: UInt +) { override fun toString(): String = buildString { append("EnergyEvseClusterEVConnectedEvent {\n") append("\tsessionID : $sessionID\n") @@ -40,10 +44,10 @@ class EnergyEvseClusterEVConnectedEvent(val sessionID: UInt) { companion object { private const val TAG_SESSION_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVConnectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVConnectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) - + tlvReader.exitContainer() return EnergyEvseClusterEVConnectedEvent(sessionID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt index 673441a49f6265..ac7c61d1a78738 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -62,28 +63,21 @@ class EnergyEvseClusterEVNotDetectedEvent( private const val TAG_SESSION_ENERGY_CHARGED = 3 private const val TAG_SESSION_ENERGY_DISCHARGED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVNotDetectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVNotDetectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val sessionDuration = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_DURATION)) val sessionEnergyCharged = tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_CHARGED)) - val sessionEnergyDischarged = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) - } else { - Optional.empty() - } - + val sessionEnergyDischarged = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterEVNotDetectedEvent( - sessionID, - state, - sessionDuration, - sessionEnergyCharged, - sessionEnergyDischarged - ) + return EnergyEvseClusterEVNotDetectedEvent(sessionID, state, sessionDuration, sessionEnergyCharged, sessionEnergyDischarged) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt index 0cd20e3e47ade3..5a121c64f1fb70 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,12 +52,12 @@ class EnergyEvseClusterEnergyTransferStartedEvent( private const val TAG_STATE = 1 private const val TAG_MAXIMUM_CURRENT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStartedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStartedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val maximumCurrent = tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_CURRENT)) - + tlvReader.exitContainer() return EnergyEvseClusterEnergyTransferStartedEvent(sessionID, state, maximumCurrent) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt index 093f687fb16662..01b19535348c67 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -54,21 +56,16 @@ class EnergyEvseClusterEnergyTransferStoppedEvent( private const val TAG_REASON = 2 private const val TAG_ENERGY_TRANSFERRED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStoppedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStoppedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val reason = tlvReader.getUByte(ContextSpecificTag(TAG_REASON)) val energyTransferred = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_TRANSFERRED)) - + tlvReader.exitContainer() - return EnergyEvseClusterEnergyTransferStoppedEvent( - sessionID, - state, - reason, - energyTransferred - ) + return EnergyEvseClusterEnergyTransferStoppedEvent(sessionID, state, reason, energyTransferred) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt index 2167c1fca408eb..e49931cd4b55b8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -58,29 +60,21 @@ class EnergyEvseClusterFaultEvent( private const val TAG_FAULT_STATE_PREVIOUS_STATE = 2 private const val TAG_FAULT_STATE_CURRENT_STATE = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterFaultEvent { tlvReader.enterStructure(tlvTag) - val sessionID = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) - null - } + val sessionID = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) + null + } val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) - val faultStatePreviousState = - tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) - val faultStateCurrentState = - tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) - + val faultStatePreviousState = tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) + val faultStateCurrentState = tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) + tlvReader.exitContainer() - return EnergyEvseClusterFaultEvent( - sessionID, - state, - faultStatePreviousState, - faultStateCurrentState - ) + return EnergyEvseClusterFaultEvent(sessionID, state, faultStatePreviousState, faultStateCurrentState) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt index cf0fe503e13bd8..6db4c1a10ed59f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterRFIDEvent(val uid: ByteArray) { +class EnergyEvseClusterRFIDEvent( + val uid: ByteArray +) { override fun toString(): String = buildString { append("EnergyEvseClusterRFIDEvent {\n") append("\tuid : $uid\n") @@ -40,10 +44,10 @@ class EnergyEvseClusterRFIDEvent(val uid: ByteArray) { companion object { private const val TAG_UID = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterRFIDEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterRFIDEvent { tlvReader.enterStructure(tlvTag) val uid = tlvReader.getByteArray(ContextSpecificTag(TAG_UID)) - + tlvReader.exitContainer() return EnergyEvseClusterRFIDEvent(uid) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt index 8d13675dece145..5d6ee591cdf22d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralDiagnosticsClusterBootReasonEvent(val bootReason: UByte) { +class GeneralDiagnosticsClusterBootReasonEvent( + val bootReason: UByte +) { override fun toString(): String = buildString { append("GeneralDiagnosticsClusterBootReasonEvent {\n") append("\tbootReason : $bootReason\n") @@ -40,10 +44,10 @@ class GeneralDiagnosticsClusterBootReasonEvent(val bootReason: UByte) { companion object { private const val TAG_BOOT_REASON = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterBootReasonEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterBootReasonEvent { tlvReader.enterStructure(tlvTag) val bootReason = tlvReader.getUByte(ContextSpecificTag(TAG_BOOT_REASON)) - + tlvReader.exitContainer() return GeneralDiagnosticsClusterBootReasonEvent(bootReason) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt index 5b7e6cd0f947aa..415b83a66b74ba 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -55,28 +56,23 @@ class GeneralDiagnosticsClusterHardwareFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): GeneralDiagnosticsClusterHardwareFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterHardwareFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterHardwareFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt index f256dddde339d2..e5ae628b6edfc1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -55,28 +56,23 @@ class GeneralDiagnosticsClusterNetworkFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): GeneralDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt index 027949831806c8..9ebbfae718bb68 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -55,25 +56,23 @@ class GeneralDiagnosticsClusterRadioFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterRadioFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterRadioFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterRadioFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt index 3326660b5e35d0..d7b7eb6f0d01d5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -78,40 +79,25 @@ class MediaPlaybackClusterStateChangedEvent( private const val TAG_DATA = 7 private const val TAG_AUDIO_ADVANCE_UNMUTED = 8 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val currentState = tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_STATE)) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - val sampledPosition = - matter.controller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv( - ContextSpecificTag(TAG_SAMPLED_POSITION), - tlvReader - ) + val sampledPosition = matter.controller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv(ContextSpecificTag(TAG_SAMPLED_POSITION), tlvReader) val playbackSpeed = tlvReader.getFloat(ContextSpecificTag(TAG_PLAYBACK_SPEED)) val seekRangeEnd = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_END)) val seekRangeStart = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_START)) - val data = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) - } else { - Optional.empty() - } + val data = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) + } else { + Optional.empty() + } val audioAdvanceUnmuted = tlvReader.getBoolean(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED)) - + tlvReader.exitContainer() - return MediaPlaybackClusterStateChangedEvent( - currentState, - startTime, - duration, - sampledPosition, - playbackSpeed, - seekRangeEnd, - seekRangeStart, - data, - audioAdvanceUnmuted - ) + return MediaPlaybackClusterStateChangedEvent(currentState, startTime, duration, sampledPosition, playbackSpeed, seekRangeEnd, seekRangeStart, data, audioAdvanceUnmuted) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt index 4ae90661a7b56b..e5a17a96700fca 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -42,17 +43,17 @@ class OperationalStateClusterOperationCompletionEvent( put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } } else { putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) } if (pausedTime != null) { if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } } else { putNull(ContextSpecificTag(TAG_PAUSED_TIME)) } @@ -65,42 +66,33 @@ class OperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OperationalStateClusterOperationCompletionEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OperationalStateClusterOperationCompletionEvent( - completionErrorCode, - totalOperationalTime, - pausedTime - ) + return OperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt index fc6e4797a28b46..10bd2f4144b114 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -42,14 +44,10 @@ class OperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = - matter.controller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv( - ContextSpecificTag(TAG_ERROR_STATE), - tlvReader - ) - + val errorState = matter.controller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) + tlvReader.exitContainer() return OperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt index e3fbe9c5bf247f..3cdebe626405a4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -62,36 +64,26 @@ class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( private const val TAG_PROGRESS_PERCENT = 2 private const val TAG_PLATFORM_CODE = 3 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val bytesDownloaded = tlvReader.getULong(ContextSpecificTag(TAG_BYTES_DOWNLOADED)) - val progressPercent = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - null - } - val platformCode = - if (!tlvReader.isNull()) { - tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) - null - } - + val progressPercent = if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + null + } + val platformCode = if (!tlvReader.isNull()) { + tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( - softwareVersion, - bytesDownloaded, - progressPercent, - platformCode - ) + return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent(softwareVersion, bytesDownloaded, progressPercent, platformCode) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt index 52ff425323115b..cacab69022c9c7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -58,30 +60,21 @@ class OtaSoftwareUpdateRequestorClusterStateTransitionEvent( private const val TAG_REASON = 2 private const val TAG_TARGET_SOFTWARE_VERSION = 3 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OtaSoftwareUpdateRequestorClusterStateTransitionEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterStateTransitionEvent { tlvReader.enterStructure(tlvTag) val previousState = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_STATE)) val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) val reason = tlvReader.getUByte(ContextSpecificTag(TAG_REASON)) - val targetSoftwareVersion = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - null - } - + val targetSoftwareVersion = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterStateTransitionEvent( - previousState, - newState, - reason, - targetSoftwareVersion - ) + return OtaSoftwareUpdateRequestorClusterStateTransitionEvent(previousState, newState, reason, targetSoftwareVersion) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt index cd39219a42e3bf..227e0915fba374 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,14 +48,11 @@ class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent( private const val TAG_SOFTWARE_VERSION = 0 private const val TAG_PRODUCT_I_D = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val productID = tlvReader.getUShort(ContextSpecificTag(TAG_PRODUCT_I_D)) - + tlvReader.exitContainer() return OtaSoftwareUpdateRequestorClusterVersionAppliedEvent(softwareVersion, productID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt index 7220e0afa693d2..c2f767d8be59a5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -42,17 +43,17 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent( put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } } else { putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) } if (pausedTime != null) { if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } } else { putNull(ContextSpecificTag(TAG_PAUSED_TIME)) } @@ -65,42 +66,33 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OvenCavityOperationalStateClusterOperationCompletionEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationCompletionEvent( - completionErrorCode, - totalOperationalTime, - pausedTime - ) + return OvenCavityOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt index bfaa8f75b3b597..ee5fe0b442932f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt @@ -16,15 +16,16 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class OvenCavityOperationalStateClusterOperationalErrorEvent( - val errorState: - matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct + val errorState: matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct ) { override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationalErrorEvent {\n") @@ -43,17 +44,10 @@ class OvenCavityOperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OvenCavityOperationalStateClusterOperationalErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = - matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct.fromTlv( - ContextSpecificTag(TAG_ERROR_STATE), - tlvReader - ) - + val errorState = matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) + tlvReader.exitContainer() return OvenCavityOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt index 8e189c26173639..6669a84bd6ec2e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -55,25 +56,23 @@ class PowerSourceClusterBatChargeFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatChargeFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt index 7aa1a81b862fd5..50752bc8ce3d78 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -23,7 +24,10 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatFaultChangeEvent(val current: List, val previous: List) { +class PowerSourceClusterBatFaultChangeEvent( + val current: List, + val previous: List +) { override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeEvent {\n") append("\tcurrent : $current\n") @@ -52,25 +56,23 @@ class PowerSourceClusterBatFaultChangeEvent(val current: List, val previo private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt index 5dc6444f06cd51..9f125a71de6a58 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -23,7 +24,10 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterWiredFaultChangeEvent(val current: List, val previous: List) { +class PowerSourceClusterWiredFaultChangeEvent( + val current: List, + val previous: List +) { override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeEvent {\n") append("\tcurrent : $current\n") @@ -52,25 +56,23 @@ class PowerSourceClusterWiredFaultChangeEvent(val current: List, val prev private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterWiredFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt index 8bfdf23df2be69..75df72186f31ce 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -54,13 +56,13 @@ class RefrigeratorAlarmClusterNotifyEvent( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getUInt(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getUInt(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return RefrigeratorAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt index eaafde5a0c8c68..82db20e092df34 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -42,17 +43,17 @@ class RvcOperationalStateClusterOperationCompletionEvent( put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } } else { putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) } if (pausedTime != null) { if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } } else { putNull(ContextSpecificTag(TAG_PAUSED_TIME)) } @@ -65,42 +66,33 @@ class RvcOperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): RvcOperationalStateClusterOperationCompletionEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationCompletionEvent( - completionErrorCode, - totalOperationalTime, - pausedTime - ) + return RvcOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt index 7a78710f647235..092b9234e3b44d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -42,17 +44,10 @@ class RvcOperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): RvcOperationalStateClusterOperationalErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = - matter.controller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv( - ContextSpecificTag(TAG_ERROR_STATE), - tlvReader - ) - + val errorState = matter.controller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) + tlvReader.exitContainer() return RvcOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt index 5570ba7a3af4a3..e6853817f212a1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SampleMeiClusterPingCountEventEvent(val count: UInt, val fabricIndex: UByte) { +class SampleMeiClusterPingCountEventEvent( + val count: UInt, + val fabricIndex: UByte +) { override fun toString(): String = buildString { append("SampleMeiClusterPingCountEventEvent {\n") append("\tcount : $count\n") @@ -43,11 +48,11 @@ class SampleMeiClusterPingCountEventEvent(val count: UInt, val fabricIndex: UByt private const val TAG_COUNT = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingCountEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SampleMeiClusterPingCountEventEvent { tlvReader.enterStructure(tlvTag) val count = tlvReader.getUInt(ContextSpecificTag(TAG_COUNT)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return SampleMeiClusterPingCountEventEvent(count, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt index 52c7a19053aacb..ab23f8de4499fc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterCOAlarmEvent(val alarmSeverityLevel: UByte) { +class SmokeCoAlarmClusterCOAlarmEvent( + val alarmSeverityLevel: UByte +) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -40,10 +44,10 @@ class SmokeCoAlarmClusterCOAlarmEvent(val alarmSeverityLevel: UByte) { companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt index 80c6a860b1ccc0..3ccd697a30d045 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterInterconnectCOAlarmEvent(val alarmSeverityLevel: UByte) { +class SmokeCoAlarmClusterInterconnectCOAlarmEvent( + val alarmSeverityLevel: UByte +) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -40,10 +44,10 @@ class SmokeCoAlarmClusterInterconnectCOAlarmEvent(val alarmSeverityLevel: UByte) companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt index 2a3f3f2d05c730..3edfa2543f5b3f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(val alarmSeverityLevel: UByte) { +class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent( + val alarmSeverityLevel: UByte +) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -40,10 +44,10 @@ class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(val alarmSeverityLevel: UBy companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt index 3930c40935d0ef..42579fecbdda42 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterLowBatteryEvent(val alarmSeverityLevel: UByte) { +class SmokeCoAlarmClusterLowBatteryEvent( + val alarmSeverityLevel: UByte +) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterLowBatteryEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -40,10 +44,10 @@ class SmokeCoAlarmClusterLowBatteryEvent(val alarmSeverityLevel: UByte) { companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterLowBatteryEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterLowBatteryEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterLowBatteryEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt index 934c42da5479a2..25a54c367090c2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterSmokeAlarmEvent(val alarmSeverityLevel: UByte) { +class SmokeCoAlarmClusterSmokeAlarmEvent( + val alarmSeverityLevel: UByte +) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -40,10 +44,10 @@ class SmokeCoAlarmClusterSmokeAlarmEvent(val alarmSeverityLevel: UByte) { companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt index c7ac6b65eae4dc..5d78915d64828a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,22 +58,20 @@ class SoftwareDiagnosticsClusterSoftwareFaultEvent( private const val TAG_NAME = 1 private const val TAG_FAULT_RECORDING = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterSoftwareFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SoftwareDiagnosticsClusterSoftwareFaultEvent { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val faultRecording = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) - } else { - Optional.empty() - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val faultRecording = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return SoftwareDiagnosticsClusterSoftwareFaultEvent(id, name, faultRecording) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt index f7a74f79826494..eef9c3864807ea 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterInitialPressEvent(val newPosition: UByte) { +class SwitchClusterInitialPressEvent( + val newPosition: UByte +) { override fun toString(): String = buildString { append("SwitchClusterInitialPressEvent {\n") append("\tnewPosition : $newPosition\n") @@ -40,10 +44,10 @@ class SwitchClusterInitialPressEvent(val newPosition: UByte) { companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterInitialPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterInitialPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterInitialPressEvent(newPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt index bacc49c76bbc53..42cd9c501135bc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterLongPressEvent(val newPosition: UByte) { +class SwitchClusterLongPressEvent( + val newPosition: UByte +) { override fun toString(): String = buildString { append("SwitchClusterLongPressEvent {\n") append("\tnewPosition : $newPosition\n") @@ -40,10 +44,10 @@ class SwitchClusterLongPressEvent(val newPosition: UByte) { companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongPressEvent(newPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt index cbd0166269542b..8de4860fe1f299 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterLongReleaseEvent(val previousPosition: UByte) { +class SwitchClusterLongReleaseEvent( + val previousPosition: UByte +) { override fun toString(): String = buildString { append("SwitchClusterLongReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") @@ -40,10 +44,10 @@ class SwitchClusterLongReleaseEvent(val previousPosition: UByte) { companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt index 4a82b4914ea426..49d9b22f9b45ff 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,12 +48,11 @@ class SwitchClusterMultiPressCompleteEvent( private const val TAG_PREVIOUS_POSITION = 0 private const val TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressCompleteEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressCompleteEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - val totalNumberOfPressesCounted = - tlvReader.getUByte(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) - + val totalNumberOfPressesCounted = tlvReader.getUByte(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressCompleteEvent(previousPosition, totalNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt index 4bf6776e64f14a..104be8f4fb63ee 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,12 +48,11 @@ class SwitchClusterMultiPressOngoingEvent( private const val TAG_NEW_POSITION = 0 private const val TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressOngoingEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressOngoingEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - val currentNumberOfPressesCounted = - tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) - + val currentNumberOfPressesCounted = tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressOngoingEvent(newPosition, currentNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt index c08c0e63f8b5e1..156c253a485af1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterShortReleaseEvent(val previousPosition: UByte) { +class SwitchClusterShortReleaseEvent( + val previousPosition: UByte +) { override fun toString(): String = buildString { append("SwitchClusterShortReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") @@ -40,10 +44,10 @@ class SwitchClusterShortReleaseEvent(val previousPosition: UByte) { companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterShortReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterShortReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterShortReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt index 4aae22fb446979..f08eaeee96a617 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterSwitchLatchedEvent(val newPosition: UByte) { +class SwitchClusterSwitchLatchedEvent( + val newPosition: UByte +) { override fun toString(): String = buildString { append("SwitchClusterSwitchLatchedEvent {\n") append("\tnewPosition : $newPosition\n") @@ -40,10 +44,10 @@ class SwitchClusterSwitchLatchedEvent(val newPosition: UByte) { companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterSwitchLatchedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterSwitchLatchedEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterSwitchLatchedEvent(newPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt index 0d56be60d4b36e..86a03eb5080eba 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -55,24 +56,18 @@ class TargetNavigatorClusterTargetUpdatedEvent( private const val TAG_CURRENT_TARGET = 1 private const val TAG_DATA = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TargetNavigatorClusterTargetUpdatedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TargetNavigatorClusterTargetUpdatedEvent { tlvReader.enterStructure(tlvTag) - val targetList = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) - while (!tlvReader.isEndOfContainer()) { - this.add( - matter.controller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() + val targetList = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) + while(!tlvReader.isEndOfContainer()) { + this.add(matter.controller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) } + tlvReader.exitContainer() + } val currentTarget = tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_TARGET)) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetUpdatedEvent(targetList, currentTarget, data) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt index 8acbb4b6aea971..823b3eb003da4a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UByte) { +class ThreadNetworkDiagnosticsClusterConnectionStatusEvent( + val connectionStatus: UByte +) { override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") @@ -40,13 +44,10 @@ class ThreadNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThreadNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUByte(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt index 3bea74d8323077..01a5989a931f38 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -55,28 +56,23 @@ class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt index 1f92e4003e280a..e8870c27fe9ff6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterDSTStatusEvent(val DSTOffsetActive: Boolean) { +class TimeSynchronizationClusterDSTStatusEvent( + val DSTOffsetActive: Boolean +) { override fun toString(): String = buildString { append("TimeSynchronizationClusterDSTStatusEvent {\n") append("\tDSTOffsetActive : $DSTOffsetActive\n") @@ -40,10 +44,10 @@ class TimeSynchronizationClusterDSTStatusEvent(val DSTOffsetActive: Boolean) { companion object { private const val TAG_D_S_T_OFFSET_ACTIVE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterDSTStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterDSTStatusEvent { tlvReader.enterStructure(tlvTag) val DSTOffsetActive = tlvReader.getBoolean(ContextSpecificTag(TAG_D_S_T_OFFSET_ACTIVE)) - + tlvReader.exitContainer() return TimeSynchronizationClusterDSTStatusEvent(DSTOffsetActive) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt index 0ef92440535c0a..0a12d142db0443 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt @@ -18,12 +18,16 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterTimeZoneStatusEvent(val offset: Int, val name: Optional) { +class TimeSynchronizationClusterTimeZoneStatusEvent( + val offset: Int, + val name: Optional +) { override fun toString(): String = buildString { append("TimeSynchronizationClusterTimeZoneStatusEvent {\n") append("\toffset : $offset\n") @@ -47,16 +51,15 @@ class TimeSynchronizationClusterTimeZoneStatusEvent(val offset: Int, val name: O private const val TAG_OFFSET = 0 private const val TAG_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTimeZoneStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTimeZoneStatusEvent { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getInt(ContextSpecificTag(TAG_OFFSET)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStatusEvent(offset, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt index b95fb1a6114b7f..2294e08b8377db 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -71,38 +72,27 @@ class UnitTestingClusterTestEventEvent( private const val TAG_ARG5 = 5 private const val TAG_ARG6 = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestEventEvent { tlvReader.enterStructure(tlvTag) val arg1 = tlvReader.getUByte(ContextSpecificTag(TAG_ARG1)) val arg2 = tlvReader.getUByte(ContextSpecificTag(TAG_ARG2)) val arg3 = tlvReader.getBoolean(ContextSpecificTag(TAG_ARG3)) - val arg4 = - matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( - ContextSpecificTag(TAG_ARG4), - tlvReader - ) - val arg5 = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) - while (!tlvReader.isEndOfContainer()) { - this.add( - matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() + val arg4 = matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_ARG4), tlvReader) + val arg5 = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) + while(!tlvReader.isEndOfContainer()) { + this.add(matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) } - val arg6 = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) - while (!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() + tlvReader.exitContainer() + } + val arg6 = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) + while(!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) } - + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterTestEventEvent(arg1, arg2, arg3, arg4, arg5, arg6) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt index b0ac8683c99209..a52b06cd5cbd96 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterTestFabricScopedEventEvent(val fabricIndex: UByte) { +class UnitTestingClusterTestFabricScopedEventEvent( + val fabricIndex: UByte +) { override fun toString(): String = buildString { append("UnitTestingClusterTestFabricScopedEventEvent {\n") append("\tfabricIndex : $fabricIndex\n") @@ -40,10 +44,10 @@ class UnitTestingClusterTestFabricScopedEventEvent(val fabricIndex: UByte) { companion object { private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScopedEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestFabricScopedEventEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return UnitTestingClusterTestFabricScopedEventEvent(fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt index 6c207e60058efa..a740d0e35331fe 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ValveConfigurationAndControlClusterValveFaultEvent(val valveFault: UShort) { +class ValveConfigurationAndControlClusterValveFaultEvent( + val valveFault: UShort +) { override fun toString(): String = buildString { append("ValveConfigurationAndControlClusterValveFaultEvent {\n") append("\tvalveFault : $valveFault\n") @@ -40,13 +44,10 @@ class ValveConfigurationAndControlClusterValveFaultEvent(val valveFault: UShort) companion object { private const val TAG_VALVE_FAULT = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ValveConfigurationAndControlClusterValveFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveFaultEvent { tlvReader.enterStructure(tlvTag) val valveFault = tlvReader.getUShort(ContextSpecificTag(TAG_VALVE_FAULT)) - + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveFaultEvent(valveFault) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt index c12b94b0e375bf..2331135586801c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,19 +51,15 @@ class ValveConfigurationAndControlClusterValveStateChangedEvent( private const val TAG_VALVE_STATE = 0 private const val TAG_VALVE_LEVEL = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ValveConfigurationAndControlClusterValveStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveStateChangedEvent { tlvReader.enterStructure(tlvTag) val valveState = tlvReader.getUByte(ContextSpecificTag(TAG_VALVE_STATE)) - val valveLevel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_VALVE_LEVEL))) - } else { - Optional.empty() - } - + val valveLevel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_VALVE_LEVEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveStateChangedEvent(valveState, valveLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt index 677577429c1796..fddf6cdad7a8a6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,15 +48,11 @@ class WiFiNetworkDiagnosticsClusterAssociationFailureEvent( private const val TAG_ASSOCIATION_FAILURE_CAUSE = 0 private const val TAG_STATUS = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): WiFiNetworkDiagnosticsClusterAssociationFailureEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterAssociationFailureEvent { tlvReader.enterStructure(tlvTag) - val associationFailureCause = - tlvReader.getUByte(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) + val associationFailureCause = tlvReader.getUByte(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) val status = tlvReader.getUShort(ContextSpecificTag(TAG_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterAssociationFailureEvent(associationFailureCause, status) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt index af8d2c296abe2e..0e668adcf859dd 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UByte) { +class WiFiNetworkDiagnosticsClusterConnectionStatusEvent( + val connectionStatus: UByte +) { override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") @@ -40,13 +44,10 @@ class WiFiNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: U companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): WiFiNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUByte(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt index a61a9742ede95a..40a4bf1d3cc947 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.eventstructs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsClusterDisconnectionEvent(val reasonCode: UShort) { +class WiFiNetworkDiagnosticsClusterDisconnectionEvent( + val reasonCode: UShort +) { override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterDisconnectionEvent {\n") append("\treasonCode : $reasonCode\n") @@ -40,13 +44,10 @@ class WiFiNetworkDiagnosticsClusterDisconnectionEvent(val reasonCode: UShort) { companion object { private const val TAG_REASON_CODE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): WiFiNetworkDiagnosticsClusterDisconnectionEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterDisconnectionEvent { tlvReader.enterStructure(tlvTag) val reasonCode = tlvReader.getUShort(ContextSpecificTag(TAG_REASON_CODE)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterDisconnectionEvent(reasonCode) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt index f177b65134c50c..bd703215de0a5b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -47,19 +48,19 @@ class AccessControlClusterAccessControlEntryStruct( put(ContextSpecificTag(TAG_AUTH_MODE), authMode) if (subjects != null) { startArray(ContextSpecificTag(TAG_SUBJECTS)) - for (item in subjects.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in subjects.iterator()) { + put(AnonymousTag, item) + } + endArray() } else { putNull(ContextSpecificTag(TAG_SUBJECTS)) } if (targets != null) { startArray(ContextSpecificTag(TAG_TARGETS)) - for (item in targets.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in targets.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } else { putNull(ContextSpecificTag(TAG_TARGETS)) } @@ -79,43 +80,35 @@ class AccessControlClusterAccessControlEntryStruct( tlvReader.enterStructure(tlvTag) val privilege = tlvReader.getUByte(ContextSpecificTag(TAG_PRIVILEGE)) val authMode = tlvReader.getUByte(ContextSpecificTag(TAG_AUTH_MODE)) - val subjects = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getULong(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) - null - } - val targets = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) - while (!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) - null - } + val subjects = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getULong(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) + null + } + val targets = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) + while(!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryStruct( - privilege, - authMode, - subjects, - targets, - fabricIndex - ) + return AccessControlClusterAccessControlEntryStruct(privilege, authMode, subjects, targets, fabricIndex) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt index 4427b4a4671abe..8ffb7a94a61ed1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,14 +48,11 @@ class AccessControlClusterAccessControlExtensionStruct( private const val TAG_DATA = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): AccessControlClusterAccessControlExtensionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlExtensionStruct { tlvReader.enterStructure(tlvTag) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return AccessControlClusterAccessControlExtensionStruct(data, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt index c0197f9d712c79..dc275d27e5f803 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -64,28 +66,25 @@ class AccessControlClusterAccessControlTargetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlTargetStruct { tlvReader.enterStructure(tlvTag) - val cluster = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) - null - } - val endpoint = - if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) - null - } - val deviceType = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_TYPE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) - null - } - + val cluster = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) + null + } + val endpoint = if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) + null + } + val deviceType = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_TYPE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) + null + } + tlvReader.exitContainer() return AccessControlClusterAccessControlTargetStruct(cluster, endpoint, deviceType) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt index 73476687b0478e..8b13dbce2d91cf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -70,17 +72,10 @@ class ActionsClusterActionStruct( val endpointListID = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val supportedCommands = tlvReader.getUShort(ContextSpecificTag(TAG_SUPPORTED_COMMANDS)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) - + tlvReader.exitContainer() - return ActionsClusterActionStruct( - actionID, - name, - type, - endpointListID, - supportedCommands, - state - ) + return ActionsClusterActionStruct(actionID, name, type, endpointListID, supportedCommands, state) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt index 94dda8930854be..33c1848cd172d3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -64,15 +65,14 @@ class ActionsClusterEndpointListStruct( val endpointListID = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) - val endpoints = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val endpoints = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ActionsClusterEndpointListStruct(endpointListID, name, type, endpoints) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt index afa7a17f5647c8..c43c172f39ad4a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,22 +48,14 @@ class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) - val productIdentifierType = - tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = - tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierType = tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) + val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( - productIdentifierType, - productIdentifierValue - ) + return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt index 2172fbb67b699f..e9566b36b3ab97 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,7 +52,7 @@ class ApplicationBasicClusterApplicationStruct( tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUShort(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationBasicClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt index 9329e2a02a429b..eeca3b79254426 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,18 +53,13 @@ class ApplicationLauncherClusterApplicationEPStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationLauncherClusterApplicationEPStruct { tlvReader.enterStructure(tlvTag) - val application = - ApplicationLauncherClusterApplicationStruct.fromTlv( - ContextSpecificTag(TAG_APPLICATION), - tlvReader - ) - val endpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - + val application = ApplicationLauncherClusterApplicationStruct.fromTlv(ContextSpecificTag(TAG_APPLICATION), tlvReader) + val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationEPStruct(application, endpoint) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt index 823ca308e47dde..4ca21f08b941b7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,7 +52,7 @@ class ApplicationLauncherClusterApplicationStruct( tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUShort(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt index 03f59264fc2501..2a48b0b450bf4a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -55,7 +57,7 @@ class AudioOutputClusterOutputInfoStruct( val index = tlvReader.getUByte(ContextSpecificTag(TAG_INDEX)) val outputType = tlvReader.getUByte(ContextSpecificTag(TAG_OUTPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return AudioOutputClusterOutputInfoStruct(index, outputType, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt index a25807e0c8d155..aa977b5fdb8578 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,17 +50,12 @@ class BasicInformationClusterCapabilityMinimaStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterCapabilityMinimaStruct { tlvReader.enterStructure(tlvTag) - val caseSessionsPerFabric = - tlvReader.getUShort(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) - val subscriptionsPerFabric = - tlvReader.getUShort(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) - + val caseSessionsPerFabric = tlvReader.getUShort(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) + val subscriptionsPerFabric = tlvReader.getUShort(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) + tlvReader.exitContainer() - return BasicInformationClusterCapabilityMinimaStruct( - caseSessionsPerFabric, - subscriptionsPerFabric - ) + return BasicInformationClusterCapabilityMinimaStruct(caseSessionsPerFabric, subscriptionsPerFabric) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt index 56583564b0c687..d5cc1315e520cd 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterProductAppearanceStruct(val finish: UByte, val primaryColor: UByte?) { +class BasicInformationClusterProductAppearanceStruct( + val finish: UByte, + val primaryColor: UByte? +) { override fun toString(): String = buildString { append("BasicInformationClusterProductAppearanceStruct {\n") append("\tfinish : $finish\n") @@ -50,14 +55,13 @@ class BasicInformationClusterProductAppearanceStruct(val finish: UByte, val prim fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUByte(ContextSpecificTag(TAG_FINISH)) - val primaryColor = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt index 84be9b6dd69995..1a382bd10ab5a0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -73,32 +74,28 @@ class BindingClusterTargetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BindingClusterTargetStruct { tlvReader.enterStructure(tlvTag) - val node = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - val group = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_GROUP))) - } else { - Optional.empty() - } - val endpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - val cluster = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER))) - } else { - Optional.empty() - } + val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + val group = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_GROUP))) + } else { + Optional.empty() + } + val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + val cluster = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BindingClusterTargetStruct(node, group, endpoint, cluster, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt index 94e9b134c06b09..9e9eabc793ef94 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,20 +52,16 @@ class BridgedDeviceBasicInformationClusterProductAppearanceStruct( private const val TAG_FINISH = 0 private const val TAG_PRIMARY_COLOR = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): BridgedDeviceBasicInformationClusterProductAppearanceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BridgedDeviceBasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUByte(ContextSpecificTag(TAG_FINISH)) - val primaryColor = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt index cd2eacc749cb0d..9c504e9f434b18 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterAdditionalInfoStruct(val name: String, val value: String) { +class ChannelClusterAdditionalInfoStruct( + val name: String, + val value: String +) { override fun toString(): String = buildString { append("ChannelClusterAdditionalInfoStruct {\n") append("\tname : $name\n") @@ -47,7 +52,7 @@ class ChannelClusterAdditionalInfoStruct(val name: String, val value: String) { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ChannelClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt index 627dcdcbefa16f..914bcad0e6cc7f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -86,48 +87,35 @@ class ChannelClusterChannelInfoStruct( tlvReader.enterStructure(tlvTag) val majorNumber = tlvReader.getUShort(ContextSpecificTag(TAG_MAJOR_NUMBER)) val minorNumber = tlvReader.getUShort(ContextSpecificTag(TAG_MINOR_NUMBER)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val callSign = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) - } else { - Optional.empty() - } - val affiliateCallSign = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) - } else { - Optional.empty() - } - val identifier = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) - } else { - Optional.empty() - } - val type = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TYPE))) - } else { - Optional.empty() - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val callSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) + } else { + Optional.empty() + } + val affiliateCallSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) + } else { + Optional.empty() + } + val identifier = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) + } else { + Optional.empty() + } + val type = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TYPE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterChannelInfoStruct( - majorNumber, - minorNumber, - name, - callSign, - affiliateCallSign, - identifier, - type - ) + return ChannelClusterChannelInfoStruct(majorNumber, minorNumber, name, callSign, affiliateCallSign, identifier, type) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt index 3d190489316d4a..f3b7c7d5f51755 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -39,17 +40,17 @@ class ChannelClusterChannelPagingStruct( startStructure(tlvTag) if (previousToken != null) { if (previousToken.isPresent) { - val optpreviousToken = previousToken.get() - optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) - } + val optpreviousToken = previousToken.get() + optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) + } } else { putNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) } if (nextToken != null) { if (nextToken.isPresent) { - val optnextToken = nextToken.get() - optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) - } + val optnextToken = nextToken.get() + optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) + } } else { putNull(ContextSpecificTag(TAG_NEXT_TOKEN)) } @@ -63,36 +64,27 @@ class ChannelClusterChannelPagingStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterChannelPagingStruct { tlvReader.enterStructure(tlvTag) - val previousToken = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { - Optional.of( - ChannelClusterPageTokenStruct.fromTlv( - ContextSpecificTag(TAG_PREVIOUS_TOKEN), - tlvReader - ) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) - null - } - val nextToken = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { - Optional.of( - ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) - null - } - + val previousToken = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { + Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) + null + } + val nextToken = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { + Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) + null + } + tlvReader.exitContainer() return ChannelClusterChannelPagingStruct(previousToken, nextToken) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt index e8e25f3fe16a7e..21eb682b010a20 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -64,20 +65,18 @@ class ChannelClusterLineupInfoStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterLineupInfoStruct { tlvReader.enterStructure(tlvTag) val operatorName = tlvReader.getString(ContextSpecificTag(TAG_OPERATOR_NAME)) - val lineupName = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) - } else { - Optional.empty() - } - val postalCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) - } else { - Optional.empty() - } + val lineupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) + } else { + Optional.empty() + } + val postalCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) + } else { + Optional.empty() + } val lineupInfoType = tlvReader.getUByte(ContextSpecificTag(TAG_LINEUP_INFO_TYPE)) - + tlvReader.exitContainer() return ChannelClusterLineupInfoStruct(operatorName, lineupName, postalCode, lineupInfoType) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt index e9712955df7799..963a7c2beb5ffa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -62,25 +63,22 @@ class ChannelClusterPageTokenStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterPageTokenStruct { tlvReader.enterStructure(tlvTag) - val limit = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_LIMIT))) - } else { - Optional.empty() - } - val after = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) - } else { - Optional.empty() - } - val before = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) - } else { - Optional.empty() - } - + val limit = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_LIMIT))) + } else { + Optional.empty() + } + val after = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) + } else { + Optional.empty() + } + val before = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterPageTokenStruct(limit, after, before) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt index 45b0a22100ef25..54568f0b775970 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterProgramCastStruct(val name: String, val role: String) { +class ChannelClusterProgramCastStruct( + val name: String, + val role: String +) { override fun toString(): String = buildString { append("ChannelClusterProgramCastStruct {\n") append("\tname : $name\n") @@ -47,7 +52,7 @@ class ChannelClusterProgramCastStruct(val name: String, val role: String) { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val role = tlvReader.getString(ContextSpecificTag(TAG_ROLE)) - + tlvReader.exitContainer() return ChannelClusterProgramCastStruct(name, role) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt index 6e89f24cd39e25..3ffaea537244dc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt @@ -18,12 +18,16 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterProgramCategoryStruct(val category: String, val subCategory: Optional) { +class ChannelClusterProgramCategoryStruct( + val category: String, + val subCategory: Optional +) { override fun toString(): String = buildString { append("ChannelClusterProgramCategoryStruct {\n") append("\tcategory : $category\n") @@ -50,13 +54,12 @@ class ChannelClusterProgramCategoryStruct(val category: String, val subCategory: fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramCategoryStruct { tlvReader.enterStructure(tlvTag) val category = tlvReader.getString(ContextSpecificTag(TAG_CATEGORY)) - val subCategory = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) - } else { - Optional.empty() - } - + val subCategory = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterProgramCategoryStruct(category, subCategory) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt index f40e13d0894446..327c6622543aff 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt @@ -88,18 +88,18 @@ class ChannelClusterProgramStruct( if (audioLanguages.isPresent) { val optaudioLanguages = audioLanguages.get() startArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - for (item in optaudioLanguages.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optaudioLanguages.iterator()) { + put(AnonymousTag, item) + } + endArray() } if (ratings.isPresent) { val optratings = ratings.get() startArray(ContextSpecificTag(TAG_RATINGS)) - for (item in optratings.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optratings.iterator()) { + put(AnonymousTag, item) + } + endArray() } if (thumbnailUrl.isPresent) { val optthumbnailUrl = thumbnailUrl.get() @@ -127,35 +127,35 @@ class ChannelClusterProgramStruct( } if (seriesInfo != null) { if (seriesInfo.isPresent) { - val optseriesInfo = seriesInfo.get() - optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) - } + val optseriesInfo = seriesInfo.get() + optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) + } } else { putNull(ContextSpecificTag(TAG_SERIES_INFO)) } if (categoryList.isPresent) { val optcategoryList = categoryList.get() startArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - for (item in optcategoryList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optcategoryList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } if (castList.isPresent) { val optcastList = castList.get() startArray(ContextSpecificTag(TAG_CAST_LIST)) - for (item in optcastList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optcastList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } if (externalIDList.isPresent) { val optexternalIDList = externalIDList.get() startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } endStructure() } @@ -185,166 +185,119 @@ class ChannelClusterProgramStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramStruct { tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER)) - val channel = - ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) + val channel = ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) val startTime = tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getUInt(ContextSpecificTag(TAG_END_TIME)) val title = tlvReader.getString(ContextSpecificTag(TAG_TITLE)) - val subtitle = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) - } else { - Optional.empty() - } - val description = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) - } else { - Optional.empty() - } - val audioLanguages = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val ratings = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val thumbnailUrl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) - } else { - Optional.empty() - } - val posterArtUrl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) - } else { - Optional.empty() - } - val dvbiUrl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) - } else { - Optional.empty() - } - val releaseDate = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) - } else { - Optional.empty() - } - val parentalGuidanceText = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) - } else { - Optional.empty() - } - val recordingFlag = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_RECORDING_FLAG))) - } else { - Optional.empty() - } - val seriesInfo = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { - Optional.of( - ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) - null - } - val categoryList = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val castList = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val externalIDList = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - + val subtitle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) + } else { + Optional.empty() + } + val description = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) + } else { + Optional.empty() + } + val audioLanguages = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val ratings = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val thumbnailUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) + } else { + Optional.empty() + } + val posterArtUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) + } else { + Optional.empty() + } + val dvbiUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) + } else { + Optional.empty() + } + val releaseDate = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) + } else { + Optional.empty() + } + val parentalGuidanceText = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) + } else { + Optional.empty() + } + val recordingFlag = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_RECORDING_FLAG))) + } else { + Optional.empty() + } + val seriesInfo = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { + Optional.of(ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) + null + } + val categoryList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val castList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterProgramStruct( - identifier, - channel, - startTime, - endTime, - title, - subtitle, - description, - audioLanguages, - ratings, - thumbnailUrl, - posterArtUrl, - dvbiUrl, - releaseDate, - parentalGuidanceText, - recordingFlag, - seriesInfo, - categoryList, - castList, - externalIDList - ) + return ChannelClusterProgramStruct(identifier, channel, startTime, endTime, title, subtitle, description, audioLanguages, ratings, thumbnailUrl, posterArtUrl, dvbiUrl, releaseDate, parentalGuidanceText, recordingFlag, seriesInfo, categoryList, castList, externalIDList) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt index 9e3928a48de8a5..c0445d55460703 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterSeriesInfoStruct(val season: String, val episode: String) { +class ChannelClusterSeriesInfoStruct( + val season: String, + val episode: String +) { override fun toString(): String = buildString { append("ChannelClusterSeriesInfoStruct {\n") append("\tseason : $season\n") @@ -47,7 +52,7 @@ class ChannelClusterSeriesInfoStruct(val season: String, val episode: String) { tlvReader.enterStructure(tlvTag) val season = tlvReader.getString(ContextSpecificTag(TAG_SEASON)) val episode = tlvReader.getString(ContextSpecificTag(TAG_EPISODE)) - + tlvReader.exitContainer() return ChannelClusterSeriesInfoStruct(season, episode) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt index c47570f255caaa..fe5058eb533a87 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -53,13 +54,12 @@ class ContentControlClusterRatingNameStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentControlClusterRatingNameStruct { tlvReader.enterStructure(tlvTag) val ratingName = tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME)) - val ratingNameDesc = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) - } else { - Optional.empty() - } - + val ratingNameDesc = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentControlClusterRatingNameStruct(ratingName, ratingNameDesc) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt index af51becfe86381..504997933652c9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherClusterAdditionalInfoStruct(val name: String, val value: String) { +class ContentLauncherClusterAdditionalInfoStruct( + val name: String, + val value: String +) { override fun toString(): String = buildString { append("ContentLauncherClusterAdditionalInfoStruct {\n") append("\tname : $name\n") @@ -47,7 +52,7 @@ class ContentLauncherClusterAdditionalInfoStruct(val name: String, val value: St tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ContentLauncherClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt index 4470b659b2e59f..e94826e1eb40d8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -78,78 +79,38 @@ class ContentLauncherClusterBrandingInformationStruct( private const val TAG_SPLASH = 4 private const val TAG_WATER_MARK = 5 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ContentLauncherClusterBrandingInformationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterBrandingInformationStruct { tlvReader.enterStructure(tlvTag) val providerName = tlvReader.getString(ContextSpecificTag(TAG_PROVIDER_NAME)) - val background = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { - Optional.of( - ContentLauncherClusterStyleInformationStruct.fromTlv( - ContextSpecificTag(TAG_BACKGROUND), - tlvReader - ) - ) - } else { - Optional.empty() - } - val logo = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { - Optional.of( - ContentLauncherClusterStyleInformationStruct.fromTlv( - ContextSpecificTag(TAG_LOGO), - tlvReader - ) - ) - } else { - Optional.empty() - } - val progressBar = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { - Optional.of( - ContentLauncherClusterStyleInformationStruct.fromTlv( - ContextSpecificTag(TAG_PROGRESS_BAR), - tlvReader - ) - ) - } else { - Optional.empty() - } - val splash = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { - Optional.of( - ContentLauncherClusterStyleInformationStruct.fromTlv( - ContextSpecificTag(TAG_SPLASH), - tlvReader - ) - ) - } else { - Optional.empty() - } - val waterMark = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { - Optional.of( - ContentLauncherClusterStyleInformationStruct.fromTlv( - ContextSpecificTag(TAG_WATER_MARK), - tlvReader - ) - ) - } else { - Optional.empty() - } - + val background = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { + Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_BACKGROUND), tlvReader)) + } else { + Optional.empty() + } + val logo = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { + Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_LOGO), tlvReader)) + } else { + Optional.empty() + } + val progressBar = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { + Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_PROGRESS_BAR), tlvReader)) + } else { + Optional.empty() + } + val splash = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { + Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_SPLASH), tlvReader)) + } else { + Optional.empty() + } + val waterMark = if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { + Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_WATER_MARK), tlvReader)) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterBrandingInformationStruct( - providerName, - background, - logo, - progressBar, - splash, - waterMark - ) + return ContentLauncherClusterBrandingInformationStruct(providerName, background, logo, progressBar, splash, waterMark) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt index 1fe0fc71463ee6..052e4f66723755 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -49,15 +50,14 @@ class ContentLauncherClusterContentSearchStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterContentSearchStruct { tlvReader.enterStructure(tlvTag) - val parameterList = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val parameterList = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ContentLauncherClusterContentSearchStruct(parameterList) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt index f9c4eb2d6f4502..5870e4079531e8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -55,7 +57,7 @@ class ContentLauncherClusterDimensionStruct( val width = tlvReader.getDouble(ContextSpecificTag(TAG_WIDTH)) val height = tlvReader.getDouble(ContextSpecificTag(TAG_HEIGHT)) val metric = tlvReader.getUByte(ContextSpecificTag(TAG_METRIC)) - + tlvReader.exitContainer() return ContentLauncherClusterDimensionStruct(width, height, metric) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt index e0975b8e1c6c9f..9b85de042f0a94 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt @@ -45,10 +45,10 @@ class ContentLauncherClusterParameterStruct( if (externalIDList.isPresent) { val optexternalIDList = externalIDList.get() startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } endStructure() } @@ -63,21 +63,18 @@ class ContentLauncherClusterParameterStruct( tlvReader.enterStructure(tlvTag) val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - val externalIDList = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - + val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterParameterStruct(type, value, externalIDList) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt index 694f35fc4364d1..adba8615ee2d73 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt @@ -45,10 +45,10 @@ class ContentLauncherClusterPlaybackPreferencesStruct( if (audioTracks.isPresent) { val optaudioTracks = audioTracks.get() startArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - for (item in optaudioTracks.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optaudioTracks.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } endStructure() } @@ -59,39 +59,25 @@ class ContentLauncherClusterPlaybackPreferencesStruct( private const val TAG_TEXT_TRACK = 1 private const val TAG_AUDIO_TRACKS = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ContentLauncherClusterPlaybackPreferencesStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterPlaybackPreferencesStruct { tlvReader.enterStructure(tlvTag) val playbackPosition = tlvReader.getULong(ContextSpecificTag(TAG_PLAYBACK_POSITION)) - val textTrack = - ContentLauncherClusterTrackPreferenceStruct.fromTlv( - ContextSpecificTag(TAG_TEXT_TRACK), - tlvReader - ) - val audioTracks = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - while (!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - + val textTrack = ContentLauncherClusterTrackPreferenceStruct.fromTlv(ContextSpecificTag(TAG_TEXT_TRACK), tlvReader) + val audioTracks = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) + while(!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterPlaybackPreferencesStruct( - playbackPosition, - textTrack, - audioTracks - ) + return ContentLauncherClusterPlaybackPreferencesStruct(playbackPosition, textTrack, audioTracks) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt index e57d04e099fb44..6c0f03344a31eb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -62,27 +63,22 @@ class ContentLauncherClusterStyleInformationStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterStyleInformationStruct { tlvReader.enterStructure(tlvTag) - val imageURL = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) - } else { - Optional.empty() - } - val color = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) - } else { - Optional.empty() - } - val size = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { - Optional.of( - ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader) - ) - } else { - Optional.empty() - } - + val imageURL = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) + } else { + Optional.empty() + } + val color = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) + } else { + Optional.empty() + } + val size = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { + Optional.of(ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader)) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterStyleInformationStruct(imageURL, color, size) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt index 74c3088d135bcc..47dadc45c6f0b3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt @@ -44,10 +44,10 @@ class ContentLauncherClusterTrackPreferenceStruct( if (characteristics.isPresent) { val optcharacteristics = characteristics.get() startArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - for (item in optcharacteristics.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optcharacteristics.iterator()) { + put(AnonymousTag, item) + } + endArray() } put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX), audioOutputIndex) endStructure() @@ -62,29 +62,22 @@ class ContentLauncherClusterTrackPreferenceStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterTrackPreferenceStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val characteristics = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } + val characteristics = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } val audioOutputIndex = tlvReader.getUByte(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX)) - + tlvReader.exitContainer() - return ContentLauncherClusterTrackPreferenceStruct( - languageCode, - characteristics, - audioOutputIndex - ) + return ContentLauncherClusterTrackPreferenceStruct(languageCode, characteristics, audioOutputIndex) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt index 4473bd4520dcd2..5a055dd4270923 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterAverageLoadControlStruct(val loadAdjustment: Byte) { +class DemandResponseLoadControlClusterAverageLoadControlStruct( + val loadAdjustment: Byte +) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterAverageLoadControlStruct {\n") append("\tloadAdjustment : $loadAdjustment\n") @@ -40,13 +44,10 @@ class DemandResponseLoadControlClusterAverageLoadControlStruct(val loadAdjustmen companion object { private const val TAG_LOAD_ADJUSTMENT = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterAverageLoadControlStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterAverageLoadControlStruct { tlvReader.enterStructure(tlvTag) val loadAdjustment = tlvReader.getByte(ContextSpecificTag(TAG_LOAD_ADJUSTMENT)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterAverageLoadControlStruct(loadAdjustment) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt index 7e53d779dda4e3..9573a4e3ff11fa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterDutyCycleControlStruct(val dutyCycle: UByte) { +class DemandResponseLoadControlClusterDutyCycleControlStruct( + val dutyCycle: UByte +) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterDutyCycleControlStruct {\n") append("\tdutyCycle : $dutyCycle\n") @@ -40,13 +44,10 @@ class DemandResponseLoadControlClusterDutyCycleControlStruct(val dutyCycle: UByt companion object { private const val TAG_DUTY_CYCLE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterDutyCycleControlStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterDutyCycleControlStruct { tlvReader.enterStructure(tlvTag) val dutyCycle = tlvReader.getUByte(ContextSpecificTag(TAG_DUTY_CYCLE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterDutyCycleControlStruct(dutyCycle) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt index aeae2026e12db2..ed90e36f3a637e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterHeatingSourceControlStruct(val heatingSource: UByte) { +class DemandResponseLoadControlClusterHeatingSourceControlStruct( + val heatingSource: UByte +) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterHeatingSourceControlStruct {\n") append("\theatingSource : $heatingSource\n") @@ -40,13 +44,10 @@ class DemandResponseLoadControlClusterHeatingSourceControlStruct(val heatingSour companion object { private const val TAG_HEATING_SOURCE = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterHeatingSourceControlStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterHeatingSourceControlStruct { tlvReader.enterStructure(tlvTag) val heatingSource = tlvReader.getUByte(ContextSpecificTag(TAG_HEATING_SOURCE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterHeatingSourceControlStruct(heatingSource) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt index e8f15e8cdb0064..f0a1f42885e734 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt @@ -87,61 +87,40 @@ class DemandResponseLoadControlClusterLoadControlEventStruct( private const val TAG_START_TIME = 6 private const val TAG_TRANSITIONS = 7 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterLoadControlEventStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterLoadControlEventStruct { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val programID = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) - null - } + val programID = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) + null + } val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) val deviceClass = tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_CLASS)) - val enrollmentGroup = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) - } else { - Optional.empty() - } + val enrollmentGroup = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) + } else { + Optional.empty() + } val criticality = tlvReader.getUByte(ContextSpecificTag(TAG_CRITICALITY)) - val startTime = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) - null - } - val transitions = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while (!tlvReader.isEndOfContainer()) { - add( - DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - + val startTime = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) + null + } + val transitions = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while(!tlvReader.isEndOfContainer()) { + add(DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStruct( - eventID, - programID, - control, - deviceClass, - enrollmentGroup, - criticality, - startTime, - transitions - ) + return DemandResponseLoadControlClusterLoadControlEventStruct(eventID, programID, control, deviceClass, enrollmentGroup, criticality, startTime, transitions) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt index 1bad4e81db4b9a..8b11bb21f1b0a0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -82,80 +83,39 @@ class DemandResponseLoadControlClusterLoadControlEventTransitionStruct( private const val TAG_POWER_SAVINGS_CONTROL = 5 private const val TAG_HEATING_SOURCE_CONTROL = 6 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterLoadControlEventTransitionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterLoadControlEventTransitionStruct { tlvReader.enterStructure(tlvTag) val duration = tlvReader.getUShort(ContextSpecificTag(TAG_DURATION)) val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of( - DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv( - ContextSpecificTag(TAG_TEMPERATURE_CONTROL), - tlvReader - ) - ) - } else { - Optional.empty() - } - val averageLoadControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of( - DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv( - ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), - tlvReader - ) - ) - } else { - Optional.empty() - } - val dutyCycleControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of( - DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv( - ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), - tlvReader - ) - ) - } else { - Optional.empty() - } - val powerSavingsControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of( - DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv( - ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), - tlvReader - ) - ) - } else { - Optional.empty() - } - val heatingSourceControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of( - DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv( - ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), - tlvReader - ) - ) - } else { - Optional.empty() - } - + val temperatureControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of(DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + val averageLoadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of(DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) + } else { + Optional.empty() + } + val dutyCycleControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of(DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + val powerSavingsControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of(DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) + } else { + Optional.empty() + } + val heatingSourceControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of(DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventTransitionStruct( - duration, - control, - temperatureControl, - averageLoadControl, - dutyCycleControl, - powerSavingsControl, - heatingSourceControl - ) + return DemandResponseLoadControlClusterLoadControlEventTransitionStruct(duration, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt index d3aea5654d479b..b40fac86f3abf0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -70,44 +72,32 @@ class DemandResponseLoadControlClusterLoadControlProgramStruct( private const val TAG_RANDOM_START_MINUTES = 3 private const val TAG_RANDOM_DURATION_MINUTES = 4 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterLoadControlProgramStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterLoadControlProgramStruct { tlvReader.enterStructure(tlvTag) val programID = tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - val enrollmentGroup = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - null - } - val randomStartMinutes = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - null - } - val randomDurationMinutes = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - null - } - + val enrollmentGroup = if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + null + } + val randomStartMinutes = if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + null + } + val randomDurationMinutes = if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlProgramStruct( - programID, - name, - enrollmentGroup, - randomStartMinutes, - randomDurationMinutes - ) + return DemandResponseLoadControlClusterLoadControlProgramStruct(programID, name, enrollmentGroup, randomStartMinutes, randomDurationMinutes) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt index 485257eb7dbf1c..08d7bc21262e2e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt @@ -16,13 +16,17 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterPowerSavingsControlStruct(val powerSavings: UByte) { +class DemandResponseLoadControlClusterPowerSavingsControlStruct( + val powerSavings: UByte +) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterPowerSavingsControlStruct {\n") append("\tpowerSavings : $powerSavings\n") @@ -40,13 +44,10 @@ class DemandResponseLoadControlClusterPowerSavingsControlStruct(val powerSavings companion object { private const val TAG_POWER_SAVINGS = 0 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterPowerSavingsControlStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterPowerSavingsControlStruct { tlvReader.enterStructure(tlvTag) val powerSavings = tlvReader.getUByte(ContextSpecificTag(TAG_POWER_SAVINGS)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterPowerSavingsControlStruct(powerSavings) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt index 635b2541684b05..d6bd0cd2524906 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -43,33 +44,33 @@ class DemandResponseLoadControlClusterTemperatureControlStruct( startStructure(tlvTag) if (coolingTempOffset != null) { if (coolingTempOffset.isPresent) { - val optcoolingTempOffset = coolingTempOffset.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) - } + val optcoolingTempOffset = coolingTempOffset.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) + } } else { putNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) } if (heatingtTempOffset != null) { if (heatingtTempOffset.isPresent) { - val optheatingtTempOffset = heatingtTempOffset.get() - put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) - } + val optheatingtTempOffset = heatingtTempOffset.get() + put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) + } } else { putNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) } if (coolingTempSetpoint != null) { if (coolingTempSetpoint.isPresent) { - val optcoolingTempSetpoint = coolingTempSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) - } + val optcoolingTempSetpoint = coolingTempSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) + } } else { putNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) } if (heatingTempSetpoint != null) { if (heatingTempSetpoint.isPresent) { - val optheatingTempSetpoint = heatingTempSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) - } + val optheatingTempSetpoint = heatingTempSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) + } } else { putNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) } @@ -83,64 +84,52 @@ class DemandResponseLoadControlClusterTemperatureControlStruct( private const val TAG_COOLING_TEMP_SETPOINT = 2 private const val TAG_HEATING_TEMP_SETPOINT = 3 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DemandResponseLoadControlClusterTemperatureControlStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterTemperatureControlStruct { tlvReader.enterStructure(tlvTag) - val coolingTempOffset = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) - null - } - val heatingtTempOffset = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) - null - } - val coolingTempSetpoint = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) - null - } - val heatingTempSetpoint = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) - null - } - + val coolingTempOffset = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) + null + } + val heatingtTempOffset = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) + null + } + val coolingTempSetpoint = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) + null + } + val heatingTempSetpoint = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterTemperatureControlStruct( - coolingTempOffset, - heatingtTempOffset, - coolingTempSetpoint, - heatingTempSetpoint - ) + return DemandResponseLoadControlClusterTemperatureControlStruct(coolingTempOffset, heatingtTempOffset, coolingTempSetpoint, heatingTempSetpoint) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt index c8cc82e04d50eb..3b1d50b42659e8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DescriptorClusterDeviceTypeStruct(val deviceType: UInt, val revision: UShort) { +class DescriptorClusterDeviceTypeStruct( + val deviceType: UInt, + val revision: UShort +) { override fun toString(): String = buildString { append("DescriptorClusterDeviceTypeStruct {\n") append("\tdeviceType : $deviceType\n") @@ -47,7 +52,7 @@ class DescriptorClusterDeviceTypeStruct(val deviceType: UInt, val revision: USho tlvReader.enterStructure(tlvTag) val deviceType = tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_TYPE)) val revision = tlvReader.getUShort(ContextSpecificTag(TAG_REVISION)) - + tlvReader.exitContainer() return DescriptorClusterDeviceTypeStruct(deviceType, revision) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt index 70a83556618698..cc8a218a8840a6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,9 +51,9 @@ class DescriptorClusterSemanticTagStruct( put(ContextSpecificTag(TAG_TAG), tag) if (label != null) { if (label.isPresent) { - val optlabel = label.get() - put(ContextSpecificTag(TAG_LABEL), optlabel) - } + val optlabel = label.get() + put(ContextSpecificTag(TAG_LABEL), optlabel) + } } else { putNull(ContextSpecificTag(TAG_LABEL)) } @@ -68,27 +69,25 @@ class DescriptorClusterSemanticTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DescriptorClusterSemanticTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) - null - } + val mfgCode = if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) + null + } val namespaceID = tlvReader.getUByte(ContextSpecificTag(TAG_NAMESPACE_I_D)) val tag = tlvReader.getUByte(ContextSpecificTag(TAG_TAG)) - val label = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) - null - } - + val label = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) + null + } + tlvReader.exitContainer() return DescriptorClusterSemanticTagStruct(mfgCode, namespaceID, tag, label) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt index 4649721a71284b..0972701ad34688 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,34 +73,25 @@ class DeviceEnergyManagementClusterConstraintsStruct( tlvReader.enterStructure(tlvTag) val startTime = tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) - val nominalPower = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val maximumEnergy = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) - } else { - Optional.empty() - } - val loadControl = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { - Optional.of(tlvReader.getByte(ContextSpecificTag(TAG_LOAD_CONTROL))) - } else { - Optional.empty() - } - + val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val maximumEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) + } else { + Optional.empty() + } + val loadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { + Optional.of(tlvReader.getByte(ContextSpecificTag(TAG_LOAD_CONTROL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterConstraintsStruct( - startTime, - duration, - nominalPower, - maximumEnergy, - loadControl - ) + return DeviceEnergyManagementClusterConstraintsStruct(startTime, duration, nominalPower, maximumEnergy, loadControl) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt index c08ce3a1eaf582..f75628b28ac4f9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -63,13 +64,12 @@ class DeviceEnergyManagementClusterCostStruct( val costType = tlvReader.getUByte(ContextSpecificTag(TAG_COST_TYPE)) val value = tlvReader.getInt(ContextSpecificTag(TAG_VALUE)) val decimalPoints = tlvReader.getUByte(ContextSpecificTag(TAG_DECIMAL_POINTS)) - val currency = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_CURRENCY))) - } else { - Optional.empty() - } - + val currency = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_CURRENCY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return DeviceEnergyManagementClusterCostStruct(costType, value, decimalPoints, currency) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt index a83d26ee3815d0..eaab7da96a369e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt @@ -62,9 +62,9 @@ class DeviceEnergyManagementClusterForecastStruct( put(ContextSpecificTag(TAG_END_TIME), endTime) if (earliestStartTime != null) { if (earliestStartTime.isPresent) { - val optearliestStartTime = earliestStartTime.get() - put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) - } + val optearliestStartTime = earliestStartTime.get() + put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) + } } else { putNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) } @@ -97,56 +97,42 @@ class DeviceEnergyManagementClusterForecastStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterForecastStruct { tlvReader.enterStructure(tlvTag) val forecastId = tlvReader.getUShort(ContextSpecificTag(TAG_FORECAST_ID)) - val activeSlotNumber = - if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - null - } + val activeSlotNumber = if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + null + } val startTime = tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getUInt(ContextSpecificTag(TAG_END_TIME)) - val earliestStartTime = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_EARLIEST_START_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) - null - } - val latestEndTime = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LATEST_END_TIME))) - } else { - Optional.empty() - } + val earliestStartTime = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_EARLIEST_START_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) + null + } + val latestEndTime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LATEST_END_TIME))) + } else { + Optional.empty() + } val isPauseable = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_PAUSEABLE)) - val slots = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) - while (!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val slots = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) + while(!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } val forecastUpdateReason = tlvReader.getUByte(ContextSpecificTag(TAG_FORECAST_UPDATE_REASON)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterForecastStruct( - forecastId, - activeSlotNumber, - startTime, - endTime, - earliestStartTime, - latestEndTime, - isPauseable, - slots, - forecastUpdateReason - ) + return DeviceEnergyManagementClusterForecastStruct(forecastId, activeSlotNumber, startTime, endTime, earliestStartTime, latestEndTime, isPauseable, slots, forecastUpdateReason) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt index c1822bb573e344..f03165bcf17f94 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,15 +62,10 @@ class DeviceEnergyManagementClusterPowerAdjustStruct( val maxPower = tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER)) val minDuration = tlvReader.getUInt(ContextSpecificTag(TAG_MIN_DURATION)) val maxDuration = tlvReader.getUInt(ContextSpecificTag(TAG_MAX_DURATION)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterPowerAdjustStruct( - minPower, - maxPower, - minDuration, - maxDuration - ) + return DeviceEnergyManagementClusterPowerAdjustStruct(minPower, maxPower, minDuration, maxDuration) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt index e11febdfd6a489..8cf41014cac8bd 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,15 +52,12 @@ class DeviceEnergyManagementClusterSlotAdjustmentStruct( private const val TAG_NOMINAL_POWER = 1 private const val TAG_DURATION = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): DeviceEnergyManagementClusterSlotAdjustmentStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterSlotAdjustmentStruct { tlvReader.enterStructure(tlvTag) val slotIndex = tlvReader.getUByte(ContextSpecificTag(TAG_SLOT_INDEX)) val nominalPower = tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER)) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterSlotAdjustmentStruct(slotIndex, nominalPower, duration) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt index 992a41573e295e..b973f2c0fcb3e5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt @@ -110,10 +110,10 @@ class DeviceEnergyManagementClusterSlotStruct( if (costs.isPresent) { val optcosts = costs.get() startArray(ContextSpecificTag(TAG_COSTS)) - for (item in optcosts.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optcosts.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } if (minPowerAdjustment.isPresent) { val optminPowerAdjustment = minPowerAdjustment.get() @@ -162,115 +162,81 @@ class DeviceEnergyManagementClusterSlotStruct( val defaultDuration = tlvReader.getUInt(ContextSpecificTag(TAG_DEFAULT_DURATION)) val elapsedSlotTime = tlvReader.getUInt(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME)) val remainingSlotTime = tlvReader.getUInt(ContextSpecificTag(TAG_REMAINING_SLOT_TIME)) - val slotIsPauseable = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) - } else { - Optional.empty() - } - val minPauseDuration = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) - } else { - Optional.empty() - } - val maxPauseDuration = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) - } else { - Optional.empty() - } - val manufacturerESAState = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) - } else { - Optional.empty() - } - val nominalPower = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val minPower = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) - } else { - Optional.empty() - } - val maxPower = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) - } else { - Optional.empty() - } - val nominalEnergy = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) - } else { - Optional.empty() - } - val costs = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) - while (!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val minPowerAdjustment = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxPowerAdjustment = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val minDurationAdjustment = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxDurationAdjustment = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - + val slotIsPauseable = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) + } else { + Optional.empty() + } + val minPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) + } else { + Optional.empty() + } + val maxPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) + } else { + Optional.empty() + } + val manufacturerESAState = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) + } else { + Optional.empty() + } + val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val minPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) + } else { + Optional.empty() + } + val maxPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) + } else { + Optional.empty() + } + val nominalEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) + } else { + Optional.empty() + } + val costs = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) + while(!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val minPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val minDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterSlotStruct( - minDuration, - maxDuration, - defaultDuration, - elapsedSlotTime, - remainingSlotTime, - slotIsPauseable, - minPauseDuration, - maxPauseDuration, - manufacturerESAState, - nominalPower, - minPower, - maxPower, - nominalEnergy, - costs, - minPowerAdjustment, - maxPowerAdjustment, - minDurationAdjustment, - maxDurationAdjustment - ) + return DeviceEnergyManagementClusterSlotStruct(minDuration, maxDuration, defaultDuration, elapsedSlotTime, remainingSlotTime, slotIsPauseable, minPauseDuration, maxPauseDuration, manufacturerESAState, nominalPower, minPower, maxPower, nominalEnergy, costs, minPowerAdjustment, maxPowerAdjustment, minDurationAdjustment, maxDurationAdjustment) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt index 3d61c5bccf50cf..d250f1c10ccccc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -59,15 +60,14 @@ class DishwasherModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return DishwasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt index 584dc79028182c..033e60f5419f37 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt @@ -18,12 +18,16 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { +class DishwasherModeClusterModeTagStruct( + val mfgCode: Optional, + val value: UShort +) { override fun toString(): String = buildString { append("DishwasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -49,14 +53,13 @@ class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val valu fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return DishwasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt index f66b57f47660ca..5f2b5c37f2d96e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterCredentialStruct(val credentialType: UByte, val credentialIndex: UShort) { +class DoorLockClusterCredentialStruct( + val credentialType: UByte, + val credentialIndex: UShort +) { override fun toString(): String = buildString { append("DoorLockClusterCredentialStruct {\n") append("\tcredentialType : $credentialType\n") @@ -47,7 +52,7 @@ class DoorLockClusterCredentialStruct(val credentialType: UByte, val credentialI tlvReader.enterStructure(tlvTag) val credentialType = tlvReader.getUByte(ContextSpecificTag(TAG_CREDENTIAL_TYPE)) val credentialIndex = tlvReader.getUShort(ContextSpecificTag(TAG_CREDENTIAL_INDEX)) - + tlvReader.exitContainer() return DoorLockClusterCredentialStruct(credentialType, credentialIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt index 46dff94ff6a1cb..397f1eab428ecf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -71,46 +72,33 @@ class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( private const val TAG_START_SYSTIME = 3 private const val TAG_END_SYSTIME = 4 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { tlvReader.enterStructure(tlvTag) val energy = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY)) - val startTimestamp = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_START_TIMESTAMP))) - } else { - Optional.empty() - } - val endTimestamp = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_END_TIMESTAMP))) - } else { - Optional.empty() - } - val startSystime = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) - } else { - Optional.empty() - } - val endSystime = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) - } else { - Optional.empty() - } - + val startTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( - energy, - startTimestamp, - endTimestamp, - startSystime, - endSystime - ) + return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct(energy, startTimestamp, endTimestamp, startSystime, endSystime) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt index 65ed89eee4272d..4e0ca217ce09fe 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -89,62 +90,44 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( private const val TAG_FIXED_MIN = 6 private const val TAG_FIXED_TYPICAL = 7 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { tlvReader.enterStructure(tlvTag) val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) - val percentMax = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MAX))) - } else { - Optional.empty() - } - val percentMin = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MIN))) - } else { - Optional.empty() - } - val percentTypical = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_TYPICAL))) - } else { - Optional.empty() - } - val fixedMax = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) - } else { - Optional.empty() - } - val fixedMin = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) - } else { - Optional.empty() - } - val fixedTypical = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) - } else { - Optional.empty() - } - + val percentMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( - rangeMin, - rangeMax, - percentMax, - percentMin, - percentTypical, - fixedMax, - fixedMin, - fixedTypical - ) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct(rangeMin, rangeMax, percentMax, percentMin, percentTypical, fixedMax, fixedMin, fixedTypical) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt index b8f7a0f8ff429e..b0ec26832b7c2d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -63,38 +64,23 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( private const val TAG_MAX_MEASURED_VALUE = 3 private const val TAG_ACCURACY_RANGES = 4 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { tlvReader.enterStructure(tlvTag) val measurementType = tlvReader.getUShort(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) - val accuracyRanges = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) - while (!tlvReader.isEndOfContainer()) { - add( - ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - + val accuracyRanges = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while(!tlvReader.isEndOfContainer()) { + add(ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( - measurementType, - measured, - minMeasuredValue, - maxMeasuredValue, - accuracyRanges - ) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct(measurementType, measured, minMeasuredValue, maxMeasuredValue, accuracyRanges) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt index eaa06f527c652f..3ed256441cd2ff 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -53,17 +54,15 @@ class EnergyEvseClusterChargingTargetScheduleStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetScheduleStruct { tlvReader.enterStructure(tlvTag) - val dayOfWeekForSequence = - tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) - val chargingTargets = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) - while (!tlvReader.isEndOfContainer()) { - add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val dayOfWeekForSequence = tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) + val chargingTargets = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) + while(!tlvReader.isEndOfContainer()) { + add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return EnergyEvseClusterChargingTargetScheduleStruct(dayOfWeekForSequence, chargingTargets) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt index db61226e1adf55..72826868a15260 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -59,28 +60,21 @@ class EnergyEvseClusterChargingTargetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetStruct { tlvReader.enterStructure(tlvTag) - val targetTimeMinutesPastMidnight = - tlvReader.getUShort(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) - val targetSoC = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TARGET_SO_C))) - } else { - Optional.empty() - } - val addedEnergy = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) - } else { - Optional.empty() - } - + val targetTimeMinutesPastMidnight = tlvReader.getUShort(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) + val targetSoC = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TARGET_SO_C))) + } else { + Optional.empty() + } + val addedEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterChargingTargetStruct( - targetTimeMinutesPastMidnight, - targetSoC, - addedEnergy - ) + return EnergyEvseClusterChargingTargetStruct(targetTimeMinutesPastMidnight, targetSoC, addedEnergy) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt index 29980664d4cbec..80e4c2b06d9cad 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt @@ -18,12 +18,16 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyPreferenceClusterBalanceStruct(val step: UByte, val label: Optional) { +class EnergyPreferenceClusterBalanceStruct( + val step: UByte, + val label: Optional +) { override fun toString(): String = buildString { append("EnergyPreferenceClusterBalanceStruct {\n") append("\tstep : $step\n") @@ -50,13 +54,12 @@ class EnergyPreferenceClusterBalanceStruct(val step: UByte, val label: Optional< fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyPreferenceClusterBalanceStruct { tlvReader.enterStructure(tlvTag) val step = tlvReader.getUByte(ContextSpecificTag(TAG_STEP)) - val label = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - + val label = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return EnergyPreferenceClusterBalanceStruct(step, label) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt index b5181c44417b6d..2465dd492ace99 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class FixedLabelClusterLabelStruct(val label: String, val value: String) { +class FixedLabelClusterLabelStruct( + val label: String, + val value: String +) { override fun toString(): String = buildString { append("FixedLabelClusterLabelStruct {\n") append("\tlabel : $label\n") @@ -47,7 +52,7 @@ class FixedLabelClusterLabelStruct(val label: String, val value: String) { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return FixedLabelClusterLabelStruct(label, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt index aa7528a466dece..b2d6b7e97638e6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,22 +48,14 @@ class GeneralCommissioningClusterBasicCommissioningInfo( private const val TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS = 0 private const val TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): GeneralCommissioningClusterBasicCommissioningInfo { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralCommissioningClusterBasicCommissioningInfo { tlvReader.enterStructure(tlvTag) - val failSafeExpiryLengthSeconds = - tlvReader.getUShort(ContextSpecificTag(TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS)) - val maxCumulativeFailsafeSeconds = - tlvReader.getUShort(ContextSpecificTag(TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS)) - + val failSafeExpiryLengthSeconds = tlvReader.getUShort(ContextSpecificTag(TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS)) + val maxCumulativeFailsafeSeconds = tlvReader.getUShort(ContextSpecificTag(TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS)) + tlvReader.exitContainer() - return GeneralCommissioningClusterBasicCommissioningInfo( - failSafeExpiryLengthSeconds, - maxCumulativeFailsafeSeconds - ) + return GeneralCommissioningClusterBasicCommissioningInfo(failSafeExpiryLengthSeconds, maxCumulativeFailsafeSeconds) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt index 200b75dde048f4..61f8691c5f053a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -52,18 +53,12 @@ class GeneralDiagnosticsClusterNetworkInterface( put(ContextSpecificTag(TAG_NAME), name) put(ContextSpecificTag(TAG_IS_OPERATIONAL), isOperational) if (offPremiseServicesReachableIPv4 != null) { - put( - ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), - offPremiseServicesReachableIPv4 - ) + put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), offPremiseServicesReachableIPv4) } else { putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) } if (offPremiseServicesReachableIPv6 != null) { - put( - ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), - offPremiseServicesReachableIPv6 - ) + put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), offPremiseServicesReachableIPv6) } else { putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) } @@ -97,51 +92,38 @@ class GeneralDiagnosticsClusterNetworkInterface( tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val isOperational = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_OPERATIONAL)) - val offPremiseServicesReachableIPv4 = - if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - null - } - val offPremiseServicesReachableIPv6 = - if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - null - } + val offPremiseServicesReachableIPv4 = if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + null + } + val offPremiseServicesReachableIPv6 = if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + null + } val hardwareAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_HARDWARE_ADDRESS)) - val IPv4Addresses = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val IPv6Addresses = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val IPv4Addresses = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val IPv6Addresses = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) - + tlvReader.exitContainer() - return GeneralDiagnosticsClusterNetworkInterface( - name, - isOperational, - offPremiseServicesReachableIPv4, - offPremiseServicesReachableIPv6, - hardwareAddress, - IPv4Addresses, - IPv6Addresses, - type - ) + return GeneralDiagnosticsClusterNetworkInterface(name, isOperational, offPremiseServicesReachableIPv4, offPremiseServicesReachableIPv6, hardwareAddress, IPv4Addresses, IPv6Addresses, type) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt index 9d0155111d4207..ef8286072bfcfd 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt @@ -66,22 +66,20 @@ class GroupKeyManagementClusterGroupInfoMapStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupInfoMapStruct { tlvReader.enterStructure(tlvTag) val groupId = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_ID)) - val endpoints = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - val groupName = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) - } else { - Optional.empty() - } + val endpoints = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + val groupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupInfoMapStruct(groupId, endpoints, groupName, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt index e5f8ecb177a11b..b40a261be6a411 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -55,7 +57,7 @@ class GroupKeyManagementClusterGroupKeyMapStruct( val groupId = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_ID)) val groupKeySetID = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupKeyMapStruct(groupId, groupKeySetID, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt index d68d0536b9bd30..86cb6fb3510b09 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -97,63 +99,47 @@ class GroupKeyManagementClusterGroupKeySetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupKeySetStruct { tlvReader.enterStructure(tlvTag) val groupKeySetID = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) - val groupKeySecurityPolicy = - tlvReader.getUByte(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) - val epochKey0 = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) - null - } - val epochStartTime0 = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - null - } - val epochKey1 = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) - null - } - val epochStartTime1 = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - null - } - val epochKey2 = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) - null - } - val epochStartTime2 = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - null - } - + val groupKeySecurityPolicy = tlvReader.getUByte(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) + val epochKey0 = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) + null + } + val epochStartTime0 = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + null + } + val epochKey1 = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) + null + } + val epochStartTime1 = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + null + } + val epochKey2 = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) + null + } + val epochStartTime2 = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + null + } + tlvReader.exitContainer() - return GroupKeyManagementClusterGroupKeySetStruct( - groupKeySetID, - groupKeySecurityPolicy, - epochKey0, - epochStartTime0, - epochKey1, - epochStartTime1, - epochKey2, - epochStartTime2 - ) + return GroupKeyManagementClusterGroupKeySetStruct(groupKeySetID, groupKeySecurityPolicy, epochKey0, epochStartTime0, epochKey1, epochStartTime1, epochKey2, epochStartTime2) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt index 99d8d0dfd05c83..c838f5450b4c90 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,22 +48,14 @@ class HepaFilterMonitoringClusterReplacementProductStruct( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): HepaFilterMonitoringClusterReplacementProductStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): HepaFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) - val productIdentifierType = - tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = - tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierType = tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) + val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return HepaFilterMonitoringClusterReplacementProductStruct( - productIdentifierType, - productIdentifierValue - ) + return HepaFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt index d3f81f766efb96..8d8e02194628e3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,22 +52,15 @@ class IcdManagementClusterMonitoringRegistrationStruct( private const val TAG_MONITORED_SUBJECT = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): IcdManagementClusterMonitoringRegistrationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): IcdManagementClusterMonitoringRegistrationStruct { tlvReader.enterStructure(tlvTag) val checkInNodeID = tlvReader.getULong(ContextSpecificTag(TAG_CHECK_IN_NODE_I_D)) val monitoredSubject = tlvReader.getULong(ContextSpecificTag(TAG_MONITORED_SUBJECT)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return IcdManagementClusterMonitoringRegistrationStruct( - checkInNodeID, - monitoredSubject, - fabricIndex - ) + return IcdManagementClusterMonitoringRegistrationStruct(checkInNodeID, monitoredSubject, fabricIndex) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt index e8392fab770bf0..869fc790e2c371 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -59,15 +60,14 @@ class LaundryWasherModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return LaundryWasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt index a12e2840ead4ab..1b9aaf99f45c57 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt @@ -18,12 +18,16 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { +class LaundryWasherModeClusterModeTagStruct( + val mfgCode: Optional, + val value: UShort +) { override fun toString(): String = buildString { append("LaundryWasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -49,14 +53,13 @@ class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val v fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): LaundryWasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return LaundryWasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt index 2aaef4b767542e..13d46092d3725f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,7 +62,7 @@ class MediaInputClusterInputInfoStruct( val inputType = tlvReader.getUByte(ContextSpecificTag(TAG_INPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val description = tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION)) - + tlvReader.exitContainer() return MediaInputClusterInputInfoStruct(index, inputType, name, description) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt index 518da6b739efc8..6df4407304fc0d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaPlaybackClusterPlaybackPositionStruct(val updatedAt: ULong, val position: ULong?) { +class MediaPlaybackClusterPlaybackPositionStruct( + val updatedAt: ULong, + val position: ULong? +) { override fun toString(): String = buildString { append("MediaPlaybackClusterPlaybackPositionStruct {\n") append("\tupdatedAt : $updatedAt\n") @@ -50,14 +55,13 @@ class MediaPlaybackClusterPlaybackPositionStruct(val updatedAt: ULong, val posit fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterPlaybackPositionStruct { tlvReader.enterStructure(tlvTag) val updatedAt = tlvReader.getULong(ContextSpecificTag(TAG_UPDATED_AT)) - val position = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) - null - } - + val position = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterPlaybackPositionStruct(updatedAt, position) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt index dfd99da8565408..b82ec49c17f735 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -40,9 +41,9 @@ class MediaPlaybackClusterTrackAttributesStruct( put(ContextSpecificTag(TAG_LANGUAGE_CODE), languageCode) if (displayName != null) { if (displayName.isPresent) { - val optdisplayName = displayName.get() - put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) - } + val optdisplayName = displayName.get() + put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) + } } else { putNull(ContextSpecificTag(TAG_DISPLAY_NAME)) } @@ -57,18 +58,17 @@ class MediaPlaybackClusterTrackAttributesStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackAttributesStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val displayName = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) - null - } - + val displayName = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackAttributesStruct(languageCode, displayName) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt index 0571df7456c16e..f4c43f16e2337f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -53,17 +55,13 @@ class MediaPlaybackClusterTrackStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getString(ContextSpecificTag(TAG_ID)) - val trackAttributes = - if (!tlvReader.isNull()) { - MediaPlaybackClusterTrackAttributesStruct.fromTlv( - ContextSpecificTag(TAG_TRACK_ATTRIBUTES), - tlvReader - ) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) - null - } - + val trackAttributes = if (!tlvReader.isNull()) { + MediaPlaybackClusterTrackAttributesStruct.fromTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackStruct(id, trackAttributes) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt index 8af30d0c768cf7..90d2e905cad2b1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -59,15 +60,14 @@ class MicrowaveOvenModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt index ee00730c425f47..6ac44a062ca27a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt @@ -18,12 +18,16 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { +class MicrowaveOvenModeClusterModeTagStruct( + val mfgCode: Optional, + val value: UShort +) { override fun toString(): String = buildString { append("MicrowaveOvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -49,14 +53,13 @@ class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val v fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MicrowaveOvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt index 558980bb83460a..ee501cf2d85532 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -59,15 +60,14 @@ class ModeSelectClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val semanticTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val semanticTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ModeSelectClusterModeOptionStruct(label, mode, semanticTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt index fe6cdd3b787f01..323f73c99e7820 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ModeSelectClusterSemanticTagStruct(val mfgCode: UShort, val value: UShort) { +class ModeSelectClusterSemanticTagStruct( + val mfgCode: UShort, + val value: UShort +) { override fun toString(): String = buildString { append("ModeSelectClusterSemanticTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -47,7 +52,7 @@ class ModeSelectClusterSemanticTagStruct(val mfgCode: UShort, val value: UShort) tlvReader.enterStructure(tlvTag) val mfgCode = tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE)) val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ModeSelectClusterSemanticTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt index ebb7d9c32e5609..443d3e377f6837 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -45,17 +46,17 @@ class NetworkCommissioningClusterNetworkInfoStruct( put(ContextSpecificTag(TAG_CONNECTED), connected) if (networkIdentifier != null) { if (networkIdentifier.isPresent) { - val optnetworkIdentifier = networkIdentifier.get() - put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) - } + val optnetworkIdentifier = networkIdentifier.get() + put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) + } } else { putNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) } if (clientIdentifier != null) { if (clientIdentifier.isPresent) { - val optclientIdentifier = clientIdentifier.get() - put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) - } + val optclientIdentifier = clientIdentifier.get() + put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) + } } else { putNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) } @@ -73,37 +74,30 @@ class NetworkCommissioningClusterNetworkInfoStruct( tlvReader.enterStructure(tlvTag) val networkID = tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_I_D)) val connected = tlvReader.getBoolean(ContextSpecificTag(TAG_CONNECTED)) - val networkIdentifier = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) - null - } - val clientIdentifier = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) - null - } - + val networkIdentifier = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) + null + } + val clientIdentifier = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) + null + } + tlvReader.exitContainer() - return NetworkCommissioningClusterNetworkInfoStruct( - networkID, - connected, - networkIdentifier, - clientIdentifier - ) + return NetworkCommissioningClusterNetworkInfoStruct(networkID, connected, networkIdentifier, clientIdentifier) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt index 93df116f49e63e..c052531cdda164 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -70,10 +72,7 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct( private const val TAG_RSSI = 6 private const val TAG_LQI = 7 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): NetworkCommissioningClusterThreadInterfaceScanResultStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): NetworkCommissioningClusterThreadInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val panId = tlvReader.getUShort(ContextSpecificTag(TAG_PAN_ID)) val extendedPanId = tlvReader.getULong(ContextSpecificTag(TAG_EXTENDED_PAN_ID)) @@ -83,19 +82,10 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct( val extendedAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_EXTENDED_ADDRESS)) val rssi = tlvReader.getByte(ContextSpecificTag(TAG_RSSI)) val lqi = tlvReader.getUByte(ContextSpecificTag(TAG_LQI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterThreadInterfaceScanResultStruct( - panId, - extendedPanId, - networkName, - channel, - version, - extendedAddress, - rssi, - lqi - ) + return NetworkCommissioningClusterThreadInterfaceScanResultStruct(panId, extendedPanId, networkName, channel, version, extendedAddress, rssi, lqi) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt index ffbb05f45a6b51..85c6cf71f7c47b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -62,10 +64,7 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( private const val TAG_WI_FI_BAND = 4 private const val TAG_RSSI = 5 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): NetworkCommissioningClusterWiFiInterfaceScanResultStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): NetworkCommissioningClusterWiFiInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val security = tlvReader.getUByte(ContextSpecificTag(TAG_SECURITY)) val ssid = tlvReader.getByteArray(ContextSpecificTag(TAG_SSID)) @@ -73,17 +72,10 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( val channel = tlvReader.getUShort(ContextSpecificTag(TAG_CHANNEL)) val wiFiBand = tlvReader.getUByte(ContextSpecificTag(TAG_WI_FI_BAND)) val rssi = tlvReader.getByte(ContextSpecificTag(TAG_RSSI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterWiFiInterfaceScanResultStruct( - security, - ssid, - bssid, - channel, - wiFiBand, - rssi - ) + return NetworkCommissioningClusterWiFiInterfaceScanResultStruct(security, ssid, bssid, channel, wiFiBand, rssi) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt index 89b9428c741564..7c980f2eaa2d01 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -62,10 +64,7 @@ class OperationalCredentialsClusterFabricDescriptorStruct( private const val TAG_LABEL = 5 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OperationalCredentialsClusterFabricDescriptorStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalCredentialsClusterFabricDescriptorStruct { tlvReader.enterStructure(tlvTag) val rootPublicKey = tlvReader.getByteArray(ContextSpecificTag(TAG_ROOT_PUBLIC_KEY)) val vendorID = tlvReader.getUShort(ContextSpecificTag(TAG_VENDOR_I_D)) @@ -73,17 +72,10 @@ class OperationalCredentialsClusterFabricDescriptorStruct( val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OperationalCredentialsClusterFabricDescriptorStruct( - rootPublicKey, - vendorID, - fabricID, - nodeID, - label, - fabricIndex - ) + return OperationalCredentialsClusterFabricDescriptorStruct(rootPublicKey, vendorID, fabricID, nodeID, label, fabricIndex) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt index 3a104b0d78b127..1a27ee6624fe40 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,15 +59,14 @@ class OperationalCredentialsClusterNOCStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalCredentialsClusterNOCStruct { tlvReader.enterStructure(tlvTag) val noc = tlvReader.getByteArray(ContextSpecificTag(TAG_NOC)) - val icac = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) - null - } + val icac = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return OperationalCredentialsClusterNOCStruct(noc, icac, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt index f1d7a22e7e757b..24ddb76ae228ca 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,26 +61,20 @@ class OperationalStateClusterErrorStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterErrorStateStruct( - errorStateID, - errorStateLabel, - errorStateDetails - ) + return OperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt index d08dc7aa0df6e9..95645f734ce9ef 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -53,19 +54,15 @@ class OperationalStateClusterOperationalStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterOperationalStateStruct( - operationalStateID, - operationalStateLabel - ) + return OperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt index f9dd92cc8640f3..a8363ebd687c3d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,22 +52,15 @@ class OtaSoftwareUpdateRequestorClusterProviderLocation( private const val TAG_ENDPOINT = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OtaSoftwareUpdateRequestorClusterProviderLocation { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OtaSoftwareUpdateRequestorClusterProviderLocation { tlvReader.enterStructure(tlvTag) val providerNodeID = tlvReader.getULong(ContextSpecificTag(TAG_PROVIDER_NODE_I_D)) val endpoint = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterProviderLocation( - providerNodeID, - endpoint, - fabricIndex - ) + return OtaSoftwareUpdateRequestorClusterProviderLocation(providerNodeID, endpoint, fabricIndex) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt index 3ca1059ea25628..825b5246771055 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,32 +58,23 @@ class OvenCavityOperationalStateClusterErrorStateStruct( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OvenCavityOperationalStateClusterErrorStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenCavityOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterErrorStateStruct( - errorStateID, - errorStateLabel, - errorStateDetails - ) + return OvenCavityOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt index f66b7a09928db4..2c051ce55bad80 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,25 +51,18 @@ class OvenCavityOperationalStateClusterOperationalStateStruct( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): OvenCavityOperationalStateClusterOperationalStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenCavityOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationalStateStruct( - operationalStateID, - operationalStateLabel - ) + return OvenCavityOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt index ba8bad6b42ff54..47fda3f789599e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -59,15 +60,14 @@ class OvenModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return OvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt index 4ba9d368de022f..3715c9253bd394 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt @@ -18,12 +18,16 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { +class OvenModeClusterModeTagStruct( + val mfgCode: Optional, + val value: UShort +) { override fun toString(): String = buildString { append("OvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -49,14 +53,13 @@ class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: USh fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return OvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt index 8b9487ac66f3e3..93b2e01e8dcd67 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -57,23 +58,21 @@ class PowerSourceClusterBatChargeFaultChangeType( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt index 6b849cc5874313..f5c4803e0482ac 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -23,7 +24,10 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatFaultChangeType(val current: List, val previous: List) { +class PowerSourceClusterBatFaultChangeType( + val current: List, + val previous: List +) { override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeType {\n") append("\tcurrent : $current\n") @@ -54,23 +58,21 @@ class PowerSourceClusterBatFaultChangeType(val current: List, val previou fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt index 9354883b16e760..0eb132ceb49b1e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -23,7 +24,10 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterWiredFaultChangeType(val current: List, val previous: List) { +class PowerSourceClusterWiredFaultChangeType( + val current: List, + val previous: List +) { override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeType {\n") append("\tcurrent : $current\n") @@ -54,23 +58,21 @@ class PowerSourceClusterWiredFaultChangeType(val current: List, val previ fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt index cd01932bc3f167..59482e83c5039d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -55,34 +56,21 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add( - RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv( - AnonymousTag, - tlvReader - ) - ) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( - label, - mode, - modeTags - ) + return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct(label, mode, modeTags) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt index 9faf469741368c..2ec589a6c0df35 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,19 +51,15 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt index a8e74c89f3ad1d..a79f2a02599eba 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -59,15 +60,14 @@ class RvcCleanModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcCleanModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt index ce35ad9a5a9960..88ea7b7b2f7002 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt @@ -18,12 +18,16 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { +class RvcCleanModeClusterModeTagStruct( + val mfgCode: Optional, + val value: UShort +) { override fun toString(): String = buildString { append("RvcCleanModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -49,14 +53,13 @@ class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcCleanModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcCleanModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt index 6fa68a81b810ad..20e4ab7ba0a318 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,26 +61,20 @@ class RvcOperationalStateClusterErrorStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterErrorStateStruct( - errorStateID, - errorStateLabel, - errorStateDetails - ) + return RvcOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt index f21d5ecb4da1cf..1d7445a75f0ac5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,25 +51,18 @@ class RvcOperationalStateClusterOperationalStateStruct( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): RvcOperationalStateClusterOperationalStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationalStateStruct( - operationalStateID, - operationalStateLabel - ) + return RvcOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt index f4193b91fac485..c98a49235c774f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -59,15 +60,14 @@ class RvcRunModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while (!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while(!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcRunModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt index 7ad69693847d17..d9c65679552d63 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt @@ -18,12 +18,16 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { +class RvcRunModeClusterModeTagStruct( + val mfgCode: Optional, + val value: UShort +) { override fun toString(): String = buildString { append("RvcRunModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -49,14 +53,13 @@ class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: U fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcRunModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcRunModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt index 1a14970ba2bd58..90b6fb8bfb24d9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ScenesManagementClusterAttributeValuePair(val attributeID: UInt, val attributeValue: UInt) { +class ScenesManagementClusterAttributeValuePair( + val attributeID: UInt, + val attributeValue: UInt +) { override fun toString(): String = buildString { append("ScenesManagementClusterAttributeValuePair {\n") append("\tattributeID : $attributeID\n") @@ -47,7 +52,7 @@ class ScenesManagementClusterAttributeValuePair(val attributeID: UInt, val attri tlvReader.enterStructure(tlvTag) val attributeID = tlvReader.getUInt(ContextSpecificTag(TAG_ATTRIBUTE_I_D)) val attributeValue = tlvReader.getUInt(ContextSpecificTag(TAG_ATTRIBUTE_VALUE)) - + tlvReader.exitContainer() return ScenesManagementClusterAttributeValuePair(attributeID, attributeValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt index 516c53bfb62604..9a7e49546361d1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -54,15 +55,14 @@ class ScenesManagementClusterExtensionFieldSet( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterExtensionFieldSet { tlvReader.enterStructure(tlvTag) val clusterID = tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER_I_D)) - val attributeValueList = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val attributeValueList = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ScenesManagementClusterExtensionFieldSet(clusterID, attributeValueList) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt index 5a753f4acf803d..ea23bcb97924f6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -70,17 +72,10 @@ class ScenesManagementClusterSceneInfoStruct( val sceneValid = tlvReader.getBoolean(ContextSpecificTag(TAG_SCENE_VALID)) val remainingCapacity = tlvReader.getUByte(ContextSpecificTag(TAG_REMAINING_CAPACITY)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return ScenesManagementClusterSceneInfoStruct( - sceneCount, - currentScene, - currentGroup, - sceneValid, - remainingCapacity, - fabricIndex - ) + return ScenesManagementClusterSceneInfoStruct(sceneCount, currentScene, currentGroup, sceneValid, remainingCapacity, fabricIndex) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt index b8f67a51a60beb..75b362e21df943 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -74,40 +75,30 @@ class SoftwareDiagnosticsClusterThreadMetricsStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterThreadMetricsStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val stackFreeCurrent = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) - } else { - Optional.empty() - } - val stackFreeMinimum = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) - } else { - Optional.empty() - } - val stackSize = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_SIZE))) - } else { - Optional.empty() - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val stackFreeCurrent = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) + } else { + Optional.empty() + } + val stackFreeMinimum = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) + } else { + Optional.empty() + } + val stackSize = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_SIZE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return SoftwareDiagnosticsClusterThreadMetricsStruct( - id, - name, - stackFreeCurrent, - stackFreeMinimum, - stackSize - ) + return SoftwareDiagnosticsClusterThreadMetricsStruct(id, name, stackFreeCurrent, stackFreeMinimum, stackSize) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt index d1c115ff44e58e..804fa744fe4660 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TargetNavigatorClusterTargetInfoStruct(val identifier: UByte, val name: String) { +class TargetNavigatorClusterTargetInfoStruct( + val identifier: UByte, + val name: String +) { override fun toString(): String = buildString { append("TargetNavigatorClusterTargetInfoStruct {\n") append("\tidentifier : $identifier\n") @@ -47,7 +52,7 @@ class TargetNavigatorClusterTargetInfoStruct(val identifier: UByte, val name: St tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getUByte(ContextSpecificTag(TAG_IDENTIFIER)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetInfoStruct(identifier, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt index 498a7a1ee039f9..be590ab0cbc7f8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -53,9 +54,9 @@ class ThermostatClusterPresetStruct( put(ContextSpecificTag(TAG_PRESET_SCENARIO), presetScenario) if (name != null) { if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } } else { putNull(ContextSpecificTag(TAG_NAME)) } @@ -86,55 +87,43 @@ class ThermostatClusterPresetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } + val presetHandle = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } val presetScenario = tlvReader.getUByte(ContextSpecificTag(TAG_PRESET_SCENARIO)) - val name = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NAME)) - null - } - val coolingSetpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - val builtIn = - if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NAME)) + null + } + val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + val builtIn = if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterPresetStruct( - presetHandle, - presetScenario, - name, - coolingSetpoint, - heatingSetpoint, - builtIn - ) + return ThermostatClusterPresetStruct(presetHandle, presetScenario, name, coolingSetpoint, heatingSetpoint, builtIn) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt index d33ca6f93fdd6b..e9d029d6a542f3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -55,7 +57,7 @@ class ThermostatClusterPresetTypeStruct( val presetScenario = tlvReader.getUByte(ContextSpecificTag(TAG_PRESET_SCENARIO)) val numberOfPresets = tlvReader.getUByte(ContextSpecificTag(TAG_NUMBER_OF_PRESETS)) val presetTypeFeatures = tlvReader.getUShort(ContextSpecificTag(TAG_PRESET_TYPE_FEATURES)) - + tlvReader.exitContainer() return ThermostatClusterPresetTypeStruct(presetScenario, numberOfPresets, presetTypeFeatures) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt index 80a2e263806dda..1ebb7e6e3c7e03 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -56,21 +58,19 @@ class ThermostatClusterQueuedPresetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterQueuedPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } - val transitionTimestamp = - if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - null - } - + val presetHandle = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } + val transitionTimestamp = if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + null + } + tlvReader.exitContainer() return ThermostatClusterQueuedPresetStruct(presetHandle, transitionTimestamp) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt index 25b8ff012cf7bc..29c6a46bc3850e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt @@ -67,9 +67,9 @@ class ThermostatClusterScheduleStruct( endArray() if (builtIn != null) { if (builtIn.isPresent) { - val optbuiltIn = builtIn.get() - put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) - } + val optbuiltIn = builtIn.get() + put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) + } } else { putNull(ContextSpecificTag(TAG_BUILT_IN)) } @@ -87,56 +87,44 @@ class ThermostatClusterScheduleStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleStruct { tlvReader.enterStructure(tlvTag) - val scheduleHandle = - if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - null - } + val scheduleHandle = if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + null + } val systemMode = tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val presetHandle = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val transitions = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while (!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val builtIn = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val transitions = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while(!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val builtIn = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterScheduleStruct( - scheduleHandle, - systemMode, - name, - presetHandle, - transitions, - builtIn - ) + return ThermostatClusterScheduleStruct(scheduleHandle, systemMode, name, presetHandle, transitions, builtIn) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt index bd9e4b6e3ca842..1bd8bfe8cbf3be 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -79,41 +80,30 @@ class ThermostatClusterScheduleTransitionStruct( tlvReader.enterStructure(tlvTag) val dayOfWeek = tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEK)) val transitionTime = tlvReader.getUShort(ContextSpecificTag(TAG_TRANSITION_TIME)) - val presetHandle = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val systemMode = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE))) - } else { - Optional.empty() - } - val coolingSetpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - + val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val systemMode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE))) + } else { + Optional.empty() + } + val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ThermostatClusterScheduleTransitionStruct( - dayOfWeek, - transitionTime, - presetHandle, - systemMode, - coolingSetpoint, - heatingSetpoint - ) + return ThermostatClusterScheduleTransitionStruct(dayOfWeek, transitionTime, presetHandle, systemMode, coolingSetpoint, heatingSetpoint) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt index 91135f990547ff..781f9fdd1aee97 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -55,14 +57,10 @@ class ThermostatClusterScheduleTypeStruct( val systemMode = tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE)) val numberOfSchedules = tlvReader.getUByte(ContextSpecificTag(TAG_NUMBER_OF_SCHEDULES)) val scheduleTypeFeatures = tlvReader.getUShort(ContextSpecificTag(TAG_SCHEDULE_TYPE_FEATURES)) - + tlvReader.exitContainer() - return ThermostatClusterScheduleTypeStruct( - systemMode, - numberOfSchedules, - scheduleTypeFeatures - ) + return ThermostatClusterScheduleTypeStruct(systemMode, numberOfSchedules, scheduleTypeFeatures) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt index 597fce1f35e644..98721edcba9faa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -58,34 +60,25 @@ class ThermostatClusterWeeklyScheduleTransitionStruct( private const val TAG_HEAT_SETPOINT = 1 private const val TAG_COOL_SETPOINT = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThermostatClusterWeeklyScheduleTransitionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterWeeklyScheduleTransitionStruct { tlvReader.enterStructure(tlvTag) val transitionTime = tlvReader.getUShort(ContextSpecificTag(TAG_TRANSITION_TIME)) - val heatSetpoint = - if (!tlvReader.isNull()) { - tlvReader.getShort(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - null - } - val coolSetpoint = - if (!tlvReader.isNull()) { - tlvReader.getShort(ContextSpecificTag(TAG_COOL_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - null - } - + val heatSetpoint = if (!tlvReader.isNull()) { + tlvReader.getShort(ContextSpecificTag(TAG_HEAT_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) + null + } + val coolSetpoint = if (!tlvReader.isNull()) { + tlvReader.getShort(ContextSpecificTag(TAG_COOL_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) + null + } + tlvReader.exitContainer() - return ThermostatClusterWeeklyScheduleTransitionStruct( - transitionTime, - heatSetpoint, - coolSetpoint - ) + return ThermostatClusterWeeklyScheduleTransitionStruct(transitionTime, heatSetpoint, coolSetpoint) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt index c3fc752f705a55..21ee03ed5e51b3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -102,10 +104,7 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct( private const val TAG_FULL_NETWORK_DATA = 12 private const val TAG_IS_CHILD = 13 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThreadNetworkDiagnosticsClusterNeighborTableStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterNeighborTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val age = tlvReader.getUInt(ContextSpecificTag(TAG_AGE)) @@ -113,45 +112,28 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct( val linkFrameCounter = tlvReader.getUInt(ContextSpecificTag(TAG_LINK_FRAME_COUNTER)) val mleFrameCounter = tlvReader.getUInt(ContextSpecificTag(TAG_MLE_FRAME_COUNTER)) val lqi = tlvReader.getUByte(ContextSpecificTag(TAG_LQI)) - val averageRssi = - if (!tlvReader.isNull()) { - tlvReader.getByte(ContextSpecificTag(TAG_AVERAGE_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) - null - } - val lastRssi = - if (!tlvReader.isNull()) { - tlvReader.getByte(ContextSpecificTag(TAG_LAST_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) - null - } + val averageRssi = if (!tlvReader.isNull()) { + tlvReader.getByte(ContextSpecificTag(TAG_AVERAGE_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) + null + } + val lastRssi = if (!tlvReader.isNull()) { + tlvReader.getByte(ContextSpecificTag(TAG_LAST_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) + null + } val frameErrorRate = tlvReader.getUByte(ContextSpecificTag(TAG_FRAME_ERROR_RATE)) val messageErrorRate = tlvReader.getUByte(ContextSpecificTag(TAG_MESSAGE_ERROR_RATE)) val rxOnWhenIdle = tlvReader.getBoolean(ContextSpecificTag(TAG_RX_ON_WHEN_IDLE)) val fullThreadDevice = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_THREAD_DEVICE)) val fullNetworkData = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_NETWORK_DATA)) val isChild = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_CHILD)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterNeighborTableStruct( - extAddress, - age, - rloc16, - linkFrameCounter, - mleFrameCounter, - lqi, - averageRssi, - lastRssi, - frameErrorRate, - messageErrorRate, - rxOnWhenIdle, - fullThreadDevice, - fullNetworkData, - isChild - ) + return ThreadNetworkDiagnosticsClusterNeighborTableStruct(extAddress, age, rloc16, linkFrameCounter, mleFrameCounter, lqi, averageRssi, lastRssi, frameErrorRate, messageErrorRate, rxOnWhenIdle, fullThreadDevice, fullNetworkData, isChild) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt index 8babb9d7bc1680..91975101984aaa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -86,45 +88,24 @@ class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( private const val TAG_SECURITY_POLICY_PRESENT = 10 private const val TAG_CHANNEL_MASK_PRESENT = 11 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { tlvReader.enterStructure(tlvTag) - val activeTimestampPresent = - tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) - val pendingTimestampPresent = - tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) + val activeTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) + val pendingTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) val masterKeyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MASTER_KEY_PRESENT)) val networkNamePresent = tlvReader.getBoolean(ContextSpecificTag(TAG_NETWORK_NAME_PRESENT)) - val extendedPanIdPresent = - tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) - val meshLocalPrefixPresent = - tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) + val extendedPanIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) + val meshLocalPrefixPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) val delayPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_DELAY_PRESENT)) val panIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PAN_ID_PRESENT)) val channelPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_PRESENT)) val pskcPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PSKC_PRESENT)) - val securityPolicyPresent = - tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) + val securityPolicyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) val channelMaskPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_MASK_PRESENT)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( - activeTimestampPresent, - pendingTimestampPresent, - masterKeyPresent, - networkNamePresent, - extendedPanIdPresent, - meshLocalPrefixPresent, - delayPresent, - panIdPresent, - channelPresent, - pskcPresent, - securityPolicyPresent, - channelMaskPresent - ) + return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents(activeTimestampPresent, pendingTimestampPresent, masterKeyPresent, networkNamePresent, extendedPanIdPresent, meshLocalPrefixPresent, delayPresent, panIdPresent, channelPresent, pskcPresent, securityPolicyPresent, channelMaskPresent) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt index 21bfbb8c4e950c..b2b470b5765c0d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -78,10 +80,7 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct( private const val TAG_ALLOCATED = 8 private const val TAG_LINK_ESTABLISHED = 9 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): ThreadNetworkDiagnosticsClusterRouteTableStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterRouteTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val rloc16 = tlvReader.getUShort(ContextSpecificTag(TAG_RLOC16)) @@ -93,21 +92,10 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct( val age = tlvReader.getUByte(ContextSpecificTag(TAG_AGE)) val allocated = tlvReader.getBoolean(ContextSpecificTag(TAG_ALLOCATED)) val linkEstablished = tlvReader.getBoolean(ContextSpecificTag(TAG_LINK_ESTABLISHED)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterRouteTableStruct( - extAddress, - rloc16, - routerId, - nextHop, - pathCost, - LQIIn, - LQIOut, - age, - allocated, - linkEstablished - ) + return ThreadNetworkDiagnosticsClusterRouteTableStruct(extAddress, rloc16, routerId, nextHop, pathCost, LQIIn, LQIOut, age, allocated, linkEstablished) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt index 720cdd6c854a72..3228a78b13b000 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterSecurityPolicy(val rotationTime: UShort, val flags: UShort) { +class ThreadNetworkDiagnosticsClusterSecurityPolicy( + val rotationTime: UShort, + val flags: UShort +) { override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterSecurityPolicy {\n") append("\trotationTime : $rotationTime\n") @@ -47,7 +52,7 @@ class ThreadNetworkDiagnosticsClusterSecurityPolicy(val rotationTime: UShort, va tlvReader.enterStructure(tlvTag) val rotationTime = tlvReader.getUShort(ContextSpecificTag(TAG_ROTATION_TIME)) val flags = tlvReader.getUShort(ContextSpecificTag(TAG_FLAGS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterSecurityPolicy(rotationTime, flags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt index b74d29b91fbebe..366d9e19dc429b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -58,14 +60,13 @@ class TimeSynchronizationClusterDSTOffsetStruct( tlvReader.enterStructure(tlvTag) val offset = tlvReader.getInt(ContextSpecificTag(TAG_OFFSET)) val validStarting = tlvReader.getULong(ContextSpecificTag(TAG_VALID_STARTING)) - val validUntil = - if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) - null - } - + val validUntil = if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) + null + } + tlvReader.exitContainer() return TimeSynchronizationClusterDSTOffsetStruct(offset, validStarting, validUntil) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt index 6681fb2948b29b..7c6440f0f2a618 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,14 +48,11 @@ class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct( private const val TAG_NODE_I_D = 0 private const val TAG_ENDPOINT = 1 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct(nodeID, endpoint) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt index ac2e8efd626715..d8b7a7a33d130e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt @@ -18,6 +18,7 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -58,13 +59,12 @@ class TimeSynchronizationClusterTimeZoneStruct( tlvReader.enterStructure(tlvTag) val offset = tlvReader.getInt(ContextSpecificTag(TAG_OFFSET)) val validAt = tlvReader.getULong(ContextSpecificTag(TAG_VALID_AT)) - val name = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStruct(offset, validAt, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt index 4e966f6c36021e..1e91548ed51086 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,15 +52,12 @@ class TimeSynchronizationClusterTrustedTimeSourceStruct( private const val TAG_NODE_I_D = 1 private const val TAG_ENDPOINT = 2 - fun fromTlv( - tlvTag: Tag, - tlvReader: TlvReader - ): TimeSynchronizationClusterTrustedTimeSourceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterTrustedTimeSourceStruct(fabricIndex, nodeID, endpoint) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt index b308907db2a90c..a78f035f9d5e70 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -23,7 +24,9 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterDoubleNestedStructList(val a: List) { +class UnitTestingClusterDoubleNestedStructList( + val a: List +) { override fun toString(): String = buildString { append("UnitTestingClusterDoubleNestedStructList {\n") append("\ta : $a\n") @@ -47,15 +50,14 @@ class UnitTestingClusterDoubleNestedStructList(val a: List { - tlvReader.enterArray(ContextSpecificTag(TAG_A)) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val a = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_A)) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterDoubleNestedStructList(a) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt index d1bb92e17a739b..21b9bab077f473 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -55,7 +57,7 @@ class UnitTestingClusterNestedStruct( val a = tlvReader.getUByte(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - + tlvReader.exitContainer() return UnitTestingClusterNestedStruct(a, b, c) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt index 3e58a31e5c24f3..653e0e8f3a39d8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt @@ -16,6 +16,7 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -88,39 +89,35 @@ class UnitTestingClusterNestedStructList( val a = tlvReader.getUByte(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - val d = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_D)) - while (!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val e = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_E)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val f = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_F)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val g = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_G)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val d = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_D)) + while(!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val e = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_E)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val f = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_F)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val g = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_G)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterNestedStructList(a, b, c, d, e, f, g) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt index 719fc4459ca37f..279d19e7f4ed48 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt @@ -69,9 +69,9 @@ class UnitTestingClusterNullablesAndOptionalsStruct( } if (nullableOptionalInt != null) { if (nullableOptionalInt.isPresent) { - val optnullableOptionalInt = nullableOptionalInt.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) - } + val optnullableOptionalInt = nullableOptionalInt.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) } @@ -86,9 +86,9 @@ class UnitTestingClusterNullablesAndOptionalsStruct( } if (nullableOptionalString != null) { if (nullableOptionalString.isPresent) { - val optnullableOptionalString = nullableOptionalString.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) - } + val optnullableOptionalString = nullableOptionalString.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) } @@ -103,38 +103,38 @@ class UnitTestingClusterNullablesAndOptionalsStruct( } if (nullableOptionalStruct != null) { if (nullableOptionalStruct.isPresent) { - val optnullableOptionalStruct = nullableOptionalStruct.get() - optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) - } + val optnullableOptionalStruct = nullableOptionalStruct.get() + optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) } if (nullableList != null) { startArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - for (item in nullableList.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in nullableList.iterator()) { + put(AnonymousTag, item) + } + endArray() } else { putNull(ContextSpecificTag(TAG_NULLABLE_LIST)) } if (optionalList.isPresent) { val optoptionalList = optionalList.get() startArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - for (item in optoptionalList.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optoptionalList.iterator()) { + put(AnonymousTag, item) + } + endArray() } if (nullableOptionalList != null) { if (nullableOptionalList.isPresent) { - val optnullableOptionalList = nullableOptionalList.get() - startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - for (item in optnullableOptionalList.iterator()) { - put(AnonymousTag, item) - } - endArray() - } + val optnullableOptionalList = nullableOptionalList.get() + startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + for (item in optnullableOptionalList.iterator()) { + put(AnonymousTag, item) + } + endArray() + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) } @@ -158,151 +158,112 @@ class UnitTestingClusterNullablesAndOptionalsStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNullablesAndOptionalsStruct { tlvReader.enterStructure(tlvTag) - val nullableInt = - if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_INT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) - null - } - val optionalInt = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_OPTIONAL_INT))) - } else { - Optional.empty() - } - val nullableOptionalInt = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) - null - } - val nullableString = - if (!tlvReader.isNull()) { - tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) - null - } - val optionalString = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) - } else { - Optional.empty() - } - val nullableOptionalString = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) - null - } - val nullableStruct = - if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) - null - } - val optionalStruct = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { - Optional.of( - UnitTestingClusterSimpleStruct.fromTlv( - ContextSpecificTag(TAG_OPTIONAL_STRUCT), - tlvReader - ) - ) - } else { - Optional.empty() - } - val nullableOptionalStruct = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { - Optional.of( - UnitTestingClusterSimpleStruct.fromTlv( - ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), - tlvReader - ) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) - null - } - val nullableList = - if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) - null - } - val optionalList = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - val nullableOptionalList = - if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { - Optional.of( - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - null - } - + val nullableInt = if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_INT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) + null + } + val optionalInt = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_OPTIONAL_INT))) + } else { + Optional.empty() + } + val nullableOptionalInt = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) + null + } + val nullableString = if (!tlvReader.isNull()) { + tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) + null + } + val optionalString = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) + } else { + Optional.empty() + } + val nullableOptionalString = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) + null + } + val nullableStruct = if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) + null + } + val optionalStruct = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { + Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), tlvReader)) + } else { + Optional.empty() + } + val nullableOptionalStruct = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { + Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), tlvReader)) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) + null + } + val nullableList = if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) + null + } + val optionalList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + val nullableOptionalList = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { + Optional.of(buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + }) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + null + } + tlvReader.exitContainer() - return UnitTestingClusterNullablesAndOptionalsStruct( - nullableInt, - optionalInt, - nullableOptionalInt, - nullableString, - optionalString, - nullableOptionalString, - nullableStruct, - optionalStruct, - nullableOptionalStruct, - nullableList, - optionalList, - nullableOptionalList - ) + return UnitTestingClusterNullablesAndOptionalsStruct(nullableInt, optionalInt, nullableOptionalInt, nullableString, optionalString, nullableOptionalString, nullableStruct, optionalStruct, nullableOptionalStruct, nullableList, optionalList, nullableOptionalList) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt index 7266ca0054d7d8..3b541c8d11d6b0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt @@ -16,7 +16,9 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -80,7 +82,7 @@ class UnitTestingClusterSimpleStruct( val f = tlvReader.getUByte(ContextSpecificTag(TAG_F)) val g = tlvReader.getFloat(ContextSpecificTag(TAG_G)) val h = tlvReader.getDouble(ContextSpecificTag(TAG_H)) - + tlvReader.exitContainer() return UnitTestingClusterSimpleStruct(a, b, c, d, e, f, g, h) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt index 4e4b00571da5d9..1f38827ddec220 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt @@ -53,10 +53,7 @@ class UnitTestingClusterTestFabricScoped( put(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U), fabricSensitiveInt8u) if (optionalFabricSensitiveInt8u.isPresent) { val optoptionalFabricSensitiveInt8u = optionalFabricSensitiveInt8u.get() - put( - ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), - optoptionalFabricSensitiveInt8u - ) + put(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), optoptionalFabricSensitiveInt8u) } if (nullableFabricSensitiveInt8u != null) { put(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U), nullableFabricSensitiveInt8u) @@ -65,12 +62,9 @@ class UnitTestingClusterTestFabricScoped( } if (nullableOptionalFabricSensitiveInt8u != null) { if (nullableOptionalFabricSensitiveInt8u.isPresent) { - val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() - put( - ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), - optnullableOptionalFabricSensitiveInt8u - ) - } + val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), optnullableOptionalFabricSensitiveInt8u) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) } @@ -99,63 +93,41 @@ class UnitTestingClusterTestFabricScoped( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScoped { tlvReader.enterStructure(tlvTag) val fabricSensitiveInt8u = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U)) - val optionalFabricSensitiveInt8u = - if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) - } else { - Optional.empty() - } - val nullableFabricSensitiveInt8u = - if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - null - } - val nullableOptionalFabricSensitiveInt8u = - if (!tlvReader.isNull()) { - if ( - tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - ) { - Optional.of( - tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - ) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - null - } - val fabricSensitiveCharString = - tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) - val fabricSensitiveStruct = - UnitTestingClusterSimpleStruct.fromTlv( - ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), - tlvReader - ) - val fabricSensitiveInt8uList = - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) - while (!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val optionalFabricSensitiveInt8u = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) + } else { + Optional.empty() + } + val nullableFabricSensitiveInt8u = if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + null + } + val nullableOptionalFabricSensitiveInt8u = if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + null + } + val fabricSensitiveCharString = tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) + val fabricSensitiveStruct = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), tlvReader) + val fabricSensitiveInt8uList = buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) + while(!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return UnitTestingClusterTestFabricScoped( - fabricSensitiveInt8u, - optionalFabricSensitiveInt8u, - nullableFabricSensitiveInt8u, - nullableOptionalFabricSensitiveInt8u, - fabricSensitiveCharString, - fabricSensitiveStruct, - fabricSensitiveInt8uList, - fabricIndex - ) + return UnitTestingClusterTestFabricScoped(fabricSensitiveInt8u, optionalFabricSensitiveInt8u, nullableFabricSensitiveInt8u, nullableOptionalFabricSensitiveInt8u, fabricSensitiveCharString, fabricSensitiveStruct, fabricSensitiveInt8uList, fabricIndex) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt index 9a7f7d3ba58b08..5478f2bd44b175 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterTestListStructOctet(val member1: ULong, val member2: ByteArray) { +class UnitTestingClusterTestListStructOctet( + val member1: ULong, + val member2: ByteArray +) { override fun toString(): String = buildString { append("UnitTestingClusterTestListStructOctet {\n") append("\tmember1 : $member1\n") @@ -47,7 +52,7 @@ class UnitTestingClusterTestListStructOctet(val member1: ULong, val member2: Byt tlvReader.enterStructure(tlvTag) val member1 = tlvReader.getULong(ContextSpecificTag(TAG_MEMBER1)) val member2 = tlvReader.getByteArray(ContextSpecificTag(TAG_MEMBER2)) - + tlvReader.exitContainer() return UnitTestingClusterTestListStructOctet(member1, member2) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt index 8840aec05a78bd..fd4efa9375bbe4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt @@ -16,13 +16,18 @@ */ package matter.controller.cluster.structs +import java.util.Optional import matter.controller.cluster.* +import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UserLabelClusterLabelStruct(val label: String, val value: String) { +class UserLabelClusterLabelStruct( + val label: String, + val value: String +) { override fun toString(): String = buildString { append("UserLabelClusterLabelStruct {\n") append("\tlabel : $label\n") @@ -47,7 +52,7 @@ class UserLabelClusterLabelStruct(val label: String, val value: String) { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return UserLabelClusterLabelStruct(label, value) diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 12a7bb3d93ac7a..dfc992b03ac6b6 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -186,6 +186,7 @@ class TestList : public Command { printf("Test_TC_OO_2_4\n"); printf("Test_TC_OPSTATE_1_1\n"); printf("Test_TC_OVENOPSTATE_1_1\n"); + printf("Test_TC_OVENOPSTATE_2_2\n"); printf("Test_TC_OVENOPSTATE_2_4\n"); printf("Test_TC_PS_1_1\n"); printf("Test_TC_PS_2_1\n"); @@ -90414,6 +90415,118 @@ class Test_TC_OVENOPSTATE_1_1 : public TestCommandBridge { } }; +class Test_TC_OVENOPSTATE_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OVENOPSTATE_2_2() + : TestCommandBridge("Test_TC_OVENOPSTATE_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OVENOPSTATE_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 3: TH reads from the DUT the OperationalStateList attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0003")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_0(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 1; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_0() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the OperationalStateList attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the OperationalStateList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); + } + + VerifyOrReturn(CheckConstraintType("operationalStateList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + class Test_TC_OVENOPSTATE_2_4 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced @@ -195025,6 +195138,7 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), From 0121f7e53951909499ddfcf2d7c2b6029f2a0a0b Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Fri, 19 Jan 2024 14:42:59 -0300 Subject: [PATCH 28/89] Revert "zap regen" This reverts commit b057c11a05a2990bf13f2247c0b1b544cf8baed1. --- ...olClusterAccessControlEntryChangedEvent.kt | 99 +- ...usterAccessControlExtensionChangedEvent.kt | 99 +- .../AccountLoginClusterLoggedOutEvent.kt | 31 +- .../ActionsClusterActionFailedEvent.kt | 21 +- .../ActionsClusterStateChangedEvent.kt | 15 +- .../BasicInformationClusterLeaveEvent.kt | 13 +- ...InformationClusterReachableChangedEvent.kt | 13 +- .../BasicInformationClusterStartUpEvent.kt | 13 +- .../BooleanStateClusterStateChangeEvent.kt | 13 +- ...igurationClusterAlarmsStateChangedEvent.kt | 38 +- ...ateConfigurationClusterSensorFaultEvent.kt | 16 +- ...InformationClusterReachableChangedEvent.kt | 16 +- ...viceBasicInformationClusterStartUpEvent.kt | 16 +- ...lusterLoadControlEventStatusChangeEvent.kt | 281 +- ...rgyManagementClusterPowerAdjustEndEvent.kt | 22 +- ...viceEnergyManagementClusterResumedEvent.kt | 13 +- .../DishwasherAlarmClusterNotifyEvent.kt | 21 +- .../DoorLockClusterDoorLockAlarmEvent.kt | 13 +- .../DoorLockClusterDoorStateChangeEvent.kt | 13 +- .../DoorLockClusterLockOperationErrorEvent.kt | 161 +- .../DoorLockClusterLockOperationEvent.kt | 158 +- .../DoorLockClusterLockUserChangeEvent.kt | 121 +- ...entClusterCumulativeEnergyMeasuredEvent.kt | 74 +- ...ementClusterPeriodicEnergyMeasuredEvent.kt | 74 +- .../EnergyEvseClusterEVConnectedEvent.kt | 13 +- .../EnergyEvseClusterEVNotDetectedEvent.kt | 49 +- ...gyEvseClusterEnergyTransferStartedEvent.kt | 19 +- ...gyEvseClusterEnergyTransferStoppedEvent.kt | 28 +- .../EnergyEvseClusterFaultEvent.kt | 55 +- .../EnergyEvseClusterRFIDEvent.kt | 13 +- ...eneralDiagnosticsClusterBootReasonEvent.kt | 13 +- ...gnosticsClusterHardwareFaultChangeEvent.kt | 49 +- ...agnosticsClusterNetworkFaultChangeEvent.kt | 49 +- ...DiagnosticsClusterRadioFaultChangeEvent.kt | 46 +- .../MediaPlaybackClusterStateChangedEvent.kt | 68 +- ...nalStateClusterOperationCompletionEvent.kt | 99 +- ...tionalStateClusterOperationalErrorEvent.kt | 21 +- ...pdateRequestorClusterDownloadErrorEvent.kt | 73 +- ...ateRequestorClusterStateTransitionEvent.kt | 52 +- ...dateRequestorClusterVersionAppliedEvent.kt | 20 +- ...nalStateClusterOperationCompletionEvent.kt | 99 +- ...tionalStateClusterOperationalErrorEvent.kt | 23 +- ...rSourceClusterBatChargeFaultChangeEvent.kt | 46 +- .../PowerSourceClusterBatFaultChangeEvent.kt | 43 +- ...PowerSourceClusterWiredFaultChangeEvent.kt | 43 +- .../RefrigeratorAlarmClusterNotifyEvent.kt | 21 +- ...nalStateClusterOperationCompletionEvent.kt | 99 +- ...tionalStateClusterOperationalErrorEvent.kt | 24 +- .../SampleMeiClusterPingCountEventEvent.kt | 14 +- .../SmokeCoAlarmClusterCOAlarmEvent.kt | 13 +- ...eCoAlarmClusterInterconnectCOAlarmEvent.kt | 13 +- ...AlarmClusterInterconnectSmokeAlarmEvent.kt | 13 +- .../SmokeCoAlarmClusterLowBatteryEvent.kt | 13 +- .../SmokeCoAlarmClusterSmokeAlarmEvent.kt | 13 +- ...areDiagnosticsClusterSoftwareFaultEvent.kt | 54 +- .../SwitchClusterInitialPressEvent.kt | 13 +- .../SwitchClusterLongPressEvent.kt | 13 +- .../SwitchClusterLongReleaseEvent.kt | 13 +- .../SwitchClusterMultiPressCompleteEvent.kt | 20 +- .../SwitchClusterMultiPressOngoingEvent.kt | 20 +- .../SwitchClusterShortReleaseEvent.kt | 13 +- .../SwitchClusterSwitchLatchedEvent.kt | 13 +- ...argetNavigatorClusterTargetUpdatedEvent.kt | 39 +- ...DiagnosticsClusterConnectionStatusEvent.kt | 16 +- ...agnosticsClusterNetworkFaultChangeEvent.kt | 49 +- ...imeSynchronizationClusterDSTStatusEvent.kt | 13 +- ...nchronizationClusterTimeZoneStatusEvent.kt | 32 +- .../UnitTestingClusterTestEventEvent.kt | 65 +- ...estingClusterTestFabricScopedEventEvent.kt | 13 +- ...urationAndControlClusterValveFaultEvent.kt | 16 +- ...AndControlClusterValveStateChangedEvent.kt | 38 +- ...agnosticsClusterAssociationFailureEvent.kt | 23 +- ...DiagnosticsClusterConnectionStatusEvent.kt | 16 +- ...orkDiagnosticsClusterDisconnectionEvent.kt | 16 +- ...sControlClusterAccessControlEntryStruct.kt | 108 +- ...trolClusterAccessControlExtensionStruct.kt | 17 +- ...ControlClusterAccessControlTargetStruct.kt | 82 +- .../structs/ActionsClusterActionStruct.kt | 34 +- .../ActionsClusterEndpointListStruct.kt | 35 +- ...nitoringClusterReplacementProductStruct.kt | 28 +- ...pplicationBasicClusterApplicationStruct.kt | 17 +- ...ationLauncherClusterApplicationEPStruct.kt | 41 +- ...icationLauncherClusterApplicationStruct.kt | 17 +- .../AudioOutputClusterOutputInfoStruct.kt | 15 +- ...nformationClusterCapabilityMinimaStruct.kt | 28 +- ...formationClusterProductAppearanceStruct.kt | 35 +- .../structs/BindingClusterTargetStruct.kt | 92 +- ...formationClusterProductAppearanceStruct.kt | 41 +- .../ChannelClusterAdditionalInfoStruct.kt | 14 +- .../ChannelClusterChannelInfoStruct.kt | 123 +- .../ChannelClusterChannelPagingStruct.kt | 95 +- .../structs/ChannelClusterLineupInfoStruct.kt | 56 +- .../structs/ChannelClusterPageTokenStruct.kt | 71 +- .../ChannelClusterProgramCastStruct.kt | 14 +- .../ChannelClusterProgramCategoryStruct.kt | 32 +- .../structs/ChannelClusterProgramStruct.kt | 434 +- .../structs/ChannelClusterSeriesInfoStruct.kt | 14 +- .../ContentControlClusterRatingNameStruct.kt | 35 +- ...tentLauncherClusterAdditionalInfoStruct.kt | 14 +- ...auncherClusterBrandingInformationStruct.kt | 148 +- ...ntentLauncherClusterContentSearchStruct.kt | 29 +- .../ContentLauncherClusterDimensionStruct.kt | 19 +- .../ContentLauncherClusterParameterStruct.kt | 56 +- ...auncherClusterPlaybackPreferencesStruct.kt | 71 +- ...ntLauncherClusterStyleInformationStruct.kt | 73 +- ...entLauncherClusterTrackPreferenceStruct.kt | 62 +- ...dControlClusterAverageLoadControlStruct.kt | 16 +- ...oadControlClusterDutyCycleControlStruct.kt | 16 +- ...ontrolClusterHeatingSourceControlStruct.kt | 16 +- ...oadControlClusterLoadControlEventStruct.kt | 122 +- ...ClusterLoadControlEventTransitionStruct.kt | 151 +- ...dControlClusterLoadControlProgramStruct.kt | 97 +- ...ControlClusterPowerSavingsControlStruct.kt | 16 +- ...dControlClusterTemperatureControlStruct.kt | 172 +- .../DescriptorClusterDeviceTypeStruct.kt | 14 +- .../DescriptorClusterSemanticTagStruct.kt | 78 +- ...nergyManagementClusterConstraintsStruct.kt | 83 +- ...DeviceEnergyManagementClusterCostStruct.kt | 39 +- ...ceEnergyManagementClusterForecastStruct.kt | 131 +- ...nergyManagementClusterPowerAdjustStruct.kt | 28 +- ...gyManagementClusterSlotAdjustmentStruct.kt | 22 +- ...DeviceEnergyManagementClusterSlotStruct.kt | 311 +- .../DishwasherModeClusterModeOptionStruct.kt | 33 +- .../DishwasherModeClusterModeTagStruct.kt | 32 +- .../DoorLockClusterCredentialStruct.kt | 14 +- ...asurementClusterEnergyMeasurementStruct.kt | 103 +- ...ntClusterMeasurementAccuracyRangeStruct.kt | 146 +- ...urementClusterMeasurementAccuracyStruct.kt | 53 +- ...EvseClusterChargingTargetScheduleStruct.kt | 31 +- .../EnergyEvseClusterChargingTargetStruct.kt | 63 +- .../EnergyPreferenceClusterBalanceStruct.kt | 32 +- .../structs/FixedLabelClusterLabelStruct.kt | 14 +- ...missioningClusterBasicCommissioningInfo.kt | 31 +- ...neralDiagnosticsClusterNetworkInterface.kt | 117 +- ...pKeyManagementClusterGroupInfoMapStruct.kt | 53 +- ...upKeyManagementClusterGroupKeyMapStruct.kt | 19 +- ...upKeyManagementClusterGroupKeySetStruct.kt | 169 +- ...nitoringClusterReplacementProductStruct.kt | 28 +- ...mentClusterMonitoringRegistrationStruct.kt | 28 +- ...aundryWasherModeClusterModeOptionStruct.kt | 33 +- .../LaundryWasherModeClusterModeTagStruct.kt | 32 +- .../MediaInputClusterInputInfoStruct.kt | 21 +- ...iaPlaybackClusterPlaybackPositionStruct.kt | 35 +- ...diaPlaybackClusterTrackAttributesStruct.kt | 53 +- .../MediaPlaybackClusterTrackStruct.kt | 41 +- ...icrowaveOvenModeClusterModeOptionStruct.kt | 33 +- .../MicrowaveOvenModeClusterModeTagStruct.kt | 32 +- .../ModeSelectClusterModeOptionStruct.kt | 33 +- .../ModeSelectClusterSemanticTagStruct.kt | 14 +- ...rkCommissioningClusterNetworkInfoStruct.kt | 99 +- ...gClusterThreadInterfaceScanResultStruct.kt | 43 +- ...ingClusterWiFiInterfaceScanResultStruct.kt | 37 +- ...redentialsClusterFabricDescriptorStruct.kt | 37 +- .../OperationalCredentialsClusterNOCStruct.kt | 40 +- ...OperationalStateClusterErrorStateStruct.kt | 60 +- ...ionalStateClusterOperationalStateStruct.kt | 40 +- ...eUpdateRequestorClusterProviderLocation.kt | 28 +- ...OperationalStateClusterErrorStateStruct.kt | 63 +- ...ionalStateClusterOperationalStateStruct.kt | 43 +- .../OvenModeClusterModeOptionStruct.kt | 33 +- .../structs/OvenModeClusterModeTagStruct.kt | 32 +- ...erSourceClusterBatChargeFaultChangeType.kt | 46 +- .../PowerSourceClusterBatFaultChangeType.kt | 43 +- .../PowerSourceClusterWiredFaultChangeType.kt | 43 +- ...olledCabinetModeClusterModeOptionStruct.kt | 47 +- ...ntrolledCabinetModeClusterModeTagStruct.kt | 38 +- .../RvcCleanModeClusterModeOptionStruct.kt | 33 +- .../RvcCleanModeClusterModeTagStruct.kt | 32 +- ...OperationalStateClusterErrorStateStruct.kt | 60 +- ...ionalStateClusterOperationalStateStruct.kt | 43 +- .../RvcRunModeClusterModeOptionStruct.kt | 33 +- .../structs/RvcRunModeClusterModeTagStruct.kt | 32 +- ...enesManagementClusterAttributeValuePair.kt | 14 +- ...cenesManagementClusterExtensionFieldSet.kt | 31 +- .../ScenesManagementClusterSceneInfoStruct.kt | 34 +- ...reDiagnosticsClusterThreadMetricsStruct.kt | 100 +- .../TargetNavigatorClusterTargetInfoStruct.kt | 14 +- .../structs/ThermostatClusterPresetStruct.kt | 146 +- .../ThermostatClusterPresetTypeStruct.kt | 19 +- .../ThermostatClusterQueuedPresetStruct.kt | 59 +- .../ThermostatClusterScheduleStruct.kt | 139 +- ...ermostatClusterScheduleTransitionStruct.kt | 103 +- .../ThermostatClusterScheduleTypeStruct.kt | 25 +- ...atClusterWeeklyScheduleTransitionStruct.kt | 70 +- ...rkDiagnosticsClusterNeighborTableStruct.kt | 103 +- ...ticsClusterOperationalDatasetComponents.kt | 70 +- ...tworkDiagnosticsClusterRouteTableStruct.kt | 49 +- ...NetworkDiagnosticsClusterSecurityPolicy.kt | 14 +- ...meSynchronizationClusterDSTOffsetStruct.kt | 40 +- ...sterFabricScopedTrustedTimeSourceStruct.kt | 20 +- ...imeSynchronizationClusterTimeZoneStruct.kt | 37 +- ...onizationClusterTrustedTimeSourceStruct.kt | 22 +- ...nitTestingClusterDoubleNestedStructList.kt | 27 +- .../structs/UnitTestingClusterNestedStruct.kt | 19 +- .../UnitTestingClusterNestedStructList.kt | 86 +- ...stingClusterNullablesAndOptionalsStruct.kt | 412 +- .../structs/UnitTestingClusterSimpleStruct.kt | 29 +- .../UnitTestingClusterTestFabricScoped.kt | 147 +- .../UnitTestingClusterTestListStructOctet.kt | 14 +- .../structs/UserLabelClusterLabelStruct.kt | 14 +- .../cluster/clusters/AccessControlCluster.kt | 1251 +- .../cluster/clusters/AccountLoginCluster.kt | 734 +- .../cluster/clusters/ActionsCluster.kt | 1185 +- .../ActivatedCarbonFilterMonitoringCluster.kt | 1404 +- .../AdministratorCommissioningCluster.kt | 1039 +- .../cluster/clusters/AirQualityCluster.kt | 757 +- .../clusters/ApplicationBasicCluster.kt | 1466 +- .../clusters/ApplicationLauncherCluster.kt | 1130 +- .../cluster/clusters/AudioOutputCluster.kt | 890 +- .../clusters/BallastConfigurationCluster.kt | 2474 ++- .../cluster/clusters/BarrierControlCluster.kt | 1802 +- .../clusters/BasicInformationCluster.kt | 2742 ++- .../clusters/BinaryInputBasicCluster.kt | 1720 +- .../cluster/clusters/BindingCluster.kt | 829 +- .../cluster/clusters/BooleanStateCluster.kt | 762 +- .../BooleanStateConfigurationCluster.kt | 1579 +- .../BridgedDeviceBasicInformationCluster.kt | 2394 ++- ...nDioxideConcentrationMeasurementCluster.kt | 2048 ++- ...MonoxideConcentrationMeasurementCluster.kt | 2048 ++- .../cluster/clusters/ChannelCluster.kt | 1304 +- .../cluster/clusters/ColorControlCluster.kt | 6889 ++++---- .../clusters/ContentAppObserverCluster.kt | 763 +- .../cluster/clusters/ContentControlCluster.kt | 1648 +- .../clusters/ContentLauncherCluster.kt | 1055 +- .../DemandResponseLoadControlCluster.kt | 1548 +- .../cluster/clusters/DescriptorCluster.kt | 1314 +- .../clusters/DeviceEnergyManagementCluster.kt | 1569 +- .../cluster/clusters/DiagnosticLogsCluster.kt | 744 +- .../clusters/DishwasherAlarmCluster.kt | 1036 +- .../cluster/clusters/DishwasherModeCluster.kt | 1271 +- .../cluster/clusters/DoorLockCluster.kt | 6839 ++++---- .../ElectricalEnergyMeasurementCluster.kt | 1372 +- .../clusters/ElectricalMeasurementCluster.kt | 13927 ++++++++-------- .../cluster/clusters/EnergyEvseCluster.kt | 3497 ++-- .../clusters/EnergyPreferenceCluster.kt | 1379 +- .../EthernetNetworkDiagnosticsCluster.kt | 1760 +- .../cluster/clusters/FanControlCluster.kt | 2111 ++- .../cluster/clusters/FaultInjectionCluster.kt | 709 +- .../cluster/clusters/FixedLabelCluster.kt | 802 +- .../clusters/FlowMeasurementCluster.kt | 1171 +- ...aldehydeConcentrationMeasurementCluster.kt | 2048 ++- .../clusters/GeneralCommissioningCluster.kt | 1253 +- .../clusters/GeneralDiagnosticsCluster.kt | 1780 +- .../clusters/GroupKeyManagementCluster.kt | 1199 +- .../cluster/clusters/GroupsCluster.kt | 986 +- .../clusters/HepaFilterMonitoringCluster.kt | 1404 +- .../cluster/clusters/IcdManagementCluster.kt | 1679 +- .../cluster/clusters/IdentifyCluster.kt | 873 +- .../clusters/IlluminanceMeasurementCluster.kt | 1314 +- .../cluster/clusters/KeypadInputCluster.kt | 705 +- .../clusters/LaundryDryerControlsCluster.kt | 952 +- .../clusters/LaundryWasherControlsCluster.kt | 1270 +- .../clusters/LaundryWasherModeCluster.kt | 1271 +- .../cluster/clusters/LevelControlCluster.kt | 2542 ++- .../LocalizationConfigurationCluster.kt | 906 +- .../cluster/clusters/LowPowerCluster.kt | 681 +- .../cluster/clusters/MediaInputCluster.kt | 894 +- .../cluster/clusters/MediaPlaybackCluster.kt | 2644 ++- .../clusters/MicrowaveOvenControlCluster.kt | 1664 +- .../clusters/MicrowaveOvenModeCluster.kt | 883 +- .../cluster/clusters/ModeSelectCluster.kt | 1426 +- .../clusters/NetworkCommissioningCluster.kt | 2582 ++- ...nDioxideConcentrationMeasurementCluster.kt | 2048 ++- .../clusters/OccupancySensingCluster.kt | 2111 ++- .../cluster/clusters/OnOffCluster.kt | 1330 +- .../OnOffSwitchConfigurationCluster.kt | 861 +- .../clusters/OperationalCredentialsCluster.kt | 1709 +- .../clusters/OperationalStateCluster.kt | 1486 +- .../OtaSoftwareUpdateProviderCluster.kt | 918 +- .../OtaSoftwareUpdateRequestorCluster.kt | 1133 +- .../OvenCavityOperationalStateCluster.kt | 1493 +- .../cluster/clusters/OvenModeCluster.kt | 1266 +- .../OzoneConcentrationMeasurementCluster.kt | 2045 ++- .../Pm10ConcentrationMeasurementCluster.kt | 2045 ++- .../Pm1ConcentrationMeasurementCluster.kt | 2045 ++- .../Pm25ConcentrationMeasurementCluster.kt | 2045 ++- .../cluster/clusters/PowerSourceCluster.kt | 4271 +++-- .../PowerSourceConfigurationCluster.kt | 804 +- .../clusters/PressureMeasurementCluster.kt | 1817 +- .../clusters/ProxyConfigurationCluster.kt | 682 +- .../cluster/clusters/ProxyDiscoveryCluster.kt | 682 +- .../cluster/clusters/ProxyValidCluster.kt | 679 +- .../clusters/PulseWidthModulationCluster.kt | 682 +- .../PumpConfigurationAndControlCluster.kt | 3619 ++-- .../RadonConcentrationMeasurementCluster.kt | 2045 ++- .../clusters/RefrigeratorAlarmCluster.kt | 919 +- ...TemperatureControlledCabinetModeCluster.kt | 1280 +- .../RelativeHumidityMeasurementCluster.kt | 1171 +- .../cluster/clusters/RvcCleanModeCluster.kt | 1102 +- .../clusters/RvcOperationalStateCluster.kt | 1509 +- .../cluster/clusters/RvcRunModeCluster.kt | 1097 +- .../cluster/clusters/SampleMeiCluster.kt | 815 +- .../clusters/ScenesManagementCluster.kt | 2219 ++- .../cluster/clusters/SmokeCoAlarmCluster.kt | 1965 ++- .../clusters/SoftwareDiagnosticsCluster.kt | 1155 +- .../cluster/clusters/SwitchCluster.kt | 944 +- .../clusters/TargetNavigatorCluster.kt | 969 +- .../clusters/TemperatureControlCluster.kt | 1376 +- .../clusters/TemperatureMeasurementCluster.kt | 1171 +- .../cluster/clusters/ThermostatCluster.kt | 8671 +++++----- ...mostatUserInterfaceConfigurationCluster.kt | 1022 +- .../ThreadNetworkDiagnosticsCluster.kt | 7529 ++++----- .../clusters/TimeFormatLocalizationCluster.kt | 1062 +- .../clusters/TimeSynchronizationCluster.kt | 2338 ++- .../cluster/clusters/TimerCluster.kt | 931 +- ...ompoundsConcentrationMeasurementCluster.kt | 2050 ++- .../clusters/UnitLocalizationCluster.kt | 811 +- .../cluster/clusters/UnitTestingCluster.kt | 12272 +++++++------- .../cluster/clusters/UserLabelCluster.kt | 829 +- .../ValveConfigurationAndControlCluster.kt | 2131 ++- .../cluster/clusters/WakeOnLanCluster.kt | 897 +- .../clusters/WiFiNetworkDiagnosticsCluster.kt | 2463 ++- .../cluster/clusters/WindowCoveringCluster.kt | 3124 ++-- ...olClusterAccessControlEntryChangedEvent.kt | 59 +- ...usterAccessControlExtensionChangedEvent.kt | 60 +- .../AccountLoginClusterLoggedOutEvent.kt | 20 +- .../ActionsClusterActionFailedEvent.kt | 6 +- .../ActionsClusterStateChangedEvent.kt | 6 +- .../BasicInformationClusterLeaveEvent.kt | 10 +- ...InformationClusterReachableChangedEvent.kt | 10 +- .../BasicInformationClusterStartUpEvent.kt | 10 +- .../BooleanStateClusterStateChangeEvent.kt | 10 +- ...igurationClusterAlarmsStateChangedEvent.kt | 19 +- ...ateConfigurationClusterSensorFaultEvent.kt | 13 +- ...InformationClusterReachableChangedEvent.kt | 13 +- ...viceBasicInformationClusterStartUpEvent.kt | 13 +- ...lusterLoadControlEventStatusChangeEvent.kt | 214 +- ...rgyManagementClusterPowerAdjustEndEvent.kt | 9 +- ...viceEnergyManagementClusterResumedEvent.kt | 10 +- .../DishwasherAlarmClusterNotifyEvent.kt | 6 +- .../DoorLockClusterDoorLockAlarmEvent.kt | 10 +- .../DoorLockClusterDoorStateChangeEvent.kt | 10 +- .../DoorLockClusterLockOperationErrorEvent.kt | 108 +- .../DoorLockClusterLockOperationEvent.kt | 107 +- .../DoorLockClusterLockUserChangeEvent.kt | 68 +- ...entClusterCumulativeEnergyMeasuredEvent.kt | 53 +- ...ementClusterPeriodicEnergyMeasuredEvent.kt | 53 +- .../EnergyEvseClusterEVConnectedEvent.kt | 10 +- .../EnergyEvseClusterEVNotDetectedEvent.kt | 24 +- ...gyEvseClusterEnergyTransferStartedEvent.kt | 6 +- ...gyEvseClusterEnergyTransferStoppedEvent.kt | 13 +- .../EnergyEvseClusterFaultEvent.kt | 32 +- .../EnergyEvseClusterRFIDEvent.kt | 10 +- ...eneralDiagnosticsClusterBootReasonEvent.kt | 10 +- ...gnosticsClusterHardwareFaultChangeEvent.kt | 34 +- ...agnosticsClusterNetworkFaultChangeEvent.kt | 34 +- ...DiagnosticsClusterRadioFaultChangeEvent.kt | 31 +- .../MediaPlaybackClusterStateChangedEvent.kt | 34 +- ...nalStateClusterOperationCompletionEvent.kt | 68 +- ...tionalStateClusterOperationalErrorEvent.kt | 12 +- ...pdateRequestorClusterDownloadErrorEvent.kt | 42 +- ...ateRequestorClusterStateTransitionEvent.kt | 29 +- ...dateRequestorClusterVersionAppliedEvent.kt | 9 +- ...nalStateClusterOperationCompletionEvent.kt | 68 +- ...tionalStateClusterOperationalErrorEvent.kt | 18 +- ...rSourceClusterBatChargeFaultChangeEvent.kt | 31 +- .../PowerSourceClusterBatFaultChangeEvent.kt | 36 +- ...PowerSourceClusterWiredFaultChangeEvent.kt | 36 +- .../RefrigeratorAlarmClusterNotifyEvent.kt | 6 +- ...nalStateClusterOperationCompletionEvent.kt | 68 +- ...tionalStateClusterOperationalErrorEvent.kt | 15 +- .../SampleMeiClusterPingCountEventEvent.kt | 11 +- .../SmokeCoAlarmClusterCOAlarmEvent.kt | 10 +- ...eCoAlarmClusterInterconnectCOAlarmEvent.kt | 10 +- ...AlarmClusterInterconnectSmokeAlarmEvent.kt | 10 +- .../SmokeCoAlarmClusterLowBatteryEvent.kt | 10 +- .../SmokeCoAlarmClusterSmokeAlarmEvent.kt | 10 +- ...areDiagnosticsClusterSoftwareFaultEvent.kt | 27 +- .../SwitchClusterInitialPressEvent.kt | 10 +- .../SwitchClusterLongPressEvent.kt | 10 +- .../SwitchClusterLongReleaseEvent.kt | 10 +- .../SwitchClusterMultiPressCompleteEvent.kt | 9 +- .../SwitchClusterMultiPressOngoingEvent.kt | 9 +- .../SwitchClusterShortReleaseEvent.kt | 10 +- .../SwitchClusterSwitchLatchedEvent.kt | 10 +- ...argetNavigatorClusterTargetUpdatedEvent.kt | 23 +- ...DiagnosticsClusterConnectionStatusEvent.kt | 13 +- ...agnosticsClusterNetworkFaultChangeEvent.kt | 34 +- ...imeSynchronizationClusterDSTStatusEvent.kt | 10 +- ...nchronizationClusterTimeZoneStatusEvent.kt | 21 +- .../UnitTestingClusterTestEventEvent.kt | 42 +- ...estingClusterTestFabricScopedEventEvent.kt | 10 +- ...urationAndControlClusterValveFaultEvent.kt | 13 +- ...AndControlClusterValveStateChangedEvent.kt | 19 +- ...agnosticsClusterAssociationFailureEvent.kt | 12 +- ...DiagnosticsClusterConnectionStatusEvent.kt | 13 +- ...orkDiagnosticsClusterDisconnectionEvent.kt | 13 +- ...sControlClusterAccessControlEntryStruct.kt | 77 +- ...trolClusterAccessControlExtensionStruct.kt | 9 +- ...ControlClusterAccessControlTargetStruct.kt | 43 +- .../structs/ActionsClusterActionStruct.kt | 13 +- .../ActionsClusterEndpointListStruct.kt | 18 +- ...nitoringClusterReplacementProductStruct.kt | 20 +- ...pplicationBasicClusterApplicationStruct.kt | 4 +- ...ationLauncherClusterApplicationEPStruct.kt | 20 +- ...icationLauncherClusterApplicationStruct.kt | 4 +- .../AudioOutputClusterOutputInfoStruct.kt | 4 +- ...nformationClusterCapabilityMinimaStruct.kt | 15 +- ...formationClusterProductAppearanceStruct.kt | 22 +- .../structs/BindingClusterTargetStruct.kt | 47 +- ...formationClusterProductAppearanceStruct.kt | 22 +- .../ChannelClusterAdditionalInfoStruct.kt | 9 +- .../ChannelClusterChannelInfoStruct.kt | 68 +- .../ChannelClusterChannelPagingStruct.kt | 64 +- .../structs/ChannelClusterLineupInfoStruct.kt | 25 +- .../structs/ChannelClusterPageTokenStruct.kt | 36 +- .../ChannelClusterProgramCastStruct.kt | 9 +- .../ChannelClusterProgramCategoryStruct.kt | 19 +- .../structs/ChannelClusterProgramStruct.kt | 309 +- .../structs/ChannelClusterSeriesInfoStruct.kt | 9 +- .../ContentControlClusterRatingNameStruct.kt | 14 +- ...tentLauncherClusterAdditionalInfoStruct.kt | 9 +- ...auncherClusterBrandingInformationStruct.kt | 97 +- ...ntentLauncherClusterContentSearchStruct.kt | 18 +- .../ContentLauncherClusterDimensionStruct.kt | 4 +- .../ContentLauncherClusterParameterStruct.kt | 35 +- ...auncherClusterPlaybackPreferencesStruct.kt | 52 +- ...ntLauncherClusterStyleInformationStruct.kt | 38 +- ...entLauncherClusterTrackPreferenceStruct.kt | 41 +- ...dControlClusterAverageLoadControlStruct.kt | 13 +- ...oadControlClusterDutyCycleControlStruct.kt | 13 +- ...ontrolClusterHeatingSourceControlStruct.kt | 13 +- ...oadControlClusterLoadControlEventStruct.kt | 75 +- ...ClusterLoadControlEventTransitionStruct.kt | 98 +- ...dControlClusterLoadControlProgramStruct.kt | 56 +- ...ControlClusterPowerSavingsControlStruct.kt | 13 +- ...dControlClusterTemperatureControlStruct.kt | 123 +- .../DescriptorClusterDeviceTypeStruct.kt | 9 +- .../DescriptorClusterSemanticTagStruct.kt | 43 +- ...nergyManagementClusterConstraintsStruct.kt | 44 +- ...DeviceEnergyManagementClusterCostStruct.kt | 14 +- ...ceEnergyManagementClusterForecastStruct.kt | 80 +- ...nergyManagementClusterPowerAdjustStruct.kt | 11 +- ...gyManagementClusterSlotAdjustmentStruct.kt | 9 +- ...DeviceEnergyManagementClusterSlotStruct.kt | 188 +- .../DishwasherModeClusterModeOptionStruct.kt | 18 +- .../DishwasherModeClusterModeTagStruct.kt | 19 +- .../DoorLockClusterCredentialStruct.kt | 9 +- ...asurementClusterEnergyMeasurementStruct.kt | 60 +- ...ntClusterMeasurementAccuracyRangeStruct.kt | 85 +- ...urementClusterMeasurementAccuracyStruct.kt | 36 +- ...EvseClusterChargingTargetScheduleStruct.kt | 21 +- .../EnergyEvseClusterChargingTargetStruct.kt | 34 +- .../EnergyPreferenceClusterBalanceStruct.kt | 19 +- .../structs/FixedLabelClusterLabelStruct.kt | 9 +- ...missioningClusterBasicCommissioningInfo.kt | 20 +- ...neralDiagnosticsClusterNetworkInterface.kt | 80 +- ...pKeyManagementClusterGroupInfoMapStruct.kt | 28 +- ...upKeyManagementClusterGroupKeyMapStruct.kt | 4 +- ...upKeyManagementClusterGroupKeySetStruct.kt | 96 +- ...nitoringClusterReplacementProductStruct.kt | 20 +- ...mentClusterMonitoringRegistrationStruct.kt | 15 +- ...aundryWasherModeClusterModeOptionStruct.kt | 18 +- .../LaundryWasherModeClusterModeTagStruct.kt | 19 +- .../MediaInputClusterInputInfoStruct.kt | 4 +- ...iaPlaybackClusterPlaybackPositionStruct.kt | 22 +- ...diaPlaybackClusterTrackAttributesStruct.kt | 30 +- .../MediaPlaybackClusterTrackStruct.kt | 20 +- ...icrowaveOvenModeClusterModeOptionStruct.kt | 18 +- .../MicrowaveOvenModeClusterModeTagStruct.kt | 19 +- .../ModeSelectClusterModeOptionStruct.kt | 18 +- .../ModeSelectClusterSemanticTagStruct.kt | 9 +- ...rkCommissioningClusterNetworkInfoStruct.kt | 64 +- ...gClusterThreadInterfaceScanResultStruct.kt | 20 +- ...ingClusterWiFiInterfaceScanResultStruct.kt | 18 +- ...redentialsClusterFabricDescriptorStruct.kt | 18 +- .../OperationalCredentialsClusterNOCStruct.kt | 17 +- ...OperationalStateClusterErrorStateStruct.kt | 31 +- ...ionalStateClusterOperationalStateStruct.kt | 19 +- ...eUpdateRequestorClusterProviderLocation.kt | 15 +- ...OperationalStateClusterErrorStateStruct.kt | 36 +- ...ionalStateClusterOperationalStateStruct.kt | 24 +- .../OvenModeClusterModeOptionStruct.kt | 18 +- .../structs/OvenModeClusterModeTagStruct.kt | 19 +- ...erSourceClusterBatChargeFaultChangeType.kt | 33 +- .../PowerSourceClusterBatFaultChangeType.kt | 38 +- .../PowerSourceClusterWiredFaultChangeType.kt | 38 +- ...olledCabinetModeClusterModeOptionStruct.kt | 34 +- ...ntrolledCabinetModeClusterModeTagStruct.kt | 19 +- .../RvcCleanModeClusterModeOptionStruct.kt | 18 +- .../RvcCleanModeClusterModeTagStruct.kt | 19 +- ...OperationalStateClusterErrorStateStruct.kt | 31 +- ...ionalStateClusterOperationalStateStruct.kt | 24 +- .../RvcRunModeClusterModeOptionStruct.kt | 18 +- .../structs/RvcRunModeClusterModeTagStruct.kt | 19 +- ...enesManagementClusterAttributeValuePair.kt | 9 +- ...cenesManagementClusterExtensionFieldSet.kt | 18 +- .../ScenesManagementClusterSceneInfoStruct.kt | 13 +- ...reDiagnosticsClusterThreadMetricsStruct.kt | 55 +- .../TargetNavigatorClusterTargetInfoStruct.kt | 9 +- .../structs/ThermostatClusterPresetStruct.kt | 87 +- .../ThermostatClusterPresetTypeStruct.kt | 4 +- .../ThermostatClusterQueuedPresetStruct.kt | 30 +- .../ThermostatClusterScheduleStruct.kt | 88 +- ...ermostatClusterScheduleTransitionStruct.kt | 56 +- .../ThermostatClusterScheduleTypeStruct.kt | 10 +- ...atClusterWeeklyScheduleTransitionStruct.kt | 41 +- ...rkDiagnosticsClusterNeighborTableStruct.kt | 52 +- ...ticsClusterOperationalDatasetComponents.kt | 39 +- ...tworkDiagnosticsClusterRouteTableStruct.kt | 22 +- ...NetworkDiagnosticsClusterSecurityPolicy.kt | 9 +- ...meSynchronizationClusterDSTOffsetStruct.kt | 17 +- ...sterFabricScopedTrustedTimeSourceStruct.kt | 9 +- ...imeSynchronizationClusterTimeZoneStruct.kt | 14 +- ...onizationClusterTrustedTimeSourceStruct.kt | 9 +- ...nitTestingClusterDoubleNestedStructList.kt | 22 +- .../structs/UnitTestingClusterNestedStruct.kt | 4 +- .../UnitTestingClusterNestedStructList.kt | 63 +- ...stingClusterNullablesAndOptionalsStruct.kt | 295 +- .../structs/UnitTestingClusterSimpleStruct.kt | 4 +- .../UnitTestingClusterTestFabricScoped.kt | 100 +- .../UnitTestingClusterTestListStructOctet.kt | 9 +- .../structs/UserLabelClusterLabelStruct.kt | 9 +- .../zap-generated/test/Commands.h | 114 - 514 files changed, 109663 insertions(+), 120782 deletions(-) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt index 75edd8da4997e5..a206757d729531 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccessControlClusterAccessControlEntryChangedEvent ( - val adminNodeID: ULong?, - val adminPasscodeID: UInt?, - val changeType: UInt, - val latestValue: chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct?, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class AccessControlClusterAccessControlEntryChangedEvent( + val adminNodeID: ULong?, + val adminPasscodeID: UInt?, + val changeType: UInt, + val latestValue: + chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct?, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlEntryChangedEvent {\n") append("\tadminNodeID : $adminNodeID\n") append("\tadminPasscodeID : $adminPasscodeID\n") @@ -46,21 +44,21 @@ class AccessControlClusterAccessControlEntryChangedEvent ( tlvWriter.apply { startStructure(tlvTag) if (adminNodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } if (adminPasscodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } put(ContextSpecificTag(TAG_CHANGE_TYPE), changeType) if (latestValue != null) { - latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) - } else { - putNull(ContextSpecificTag(TAG_LATEST_VALUE)) - } + latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) + } else { + putNull(ContextSpecificTag(TAG_LATEST_VALUE)) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -73,32 +71,45 @@ class AccessControlClusterAccessControlEntryChangedEvent ( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlEntryChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlEntryChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUInt(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = if (!tlvReader.isNull()) { - chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = + if (!tlvReader.isNull()) { + chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlEntryStruct + .fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) + return AccessControlClusterAccessControlEntryChangedEvent( + adminNodeID, + adminPasscodeID, + changeType, + latestValue, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt index 31aad754e04833..8377cc96d5f545 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccessControlClusterAccessControlExtensionChangedEvent ( - val adminNodeID: ULong?, - val adminPasscodeID: UInt?, - val changeType: UInt, - val latestValue: chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class AccessControlClusterAccessControlExtensionChangedEvent( + val adminNodeID: ULong?, + val adminPasscodeID: UInt?, + val changeType: UInt, + val latestValue: + chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlExtensionChangedEvent {\n") append("\tadminNodeID : $adminNodeID\n") append("\tadminPasscodeID : $adminPasscodeID\n") @@ -46,21 +44,21 @@ class AccessControlClusterAccessControlExtensionChangedEvent ( tlvWriter.apply { startStructure(tlvTag) if (adminNodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_NODE_I_D), adminNodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } if (adminPasscodeID != null) { - put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) - } else { - putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } + put(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D), adminPasscodeID) + } else { + putNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } put(ContextSpecificTag(TAG_CHANGE_TYPE), changeType) if (latestValue != null) { - latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) - } else { - putNull(ContextSpecificTag(TAG_LATEST_VALUE)) - } + latestValue.toTlv(ContextSpecificTag(TAG_LATEST_VALUE), this) + } else { + putNull(ContextSpecificTag(TAG_LATEST_VALUE)) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -73,32 +71,45 @@ class AccessControlClusterAccessControlExtensionChangedEvent ( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlExtensionChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlExtensionChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUInt(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = if (!tlvReader.isNull()) { - chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = + if (!tlvReader.isNull()) { + chip.devicecontroller.cluster.structs.AccessControlClusterAccessControlExtensionStruct + .fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlExtensionChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) + return AccessControlClusterAccessControlExtensionChangedEvent( + adminNodeID, + adminPasscodeID, + changeType, + latestValue, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt index b608b8499d5445..5c1bf98d9c4f79 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt @@ -17,18 +17,14 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccountLoginClusterLoggedOutEvent ( - val node: Optional) { - override fun toString(): String = buildString { +class AccountLoginClusterLoggedOutEvent(val node: Optional) { + override fun toString(): String = buildString { append("AccountLoginClusterLoggedOutEvent {\n") append("\tnode : $node\n") append("}\n") @@ -38,9 +34,9 @@ class AccountLoginClusterLoggedOutEvent ( tlvWriter.apply { startStructure(tlvTag) if (node.isPresent) { - val optnode = node.get() - put(ContextSpecificTag(TAG_NODE), optnode) - } + val optnode = node.get() + put(ContextSpecificTag(TAG_NODE), optnode) + } endStructure() } } @@ -48,14 +44,15 @@ class AccountLoginClusterLoggedOutEvent ( companion object { private const val TAG_NODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccountLoginClusterLoggedOutEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccountLoginClusterLoggedOutEvent { tlvReader.enterStructure(tlvTag) - val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - + val node = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return AccountLoginClusterLoggedOutEvent(node) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt index 59405162837cd8..ea2f1931564f35 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ActionsClusterActionFailedEvent ( - val actionID: UInt, - val invokeID: ULong, - val newState: UInt, - val error: UInt) { - override fun toString(): String = buildString { +class ActionsClusterActionFailedEvent( + val actionID: UInt, + val invokeID: ULong, + val newState: UInt, + val error: UInt +) { + override fun toString(): String = buildString { append("ActionsClusterActionFailedEvent {\n") append("\tactionID : $actionID\n") append("\tinvokeID : $invokeID\n") @@ -57,13 +54,13 @@ class ActionsClusterActionFailedEvent ( private const val TAG_NEW_STATE = 2 private const val TAG_ERROR = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterActionFailedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterActionFailedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUInt(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getULong(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) val error = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR)) - + tlvReader.exitContainer() return ActionsClusterActionFailedEvent(actionID, invokeID, newState, error) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt index 868fbace2ac50e..d95c5e9d66480b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt @@ -17,20 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ActionsClusterStateChangedEvent ( - val actionID: UInt, - val invokeID: ULong, - val newState: UInt) { - override fun toString(): String = buildString { +class ActionsClusterStateChangedEvent(val actionID: UInt, val invokeID: ULong, val newState: UInt) { + override fun toString(): String = buildString { append("ActionsClusterStateChangedEvent {\n") append("\tactionID : $actionID\n") append("\tinvokeID : $invokeID\n") @@ -53,12 +46,12 @@ class ActionsClusterStateChangedEvent ( private const val TAG_INVOKE_I_D = 1 private const val TAG_NEW_STATE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUInt(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getULong(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) - + tlvReader.exitContainer() return ActionsClusterStateChangedEvent(actionID, invokeID, newState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt index 8ca5a2a0195e9c..6d2c068c849afb 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BasicInformationClusterLeaveEvent ( - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class BasicInformationClusterLeaveEvent(val fabricIndex: UInt) { + override fun toString(): String = buildString { append("BasicInformationClusterLeaveEvent {\n") append("\tfabricIndex : $fabricIndex\n") append("}\n") @@ -45,10 +40,10 @@ class BasicInformationClusterLeaveEvent ( companion object { private const val TAG_FABRIC_INDEX = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterLeaveEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterLeaveEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BasicInformationClusterLeaveEvent(fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt index 4a6bf00b468e48..4e6cb20e13c5e0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BasicInformationClusterReachableChangedEvent ( - val reachableNewValue: Boolean) { - override fun toString(): String = buildString { +class BasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { + override fun toString(): String = buildString { append("BasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") append("}\n") @@ -45,10 +40,10 @@ class BasicInformationClusterReachableChangedEvent ( companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterReachableChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt index b87f7ebee81d72..5ba3a8d3591e9a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BasicInformationClusterStartUpEvent ( - val softwareVersion: ULong) { - override fun toString(): String = buildString { +class BasicInformationClusterStartUpEvent(val softwareVersion: ULong) { + override fun toString(): String = buildString { append("BasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("}\n") @@ -45,10 +40,10 @@ class BasicInformationClusterStartUpEvent ( companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterStartUpEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt index 632226d00db082..f133fd21988180 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BooleanStateClusterStateChangeEvent ( - val stateValue: Boolean) { - override fun toString(): String = buildString { +class BooleanStateClusterStateChangeEvent(val stateValue: Boolean) { + override fun toString(): String = buildString { append("BooleanStateClusterStateChangeEvent {\n") append("\tstateValue : $stateValue\n") append("}\n") @@ -45,10 +40,10 @@ class BooleanStateClusterStateChangeEvent ( companion object { private const val TAG_STATE_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateClusterStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BooleanStateClusterStateChangeEvent { tlvReader.enterStructure(tlvTag) val stateValue = tlvReader.getBoolean(ContextSpecificTag(TAG_STATE_VALUE)) - + tlvReader.exitContainer() return BooleanStateClusterStateChangeEvent(stateValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt index 81fa108828d662..4c7e0fd2bb6110 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BooleanStateConfigurationClusterAlarmsStateChangedEvent ( - val alarmsActive: UInt, - val alarmsSuppressed: Optional) { - override fun toString(): String = buildString { +class BooleanStateConfigurationClusterAlarmsStateChangedEvent( + val alarmsActive: UInt, + val alarmsSuppressed: Optional +) { + override fun toString(): String = buildString { append("BooleanStateConfigurationClusterAlarmsStateChangedEvent {\n") append("\talarmsActive : $alarmsActive\n") append("\talarmsSuppressed : $alarmsSuppressed\n") @@ -41,9 +39,9 @@ class BooleanStateConfigurationClusterAlarmsStateChangedEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ALARMS_ACTIVE), alarmsActive) if (alarmsSuppressed.isPresent) { - val optalarmsSuppressed = alarmsSuppressed.get() - put(ContextSpecificTag(TAG_ALARMS_SUPPRESSED), optalarmsSuppressed) - } + val optalarmsSuppressed = alarmsSuppressed.get() + put(ContextSpecificTag(TAG_ALARMS_SUPPRESSED), optalarmsSuppressed) + } endStructure() } } @@ -52,15 +50,19 @@ class BooleanStateConfigurationClusterAlarmsStateChangedEvent ( private const val TAG_ALARMS_ACTIVE = 0 private const val TAG_ALARMS_SUPPRESSED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterAlarmsStateChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BooleanStateConfigurationClusterAlarmsStateChangedEvent { tlvReader.enterStructure(tlvTag) val alarmsActive = tlvReader.getUInt(ContextSpecificTag(TAG_ALARMS_ACTIVE)) - val alarmsSuppressed = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) - } else { - Optional.empty() - } - + val alarmsSuppressed = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return BooleanStateConfigurationClusterAlarmsStateChangedEvent(alarmsActive, alarmsSuppressed) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt index 8349bb8fd86151..6232f56300e520 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BooleanStateConfigurationClusterSensorFaultEvent ( - val sensorFault: UInt) { - override fun toString(): String = buildString { +class BooleanStateConfigurationClusterSensorFaultEvent(val sensorFault: UInt) { + override fun toString(): String = buildString { append("BooleanStateConfigurationClusterSensorFaultEvent {\n") append("\tsensorFault : $sensorFault\n") append("}\n") @@ -45,10 +40,13 @@ class BooleanStateConfigurationClusterSensorFaultEvent ( companion object { private const val TAG_SENSOR_FAULT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterSensorFaultEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BooleanStateConfigurationClusterSensorFaultEvent { tlvReader.enterStructure(tlvTag) val sensorFault = tlvReader.getUInt(ContextSpecificTag(TAG_SENSOR_FAULT)) - + tlvReader.exitContainer() return BooleanStateConfigurationClusterSensorFaultEvent(sensorFault) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt index b5bbae742887b3..4a66dd930bf954 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BridgedDeviceBasicInformationClusterReachableChangedEvent ( - val reachableNewValue: Boolean) { - override fun toString(): String = buildString { +class BridgedDeviceBasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { + override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") append("}\n") @@ -45,10 +40,13 @@ class BridgedDeviceBasicInformationClusterReachableChangedEvent ( companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterReachableChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt index ac2c49d2929233..33e897ec0dcc9c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BridgedDeviceBasicInformationClusterStartUpEvent ( - val softwareVersion: ULong) { - override fun toString(): String = buildString { +class BridgedDeviceBasicInformationClusterStartUpEvent(val softwareVersion: ULong) { + override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("}\n") @@ -45,10 +40,13 @@ class BridgedDeviceBasicInformationClusterStartUpEvent ( companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterStartUpEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt index 788512180453b2..a4ab48a89bc770 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt @@ -17,27 +17,40 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent ( - val eventID: ByteArray, - val transitionIndex: UInt?, - val status: UInt, - val criticality: UInt, - val control: UInt, - val temperatureControl: Optional?, - val averageLoadControl: Optional?, - val dutyCycleControl: Optional?, - val powerSavingsControl: Optional?, - val heatingSourceControl: Optional?) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( + val eventID: ByteArray, + val transitionIndex: UInt?, + val status: UInt, + val criticality: UInt, + val control: UInt, + val temperatureControl: + Optional< + chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct + >?, + val averageLoadControl: + Optional< + chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct + >?, + val dutyCycleControl: + Optional< + chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct + >?, + val powerSavingsControl: + Optional< + chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct + >?, + val heatingSourceControl: + Optional< + chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct + >? +) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent {\n") append("\teventID : $eventID\n") append("\ttransitionIndex : $transitionIndex\n") @@ -57,53 +70,53 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_EVENT_I_D), eventID) if (transitionIndex != null) { - put(ContextSpecificTag(TAG_TRANSITION_INDEX), transitionIndex) - } else { - putNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) - } + put(ContextSpecificTag(TAG_TRANSITION_INDEX), transitionIndex) + } else { + putNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) + } put(ContextSpecificTag(TAG_STATUS), status) put(ContextSpecificTag(TAG_CRITICALITY), criticality) put(ContextSpecificTag(TAG_CONTROL), control) if (temperatureControl != null) { - if (temperatureControl.isPresent) { - val opttemperatureControl = temperatureControl.get() - opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) - } + if (temperatureControl.isPresent) { + val opttemperatureControl = temperatureControl.get() + opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) + } if (averageLoadControl != null) { - if (averageLoadControl.isPresent) { - val optaverageLoadControl = averageLoadControl.get() - optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) - } + if (averageLoadControl.isPresent) { + val optaverageLoadControl = averageLoadControl.get() + optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) + } if (dutyCycleControl != null) { - if (dutyCycleControl.isPresent) { - val optdutyCycleControl = dutyCycleControl.get() - optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) - } + if (dutyCycleControl.isPresent) { + val optdutyCycleControl = dutyCycleControl.get() + optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) + } if (powerSavingsControl != null) { - if (powerSavingsControl.isPresent) { - val optpowerSavingsControl = powerSavingsControl.get() - optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) - } + if (powerSavingsControl.isPresent) { + val optpowerSavingsControl = powerSavingsControl.get() + optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) + } if (heatingSourceControl != null) { - if (heatingSourceControl.isPresent) { - val optheatingSourceControl = heatingSourceControl.get() - optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) - } - } else { - putNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) - } + if (heatingSourceControl.isPresent) { + val optheatingSourceControl = heatingSourceControl.get() + optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) + } + } else { + putNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) + } endStructure() } } @@ -120,72 +133,112 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent ( private const val TAG_POWER_SAVINGS_CONTROL = 8 private const val TAG_HEATING_SOURCE_CONTROL = 9 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val transitionIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) - null - } + val transitionIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) + null + } val status = tlvReader.getUInt(ContextSpecificTag(TAG_STATUS)) val criticality = tlvReader.getUInt(ContextSpecificTag(TAG_CRITICALITY)) val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) - null - } - val averageLoadControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) - null - } - val dutyCycleControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) - null - } - val powerSavingsControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) - null - } - val heatingSourceControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of(chip.devicecontroller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) - null - } - + val temperatureControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of( + chip.devicecontroller.cluster.structs + .DemandResponseLoadControlClusterTemperatureControlStruct + .fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) + null + } + val averageLoadControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of( + chip.devicecontroller.cluster.structs + .DemandResponseLoadControlClusterAverageLoadControlStruct + .fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) + null + } + val dutyCycleControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of( + chip.devicecontroller.cluster.structs + .DemandResponseLoadControlClusterDutyCycleControlStruct + .fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) + null + } + val powerSavingsControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of( + chip.devicecontroller.cluster.structs + .DemandResponseLoadControlClusterPowerSavingsControlStruct + .fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) + null + } + val heatingSourceControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of( + chip.devicecontroller.cluster.structs + .DemandResponseLoadControlClusterHeatingSourceControlStruct + .fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent(eventID, transitionIndex, status, criticality, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) + return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( + eventID, + transitionIndex, + status, + criticality, + control, + temperatureControl, + averageLoadControl, + dutyCycleControl, + powerSavingsControl, + heatingSourceControl + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt index 80397f205a2435..4bb96ee1c6026f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterPowerAdjustEndEvent ( - val cause: UInt, - val duration: ULong, - val energyUse: Long) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterPowerAdjustEndEvent( + val cause: UInt, + val duration: ULong, + val energyUse: Long +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterPowerAdjustEndEvent {\n") append("\tcause : $cause\n") append("\tduration : $duration\n") @@ -53,12 +50,15 @@ class DeviceEnergyManagementClusterPowerAdjustEndEvent ( private const val TAG_DURATION = 1 private const val TAG_ENERGY_USE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterPowerAdjustEndEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterPowerAdjustEndEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUInt(ContextSpecificTag(TAG_CAUSE)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) val energyUse = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_USE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterPowerAdjustEndEvent(cause, duration, energyUse) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt index 9d64e16ea5a9fd..5b4be5cfc2fd55 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterResumedEvent ( - val cause: UInt) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterResumedEvent(val cause: UInt) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterResumedEvent {\n") append("\tcause : $cause\n") append("}\n") @@ -45,10 +40,10 @@ class DeviceEnergyManagementClusterResumedEvent ( companion object { private const val TAG_CAUSE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterResumedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterResumedEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUInt(ContextSpecificTag(TAG_CAUSE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterResumedEvent(cause) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt index 71bdf0da0ad747..233b0d7030c8e5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DishwasherAlarmClusterNotifyEvent ( - val active: ULong, - val inactive: ULong, - val state: ULong, - val mask: ULong) { - override fun toString(): String = buildString { +class DishwasherAlarmClusterNotifyEvent( + val active: ULong, + val inactive: ULong, + val state: ULong, + val mask: ULong +) { + override fun toString(): String = buildString { append("DishwasherAlarmClusterNotifyEvent {\n") append("\tactive : $active\n") append("\tinactive : $inactive\n") @@ -57,13 +54,13 @@ class DishwasherAlarmClusterNotifyEvent ( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getULong(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getULong(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getULong(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getULong(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return DishwasherAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt index a64fa042cfcd15..918abe443473eb 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterDoorLockAlarmEvent ( - val alarmCode: UInt) { - override fun toString(): String = buildString { +class DoorLockClusterDoorLockAlarmEvent(val alarmCode: UInt) { + override fun toString(): String = buildString { append("DoorLockClusterDoorLockAlarmEvent {\n") append("\talarmCode : $alarmCode\n") append("}\n") @@ -45,10 +40,10 @@ class DoorLockClusterDoorLockAlarmEvent ( companion object { private const val TAG_ALARM_CODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorLockAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorLockAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmCode = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_CODE)) - + tlvReader.exitContainer() return DoorLockClusterDoorLockAlarmEvent(alarmCode) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt index bed611cb8674c0..64b69e7e205eb0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterDoorStateChangeEvent ( - val doorState: UInt) { - override fun toString(): String = buildString { +class DoorLockClusterDoorStateChangeEvent(val doorState: UInt) { + override fun toString(): String = buildString { append("DoorLockClusterDoorStateChangeEvent {\n") append("\tdoorState : $doorState\n") append("}\n") @@ -45,10 +40,10 @@ class DoorLockClusterDoorStateChangeEvent ( companion object { private const val TAG_DOOR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorStateChangeEvent { tlvReader.enterStructure(tlvTag) val doorState = tlvReader.getUInt(ContextSpecificTag(TAG_DOOR_STATE)) - + tlvReader.exitContainer() return DoorLockClusterDoorStateChangeEvent(doorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt index c57900a30d7946..d943e5d8ece7b8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt @@ -17,24 +17,24 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterLockOperationErrorEvent ( - val lockOperationType: UInt, - val operationSource: UInt, - val operationError: UInt, - val userIndex: UInt?, - val fabricIndex: UInt?, - val sourceNode: ULong?, - val credentials: Optional>?) { - override fun toString(): String = buildString { +class DoorLockClusterLockOperationErrorEvent( + val lockOperationType: UInt, + val operationSource: UInt, + val operationError: UInt, + val userIndex: UInt?, + val fabricIndex: UInt?, + val sourceNode: ULong?, + val credentials: + Optional>? +) { + override fun toString(): String = buildString { append("DoorLockClusterLockOperationErrorEvent {\n") append("\tlockOperationType : $lockOperationType\n") append("\toperationSource : $operationSource\n") @@ -53,32 +53,32 @@ class DoorLockClusterLockOperationErrorEvent ( put(ContextSpecificTag(TAG_OPERATION_SOURCE), operationSource) put(ContextSpecificTag(TAG_OPERATION_ERROR), operationError) if (userIndex != null) { - put(ContextSpecificTag(TAG_USER_INDEX), userIndex) - } else { - putNull(ContextSpecificTag(TAG_USER_INDEX)) - } + put(ContextSpecificTag(TAG_USER_INDEX), userIndex) + } else { + putNull(ContextSpecificTag(TAG_USER_INDEX)) + } if (fabricIndex != null) { - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - } else { - putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - } + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + } else { + putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + } if (sourceNode != null) { - put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) - } else { - putNull(ContextSpecificTag(TAG_SOURCE_NODE)) - } + put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) + } else { + putNull(ContextSpecificTag(TAG_SOURCE_NODE)) + } if (credentials != null) { - if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) + if (credentials.isPresent) { + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } + } else { + putNull(ContextSpecificTag(TAG_CREDENTIALS)) } - endArray() - } - } else { - putNull(ContextSpecificTag(TAG_CREDENTIALS)) - } endStructure() } } @@ -92,49 +92,68 @@ class DoorLockClusterLockOperationErrorEvent ( private const val TAG_SOURCE_NODE = 5 private const val TAG_CREDENTIALS = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationErrorEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) val operationError = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_ERROR)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while(!tlvReader.isEndOfContainer()) { - this.add(chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null - } - + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while (!tlvReader.isEndOfContainer()) { + this.add( + chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationErrorEvent(lockOperationType, operationSource, operationError, userIndex, fabricIndex, sourceNode, credentials) + return DoorLockClusterLockOperationErrorEvent( + lockOperationType, + operationSource, + operationError, + userIndex, + fabricIndex, + sourceNode, + credentials + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt index e86a8e434ee3ae..0e7c7e678bac46 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt @@ -17,23 +17,23 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterLockOperationEvent ( - val lockOperationType: UInt, - val operationSource: UInt, - val userIndex: UInt?, - val fabricIndex: UInt?, - val sourceNode: ULong?, - val credentials: Optional>?) { - override fun toString(): String = buildString { +class DoorLockClusterLockOperationEvent( + val lockOperationType: UInt, + val operationSource: UInt, + val userIndex: UInt?, + val fabricIndex: UInt?, + val sourceNode: ULong?, + val credentials: + Optional>? +) { + override fun toString(): String = buildString { append("DoorLockClusterLockOperationEvent {\n") append("\tlockOperationType : $lockOperationType\n") append("\toperationSource : $operationSource\n") @@ -50,32 +50,32 @@ class DoorLockClusterLockOperationEvent ( put(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE), lockOperationType) put(ContextSpecificTag(TAG_OPERATION_SOURCE), operationSource) if (userIndex != null) { - put(ContextSpecificTag(TAG_USER_INDEX), userIndex) - } else { - putNull(ContextSpecificTag(TAG_USER_INDEX)) - } + put(ContextSpecificTag(TAG_USER_INDEX), userIndex) + } else { + putNull(ContextSpecificTag(TAG_USER_INDEX)) + } if (fabricIndex != null) { - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - } else { - putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - } + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + } else { + putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + } if (sourceNode != null) { - put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) - } else { - putNull(ContextSpecificTag(TAG_SOURCE_NODE)) - } + put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) + } else { + putNull(ContextSpecificTag(TAG_SOURCE_NODE)) + } if (credentials != null) { - if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) + if (credentials.isPresent) { + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } + } else { + putNull(ContextSpecificTag(TAG_CREDENTIALS)) } - endArray() - } - } else { - putNull(ContextSpecificTag(TAG_CREDENTIALS)) - } endStructure() } } @@ -88,48 +88,66 @@ class DoorLockClusterLockOperationEvent ( private const val TAG_SOURCE_NODE = 4 private const val TAG_CREDENTIALS = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while(!tlvReader.isEndOfContainer()) { - this.add(chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null - } - + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while (!tlvReader.isEndOfContainer()) { + this.add( + chip.devicecontroller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationEvent(lockOperationType, operationSource, userIndex, fabricIndex, sourceNode, credentials) + return DoorLockClusterLockOperationEvent( + lockOperationType, + operationSource, + userIndex, + fabricIndex, + sourceNode, + credentials + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt index 7ef7dc4931b846..a5fc3f3725485e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt @@ -17,24 +17,21 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterLockUserChangeEvent ( - val lockDataType: UInt, - val dataOperationType: UInt, - val operationSource: UInt, - val userIndex: UInt?, - val fabricIndex: UInt?, - val sourceNode: ULong?, - val dataIndex: UInt?) { - override fun toString(): String = buildString { +class DoorLockClusterLockUserChangeEvent( + val lockDataType: UInt, + val dataOperationType: UInt, + val operationSource: UInt, + val userIndex: UInt?, + val fabricIndex: UInt?, + val sourceNode: ULong?, + val dataIndex: UInt? +) { + override fun toString(): String = buildString { append("DoorLockClusterLockUserChangeEvent {\n") append("\tlockDataType : $lockDataType\n") append("\tdataOperationType : $dataOperationType\n") @@ -53,25 +50,25 @@ class DoorLockClusterLockUserChangeEvent ( put(ContextSpecificTag(TAG_DATA_OPERATION_TYPE), dataOperationType) put(ContextSpecificTag(TAG_OPERATION_SOURCE), operationSource) if (userIndex != null) { - put(ContextSpecificTag(TAG_USER_INDEX), userIndex) - } else { - putNull(ContextSpecificTag(TAG_USER_INDEX)) - } + put(ContextSpecificTag(TAG_USER_INDEX), userIndex) + } else { + putNull(ContextSpecificTag(TAG_USER_INDEX)) + } if (fabricIndex != null) { - put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) - } else { - putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - } + put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) + } else { + putNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + } if (sourceNode != null) { - put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) - } else { - putNull(ContextSpecificTag(TAG_SOURCE_NODE)) - } + put(ContextSpecificTag(TAG_SOURCE_NODE), sourceNode) + } else { + putNull(ContextSpecificTag(TAG_SOURCE_NODE)) + } if (dataIndex != null) { - put(ContextSpecificTag(TAG_DATA_INDEX), dataIndex) - } else { - putNull(ContextSpecificTag(TAG_DATA_INDEX)) - } + put(ContextSpecificTag(TAG_DATA_INDEX), dataIndex) + } else { + putNull(ContextSpecificTag(TAG_DATA_INDEX)) + } endStructure() } } @@ -85,39 +82,51 @@ class DoorLockClusterLockUserChangeEvent ( private const val TAG_SOURCE_NODE = 5 private const val TAG_DATA_INDEX = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockUserChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockUserChangeEvent { tlvReader.enterStructure(tlvTag) val lockDataType = tlvReader.getUInt(ContextSpecificTag(TAG_LOCK_DATA_TYPE)) val dataOperationType = tlvReader.getUInt(ContextSpecificTag(TAG_DATA_OPERATION_TYPE)) val operationSource = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val dataIndex = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_DATA_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) - null - } - + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val dataIndex = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_DATA_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockUserChangeEvent(lockDataType, dataOperationType, operationSource, userIndex, fabricIndex, sourceNode, dataIndex) + return DoorLockClusterLockUserChangeEvent( + lockDataType, + dataOperationType, + operationSource, + userIndex, + fabricIndex, + sourceNode, + dataIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt index 5ffcdf60628cff..8e0a4253bbc183 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt @@ -17,19 +17,23 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent ( - val energyImported: Optional, - val energyExported: Optional) { - override fun toString(): String = buildString { +class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + val energyImported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > +) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent {\n") append("\tenergyImported : $energyImported\n") append("\tenergyExported : $energyExported\n") @@ -40,13 +44,13 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent ( tlvWriter.apply { startStructure(tlvTag) if (energyImported.isPresent) { - val optenergyImported = energyImported.get() - optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) - } + val optenergyImported = energyImported.get() + optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) + } if (energyExported.isPresent) { - val optenergyExported = energyExported.get() - optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) - } + val optenergyExported = energyExported.get() + optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) + } endStructure() } } @@ -55,22 +59,38 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent ( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) - } else { - Optional.empty() - } - val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) - } else { - Optional.empty() - } - + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent(energyImported, energyExported) + return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + energyImported, + energyExported + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt index b98ed116089884..a2ffd06d482dc8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt @@ -17,19 +17,23 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent ( - val energyImported: Optional, - val energyExported: Optional) { - override fun toString(): String = buildString { +class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + val energyImported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > +) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent {\n") append("\tenergyImported : $energyImported\n") append("\tenergyExported : $energyExported\n") @@ -40,13 +44,13 @@ class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent ( tlvWriter.apply { startStructure(tlvTag) if (energyImported.isPresent) { - val optenergyImported = energyImported.get() - optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) - } + val optenergyImported = energyImported.get() + optenergyImported.toTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), this) + } if (energyExported.isPresent) { - val optenergyExported = energyExported.get() - optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) - } + val optenergyExported = energyExported.get() + optenergyExported.toTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), this) + } endStructure() } } @@ -55,22 +59,38 @@ class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent ( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) - } else { - Optional.empty() - } - val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of(chip.devicecontroller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) - } else { - Optional.empty() - } - + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + chip.devicecontroller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent(energyImported, energyExported) + return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + energyImported, + energyExported + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt index f7cf6196cf4937..37d91a3291a9f2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterEVConnectedEvent ( - val sessionID: ULong) { - override fun toString(): String = buildString { +class EnergyEvseClusterEVConnectedEvent(val sessionID: ULong) { + override fun toString(): String = buildString { append("EnergyEvseClusterEVConnectedEvent {\n") append("\tsessionID : $sessionID\n") append("}\n") @@ -45,10 +40,10 @@ class EnergyEvseClusterEVConnectedEvent ( companion object { private const val TAG_SESSION_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVConnectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVConnectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) - + tlvReader.exitContainer() return EnergyEvseClusterEVConnectedEvent(sessionID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt index f3e95efb7fcbfc..5720d4469df39c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterEVNotDetectedEvent ( - val sessionID: ULong, - val state: UInt, - val sessionDuration: ULong, - val sessionEnergyCharged: Long, - val sessionEnergyDischarged: Optional) { - override fun toString(): String = buildString { +class EnergyEvseClusterEVNotDetectedEvent( + val sessionID: ULong, + val state: UInt, + val sessionDuration: ULong, + val sessionEnergyCharged: Long, + val sessionEnergyDischarged: Optional +) { + override fun toString(): String = buildString { append("EnergyEvseClusterEVNotDetectedEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -50,9 +48,9 @@ class EnergyEvseClusterEVNotDetectedEvent ( put(ContextSpecificTag(TAG_SESSION_DURATION), sessionDuration) put(ContextSpecificTag(TAG_SESSION_ENERGY_CHARGED), sessionEnergyCharged) if (sessionEnergyDischarged.isPresent) { - val optsessionEnergyDischarged = sessionEnergyDischarged.get() - put(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED), optsessionEnergyDischarged) - } + val optsessionEnergyDischarged = sessionEnergyDischarged.get() + put(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED), optsessionEnergyDischarged) + } endStructure() } } @@ -64,21 +62,28 @@ class EnergyEvseClusterEVNotDetectedEvent ( private const val TAG_SESSION_ENERGY_CHARGED = 3 private const val TAG_SESSION_ENERGY_DISCHARGED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVNotDetectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVNotDetectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val sessionDuration = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_DURATION)) val sessionEnergyCharged = tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_CHARGED)) - val sessionEnergyDischarged = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) - } else { - Optional.empty() - } - + val sessionEnergyDischarged = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterEVNotDetectedEvent(sessionID, state, sessionDuration, sessionEnergyCharged, sessionEnergyDischarged) + return EnergyEvseClusterEVNotDetectedEvent( + sessionID, + state, + sessionDuration, + sessionEnergyCharged, + sessionEnergyDischarged + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt index 29444bb45ec2c8..7843215518c11d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterEnergyTransferStartedEvent ( - val sessionID: ULong, - val state: UInt, - val maximumCurrent: Long) { - override fun toString(): String = buildString { +class EnergyEvseClusterEnergyTransferStartedEvent( + val sessionID: ULong, + val state: UInt, + val maximumCurrent: Long +) { + override fun toString(): String = buildString { append("EnergyEvseClusterEnergyTransferStartedEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -53,12 +50,12 @@ class EnergyEvseClusterEnergyTransferStartedEvent ( private const val TAG_STATE = 1 private const val TAG_MAXIMUM_CURRENT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStartedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStartedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val maximumCurrent = tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_CURRENT)) - + tlvReader.exitContainer() return EnergyEvseClusterEnergyTransferStartedEvent(sessionID, state, maximumCurrent) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt index ab277d74545a32..642bbc9b5e7a04 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterEnergyTransferStoppedEvent ( - val sessionID: ULong, - val state: UInt, - val reason: UInt, - val energyTransferred: Long) { - override fun toString(): String = buildString { +class EnergyEvseClusterEnergyTransferStoppedEvent( + val sessionID: ULong, + val state: UInt, + val reason: UInt, + val energyTransferred: Long +) { + override fun toString(): String = buildString { append("EnergyEvseClusterEnergyTransferStoppedEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -57,16 +54,21 @@ class EnergyEvseClusterEnergyTransferStoppedEvent ( private const val TAG_REASON = 2 private const val TAG_ENERGY_TRANSFERRED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStoppedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStoppedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val reason = tlvReader.getUInt(ContextSpecificTag(TAG_REASON)) val energyTransferred = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_TRANSFERRED)) - + tlvReader.exitContainer() - return EnergyEvseClusterEnergyTransferStoppedEvent(sessionID, state, reason, energyTransferred) + return EnergyEvseClusterEnergyTransferStoppedEvent( + sessionID, + state, + reason, + energyTransferred + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt index d95cc19e30fd92..53ca88273b038d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterFaultEvent ( - val sessionID: ULong?, - val state: UInt, - val faultStatePreviousState: UInt, - val faultStateCurrentState: UInt) { - override fun toString(): String = buildString { +class EnergyEvseClusterFaultEvent( + val sessionID: ULong?, + val state: UInt, + val faultStatePreviousState: UInt, + val faultStateCurrentState: UInt +) { + override fun toString(): String = buildString { append("EnergyEvseClusterFaultEvent {\n") append("\tsessionID : $sessionID\n") append("\tstate : $state\n") @@ -44,10 +41,10 @@ class EnergyEvseClusterFaultEvent ( tlvWriter.apply { startStructure(tlvTag) if (sessionID != null) { - put(ContextSpecificTag(TAG_SESSION_I_D), sessionID) - } else { - putNull(ContextSpecificTag(TAG_SESSION_I_D)) - } + put(ContextSpecificTag(TAG_SESSION_I_D), sessionID) + } else { + putNull(ContextSpecificTag(TAG_SESSION_I_D)) + } put(ContextSpecificTag(TAG_STATE), state) put(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE), faultStatePreviousState) put(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE), faultStateCurrentState) @@ -61,21 +58,29 @@ class EnergyEvseClusterFaultEvent ( private const val TAG_FAULT_STATE_PREVIOUS_STATE = 2 private const val TAG_FAULT_STATE_CURRENT_STATE = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterFaultEvent { tlvReader.enterStructure(tlvTag) - val sessionID = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) - null - } + val sessionID = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SESSION_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) + null + } val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) - val faultStatePreviousState = tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) - val faultStateCurrentState = tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) - + val faultStatePreviousState = + tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) + val faultStateCurrentState = + tlvReader.getUInt(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) + tlvReader.exitContainer() - return EnergyEvseClusterFaultEvent(sessionID, state, faultStatePreviousState, faultStateCurrentState) + return EnergyEvseClusterFaultEvent( + sessionID, + state, + faultStatePreviousState, + faultStateCurrentState + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt index 13834fdaa5eb5b..760bc2cd92b2eb 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterRFIDEvent ( - val uid: ByteArray) { - override fun toString(): String = buildString { +class EnergyEvseClusterRFIDEvent(val uid: ByteArray) { + override fun toString(): String = buildString { append("EnergyEvseClusterRFIDEvent {\n") append("\tuid : $uid\n") append("}\n") @@ -45,10 +40,10 @@ class EnergyEvseClusterRFIDEvent ( companion object { private const val TAG_UID = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterRFIDEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterRFIDEvent { tlvReader.enterStructure(tlvTag) val uid = tlvReader.getByteArray(ContextSpecificTag(TAG_UID)) - + tlvReader.exitContainer() return EnergyEvseClusterRFIDEvent(uid) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt index c3100ce31c6f9b..ab8a2c3ad964b4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralDiagnosticsClusterBootReasonEvent ( - val bootReason: UInt) { - override fun toString(): String = buildString { +class GeneralDiagnosticsClusterBootReasonEvent(val bootReason: UInt) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterBootReasonEvent {\n") append("\tbootReason : $bootReason\n") append("}\n") @@ -45,10 +40,10 @@ class GeneralDiagnosticsClusterBootReasonEvent ( companion object { private const val TAG_BOOT_REASON = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterBootReasonEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterBootReasonEvent { tlvReader.enterStructure(tlvTag) val bootReason = tlvReader.getUInt(ContextSpecificTag(TAG_BOOT_REASON)) - + tlvReader.exitContainer() return GeneralDiagnosticsClusterBootReasonEvent(bootReason) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt index f93896c837f200..e09f3961230b34 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralDiagnosticsClusterHardwareFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class GeneralDiagnosticsClusterHardwareFaultChangeEvent( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterHardwareFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,28 @@ class GeneralDiagnosticsClusterHardwareFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterHardwareFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralDiagnosticsClusterHardwareFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterHardwareFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt index ebc04643e795f2..2d17b1773194dc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralDiagnosticsClusterNetworkFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class GeneralDiagnosticsClusterNetworkFaultChangeEvent( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterNetworkFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,28 @@ class GeneralDiagnosticsClusterNetworkFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt index 238e8657f6984b..3fc425674dde60 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralDiagnosticsClusterRadioFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class GeneralDiagnosticsClusterRadioFaultChangeEvent( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterRadioFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,25 @@ class GeneralDiagnosticsClusterRadioFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterRadioFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterRadioFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return GeneralDiagnosticsClusterRadioFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt index c8127f90ae7b9c..8626f9daed4e01 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt @@ -17,26 +17,25 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MediaPlaybackClusterStateChangedEvent ( - val currentState: UInt, - val startTime: ULong, - val duration: ULong, - val sampledPosition: chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct, - val playbackSpeed: Float, - val seekRangeEnd: ULong, - val seekRangeStart: ULong, - val data: Optional, - val audioAdvanceUnmuted: Boolean) { - override fun toString(): String = buildString { +class MediaPlaybackClusterStateChangedEvent( + val currentState: UInt, + val startTime: ULong, + val duration: ULong, + val sampledPosition: + chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct, + val playbackSpeed: Float, + val seekRangeEnd: ULong, + val seekRangeStart: ULong, + val data: Optional, + val audioAdvanceUnmuted: Boolean +) { + override fun toString(): String = buildString { append("MediaPlaybackClusterStateChangedEvent {\n") append("\tcurrentState : $currentState\n") append("\tstartTime : $startTime\n") @@ -61,9 +60,9 @@ class MediaPlaybackClusterStateChangedEvent ( put(ContextSpecificTag(TAG_SEEK_RANGE_END), seekRangeEnd) put(ContextSpecificTag(TAG_SEEK_RANGE_START), seekRangeStart) if (data.isPresent) { - val optdata = data.get() - put(ContextSpecificTag(TAG_DATA), optdata) - } + val optdata = data.get() + put(ContextSpecificTag(TAG_DATA), optdata) + } put(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED), audioAdvanceUnmuted) endStructure() } @@ -80,25 +79,40 @@ class MediaPlaybackClusterStateChangedEvent ( private const val TAG_DATA = 7 private const val TAG_AUDIO_ADVANCE_UNMUTED = 8 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val currentState = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_STATE)) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - val sampledPosition = chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv(ContextSpecificTag(TAG_SAMPLED_POSITION), tlvReader) + val sampledPosition = + chip.devicecontroller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv( + ContextSpecificTag(TAG_SAMPLED_POSITION), + tlvReader + ) val playbackSpeed = tlvReader.getFloat(ContextSpecificTag(TAG_PLAYBACK_SPEED)) val seekRangeEnd = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_END)) val seekRangeStart = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_START)) - val data = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) - } else { - Optional.empty() - } + val data = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) + } else { + Optional.empty() + } val audioAdvanceUnmuted = tlvReader.getBoolean(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED)) - + tlvReader.exitContainer() - return MediaPlaybackClusterStateChangedEvent(currentState, startTime, duration, sampledPosition, playbackSpeed, seekRangeEnd, seekRangeStart, data, audioAdvanceUnmuted) + return MediaPlaybackClusterStateChangedEvent( + currentState, + startTime, + duration, + sampledPosition, + playbackSpeed, + seekRangeEnd, + seekRangeStart, + data, + audioAdvanceUnmuted + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt index bd2f7895bfd1e2..95cf699d416744 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalStateClusterOperationCompletionEvent ( - val completionErrorCode: UInt, - val totalOperationalTime: Optional?, - val pausedTime: Optional?) { - override fun toString(): String = buildString { +class OperationalStateClusterOperationCompletionEvent( + val completionErrorCode: UInt, + val totalOperationalTime: Optional?, + val pausedTime: Optional? +) { + override fun toString(): String = buildString { append("OperationalStateClusterOperationCompletionEvent {\n") append("\tcompletionErrorCode : $completionErrorCode\n") append("\ttotalOperationalTime : $totalOperationalTime\n") @@ -43,21 +41,21 @@ class OperationalStateClusterOperationCompletionEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { - if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } - } else { - putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - } + if (totalOperationalTime.isPresent) { + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } + } else { + putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + } if (pausedTime != null) { - if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } - } else { - putNull(ContextSpecificTag(TAG_PAUSED_TIME)) - } + if (pausedTime.isPresent) { + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } + } else { + putNull(ContextSpecificTag(TAG_PAUSED_TIME)) + } endStructure() } } @@ -67,33 +65,42 @@ class OperationalStateClusterOperationCompletionEvent ( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return OperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt index f0cd196223d72c..4ff0719f3d0f3b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt @@ -17,18 +17,15 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalStateClusterOperationalErrorEvent ( - val errorState: chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct) { - override fun toString(): String = buildString { +class OperationalStateClusterOperationalErrorEvent( + val errorState: chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct +) { + override fun toString(): String = buildString { append("OperationalStateClusterOperationalErrorEvent {\n") append("\terrorState : $errorState\n") append("}\n") @@ -45,10 +42,14 @@ class OperationalStateClusterOperationalErrorEvent ( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationalErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + chip.devicecontroller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv( + ContextSpecificTag(TAG_ERROR_STATE), + tlvReader + ) + tlvReader.exitContainer() return OperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt index 67e9047f0532a4..8156c9578afadc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent ( - val softwareVersion: ULong, - val bytesDownloaded: ULong, - val progressPercent: UInt?, - val platformCode: Long?) { - override fun toString(): String = buildString { +class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( + val softwareVersion: ULong, + val bytesDownloaded: ULong, + val progressPercent: UInt?, + val platformCode: Long? +) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterDownloadErrorEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("\tbytesDownloaded : $bytesDownloaded\n") @@ -46,15 +43,15 @@ class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent ( put(ContextSpecificTag(TAG_SOFTWARE_VERSION), softwareVersion) put(ContextSpecificTag(TAG_BYTES_DOWNLOADED), bytesDownloaded) if (progressPercent != null) { - put(ContextSpecificTag(TAG_PROGRESS_PERCENT), progressPercent) - } else { - putNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - } + put(ContextSpecificTag(TAG_PROGRESS_PERCENT), progressPercent) + } else { + putNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + } if (platformCode != null) { - put(ContextSpecificTag(TAG_PLATFORM_CODE), platformCode) - } else { - putNull(ContextSpecificTag(TAG_PLATFORM_CODE)) - } + put(ContextSpecificTag(TAG_PLATFORM_CODE), platformCode) + } else { + putNull(ContextSpecificTag(TAG_PLATFORM_CODE)) + } endStructure() } } @@ -65,26 +62,36 @@ class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent ( private const val TAG_PROGRESS_PERCENT = 2 private const val TAG_PLATFORM_CODE = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val bytesDownloaded = tlvReader.getULong(ContextSpecificTag(TAG_BYTES_DOWNLOADED)) - val progressPercent = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - null - } - val platformCode = if (!tlvReader.isNull()) { - tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) - null - } - + val progressPercent = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + null + } + val platformCode = + if (!tlvReader.isNull()) { + tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent(softwareVersion, bytesDownloaded, progressPercent, platformCode) + return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( + softwareVersion, + bytesDownloaded, + progressPercent, + platformCode + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt index 99acba4d90a2dd..3843fe8b3b782a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OtaSoftwareUpdateRequestorClusterStateTransitionEvent ( - val previousState: UInt, - val newState: UInt, - val reason: UInt, - val targetSoftwareVersion: ULong?) { - override fun toString(): String = buildString { +class OtaSoftwareUpdateRequestorClusterStateTransitionEvent( + val previousState: UInt, + val newState: UInt, + val reason: UInt, + val targetSoftwareVersion: ULong? +) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterStateTransitionEvent {\n") append("\tpreviousState : $previousState\n") append("\tnewState : $newState\n") @@ -47,10 +44,10 @@ class OtaSoftwareUpdateRequestorClusterStateTransitionEvent ( put(ContextSpecificTag(TAG_NEW_STATE), newState) put(ContextSpecificTag(TAG_REASON), reason) if (targetSoftwareVersion != null) { - put(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION), targetSoftwareVersion) - } else { - putNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - } + put(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION), targetSoftwareVersion) + } else { + putNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + } endStructure() } } @@ -61,21 +58,30 @@ class OtaSoftwareUpdateRequestorClusterStateTransitionEvent ( private const val TAG_REASON = 2 private const val TAG_TARGET_SOFTWARE_VERSION = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterStateTransitionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterStateTransitionEvent { tlvReader.enterStructure(tlvTag) val previousState = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_STATE)) val newState = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_STATE)) val reason = tlvReader.getUInt(ContextSpecificTag(TAG_REASON)) - val targetSoftwareVersion = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - null - } - + val targetSoftwareVersion = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterStateTransitionEvent(previousState, newState, reason, targetSoftwareVersion) + return OtaSoftwareUpdateRequestorClusterStateTransitionEvent( + previousState, + newState, + reason, + targetSoftwareVersion + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt index 50dda1eeae85db..43ec6b74bfc442 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent ( - val softwareVersion: ULong, - val productID: UInt) { - override fun toString(): String = buildString { +class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent( + val softwareVersion: ULong, + val productID: UInt +) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterVersionAppliedEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") append("\tproductID : $productID\n") @@ -49,11 +46,14 @@ class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent ( private const val TAG_SOFTWARE_VERSION = 0 private const val TAG_PRODUCT_I_D = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getULong(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val productID = tlvReader.getUInt(ContextSpecificTag(TAG_PRODUCT_I_D)) - + tlvReader.exitContainer() return OtaSoftwareUpdateRequestorClusterVersionAppliedEvent(softwareVersion, productID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt index c823fe799eb82b..b5a235e97841ba 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenCavityOperationalStateClusterOperationCompletionEvent ( - val completionErrorCode: UInt, - val totalOperationalTime: Optional?, - val pausedTime: Optional?) { - override fun toString(): String = buildString { +class OvenCavityOperationalStateClusterOperationCompletionEvent( + val completionErrorCode: UInt, + val totalOperationalTime: Optional?, + val pausedTime: Optional? +) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationCompletionEvent {\n") append("\tcompletionErrorCode : $completionErrorCode\n") append("\ttotalOperationalTime : $totalOperationalTime\n") @@ -43,21 +41,21 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { - if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } - } else { - putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - } + if (totalOperationalTime.isPresent) { + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } + } else { + putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + } if (pausedTime != null) { - if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } - } else { - putNull(ContextSpecificTag(TAG_PAUSED_TIME)) - } + if (pausedTime.isPresent) { + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } + } else { + putNull(ContextSpecificTag(TAG_PAUSED_TIME)) + } endStructure() } } @@ -67,33 +65,42 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent ( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return OvenCavityOperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt index 9ba1604dedd97a..8b1b9345a7df0b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt @@ -17,18 +17,16 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenCavityOperationalStateClusterOperationalErrorEvent ( - val errorState: chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct) { - override fun toString(): String = buildString { +class OvenCavityOperationalStateClusterOperationalErrorEvent( + val errorState: + chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct +) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationalErrorEvent {\n") append("\terrorState : $errorState\n") append("}\n") @@ -45,10 +43,15 @@ class OvenCavityOperationalStateClusterOperationalErrorEvent ( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationalErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + chip.devicecontroller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct + .fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) + tlvReader.exitContainer() return OvenCavityOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt index b09829b20efd50..fdb0b033a7616a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterBatChargeFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterBatChargeFaultChangeEvent( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("PowerSourceClusterBatChargeFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,25 @@ class PowerSourceClusterBatChargeFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatChargeFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt index ef4689fff56f84..7a5d133299cef5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt @@ -20,16 +20,11 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterBatFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterBatFaultChangeEvent(val current: List, val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +52,25 @@ class PowerSourceClusterBatFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt index 5062e14fc47019..1f004191d406f0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt @@ -20,16 +20,11 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterWiredFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterWiredFaultChangeEvent(val current: List, val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +52,25 @@ class PowerSourceClusterWiredFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterWiredFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt index 0d0ec7f29f122c..2584478cd02e39 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RefrigeratorAlarmClusterNotifyEvent ( - val active: ULong, - val inactive: ULong, - val state: ULong, - val mask: ULong) { - override fun toString(): String = buildString { +class RefrigeratorAlarmClusterNotifyEvent( + val active: ULong, + val inactive: ULong, + val state: ULong, + val mask: ULong +) { + override fun toString(): String = buildString { append("RefrigeratorAlarmClusterNotifyEvent {\n") append("\tactive : $active\n") append("\tinactive : $inactive\n") @@ -57,13 +54,13 @@ class RefrigeratorAlarmClusterNotifyEvent ( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getULong(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getULong(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getULong(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getULong(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return RefrigeratorAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt index a9817567e22677..cfea1b82753b91 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcOperationalStateClusterOperationCompletionEvent ( - val completionErrorCode: UInt, - val totalOperationalTime: Optional?, - val pausedTime: Optional?) { - override fun toString(): String = buildString { +class RvcOperationalStateClusterOperationCompletionEvent( + val completionErrorCode: UInt, + val totalOperationalTime: Optional?, + val pausedTime: Optional? +) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterOperationCompletionEvent {\n") append("\tcompletionErrorCode : $completionErrorCode\n") append("\ttotalOperationalTime : $totalOperationalTime\n") @@ -43,21 +41,21 @@ class RvcOperationalStateClusterOperationCompletionEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { - if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } - } else { - putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - } + if (totalOperationalTime.isPresent) { + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } + } else { + putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + } if (pausedTime != null) { - if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } - } else { - putNull(ContextSpecificTag(TAG_PAUSED_TIME)) - } + if (pausedTime.isPresent) { + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } + } else { + putNull(ContextSpecificTag(TAG_PAUSED_TIME)) + } endStructure() } } @@ -67,33 +65,42 @@ class RvcOperationalStateClusterOperationCompletionEvent ( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUInt(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return RvcOperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt index 406ef9431645cd..6ad8a5e8875408 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt @@ -17,18 +17,15 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcOperationalStateClusterOperationalErrorEvent ( - val errorState: chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct) { - override fun toString(): String = buildString { +class RvcOperationalStateClusterOperationalErrorEvent( + val errorState: chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct +) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterOperationalErrorEvent {\n") append("\terrorState : $errorState\n") append("}\n") @@ -45,10 +42,17 @@ class RvcOperationalStateClusterOperationalErrorEvent ( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationalErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + chip.devicecontroller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv( + ContextSpecificTag(TAG_ERROR_STATE), + tlvReader + ) + tlvReader.exitContainer() return RvcOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt index 03b105c427a397..a0588f4ad66d56 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SampleMeiClusterPingCountEventEvent ( - val count: ULong, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class SampleMeiClusterPingCountEventEvent(val count: ULong, val fabricIndex: UInt) { + override fun toString(): String = buildString { append("SampleMeiClusterPingCountEventEvent {\n") append("\tcount : $count\n") append("\tfabricIndex : $fabricIndex\n") @@ -49,11 +43,11 @@ class SampleMeiClusterPingCountEventEvent ( private const val TAG_COUNT = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SampleMeiClusterPingCountEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingCountEventEvent { tlvReader.enterStructure(tlvTag) val count = tlvReader.getULong(ContextSpecificTag(TAG_COUNT)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return SampleMeiClusterPingCountEventEvent(count, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt index 48acd74033fca2..a34090499ca233 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SmokeCoAlarmClusterCOAlarmEvent ( - val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +class SmokeCoAlarmClusterCOAlarmEvent(val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -45,10 +40,10 @@ class SmokeCoAlarmClusterCOAlarmEvent ( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt index 685a6ab5fc1059..c3ec4fbf491c87 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SmokeCoAlarmClusterInterconnectCOAlarmEvent ( - val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +class SmokeCoAlarmClusterInterconnectCOAlarmEvent(val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -45,10 +40,10 @@ class SmokeCoAlarmClusterInterconnectCOAlarmEvent ( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt index 1fb60bf24aec59..3957d722ade622 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent ( - val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -45,10 +40,10 @@ class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent ( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt index 91345969b757b4..e855a9391a7491 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SmokeCoAlarmClusterLowBatteryEvent ( - val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +class SmokeCoAlarmClusterLowBatteryEvent(val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterLowBatteryEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -45,10 +40,10 @@ class SmokeCoAlarmClusterLowBatteryEvent ( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterLowBatteryEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterLowBatteryEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterLowBatteryEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt index 3494dffe4f3d5b..5e5ff96385c265 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SmokeCoAlarmClusterSmokeAlarmEvent ( - val alarmSeverityLevel: UInt) { - override fun toString(): String = buildString { +class SmokeCoAlarmClusterSmokeAlarmEvent(val alarmSeverityLevel: UInt) { + override fun toString(): String = buildString { append("SmokeCoAlarmClusterSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") append("}\n") @@ -45,10 +40,10 @@ class SmokeCoAlarmClusterSmokeAlarmEvent ( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUInt(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt index b0e0d4844fadca..d3389bbaf8f367 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SoftwareDiagnosticsClusterSoftwareFaultEvent ( - val id: ULong, - val name: Optional, - val faultRecording: Optional) { - override fun toString(): String = buildString { +class SoftwareDiagnosticsClusterSoftwareFaultEvent( + val id: ULong, + val name: Optional, + val faultRecording: Optional +) { + override fun toString(): String = buildString { append("SoftwareDiagnosticsClusterSoftwareFaultEvent {\n") append("\tid : $id\n") append("\tname : $name\n") @@ -43,13 +41,13 @@ class SoftwareDiagnosticsClusterSoftwareFaultEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ID), id) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (faultRecording.isPresent) { - val optfaultRecording = faultRecording.get() - put(ContextSpecificTag(TAG_FAULT_RECORDING), optfaultRecording) - } + val optfaultRecording = faultRecording.get() + put(ContextSpecificTag(TAG_FAULT_RECORDING), optfaultRecording) + } endStructure() } } @@ -59,20 +57,22 @@ class SoftwareDiagnosticsClusterSoftwareFaultEvent ( private const val TAG_NAME = 1 private const val TAG_FAULT_RECORDING = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SoftwareDiagnosticsClusterSoftwareFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterSoftwareFaultEvent { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val faultRecording = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val faultRecording = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return SoftwareDiagnosticsClusterSoftwareFaultEvent(id, name, faultRecording) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt index fa3cf254ebdb96..965bc1a81af5ac 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterInitialPressEvent ( - val newPosition: UInt) { - override fun toString(): String = buildString { +class SwitchClusterInitialPressEvent(val newPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterInitialPressEvent {\n") append("\tnewPosition : $newPosition\n") append("}\n") @@ -45,10 +40,10 @@ class SwitchClusterInitialPressEvent ( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterInitialPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterInitialPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterInitialPressEvent(newPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt index 2748e8e6a44449..e986ef1d8d97fe 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongPressEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterLongPressEvent ( - val newPosition: UInt) { - override fun toString(): String = buildString { +class SwitchClusterLongPressEvent(val newPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterLongPressEvent {\n") append("\tnewPosition : $newPosition\n") append("}\n") @@ -45,10 +40,10 @@ class SwitchClusterLongPressEvent ( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongPressEvent(newPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt index f4661d48d8e63e..e99b119d906e8b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterLongReleaseEvent ( - val previousPosition: UInt) { - override fun toString(): String = buildString { +class SwitchClusterLongReleaseEvent(val previousPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterLongReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") append("}\n") @@ -45,10 +40,10 @@ class SwitchClusterLongReleaseEvent ( companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt index b5d580a7cf0c55..381ec17ae29ac5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterMultiPressCompleteEvent ( - val previousPosition: UInt, - val totalNumberOfPressesCounted: UInt) { - override fun toString(): String = buildString { +class SwitchClusterMultiPressCompleteEvent( + val previousPosition: UInt, + val totalNumberOfPressesCounted: UInt +) { + override fun toString(): String = buildString { append("SwitchClusterMultiPressCompleteEvent {\n") append("\tpreviousPosition : $previousPosition\n") append("\ttotalNumberOfPressesCounted : $totalNumberOfPressesCounted\n") @@ -49,11 +46,12 @@ class SwitchClusterMultiPressCompleteEvent ( private const val TAG_PREVIOUS_POSITION = 0 private const val TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressCompleteEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressCompleteEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - val totalNumberOfPressesCounted = tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) - + val totalNumberOfPressesCounted = + tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressCompleteEvent(previousPosition, totalNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt index fcaf6c0ca5ef5f..dd904f59cb9fdc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterMultiPressOngoingEvent ( - val newPosition: UInt, - val currentNumberOfPressesCounted: UInt) { - override fun toString(): String = buildString { +class SwitchClusterMultiPressOngoingEvent( + val newPosition: UInt, + val currentNumberOfPressesCounted: UInt +) { + override fun toString(): String = buildString { append("SwitchClusterMultiPressOngoingEvent {\n") append("\tnewPosition : $newPosition\n") append("\tcurrentNumberOfPressesCounted : $currentNumberOfPressesCounted\n") @@ -49,11 +46,12 @@ class SwitchClusterMultiPressOngoingEvent ( private const val TAG_NEW_POSITION = 0 private const val TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressOngoingEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressOngoingEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - val currentNumberOfPressesCounted = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) - + val currentNumberOfPressesCounted = + tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressOngoingEvent(newPosition, currentNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt index 91a786b4f78740..477dc53e895a2a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterShortReleaseEvent ( - val previousPosition: UInt) { - override fun toString(): String = buildString { +class SwitchClusterShortReleaseEvent(val previousPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterShortReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") append("}\n") @@ -45,10 +40,10 @@ class SwitchClusterShortReleaseEvent ( companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterShortReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterShortReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUInt(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterShortReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt index f6537ab66e931a..6a2ea4883e4f6f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SwitchClusterSwitchLatchedEvent ( - val newPosition: UInt) { - override fun toString(): String = buildString { +class SwitchClusterSwitchLatchedEvent(val newPosition: UInt) { + override fun toString(): String = buildString { append("SwitchClusterSwitchLatchedEvent {\n") append("\tnewPosition : $newPosition\n") append("}\n") @@ -45,10 +40,10 @@ class SwitchClusterSwitchLatchedEvent ( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterSwitchLatchedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterSwitchLatchedEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUInt(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterSwitchLatchedEvent(newPosition) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt index e49f93ead0165f..ce5bbb1df841c9 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt @@ -20,17 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TargetNavigatorClusterTargetUpdatedEvent ( - val targetList: List, - val currentTarget: UInt, - val data: ByteArray) { - override fun toString(): String = buildString { +class TargetNavigatorClusterTargetUpdatedEvent( + val targetList: + List, + val currentTarget: UInt, + val data: ByteArray +) { + override fun toString(): String = buildString { append("TargetNavigatorClusterTargetUpdatedEvent {\n") append("\ttargetList : $targetList\n") append("\tcurrentTarget : $currentTarget\n") @@ -57,18 +56,24 @@ class TargetNavigatorClusterTargetUpdatedEvent ( private const val TAG_CURRENT_TARGET = 1 private const val TAG_DATA = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TargetNavigatorClusterTargetUpdatedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TargetNavigatorClusterTargetUpdatedEvent { tlvReader.enterStructure(tlvTag) - val targetList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) - while(!tlvReader.isEndOfContainer()) { - this.add(chip.devicecontroller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val targetList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) + while (!tlvReader.isEndOfContainer()) { + this.add( + chip.devicecontroller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } val currentTarget = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_TARGET)) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetUpdatedEvent(targetList, currentTarget, data) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt index 7a9290a163f25e..dc55e372090536 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterConnectionStatusEvent ( - val connectionStatus: UInt) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UInt) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") append("}\n") @@ -45,10 +40,13 @@ class ThreadNetworkDiagnosticsClusterConnectionStatusEvent ( companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUInt(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt index 384675b471a0d6..f2ce60e4c710ba 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,28 @@ class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt index d4162a1dd3f5ae..7564293e97be61 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterDSTStatusEvent ( - val DSTOffsetActive: Boolean) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterDSTStatusEvent(val DSTOffsetActive: Boolean) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterDSTStatusEvent {\n") append("\tDSTOffsetActive : $DSTOffsetActive\n") append("}\n") @@ -45,10 +40,10 @@ class TimeSynchronizationClusterDSTStatusEvent ( companion object { private const val TAG_D_S_T_OFFSET_ACTIVE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterDSTStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterDSTStatusEvent { tlvReader.enterStructure(tlvTag) val DSTOffsetActive = tlvReader.getBoolean(ContextSpecificTag(TAG_D_S_T_OFFSET_ACTIVE)) - + tlvReader.exitContainer() return TimeSynchronizationClusterDSTStatusEvent(DSTOffsetActive) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt index 52b2b4fd1e1dfa..9e9d5ef9f1355f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterTimeZoneStatusEvent ( - val offset: Long, - val name: Optional) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterTimeZoneStatusEvent(val offset: Long, val name: Optional) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterTimeZoneStatusEvent {\n") append("\toffset : $offset\n") append("\tname : $name\n") @@ -41,9 +36,9 @@ class TimeSynchronizationClusterTimeZoneStatusEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_OFFSET), offset) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } endStructure() } } @@ -52,15 +47,16 @@ class TimeSynchronizationClusterTimeZoneStatusEvent ( private const val TAG_OFFSET = 0 private const val TAG_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTimeZoneStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTimeZoneStatusEvent { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getLong(ContextSpecificTag(TAG_OFFSET)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStatusEvent(offset, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt index 89dbdc9593b84e..d92c0b6b531a6b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt @@ -20,20 +20,18 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterTestEventEvent ( - val arg1: UInt, - val arg2: UInt, - val arg3: Boolean, - val arg4: chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct, - val arg5: List, - val arg6: List) { - override fun toString(): String = buildString { +class UnitTestingClusterTestEventEvent( + val arg1: UInt, + val arg2: UInt, + val arg3: Boolean, + val arg4: chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct, + val arg5: List, + val arg6: List +) { + override fun toString(): String = buildString { append("UnitTestingClusterTestEventEvent {\n") append("\targ1 : $arg1\n") append("\targ2 : $arg2\n") @@ -73,27 +71,38 @@ class UnitTestingClusterTestEventEvent ( private const val TAG_ARG5 = 5 private const val TAG_ARG6 = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestEventEvent { tlvReader.enterStructure(tlvTag) val arg1 = tlvReader.getUInt(ContextSpecificTag(TAG_ARG1)) val arg2 = tlvReader.getUInt(ContextSpecificTag(TAG_ARG2)) val arg3 = tlvReader.getBoolean(ContextSpecificTag(TAG_ARG3)) - val arg4 = chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_ARG4), tlvReader) - val arg5 = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) - while(!tlvReader.isEndOfContainer()) { - this.add(chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val arg6 = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val arg4 = + chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_ARG4), + tlvReader + ) + val arg5 = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) + while (!tlvReader.isEndOfContainer()) { + this.add( + chip.devicecontroller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + val arg6 = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterTestEventEvent(arg1, arg2, arg3, arg4, arg5, arg6) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt index b71c9c788a3a76..b6cc1c77125923 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterTestFabricScopedEventEvent ( - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class UnitTestingClusterTestFabricScopedEventEvent(val fabricIndex: UInt) { + override fun toString(): String = buildString { append("UnitTestingClusterTestFabricScopedEventEvent {\n") append("\tfabricIndex : $fabricIndex\n") append("}\n") @@ -45,10 +40,10 @@ class UnitTestingClusterTestFabricScopedEventEvent ( companion object { private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestFabricScopedEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScopedEventEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return UnitTestingClusterTestFabricScopedEventEvent(fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt index cead9f186377e2..cb432d975e1275 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ValveConfigurationAndControlClusterValveFaultEvent ( - val valveFault: UInt) { - override fun toString(): String = buildString { +class ValveConfigurationAndControlClusterValveFaultEvent(val valveFault: UInt) { + override fun toString(): String = buildString { append("ValveConfigurationAndControlClusterValveFaultEvent {\n") append("\tvalveFault : $valveFault\n") append("}\n") @@ -45,10 +40,13 @@ class ValveConfigurationAndControlClusterValveFaultEvent ( companion object { private const val TAG_VALVE_FAULT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveFaultEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ValveConfigurationAndControlClusterValveFaultEvent { tlvReader.enterStructure(tlvTag) val valveFault = tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_FAULT)) - + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveFaultEvent(valveFault) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt index d8714935057610..e34e14aee60c7d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ValveConfigurationAndControlClusterValveStateChangedEvent ( - val valveState: UInt, - val valveLevel: Optional) { - override fun toString(): String = buildString { +class ValveConfigurationAndControlClusterValveStateChangedEvent( + val valveState: UInt, + val valveLevel: Optional +) { + override fun toString(): String = buildString { append("ValveConfigurationAndControlClusterValveStateChangedEvent {\n") append("\tvalveState : $valveState\n") append("\tvalveLevel : $valveLevel\n") @@ -41,9 +39,9 @@ class ValveConfigurationAndControlClusterValveStateChangedEvent ( startStructure(tlvTag) put(ContextSpecificTag(TAG_VALVE_STATE), valveState) if (valveLevel.isPresent) { - val optvalveLevel = valveLevel.get() - put(ContextSpecificTag(TAG_VALVE_LEVEL), optvalveLevel) - } + val optvalveLevel = valveLevel.get() + put(ContextSpecificTag(TAG_VALVE_LEVEL), optvalveLevel) + } endStructure() } } @@ -52,15 +50,19 @@ class ValveConfigurationAndControlClusterValveStateChangedEvent ( private const val TAG_VALVE_STATE = 0 private const val TAG_VALVE_LEVEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveStateChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ValveConfigurationAndControlClusterValveStateChangedEvent { tlvReader.enterStructure(tlvTag) val valveState = tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_STATE)) - val valveLevel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_LEVEL))) - } else { - Optional.empty() - } - + val valveLevel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_VALVE_LEVEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveStateChangedEvent(valveState, valveLevel) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt index 353230c4664dc5..2f94dc8e6b1c58 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class WiFiNetworkDiagnosticsClusterAssociationFailureEvent ( - val associationFailureCause: UInt, - val status: UInt) { - override fun toString(): String = buildString { +class WiFiNetworkDiagnosticsClusterAssociationFailureEvent( + val associationFailureCause: UInt, + val status: UInt +) { + override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterAssociationFailureEvent {\n") append("\tassociationFailureCause : $associationFailureCause\n") append("\tstatus : $status\n") @@ -49,11 +46,15 @@ class WiFiNetworkDiagnosticsClusterAssociationFailureEvent ( private const val TAG_ASSOCIATION_FAILURE_CAUSE = 0 private const val TAG_STATUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterAssociationFailureEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterAssociationFailureEvent { tlvReader.enterStructure(tlvTag) - val associationFailureCause = tlvReader.getUInt(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) + val associationFailureCause = + tlvReader.getUInt(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) val status = tlvReader.getUInt(ContextSpecificTag(TAG_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterAssociationFailureEvent(associationFailureCause, status) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt index e106ddd9b7498d..34b126059fffd2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class WiFiNetworkDiagnosticsClusterConnectionStatusEvent ( - val connectionStatus: UInt) { - override fun toString(): String = buildString { +class WiFiNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UInt) { + override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") append("}\n") @@ -45,10 +40,13 @@ class WiFiNetworkDiagnosticsClusterConnectionStatusEvent ( companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUInt(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt index 33cb99c03f48a2..9c0875da20a177 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.eventstructs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class WiFiNetworkDiagnosticsClusterDisconnectionEvent ( - val reasonCode: UInt) { - override fun toString(): String = buildString { +class WiFiNetworkDiagnosticsClusterDisconnectionEvent(val reasonCode: UInt) { + override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterDisconnectionEvent {\n") append("\treasonCode : $reasonCode\n") append("}\n") @@ -45,10 +40,13 @@ class WiFiNetworkDiagnosticsClusterDisconnectionEvent ( companion object { private const val TAG_REASON_CODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterDisconnectionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterDisconnectionEvent { tlvReader.enterStructure(tlvTag) val reasonCode = tlvReader.getUInt(ContextSpecificTag(TAG_REASON_CODE)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterDisconnectionEvent(reasonCode) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt index d228ef19fb8e79..ad7257cc39f901 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt @@ -20,19 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccessControlClusterAccessControlEntryStruct ( - val privilege: UInt, - val authMode: UInt, - val subjects: List?, - val targets: List?, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class AccessControlClusterAccessControlEntryStruct( + val privilege: UInt, + val authMode: UInt, + val subjects: List?, + val targets: List?, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlEntryStruct {\n") append("\tprivilege : $privilege\n") append("\tauthMode : $authMode\n") @@ -48,23 +46,23 @@ class AccessControlClusterAccessControlEntryStruct ( put(ContextSpecificTag(TAG_PRIVILEGE), privilege) put(ContextSpecificTag(TAG_AUTH_MODE), authMode) if (subjects != null) { - startArray(ContextSpecificTag(TAG_SUBJECTS)) - for (item in subjects.iterator()) { - put(AnonymousTag, item) + startArray(ContextSpecificTag(TAG_SUBJECTS)) + for (item in subjects.iterator()) { + put(AnonymousTag, item) + } + endArray() + } else { + putNull(ContextSpecificTag(TAG_SUBJECTS)) } - endArray() - } else { - putNull(ContextSpecificTag(TAG_SUBJECTS)) - } if (targets != null) { - startArray(ContextSpecificTag(TAG_TARGETS)) - for (item in targets.iterator()) { - item.toTlv(AnonymousTag, this) + startArray(ContextSpecificTag(TAG_TARGETS)) + for (item in targets.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } else { + putNull(ContextSpecificTag(TAG_TARGETS)) } - endArray() - } else { - putNull(ContextSpecificTag(TAG_TARGETS)) - } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -77,39 +75,47 @@ class AccessControlClusterAccessControlEntryStruct ( private const val TAG_TARGETS = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlEntryStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlEntryStruct { tlvReader.enterStructure(tlvTag) val privilege = tlvReader.getUInt(ContextSpecificTag(TAG_PRIVILEGE)) val authMode = tlvReader.getUInt(ContextSpecificTag(TAG_AUTH_MODE)) - val subjects = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getULong(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) - null - } - val targets = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) - null - } + val subjects = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getULong(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) + null + } + val targets = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryStruct(privilege, authMode, subjects, targets, fabricIndex) + return AccessControlClusterAccessControlEntryStruct( + privilege, + authMode, + subjects, + targets, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt index b41ebafd9de72a..c75c7632f06be3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccessControlClusterAccessControlExtensionStruct ( - val data: ByteArray, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class AccessControlClusterAccessControlExtensionStruct(val data: ByteArray, val fabricIndex: UInt) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlExtensionStruct {\n") append("\tdata : $data\n") append("\tfabricIndex : $fabricIndex\n") @@ -49,11 +43,14 @@ class AccessControlClusterAccessControlExtensionStruct ( private const val TAG_DATA = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlExtensionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlExtensionStruct { tlvReader.enterStructure(tlvTag) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return AccessControlClusterAccessControlExtensionStruct(data, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt index 1eab00f450d8f0..5fb4de109d6c6a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AccessControlClusterAccessControlTargetStruct ( - val cluster: ULong?, - val endpoint: UInt?, - val deviceType: ULong?) { - override fun toString(): String = buildString { +class AccessControlClusterAccessControlTargetStruct( + val cluster: ULong?, + val endpoint: UInt?, + val deviceType: ULong? +) { + override fun toString(): String = buildString { append("AccessControlClusterAccessControlTargetStruct {\n") append("\tcluster : $cluster\n") append("\tendpoint : $endpoint\n") @@ -42,20 +39,20 @@ class AccessControlClusterAccessControlTargetStruct ( tlvWriter.apply { startStructure(tlvTag) if (cluster != null) { - put(ContextSpecificTag(TAG_CLUSTER), cluster) - } else { - putNull(ContextSpecificTag(TAG_CLUSTER)) - } + put(ContextSpecificTag(TAG_CLUSTER), cluster) + } else { + putNull(ContextSpecificTag(TAG_CLUSTER)) + } if (endpoint != null) { - put(ContextSpecificTag(TAG_ENDPOINT), endpoint) - } else { - putNull(ContextSpecificTag(TAG_ENDPOINT)) - } + put(ContextSpecificTag(TAG_ENDPOINT), endpoint) + } else { + putNull(ContextSpecificTag(TAG_ENDPOINT)) + } if (deviceType != null) { - put(ContextSpecificTag(TAG_DEVICE_TYPE), deviceType) - } else { - putNull(ContextSpecificTag(TAG_DEVICE_TYPE)) - } + put(ContextSpecificTag(TAG_DEVICE_TYPE), deviceType) + } else { + putNull(ContextSpecificTag(TAG_DEVICE_TYPE)) + } endStructure() } } @@ -65,27 +62,30 @@ class AccessControlClusterAccessControlTargetStruct ( private const val TAG_ENDPOINT = 1 private const val TAG_DEVICE_TYPE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlTargetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlTargetStruct { tlvReader.enterStructure(tlvTag) - val cluster = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) - null - } - val endpoint = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) - null - } - val deviceType = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_TYPE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) - null - } - + val cluster = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) + null + } + val endpoint = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) + null + } + val deviceType = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_TYPE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) + null + } + tlvReader.exitContainer() return AccessControlClusterAccessControlTargetStruct(cluster, endpoint, deviceType) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt index 8ae474f8e727db..5d5c21a6906968 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterActionStruct.kt @@ -17,23 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ActionsClusterActionStruct ( - val actionID: UInt, - val name: String, - val type: UInt, - val endpointListID: UInt, - val supportedCommands: UInt, - val state: UInt) { - override fun toString(): String = buildString { +class ActionsClusterActionStruct( + val actionID: UInt, + val name: String, + val type: UInt, + val endpointListID: UInt, + val supportedCommands: UInt, + val state: UInt +) { + override fun toString(): String = buildString { append("ActionsClusterActionStruct {\n") append("\tactionID : $actionID\n") append("\tname : $name\n") @@ -65,7 +62,7 @@ class ActionsClusterActionStruct ( private const val TAG_SUPPORTED_COMMANDS = 4 private const val TAG_STATE = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterActionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterActionStruct { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUInt(ContextSpecificTag(TAG_ACTION_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) @@ -73,10 +70,17 @@ class ActionsClusterActionStruct ( val endpointListID = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val supportedCommands = tlvReader.getUInt(ContextSpecificTag(TAG_SUPPORTED_COMMANDS)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) - + tlvReader.exitContainer() - return ActionsClusterActionStruct(actionID, name, type, endpointListID, supportedCommands, state) + return ActionsClusterActionStruct( + actionID, + name, + type, + endpointListID, + supportedCommands, + state + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt index a8f078a4ba75c6..d5716531a18c99 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActionsClusterEndpointListStruct.kt @@ -20,18 +20,16 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ActionsClusterEndpointListStruct ( - val endpointListID: UInt, - val name: String, - val type: UInt, - val endpoints: List) { - override fun toString(): String = buildString { +class ActionsClusterEndpointListStruct( + val endpointListID: UInt, + val name: String, + val type: UInt, + val endpoints: List +) { + override fun toString(): String = buildString { append("ActionsClusterEndpointListStruct {\n") append("\tendpointListID : $endpointListID\n") append("\tname : $name\n") @@ -61,19 +59,20 @@ class ActionsClusterEndpointListStruct ( private const val TAG_TYPE = 2 private const val TAG_ENDPOINTS = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterEndpointListStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterEndpointListStruct { tlvReader.enterStructure(tlvTag) val endpointListID = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) - val endpoints = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val endpoints = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ActionsClusterEndpointListStruct(endpointListID, name, type, endpoints) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt index fa41e784da11de..138571f0342bb8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct ( - val productIdentifierType: UInt, - val productIdentifierValue: String) { - override fun toString(): String = buildString { +class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( + val productIdentifierType: UInt, + val productIdentifierValue: String +) { + override fun toString(): String = buildString { append("ActivatedCarbonFilterMonitoringClusterReplacementProductStruct {\n") append("\tproductIdentifierType : $productIdentifierType\n") append("\tproductIdentifierValue : $productIdentifierValue\n") @@ -49,14 +46,21 @@ class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct ( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) val productIdentifierType = tlvReader.getUInt(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierValue = + tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) + return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( + productIdentifierType, + productIdentifierValue + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt index f052c51f03c144..1fb108656c7973 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ApplicationBasicClusterApplicationStruct ( - val catalogVendorID: UInt, - val applicationID: String) { - override fun toString(): String = buildString { +class ApplicationBasicClusterApplicationStruct( + val catalogVendorID: UInt, + val applicationID: String +) { + override fun toString(): String = buildString { append("ApplicationBasicClusterApplicationStruct {\n") append("\tcatalogVendorID : $catalogVendorID\n") append("\tapplicationID : $applicationID\n") @@ -49,11 +46,11 @@ class ApplicationBasicClusterApplicationStruct ( private const val TAG_CATALOG_VENDOR_I_D = 0 private const val TAG_APPLICATION_I_D = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ApplicationBasicClusterApplicationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationBasicClusterApplicationStruct { tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUInt(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationBasicClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt index 89f372803fe317..ea33f81faaf3e0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ApplicationLauncherClusterApplicationEPStruct ( - val application: ApplicationLauncherClusterApplicationStruct, - val endpoint: Optional) { - override fun toString(): String = buildString { +class ApplicationLauncherClusterApplicationEPStruct( + val application: ApplicationLauncherClusterApplicationStruct, + val endpoint: Optional +) { + override fun toString(): String = buildString { append("ApplicationLauncherClusterApplicationEPStruct {\n") append("\tapplication : $application\n") append("\tendpoint : $endpoint\n") @@ -41,9 +39,9 @@ class ApplicationLauncherClusterApplicationEPStruct ( startStructure(tlvTag) application.toTlv(ContextSpecificTag(TAG_APPLICATION), this) if (endpoint.isPresent) { - val optendpoint = endpoint.get() - put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) - } + val optendpoint = endpoint.get() + put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) + } endStructure() } } @@ -52,15 +50,20 @@ class ApplicationLauncherClusterApplicationEPStruct ( private const val TAG_APPLICATION = 0 private const val TAG_ENDPOINT = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ApplicationLauncherClusterApplicationEPStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationLauncherClusterApplicationEPStruct { tlvReader.enterStructure(tlvTag) - val application = ApplicationLauncherClusterApplicationStruct.fromTlv(ContextSpecificTag(TAG_APPLICATION), tlvReader) - val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - + val application = + ApplicationLauncherClusterApplicationStruct.fromTlv( + ContextSpecificTag(TAG_APPLICATION), + tlvReader + ) + val endpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationEPStruct(application, endpoint) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt index b306cbca62125a..c7ec51b47dfb4b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ApplicationLauncherClusterApplicationStruct ( - val catalogVendorID: UInt, - val applicationID: String) { - override fun toString(): String = buildString { +class ApplicationLauncherClusterApplicationStruct( + val catalogVendorID: UInt, + val applicationID: String +) { + override fun toString(): String = buildString { append("ApplicationLauncherClusterApplicationStruct {\n") append("\tcatalogVendorID : $catalogVendorID\n") append("\tapplicationID : $applicationID\n") @@ -49,11 +46,11 @@ class ApplicationLauncherClusterApplicationStruct ( private const val TAG_CATALOG_VENDOR_I_D = 0 private const val TAG_APPLICATION_I_D = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ApplicationLauncherClusterApplicationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationLauncherClusterApplicationStruct { tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUInt(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt index 60726ce82d5c56..6336549e45a0bc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt @@ -17,20 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class AudioOutputClusterOutputInfoStruct ( - val index: UInt, - val outputType: UInt, - val name: String) { - override fun toString(): String = buildString { +class AudioOutputClusterOutputInfoStruct(val index: UInt, val outputType: UInt, val name: String) { + override fun toString(): String = buildString { append("AudioOutputClusterOutputInfoStruct {\n") append("\tindex : $index\n") append("\toutputType : $outputType\n") @@ -53,12 +46,12 @@ class AudioOutputClusterOutputInfoStruct ( private const val TAG_OUTPUT_TYPE = 1 private const val TAG_NAME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AudioOutputClusterOutputInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AudioOutputClusterOutputInfoStruct { tlvReader.enterStructure(tlvTag) val index = tlvReader.getUInt(ContextSpecificTag(TAG_INDEX)) val outputType = tlvReader.getUInt(ContextSpecificTag(TAG_OUTPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return AudioOutputClusterOutputInfoStruct(index, outputType, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt index 494c946f40b998..d79225dd61468e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BasicInformationClusterCapabilityMinimaStruct ( - val caseSessionsPerFabric: UInt, - val subscriptionsPerFabric: UInt) { - override fun toString(): String = buildString { +class BasicInformationClusterCapabilityMinimaStruct( + val caseSessionsPerFabric: UInt, + val subscriptionsPerFabric: UInt +) { + override fun toString(): String = buildString { append("BasicInformationClusterCapabilityMinimaStruct {\n") append("\tcaseSessionsPerFabric : $caseSessionsPerFabric\n") append("\tsubscriptionsPerFabric : $subscriptionsPerFabric\n") @@ -49,14 +46,19 @@ class BasicInformationClusterCapabilityMinimaStruct ( private const val TAG_CASE_SESSIONS_PER_FABRIC = 0 private const val TAG_SUBSCRIPTIONS_PER_FABRIC = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterCapabilityMinimaStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterCapabilityMinimaStruct { tlvReader.enterStructure(tlvTag) - val caseSessionsPerFabric = tlvReader.getUInt(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) - val subscriptionsPerFabric = tlvReader.getUInt(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) - + val caseSessionsPerFabric = + tlvReader.getUInt(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) + val subscriptionsPerFabric = + tlvReader.getUInt(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) + tlvReader.exitContainer() - return BasicInformationClusterCapabilityMinimaStruct(caseSessionsPerFabric, subscriptionsPerFabric) + return BasicInformationClusterCapabilityMinimaStruct( + caseSessionsPerFabric, + subscriptionsPerFabric + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt index 44f42edb6adf2d..5a0eb3ace2ef7b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BasicInformationClusterProductAppearanceStruct ( - val finish: UInt, - val primaryColor: UInt?) { - override fun toString(): String = buildString { +class BasicInformationClusterProductAppearanceStruct(val finish: UInt, val primaryColor: UInt?) { + override fun toString(): String = buildString { append("BasicInformationClusterProductAppearanceStruct {\n") append("\tfinish : $finish\n") append("\tprimaryColor : $primaryColor\n") @@ -41,10 +35,10 @@ class BasicInformationClusterProductAppearanceStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_FINISH), finish) if (primaryColor != null) { - put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) - } else { - putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } + put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) + } else { + putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } endStructure() } } @@ -53,16 +47,17 @@ class BasicInformationClusterProductAppearanceStruct ( private const val TAG_FINISH = 0 private const val TAG_PRIMARY_COLOR = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterProductAppearanceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUInt(ContextSpecificTag(TAG_FINISH)) - val primaryColor = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt index 9454790cb7ac05..70c8deedaaaf6a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BindingClusterTargetStruct.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BindingClusterTargetStruct ( - val node: Optional, - val group: Optional, - val endpoint: Optional, - val cluster: Optional, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class BindingClusterTargetStruct( + val node: Optional, + val group: Optional, + val endpoint: Optional, + val cluster: Optional, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("BindingClusterTargetStruct {\n") append("\tnode : $node\n") append("\tgroup : $group\n") @@ -46,21 +44,21 @@ class BindingClusterTargetStruct ( tlvWriter.apply { startStructure(tlvTag) if (node.isPresent) { - val optnode = node.get() - put(ContextSpecificTag(TAG_NODE), optnode) - } + val optnode = node.get() + put(ContextSpecificTag(TAG_NODE), optnode) + } if (group.isPresent) { - val optgroup = group.get() - put(ContextSpecificTag(TAG_GROUP), optgroup) - } + val optgroup = group.get() + put(ContextSpecificTag(TAG_GROUP), optgroup) + } if (endpoint.isPresent) { - val optendpoint = endpoint.get() - put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) - } + val optendpoint = endpoint.get() + put(ContextSpecificTag(TAG_ENDPOINT), optendpoint) + } if (cluster.isPresent) { - val optcluster = cluster.get() - put(ContextSpecificTag(TAG_CLUSTER), optcluster) - } + val optcluster = cluster.get() + put(ContextSpecificTag(TAG_CLUSTER), optcluster) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -73,30 +71,34 @@ class BindingClusterTargetStruct ( private const val TAG_CLUSTER = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BindingClusterTargetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BindingClusterTargetStruct { tlvReader.enterStructure(tlvTag) - val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - val group = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_GROUP))) - } else { - Optional.empty() - } - val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - val cluster = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER))) - } else { - Optional.empty() - } + val node = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + val group = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_GROUP))) + } else { + Optional.empty() + } + val endpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + val cluster = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BindingClusterTargetStruct(node, group, endpoint, cluster, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt index 6f548b1a015b9c..ec2d58aa588cea 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class BridgedDeviceBasicInformationClusterProductAppearanceStruct ( - val finish: UInt, - val primaryColor: UInt?) { - override fun toString(): String = buildString { +class BridgedDeviceBasicInformationClusterProductAppearanceStruct( + val finish: UInt, + val primaryColor: UInt? +) { + override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterProductAppearanceStruct {\n") append("\tfinish : $finish\n") append("\tprimaryColor : $primaryColor\n") @@ -41,10 +38,10 @@ class BridgedDeviceBasicInformationClusterProductAppearanceStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_FINISH), finish) if (primaryColor != null) { - put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) - } else { - putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } + put(ContextSpecificTag(TAG_PRIMARY_COLOR), primaryColor) + } else { + putNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } endStructure() } } @@ -53,16 +50,20 @@ class BridgedDeviceBasicInformationClusterProductAppearanceStruct ( private const val TAG_FINISH = 0 private const val TAG_PRIMARY_COLOR = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterProductAppearanceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUInt(ContextSpecificTag(TAG_FINISH)) - val primaryColor = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt index 9fe7d172bf4551..082ea9c5debbbc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterAdditionalInfoStruct ( - val name: String, - val value: String) { - override fun toString(): String = buildString { +class ChannelClusterAdditionalInfoStruct(val name: String, val value: String) { + override fun toString(): String = buildString { append("ChannelClusterAdditionalInfoStruct {\n") append("\tname : $name\n") append("\tvalue : $value\n") @@ -49,11 +43,11 @@ class ChannelClusterAdditionalInfoStruct ( private const val TAG_NAME = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterAdditionalInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterAdditionalInfoStruct { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ChannelClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt index a72550236ad007..deb76c4fb0791c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelInfoStruct.kt @@ -17,24 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterChannelInfoStruct ( - val majorNumber: UInt, - val minorNumber: UInt, - val name: Optional, - val callSign: Optional, - val affiliateCallSign: Optional, - val identifier: Optional, - val type: Optional) { - override fun toString(): String = buildString { +class ChannelClusterChannelInfoStruct( + val majorNumber: UInt, + val minorNumber: UInt, + val name: Optional, + val callSign: Optional, + val affiliateCallSign: Optional, + val identifier: Optional, + val type: Optional +) { + override fun toString(): String = buildString { append("ChannelClusterChannelInfoStruct {\n") append("\tmajorNumber : $majorNumber\n") append("\tminorNumber : $minorNumber\n") @@ -52,25 +50,25 @@ class ChannelClusterChannelInfoStruct ( put(ContextSpecificTag(TAG_MAJOR_NUMBER), majorNumber) put(ContextSpecificTag(TAG_MINOR_NUMBER), minorNumber) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (callSign.isPresent) { - val optcallSign = callSign.get() - put(ContextSpecificTag(TAG_CALL_SIGN), optcallSign) - } + val optcallSign = callSign.get() + put(ContextSpecificTag(TAG_CALL_SIGN), optcallSign) + } if (affiliateCallSign.isPresent) { - val optaffiliateCallSign = affiliateCallSign.get() - put(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN), optaffiliateCallSign) - } + val optaffiliateCallSign = affiliateCallSign.get() + put(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN), optaffiliateCallSign) + } if (identifier.isPresent) { - val optidentifier = identifier.get() - put(ContextSpecificTag(TAG_IDENTIFIER), optidentifier) - } + val optidentifier = identifier.get() + put(ContextSpecificTag(TAG_IDENTIFIER), optidentifier) + } if (type.isPresent) { - val opttype = type.get() - put(ContextSpecificTag(TAG_TYPE), opttype) - } + val opttype = type.get() + put(ContextSpecificTag(TAG_TYPE), opttype) + } endStructure() } } @@ -84,39 +82,52 @@ class ChannelClusterChannelInfoStruct ( private const val TAG_IDENTIFIER = 5 private const val TAG_TYPE = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterChannelInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterChannelInfoStruct { tlvReader.enterStructure(tlvTag) val majorNumber = tlvReader.getUInt(ContextSpecificTag(TAG_MAJOR_NUMBER)) val minorNumber = tlvReader.getUInt(ContextSpecificTag(TAG_MINOR_NUMBER)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val callSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) - } else { - Optional.empty() - } - val affiliateCallSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) - } else { - Optional.empty() - } - val identifier = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) - } else { - Optional.empty() - } - val type = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TYPE))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val callSign = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) + } else { + Optional.empty() + } + val affiliateCallSign = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) + } else { + Optional.empty() + } + val identifier = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) + } else { + Optional.empty() + } + val type = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TYPE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterChannelInfoStruct(majorNumber, minorNumber, name, callSign, affiliateCallSign, identifier, type) + return ChannelClusterChannelInfoStruct( + majorNumber, + minorNumber, + name, + callSign, + affiliateCallSign, + identifier, + type + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt index 936bdfd02a603b..64b035d2b02583 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterChannelPagingStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterChannelPagingStruct ( - val previousToken: Optional?, - val nextToken: Optional?) { - override fun toString(): String = buildString { +class ChannelClusterChannelPagingStruct( + val previousToken: Optional?, + val nextToken: Optional? +) { + override fun toString(): String = buildString { append("ChannelClusterChannelPagingStruct {\n") append("\tpreviousToken : $previousToken\n") append("\tnextToken : $nextToken\n") @@ -40,21 +38,21 @@ class ChannelClusterChannelPagingStruct ( tlvWriter.apply { startStructure(tlvTag) if (previousToken != null) { - if (previousToken.isPresent) { - val optpreviousToken = previousToken.get() - optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) - } - } else { - putNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) - } + if (previousToken.isPresent) { + val optpreviousToken = previousToken.get() + optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) + } + } else { + putNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) + } if (nextToken != null) { - if (nextToken.isPresent) { - val optnextToken = nextToken.get() - optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) - } - } else { - putNull(ContextSpecificTag(TAG_NEXT_TOKEN)) - } + if (nextToken.isPresent) { + val optnextToken = nextToken.get() + optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) + } + } else { + putNull(ContextSpecificTag(TAG_NEXT_TOKEN)) + } endStructure() } } @@ -63,29 +61,38 @@ class ChannelClusterChannelPagingStruct ( private const val TAG_PREVIOUS_TOKEN = 0 private const val TAG_NEXT_TOKEN = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterChannelPagingStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterChannelPagingStruct { tlvReader.enterStructure(tlvTag) - val previousToken = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { - Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) - null - } - val nextToken = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { - Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) - null - } - + val previousToken = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { + Optional.of( + ChannelClusterPageTokenStruct.fromTlv( + ContextSpecificTag(TAG_PREVIOUS_TOKEN), + tlvReader + ) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) + null + } + val nextToken = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { + Optional.of( + ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) + null + } + tlvReader.exitContainer() return ChannelClusterChannelPagingStruct(previousToken, nextToken) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt index 357509b7e3eb70..d205e89f966bae 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterLineupInfoStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterLineupInfoStruct ( - val operatorName: String, - val lineupName: Optional, - val postalCode: Optional, - val lineupInfoType: UInt) { - override fun toString(): String = buildString { +class ChannelClusterLineupInfoStruct( + val operatorName: String, + val lineupName: Optional, + val postalCode: Optional, + val lineupInfoType: UInt +) { + override fun toString(): String = buildString { append("ChannelClusterLineupInfoStruct {\n") append("\toperatorName : $operatorName\n") append("\tlineupName : $lineupName\n") @@ -45,13 +43,13 @@ class ChannelClusterLineupInfoStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATOR_NAME), operatorName) if (lineupName.isPresent) { - val optlineupName = lineupName.get() - put(ContextSpecificTag(TAG_LINEUP_NAME), optlineupName) - } + val optlineupName = lineupName.get() + put(ContextSpecificTag(TAG_LINEUP_NAME), optlineupName) + } if (postalCode.isPresent) { - val optpostalCode = postalCode.get() - put(ContextSpecificTag(TAG_POSTAL_CODE), optpostalCode) - } + val optpostalCode = postalCode.get() + put(ContextSpecificTag(TAG_POSTAL_CODE), optpostalCode) + } put(ContextSpecificTag(TAG_LINEUP_INFO_TYPE), lineupInfoType) endStructure() } @@ -63,21 +61,23 @@ class ChannelClusterLineupInfoStruct ( private const val TAG_POSTAL_CODE = 2 private const val TAG_LINEUP_INFO_TYPE = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterLineupInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterLineupInfoStruct { tlvReader.enterStructure(tlvTag) val operatorName = tlvReader.getString(ContextSpecificTag(TAG_OPERATOR_NAME)) - val lineupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) - } else { - Optional.empty() - } - val postalCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) - } else { - Optional.empty() - } + val lineupName = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) + } else { + Optional.empty() + } + val postalCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) + } else { + Optional.empty() + } val lineupInfoType = tlvReader.getUInt(ContextSpecificTag(TAG_LINEUP_INFO_TYPE)) - + tlvReader.exitContainer() return ChannelClusterLineupInfoStruct(operatorName, lineupName, postalCode, lineupInfoType) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt index 73639a9681a7b3..18e92f157a24d4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterPageTokenStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterPageTokenStruct ( - val limit: Optional, - val after: Optional, - val before: Optional) { - override fun toString(): String = buildString { +class ChannelClusterPageTokenStruct( + val limit: Optional, + val after: Optional, + val before: Optional +) { + override fun toString(): String = buildString { append("ChannelClusterPageTokenStruct {\n") append("\tlimit : $limit\n") append("\tafter : $after\n") @@ -42,17 +40,17 @@ class ChannelClusterPageTokenStruct ( tlvWriter.apply { startStructure(tlvTag) if (limit.isPresent) { - val optlimit = limit.get() - put(ContextSpecificTag(TAG_LIMIT), optlimit) - } + val optlimit = limit.get() + put(ContextSpecificTag(TAG_LIMIT), optlimit) + } if (after.isPresent) { - val optafter = after.get() - put(ContextSpecificTag(TAG_AFTER), optafter) - } + val optafter = after.get() + put(ContextSpecificTag(TAG_AFTER), optafter) + } if (before.isPresent) { - val optbefore = before.get() - put(ContextSpecificTag(TAG_BEFORE), optbefore) - } + val optbefore = before.get() + put(ContextSpecificTag(TAG_BEFORE), optbefore) + } endStructure() } } @@ -62,24 +60,27 @@ class ChannelClusterPageTokenStruct ( private const val TAG_AFTER = 1 private const val TAG_BEFORE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterPageTokenStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterPageTokenStruct { tlvReader.enterStructure(tlvTag) - val limit = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LIMIT))) - } else { - Optional.empty() - } - val after = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) - } else { - Optional.empty() - } - val before = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) - } else { - Optional.empty() - } - + val limit = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LIMIT))) + } else { + Optional.empty() + } + val after = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) + } else { + Optional.empty() + } + val before = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterPageTokenStruct(limit, after, before) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt index 5d03551b82d852..b11edabf62f0b0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCastStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterProgramCastStruct ( - val name: String, - val role: String) { - override fun toString(): String = buildString { +class ChannelClusterProgramCastStruct(val name: String, val role: String) { + override fun toString(): String = buildString { append("ChannelClusterProgramCastStruct {\n") append("\tname : $name\n") append("\trole : $role\n") @@ -49,11 +43,11 @@ class ChannelClusterProgramCastStruct ( private const val TAG_NAME = 0 private const val TAG_ROLE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterProgramCastStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramCastStruct { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val role = tlvReader.getString(ContextSpecificTag(TAG_ROLE)) - + tlvReader.exitContainer() return ChannelClusterProgramCastStruct(name, role) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt index 66800400ce15bb..d22742f8be42c5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramCategoryStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterProgramCategoryStruct ( - val category: String, - val subCategory: Optional) { - override fun toString(): String = buildString { +class ChannelClusterProgramCategoryStruct(val category: String, val subCategory: Optional) { + override fun toString(): String = buildString { append("ChannelClusterProgramCategoryStruct {\n") append("\tcategory : $category\n") append("\tsubCategory : $subCategory\n") @@ -41,9 +36,9 @@ class ChannelClusterProgramCategoryStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_CATEGORY), category) if (subCategory.isPresent) { - val optsubCategory = subCategory.get() - put(ContextSpecificTag(TAG_SUB_CATEGORY), optsubCategory) - } + val optsubCategory = subCategory.get() + put(ContextSpecificTag(TAG_SUB_CATEGORY), optsubCategory) + } endStructure() } } @@ -52,15 +47,16 @@ class ChannelClusterProgramCategoryStruct ( private const val TAG_CATEGORY = 0 private const val TAG_SUB_CATEGORY = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterProgramCategoryStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramCategoryStruct { tlvReader.enterStructure(tlvTag) val category = tlvReader.getString(ContextSpecificTag(TAG_CATEGORY)) - val subCategory = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) - } else { - Optional.empty() - } - + val subCategory = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterProgramCategoryStruct(category, subCategory) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt index 82c4ab33b445ed..5f5a7e48d1b8dc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterProgramStruct.kt @@ -17,36 +17,35 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterProgramStruct ( - val identifier: String, - val channel: ChannelClusterChannelInfoStruct, - val startTime: ULong, - val endTime: ULong, - val title: String, - val subtitle: Optional, - val description: Optional, - val audioLanguages: Optional>, - val ratings: Optional>, - val thumbnailUrl: Optional, - val posterArtUrl: Optional, - val dvbiUrl: Optional, - val releaseDate: Optional, - val parentalGuidanceText: Optional, - val recordingFlag: Optional, - val seriesInfo: Optional?, - val categoryList: Optional>, - val castList: Optional>, - val externalIDList: Optional>) { - override fun toString(): String = buildString { +class ChannelClusterProgramStruct( + val identifier: String, + val channel: ChannelClusterChannelInfoStruct, + val startTime: ULong, + val endTime: ULong, + val title: String, + val subtitle: Optional, + val description: Optional, + val audioLanguages: Optional>, + val ratings: Optional>, + val thumbnailUrl: Optional, + val posterArtUrl: Optional, + val dvbiUrl: Optional, + val releaseDate: Optional, + val parentalGuidanceText: Optional, + val recordingFlag: Optional, + val seriesInfo: Optional?, + val categoryList: Optional>, + val castList: Optional>, + val externalIDList: Optional> +) { + override fun toString(): String = buildString { append("ChannelClusterProgramStruct {\n") append("\tidentifier : $identifier\n") append("\tchannel : $channel\n") @@ -79,85 +78,85 @@ class ChannelClusterProgramStruct ( put(ContextSpecificTag(TAG_END_TIME), endTime) put(ContextSpecificTag(TAG_TITLE), title) if (subtitle.isPresent) { - val optsubtitle = subtitle.get() - put(ContextSpecificTag(TAG_SUBTITLE), optsubtitle) - } + val optsubtitle = subtitle.get() + put(ContextSpecificTag(TAG_SUBTITLE), optsubtitle) + } if (description.isPresent) { - val optdescription = description.get() - put(ContextSpecificTag(TAG_DESCRIPTION), optdescription) - } + val optdescription = description.get() + put(ContextSpecificTag(TAG_DESCRIPTION), optdescription) + } if (audioLanguages.isPresent) { - val optaudioLanguages = audioLanguages.get() - startArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - for (item in optaudioLanguages.iterator()) { - put(AnonymousTag, item) + val optaudioLanguages = audioLanguages.get() + startArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) + for (item in optaudioLanguages.iterator()) { + put(AnonymousTag, item) + } + endArray() } - endArray() - } if (ratings.isPresent) { - val optratings = ratings.get() - startArray(ContextSpecificTag(TAG_RATINGS)) - for (item in optratings.iterator()) { - put(AnonymousTag, item) + val optratings = ratings.get() + startArray(ContextSpecificTag(TAG_RATINGS)) + for (item in optratings.iterator()) { + put(AnonymousTag, item) + } + endArray() } - endArray() - } if (thumbnailUrl.isPresent) { - val optthumbnailUrl = thumbnailUrl.get() - put(ContextSpecificTag(TAG_THUMBNAIL_URL), optthumbnailUrl) - } + val optthumbnailUrl = thumbnailUrl.get() + put(ContextSpecificTag(TAG_THUMBNAIL_URL), optthumbnailUrl) + } if (posterArtUrl.isPresent) { - val optposterArtUrl = posterArtUrl.get() - put(ContextSpecificTag(TAG_POSTER_ART_URL), optposterArtUrl) - } + val optposterArtUrl = posterArtUrl.get() + put(ContextSpecificTag(TAG_POSTER_ART_URL), optposterArtUrl) + } if (dvbiUrl.isPresent) { - val optdvbiUrl = dvbiUrl.get() - put(ContextSpecificTag(TAG_DVBI_URL), optdvbiUrl) - } + val optdvbiUrl = dvbiUrl.get() + put(ContextSpecificTag(TAG_DVBI_URL), optdvbiUrl) + } if (releaseDate.isPresent) { - val optreleaseDate = releaseDate.get() - put(ContextSpecificTag(TAG_RELEASE_DATE), optreleaseDate) - } + val optreleaseDate = releaseDate.get() + put(ContextSpecificTag(TAG_RELEASE_DATE), optreleaseDate) + } if (parentalGuidanceText.isPresent) { - val optparentalGuidanceText = parentalGuidanceText.get() - put(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT), optparentalGuidanceText) - } + val optparentalGuidanceText = parentalGuidanceText.get() + put(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT), optparentalGuidanceText) + } if (recordingFlag.isPresent) { - val optrecordingFlag = recordingFlag.get() - put(ContextSpecificTag(TAG_RECORDING_FLAG), optrecordingFlag) - } + val optrecordingFlag = recordingFlag.get() + put(ContextSpecificTag(TAG_RECORDING_FLAG), optrecordingFlag) + } if (seriesInfo != null) { - if (seriesInfo.isPresent) { - val optseriesInfo = seriesInfo.get() - optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) - } - } else { - putNull(ContextSpecificTag(TAG_SERIES_INFO)) - } + if (seriesInfo.isPresent) { + val optseriesInfo = seriesInfo.get() + optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) + } + } else { + putNull(ContextSpecificTag(TAG_SERIES_INFO)) + } if (categoryList.isPresent) { - val optcategoryList = categoryList.get() - startArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - for (item in optcategoryList.iterator()) { - item.toTlv(AnonymousTag, this) + val optcategoryList = categoryList.get() + startArray(ContextSpecificTag(TAG_CATEGORY_LIST)) + for (item in optcategoryList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } if (castList.isPresent) { - val optcastList = castList.get() - startArray(ContextSpecificTag(TAG_CAST_LIST)) - for (item in optcastList.iterator()) { - item.toTlv(AnonymousTag, this) + val optcastList = castList.get() + startArray(ContextSpecificTag(TAG_CAST_LIST)) + for (item in optcastList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } if (externalIDList.isPresent) { - val optexternalIDList = externalIDList.get() - startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) + val optexternalIDList = externalIDList.get() + startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } endStructure() } } @@ -183,122 +182,169 @@ class ChannelClusterProgramStruct ( private const val TAG_CAST_LIST = 17 private const val TAG_EXTERNAL_I_D_LIST = 18 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterProgramStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramStruct { tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER)) - val channel = ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) + val channel = + ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getULong(ContextSpecificTag(TAG_END_TIME)) val title = tlvReader.getString(ContextSpecificTag(TAG_TITLE)) - val subtitle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) - } else { - Optional.empty() - } - val description = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) - } else { - Optional.empty() - } - val audioLanguages = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val ratings = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val thumbnailUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) - } else { - Optional.empty() - } - val posterArtUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) - } else { - Optional.empty() - } - val dvbiUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) - } else { - Optional.empty() - } - val releaseDate = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) - } else { - Optional.empty() - } - val parentalGuidanceText = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) - } else { - Optional.empty() - } - val recordingFlag = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_RECORDING_FLAG))) - } else { - Optional.empty() - } - val seriesInfo = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { - Optional.of(ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) - null - } - val categoryList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val castList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val subtitle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) + } else { + Optional.empty() + } + val description = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) + } else { + Optional.empty() + } + val audioLanguages = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val ratings = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val thumbnailUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) + } else { + Optional.empty() + } + val posterArtUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) + } else { + Optional.empty() + } + val dvbiUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) + } else { + Optional.empty() + } + val releaseDate = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) + } else { + Optional.empty() + } + val parentalGuidanceText = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) + } else { + Optional.empty() + } + val recordingFlag = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_RECORDING_FLAG))) + } else { + Optional.empty() + } + val seriesInfo = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { + Optional.of( + ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) + null + } + val categoryList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val castList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val externalIDList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterProgramStruct(identifier, channel, startTime, endTime, title, subtitle, description, audioLanguages, ratings, thumbnailUrl, posterArtUrl, dvbiUrl, releaseDate, parentalGuidanceText, recordingFlag, seriesInfo, categoryList, castList, externalIDList) + return ChannelClusterProgramStruct( + identifier, + channel, + startTime, + endTime, + title, + subtitle, + description, + audioLanguages, + ratings, + thumbnailUrl, + posterArtUrl, + dvbiUrl, + releaseDate, + parentalGuidanceText, + recordingFlag, + seriesInfo, + categoryList, + castList, + externalIDList + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt index 93e49be4ae9eb0..eb06e3fe6dac2a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ChannelClusterSeriesInfoStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ChannelClusterSeriesInfoStruct ( - val season: String, - val episode: String) { - override fun toString(): String = buildString { +class ChannelClusterSeriesInfoStruct(val season: String, val episode: String) { + override fun toString(): String = buildString { append("ChannelClusterSeriesInfoStruct {\n") append("\tseason : $season\n") append("\tepisode : $episode\n") @@ -49,11 +43,11 @@ class ChannelClusterSeriesInfoStruct ( private const val TAG_SEASON = 0 private const val TAG_EPISODE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ChannelClusterSeriesInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterSeriesInfoStruct { tlvReader.enterStructure(tlvTag) val season = tlvReader.getString(ContextSpecificTag(TAG_SEASON)) val episode = tlvReader.getString(ContextSpecificTag(TAG_EPISODE)) - + tlvReader.exitContainer() return ChannelClusterSeriesInfoStruct(season, episode) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt index c1aab30b53c51f..c22158cb36c3bd 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentControlClusterRatingNameStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentControlClusterRatingNameStruct ( - val ratingName: String, - val ratingNameDesc: Optional) { - override fun toString(): String = buildString { +class ContentControlClusterRatingNameStruct( + val ratingName: String, + val ratingNameDesc: Optional +) { + override fun toString(): String = buildString { append("ContentControlClusterRatingNameStruct {\n") append("\tratingName : $ratingName\n") append("\tratingNameDesc : $ratingNameDesc\n") @@ -41,9 +39,9 @@ class ContentControlClusterRatingNameStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_RATING_NAME), ratingName) if (ratingNameDesc.isPresent) { - val optratingNameDesc = ratingNameDesc.get() - put(ContextSpecificTag(TAG_RATING_NAME_DESC), optratingNameDesc) - } + val optratingNameDesc = ratingNameDesc.get() + put(ContextSpecificTag(TAG_RATING_NAME_DESC), optratingNameDesc) + } endStructure() } } @@ -52,15 +50,16 @@ class ContentControlClusterRatingNameStruct ( private const val TAG_RATING_NAME = 0 private const val TAG_RATING_NAME_DESC = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentControlClusterRatingNameStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentControlClusterRatingNameStruct { tlvReader.enterStructure(tlvTag) val ratingName = tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME)) - val ratingNameDesc = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) - } else { - Optional.empty() - } - + val ratingNameDesc = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentControlClusterRatingNameStruct(ratingName, ratingNameDesc) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt index cdc41e36467d57..c9df652a2ca5a8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterAdditionalInfoStruct ( - val name: String, - val value: String) { - override fun toString(): String = buildString { +class ContentLauncherClusterAdditionalInfoStruct(val name: String, val value: String) { + override fun toString(): String = buildString { append("ContentLauncherClusterAdditionalInfoStruct {\n") append("\tname : $name\n") append("\tvalue : $value\n") @@ -49,11 +43,11 @@ class ContentLauncherClusterAdditionalInfoStruct ( private const val TAG_NAME = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterAdditionalInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterAdditionalInfoStruct { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ContentLauncherClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt index 56028fc4d11e93..5508763757c036 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt @@ -17,23 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterBrandingInformationStruct ( - val providerName: String, - val background: Optional, - val logo: Optional, - val progressBar: Optional, - val splash: Optional, - val waterMark: Optional) { - override fun toString(): String = buildString { +class ContentLauncherClusterBrandingInformationStruct( + val providerName: String, + val background: Optional, + val logo: Optional, + val progressBar: Optional, + val splash: Optional, + val waterMark: Optional +) { + override fun toString(): String = buildString { append("ContentLauncherClusterBrandingInformationStruct {\n") append("\tproviderName : $providerName\n") append("\tbackground : $background\n") @@ -49,25 +47,25 @@ class ContentLauncherClusterBrandingInformationStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_PROVIDER_NAME), providerName) if (background.isPresent) { - val optbackground = background.get() - optbackground.toTlv(ContextSpecificTag(TAG_BACKGROUND), this) - } + val optbackground = background.get() + optbackground.toTlv(ContextSpecificTag(TAG_BACKGROUND), this) + } if (logo.isPresent) { - val optlogo = logo.get() - optlogo.toTlv(ContextSpecificTag(TAG_LOGO), this) - } + val optlogo = logo.get() + optlogo.toTlv(ContextSpecificTag(TAG_LOGO), this) + } if (progressBar.isPresent) { - val optprogressBar = progressBar.get() - optprogressBar.toTlv(ContextSpecificTag(TAG_PROGRESS_BAR), this) - } + val optprogressBar = progressBar.get() + optprogressBar.toTlv(ContextSpecificTag(TAG_PROGRESS_BAR), this) + } if (splash.isPresent) { - val optsplash = splash.get() - optsplash.toTlv(ContextSpecificTag(TAG_SPLASH), this) - } + val optsplash = splash.get() + optsplash.toTlv(ContextSpecificTag(TAG_SPLASH), this) + } if (waterMark.isPresent) { - val optwaterMark = waterMark.get() - optwaterMark.toTlv(ContextSpecificTag(TAG_WATER_MARK), this) - } + val optwaterMark = waterMark.get() + optwaterMark.toTlv(ContextSpecificTag(TAG_WATER_MARK), this) + } endStructure() } } @@ -80,38 +78,78 @@ class ContentLauncherClusterBrandingInformationStruct ( private const val TAG_SPLASH = 4 private const val TAG_WATER_MARK = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterBrandingInformationStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ContentLauncherClusterBrandingInformationStruct { tlvReader.enterStructure(tlvTag) val providerName = tlvReader.getString(ContextSpecificTag(TAG_PROVIDER_NAME)) - val background = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_BACKGROUND), tlvReader)) - } else { - Optional.empty() - } - val logo = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_LOGO), tlvReader)) - } else { - Optional.empty() - } - val progressBar = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_PROGRESS_BAR), tlvReader)) - } else { - Optional.empty() - } - val splash = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_SPLASH), tlvReader)) - } else { - Optional.empty() - } - val waterMark = if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_WATER_MARK), tlvReader)) - } else { - Optional.empty() - } - + val background = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_BACKGROUND), + tlvReader + ) + ) + } else { + Optional.empty() + } + val logo = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_LOGO), + tlvReader + ) + ) + } else { + Optional.empty() + } + val progressBar = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_PROGRESS_BAR), + tlvReader + ) + ) + } else { + Optional.empty() + } + val splash = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_SPLASH), + tlvReader + ) + ) + } else { + Optional.empty() + } + val waterMark = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_WATER_MARK), + tlvReader + ) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterBrandingInformationStruct(providerName, background, logo, progressBar, splash, waterMark) + return ContentLauncherClusterBrandingInformationStruct( + providerName, + background, + logo, + progressBar, + splash, + waterMark + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt index 9f100e058c4305..fc1cfc5de7b014 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt @@ -20,15 +20,13 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterContentSearchStruct ( - val parameterList: List) { - override fun toString(): String = buildString { +class ContentLauncherClusterContentSearchStruct( + val parameterList: List +) { + override fun toString(): String = buildString { append("ContentLauncherClusterContentSearchStruct {\n") append("\tparameterList : $parameterList\n") append("}\n") @@ -49,16 +47,17 @@ class ContentLauncherClusterContentSearchStruct ( companion object { private const val TAG_PARAMETER_LIST = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterContentSearchStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterContentSearchStruct { tlvReader.enterStructure(tlvTag) - val parameterList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val parameterList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ContentLauncherClusterContentSearchStruct(parameterList) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt index 8c6fd83e614072..f00027d639958c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterDimensionStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterDimensionStruct ( - val width: Double, - val height: Double, - val metric: UInt) { - override fun toString(): String = buildString { +class ContentLauncherClusterDimensionStruct( + val width: Double, + val height: Double, + val metric: UInt +) { + override fun toString(): String = buildString { append("ContentLauncherClusterDimensionStruct {\n") append("\twidth : $width\n") append("\theight : $height\n") @@ -53,12 +50,12 @@ class ContentLauncherClusterDimensionStruct ( private const val TAG_HEIGHT = 1 private const val TAG_METRIC = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterDimensionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterDimensionStruct { tlvReader.enterStructure(tlvTag) val width = tlvReader.getDouble(ContextSpecificTag(TAG_WIDTH)) val height = tlvReader.getDouble(ContextSpecificTag(TAG_HEIGHT)) val metric = tlvReader.getUInt(ContextSpecificTag(TAG_METRIC)) - + tlvReader.exitContainer() return ContentLauncherClusterDimensionStruct(width, height, metric) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt index 0a547a665e8609..458fb5e7b29d9c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterParameterStruct.kt @@ -17,20 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterParameterStruct ( - val type: UInt, - val value: String, - val externalIDList: Optional>) { - override fun toString(): String = buildString { +class ContentLauncherClusterParameterStruct( + val type: UInt, + val value: String, + val externalIDList: Optional> +) { + override fun toString(): String = buildString { append("ContentLauncherClusterParameterStruct {\n") append("\ttype : $type\n") append("\tvalue : $value\n") @@ -44,13 +43,13 @@ class ContentLauncherClusterParameterStruct ( put(ContextSpecificTag(TAG_TYPE), type) put(ContextSpecificTag(TAG_VALUE), value) if (externalIDList.isPresent) { - val optexternalIDList = externalIDList.get() - startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) + val optexternalIDList = externalIDList.get() + startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } endStructure() } } @@ -60,22 +59,25 @@ class ContentLauncherClusterParameterStruct ( private const val TAG_VALUE = 1 private const val TAG_EXTERNAL_I_D_LIST = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterParameterStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterParameterStruct { tlvReader.enterStructure(tlvTag) val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val externalIDList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterParameterStruct(type, value, externalIDList) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt index 6ca30cceaac011..4199602517911f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt @@ -17,20 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterPlaybackPreferencesStruct ( - val playbackPosition: ULong, - val textTrack: ContentLauncherClusterTrackPreferenceStruct, - val audioTracks: Optional>) { - override fun toString(): String = buildString { +class ContentLauncherClusterPlaybackPreferencesStruct( + val playbackPosition: ULong, + val textTrack: ContentLauncherClusterTrackPreferenceStruct, + val audioTracks: Optional> +) { + override fun toString(): String = buildString { append("ContentLauncherClusterPlaybackPreferencesStruct {\n") append("\tplaybackPosition : $playbackPosition\n") append("\ttextTrack : $textTrack\n") @@ -44,13 +43,13 @@ class ContentLauncherClusterPlaybackPreferencesStruct ( put(ContextSpecificTag(TAG_PLAYBACK_POSITION), playbackPosition) textTrack.toTlv(ContextSpecificTag(TAG_TEXT_TRACK), this) if (audioTracks.isPresent) { - val optaudioTracks = audioTracks.get() - startArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - for (item in optaudioTracks.iterator()) { - item.toTlv(AnonymousTag, this) + val optaudioTracks = audioTracks.get() + startArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) + for (item in optaudioTracks.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } endStructure() } } @@ -60,25 +59,39 @@ class ContentLauncherClusterPlaybackPreferencesStruct ( private const val TAG_TEXT_TRACK = 1 private const val TAG_AUDIO_TRACKS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterPlaybackPreferencesStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ContentLauncherClusterPlaybackPreferencesStruct { tlvReader.enterStructure(tlvTag) val playbackPosition = tlvReader.getULong(ContextSpecificTag(TAG_PLAYBACK_POSITION)) - val textTrack = ContentLauncherClusterTrackPreferenceStruct.fromTlv(ContextSpecificTag(TAG_TEXT_TRACK), tlvReader) - val audioTracks = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val textTrack = + ContentLauncherClusterTrackPreferenceStruct.fromTlv( + ContextSpecificTag(TAG_TEXT_TRACK), + tlvReader + ) + val audioTracks = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterPlaybackPreferencesStruct(playbackPosition, textTrack, audioTracks) + return ContentLauncherClusterPlaybackPreferencesStruct( + playbackPosition, + textTrack, + audioTracks + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt index c5de0e5706eaea..9b34f59f3eefa6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterStyleInformationStruct ( - val imageURL: Optional, - val color: Optional, - val size: Optional) { - override fun toString(): String = buildString { +class ContentLauncherClusterStyleInformationStruct( + val imageURL: Optional, + val color: Optional, + val size: Optional +) { + override fun toString(): String = buildString { append("ContentLauncherClusterStyleInformationStruct {\n") append("\timageURL : $imageURL\n") append("\tcolor : $color\n") @@ -42,17 +40,17 @@ class ContentLauncherClusterStyleInformationStruct ( tlvWriter.apply { startStructure(tlvTag) if (imageURL.isPresent) { - val optimageURL = imageURL.get() - put(ContextSpecificTag(TAG_IMAGE_U_R_L), optimageURL) - } + val optimageURL = imageURL.get() + put(ContextSpecificTag(TAG_IMAGE_U_R_L), optimageURL) + } if (color.isPresent) { - val optcolor = color.get() - put(ContextSpecificTag(TAG_COLOR), optcolor) - } + val optcolor = color.get() + put(ContextSpecificTag(TAG_COLOR), optcolor) + } if (size.isPresent) { - val optsize = size.get() - optsize.toTlv(ContextSpecificTag(TAG_SIZE), this) - } + val optsize = size.get() + optsize.toTlv(ContextSpecificTag(TAG_SIZE), this) + } endStructure() } } @@ -62,24 +60,29 @@ class ContentLauncherClusterStyleInformationStruct ( private const val TAG_COLOR = 1 private const val TAG_SIZE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterStyleInformationStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterStyleInformationStruct { tlvReader.enterStructure(tlvTag) - val imageURL = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) - } else { - Optional.empty() - } - val color = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) - } else { - Optional.empty() - } - val size = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { - Optional.of(ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader)) - } else { - Optional.empty() - } - + val imageURL = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) + } else { + Optional.empty() + } + val color = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) + } else { + Optional.empty() + } + val size = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { + Optional.of( + ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterStyleInformationStruct(imageURL, color, size) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt index a1f60ee83fe421..d5a3e09a859f73 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt @@ -17,20 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ContentLauncherClusterTrackPreferenceStruct ( - val languageCode: String, - val characteristics: Optional>, - val audioOutputIndex: UInt) { - override fun toString(): String = buildString { +class ContentLauncherClusterTrackPreferenceStruct( + val languageCode: String, + val characteristics: Optional>, + val audioOutputIndex: UInt +) { + override fun toString(): String = buildString { append("ContentLauncherClusterTrackPreferenceStruct {\n") append("\tlanguageCode : $languageCode\n") append("\tcharacteristics : $characteristics\n") @@ -43,13 +42,13 @@ class ContentLauncherClusterTrackPreferenceStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_LANGUAGE_CODE), languageCode) if (characteristics.isPresent) { - val optcharacteristics = characteristics.get() - startArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - for (item in optcharacteristics.iterator()) { - put(AnonymousTag, item) + val optcharacteristics = characteristics.get() + startArray(ContextSpecificTag(TAG_CHARACTERISTICS)) + for (item in optcharacteristics.iterator()) { + put(AnonymousTag, item) + } + endArray() } - endArray() - } put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX), audioOutputIndex) endStructure() } @@ -60,25 +59,32 @@ class ContentLauncherClusterTrackPreferenceStruct ( private const val TAG_CHARACTERISTICS = 1 private const val TAG_AUDIO_OUTPUT_INDEX = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ContentLauncherClusterTrackPreferenceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterTrackPreferenceStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val characteristics = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } + val characteristics = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } val audioOutputIndex = tlvReader.getUInt(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX)) - + tlvReader.exitContainer() - return ContentLauncherClusterTrackPreferenceStruct(languageCode, characteristics, audioOutputIndex) + return ContentLauncherClusterTrackPreferenceStruct( + languageCode, + characteristics, + audioOutputIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt index 4357cf625ca244..a4dd7c659efb22 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterAverageLoadControlStruct ( - val loadAdjustment: Int) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterAverageLoadControlStruct(val loadAdjustment: Int) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterAverageLoadControlStruct {\n") append("\tloadAdjustment : $loadAdjustment\n") append("}\n") @@ -45,10 +40,13 @@ class DemandResponseLoadControlClusterAverageLoadControlStruct ( companion object { private const val TAG_LOAD_ADJUSTMENT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterAverageLoadControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterAverageLoadControlStruct { tlvReader.enterStructure(tlvTag) val loadAdjustment = tlvReader.getInt(ContextSpecificTag(TAG_LOAD_ADJUSTMENT)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterAverageLoadControlStruct(loadAdjustment) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt index ce5980bf12eab7..af1ad8026cc11b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterDutyCycleControlStruct ( - val dutyCycle: UInt) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterDutyCycleControlStruct(val dutyCycle: UInt) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterDutyCycleControlStruct {\n") append("\tdutyCycle : $dutyCycle\n") append("}\n") @@ -45,10 +40,13 @@ class DemandResponseLoadControlClusterDutyCycleControlStruct ( companion object { private const val TAG_DUTY_CYCLE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterDutyCycleControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterDutyCycleControlStruct { tlvReader.enterStructure(tlvTag) val dutyCycle = tlvReader.getUInt(ContextSpecificTag(TAG_DUTY_CYCLE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterDutyCycleControlStruct(dutyCycle) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt index c957612bd8942e..049c061b9966e1 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterHeatingSourceControlStruct ( - val heatingSource: UInt) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterHeatingSourceControlStruct(val heatingSource: UInt) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterHeatingSourceControlStruct {\n") append("\theatingSource : $heatingSource\n") append("}\n") @@ -45,10 +40,13 @@ class DemandResponseLoadControlClusterHeatingSourceControlStruct ( companion object { private const val TAG_HEATING_SOURCE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterHeatingSourceControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterHeatingSourceControlStruct { tlvReader.enterStructure(tlvTag) val heatingSource = tlvReader.getUInt(ContextSpecificTag(TAG_HEATING_SOURCE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterHeatingSourceControlStruct(heatingSource) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt index 150b4bc952bad3..f714af6d7b8fbd 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt @@ -17,25 +17,24 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterLoadControlEventStruct ( - val eventID: ByteArray, - val programID: ByteArray?, - val control: UInt, - val deviceClass: ULong, - val enrollmentGroup: Optional, - val criticality: UInt, - val startTime: ULong?, - val transitions: List) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterLoadControlEventStruct( + val eventID: ByteArray, + val programID: ByteArray?, + val control: UInt, + val deviceClass: ULong, + val enrollmentGroup: Optional, + val criticality: UInt, + val startTime: ULong?, + val transitions: List +) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventStruct {\n") append("\teventID : $eventID\n") append("\tprogramID : $programID\n") @@ -53,22 +52,22 @@ class DemandResponseLoadControlClusterLoadControlEventStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_EVENT_I_D), eventID) if (programID != null) { - put(ContextSpecificTag(TAG_PROGRAM_I_D), programID) - } else { - putNull(ContextSpecificTag(TAG_PROGRAM_I_D)) - } + put(ContextSpecificTag(TAG_PROGRAM_I_D), programID) + } else { + putNull(ContextSpecificTag(TAG_PROGRAM_I_D)) + } put(ContextSpecificTag(TAG_CONTROL), control) put(ContextSpecificTag(TAG_DEVICE_CLASS), deviceClass) if (enrollmentGroup.isPresent) { - val optenrollmentGroup = enrollmentGroup.get() - put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), optenrollmentGroup) - } + val optenrollmentGroup = enrollmentGroup.get() + put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), optenrollmentGroup) + } put(ContextSpecificTag(TAG_CRITICALITY), criticality) if (startTime != null) { - put(ContextSpecificTag(TAG_START_TIME), startTime) - } else { - putNull(ContextSpecificTag(TAG_START_TIME)) - } + put(ContextSpecificTag(TAG_START_TIME), startTime) + } else { + putNull(ContextSpecificTag(TAG_START_TIME)) + } startArray(ContextSpecificTag(TAG_TRANSITIONS)) for (item in transitions.iterator()) { item.toTlv(AnonymousTag, this) @@ -88,40 +87,61 @@ class DemandResponseLoadControlClusterLoadControlEventStruct ( private const val TAG_START_TIME = 6 private const val TAG_TRANSITIONS = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventStruct { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val programID = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) - null - } + val programID = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) + null + } val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) val deviceClass = tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_CLASS)) - val enrollmentGroup = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) - } else { - Optional.empty() - } + val enrollmentGroup = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) + } else { + Optional.empty() + } val criticality = tlvReader.getUInt(ContextSpecificTag(TAG_CRITICALITY)) - val startTime = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) - null - } - val transitions = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val startTime = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) + null + } + val transitions = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStruct(eventID, programID, control, deviceClass, enrollmentGroup, criticality, startTime, transitions) + return DemandResponseLoadControlClusterLoadControlEventStruct( + eventID, + programID, + control, + deviceClass, + enrollmentGroup, + criticality, + startTime, + transitions + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt index c1643805f9a6bf..6d44b1e020d180 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt @@ -17,24 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterLoadControlEventTransitionStruct ( - val duration: UInt, - val control: UInt, - val temperatureControl: Optional, - val averageLoadControl: Optional, - val dutyCycleControl: Optional, - val powerSavingsControl: Optional, - val heatingSourceControl: Optional) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterLoadControlEventTransitionStruct( + val duration: UInt, + val control: UInt, + val temperatureControl: Optional, + val averageLoadControl: Optional, + val dutyCycleControl: Optional, + val powerSavingsControl: Optional, + val heatingSourceControl: Optional +) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventTransitionStruct {\n") append("\tduration : $duration\n") append("\tcontrol : $control\n") @@ -52,25 +50,25 @@ class DemandResponseLoadControlClusterLoadControlEventTransitionStruct ( put(ContextSpecificTag(TAG_DURATION), duration) put(ContextSpecificTag(TAG_CONTROL), control) if (temperatureControl.isPresent) { - val opttemperatureControl = temperatureControl.get() - opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) - } + val opttemperatureControl = temperatureControl.get() + opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) + } if (averageLoadControl.isPresent) { - val optaverageLoadControl = averageLoadControl.get() - optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) - } + val optaverageLoadControl = averageLoadControl.get() + optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) + } if (dutyCycleControl.isPresent) { - val optdutyCycleControl = dutyCycleControl.get() - optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) - } + val optdutyCycleControl = dutyCycleControl.get() + optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) + } if (powerSavingsControl.isPresent) { - val optpowerSavingsControl = powerSavingsControl.get() - optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) - } + val optpowerSavingsControl = powerSavingsControl.get() + optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) + } if (heatingSourceControl.isPresent) { - val optheatingSourceControl = heatingSourceControl.get() - optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) - } + val optheatingSourceControl = heatingSourceControl.get() + optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) + } endStructure() } } @@ -84,39 +82,80 @@ class DemandResponseLoadControlClusterLoadControlEventTransitionStruct ( private const val TAG_POWER_SAVINGS_CONTROL = 5 private const val TAG_HEATING_SOURCE_CONTROL = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventTransitionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventTransitionStruct { tlvReader.enterStructure(tlvTag) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) val control = tlvReader.getUInt(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val averageLoadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val dutyCycleControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val powerSavingsControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val heatingSourceControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - + val temperatureControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv( + ContextSpecificTag(TAG_TEMPERATURE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val averageLoadControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv( + ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val dutyCycleControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv( + ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val powerSavingsControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv( + ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val heatingSourceControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv( + ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventTransitionStruct(duration, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) + return DemandResponseLoadControlClusterLoadControlEventTransitionStruct( + duration, + control, + temperatureControl, + averageLoadControl, + dutyCycleControl, + powerSavingsControl, + heatingSourceControl + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt index 70787ef931f659..289e4b0a1dbebf 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt @@ -17,22 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterLoadControlProgramStruct ( - val programID: ByteArray, - val name: String, - val enrollmentGroup: UInt?, - val randomStartMinutes: UInt?, - val randomDurationMinutes: UInt?) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterLoadControlProgramStruct( + val programID: ByteArray, + val name: String, + val enrollmentGroup: UInt?, + val randomStartMinutes: UInt?, + val randomDurationMinutes: UInt? +) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlProgramStruct {\n") append("\tprogramID : $programID\n") append("\tname : $name\n") @@ -48,20 +45,20 @@ class DemandResponseLoadControlClusterLoadControlProgramStruct ( put(ContextSpecificTag(TAG_PROGRAM_I_D), programID) put(ContextSpecificTag(TAG_NAME), name) if (enrollmentGroup != null) { - put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), enrollmentGroup) - } else { - putNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } + put(ContextSpecificTag(TAG_ENROLLMENT_GROUP), enrollmentGroup) + } else { + putNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + } if (randomStartMinutes != null) { - put(ContextSpecificTag(TAG_RANDOM_START_MINUTES), randomStartMinutes) - } else { - putNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - } + put(ContextSpecificTag(TAG_RANDOM_START_MINUTES), randomStartMinutes) + } else { + putNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + } if (randomDurationMinutes != null) { - put(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES), randomDurationMinutes) - } else { - putNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - } + put(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES), randomDurationMinutes) + } else { + putNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + } endStructure() } } @@ -73,32 +70,44 @@ class DemandResponseLoadControlClusterLoadControlProgramStruct ( private const val TAG_RANDOM_START_MINUTES = 3 private const val TAG_RANDOM_DURATION_MINUTES = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlProgramStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlProgramStruct { tlvReader.enterStructure(tlvTag) val programID = tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - val enrollmentGroup = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - null - } - val randomStartMinutes = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - null - } - val randomDurationMinutes = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - null - } - + val enrollmentGroup = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + null + } + val randomStartMinutes = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + null + } + val randomDurationMinutes = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlProgramStruct(programID, name, enrollmentGroup, randomStartMinutes, randomDurationMinutes) + return DemandResponseLoadControlClusterLoadControlProgramStruct( + programID, + name, + enrollmentGroup, + randomStartMinutes, + randomDurationMinutes + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt index a06b0011af0b89..30ed601d4ac156 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt @@ -17,18 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterPowerSavingsControlStruct ( - val powerSavings: UInt) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterPowerSavingsControlStruct(val powerSavings: UInt) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterPowerSavingsControlStruct {\n") append("\tpowerSavings : $powerSavings\n") append("}\n") @@ -45,10 +40,13 @@ class DemandResponseLoadControlClusterPowerSavingsControlStruct ( companion object { private const val TAG_POWER_SAVINGS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterPowerSavingsControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterPowerSavingsControlStruct { tlvReader.enterStructure(tlvTag) val powerSavings = tlvReader.getUInt(ContextSpecificTag(TAG_POWER_SAVINGS)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterPowerSavingsControlStruct(powerSavings) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt index 70524b6e349fca..925c1db888410a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DemandResponseLoadControlClusterTemperatureControlStruct ( - val coolingTempOffset: Optional?, - val heatingtTempOffset: Optional?, - val coolingTempSetpoint: Optional?, - val heatingTempSetpoint: Optional?) { - override fun toString(): String = buildString { +class DemandResponseLoadControlClusterTemperatureControlStruct( + val coolingTempOffset: Optional?, + val heatingtTempOffset: Optional?, + val coolingTempSetpoint: Optional?, + val heatingTempSetpoint: Optional? +) { + override fun toString(): String = buildString { append("DemandResponseLoadControlClusterTemperatureControlStruct {\n") append("\tcoolingTempOffset : $coolingTempOffset\n") append("\theatingtTempOffset : $heatingtTempOffset\n") @@ -44,37 +42,37 @@ class DemandResponseLoadControlClusterTemperatureControlStruct ( tlvWriter.apply { startStructure(tlvTag) if (coolingTempOffset != null) { - if (coolingTempOffset.isPresent) { - val optcoolingTempOffset = coolingTempOffset.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) - } - } else { - putNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) - } + if (coolingTempOffset.isPresent) { + val optcoolingTempOffset = coolingTempOffset.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) + } + } else { + putNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) + } if (heatingtTempOffset != null) { - if (heatingtTempOffset.isPresent) { - val optheatingtTempOffset = heatingtTempOffset.get() - put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) - } - } else { - putNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) - } + if (heatingtTempOffset.isPresent) { + val optheatingtTempOffset = heatingtTempOffset.get() + put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) + } + } else { + putNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) + } if (coolingTempSetpoint != null) { - if (coolingTempSetpoint.isPresent) { - val optcoolingTempSetpoint = coolingTempSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) - } - } else { - putNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) - } + if (coolingTempSetpoint.isPresent) { + val optcoolingTempSetpoint = coolingTempSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) + } + } else { + putNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) + } if (heatingTempSetpoint != null) { - if (heatingTempSetpoint.isPresent) { - val optheatingTempSetpoint = heatingTempSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) - } - } else { - putNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) - } + if (heatingTempSetpoint.isPresent) { + val optheatingTempSetpoint = heatingTempSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) + } + } else { + putNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) + } endStructure() } } @@ -85,52 +83,64 @@ class DemandResponseLoadControlClusterTemperatureControlStruct ( private const val TAG_COOLING_TEMP_SETPOINT = 2 private const val TAG_HEATING_TEMP_SETPOINT = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterTemperatureControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterTemperatureControlStruct { tlvReader.enterStructure(tlvTag) - val coolingTempOffset = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) - null - } - val heatingtTempOffset = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) - null - } - val coolingTempSetpoint = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) - null - } - val heatingTempSetpoint = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) - null - } - + val coolingTempOffset = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) + null + } + val heatingtTempOffset = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) + null + } + val coolingTempSetpoint = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) + null + } + val heatingTempSetpoint = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterTemperatureControlStruct(coolingTempOffset, heatingtTempOffset, coolingTempSetpoint, heatingTempSetpoint) + return DemandResponseLoadControlClusterTemperatureControlStruct( + coolingTempOffset, + heatingtTempOffset, + coolingTempSetpoint, + heatingTempSetpoint + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt index c5529da5072ea8..0a867ba2296515 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DescriptorClusterDeviceTypeStruct ( - val deviceType: ULong, - val revision: UInt) { - override fun toString(): String = buildString { +class DescriptorClusterDeviceTypeStruct(val deviceType: ULong, val revision: UInt) { + override fun toString(): String = buildString { append("DescriptorClusterDeviceTypeStruct {\n") append("\tdeviceType : $deviceType\n") append("\trevision : $revision\n") @@ -49,11 +43,11 @@ class DescriptorClusterDeviceTypeStruct ( private const val TAG_DEVICE_TYPE = 0 private const val TAG_REVISION = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DescriptorClusterDeviceTypeStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DescriptorClusterDeviceTypeStruct { tlvReader.enterStructure(tlvTag) val deviceType = tlvReader.getULong(ContextSpecificTag(TAG_DEVICE_TYPE)) val revision = tlvReader.getUInt(ContextSpecificTag(TAG_REVISION)) - + tlvReader.exitContainer() return DescriptorClusterDeviceTypeStruct(deviceType, revision) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt index 89967a1445d75d..91d33d5c0fe2e5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DescriptorClusterSemanticTagStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DescriptorClusterSemanticTagStruct ( - val mfgCode: UInt?, - val namespaceID: UInt, - val tag: UInt, - val label: Optional?) { - override fun toString(): String = buildString { +class DescriptorClusterSemanticTagStruct( + val mfgCode: UInt?, + val namespaceID: UInt, + val tag: UInt, + val label: Optional? +) { + override fun toString(): String = buildString { append("DescriptorClusterSemanticTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tnamespaceID : $namespaceID\n") @@ -44,20 +42,20 @@ class DescriptorClusterSemanticTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode != null) { - put(ContextSpecificTag(TAG_MFG_CODE), mfgCode) - } else { - putNull(ContextSpecificTag(TAG_MFG_CODE)) - } + put(ContextSpecificTag(TAG_MFG_CODE), mfgCode) + } else { + putNull(ContextSpecificTag(TAG_MFG_CODE)) + } put(ContextSpecificTag(TAG_NAMESPACE_I_D), namespaceID) put(ContextSpecificTag(TAG_TAG), tag) if (label != null) { - if (label.isPresent) { - val optlabel = label.get() - put(ContextSpecificTag(TAG_LABEL), optlabel) - } - } else { - putNull(ContextSpecificTag(TAG_LABEL)) - } + if (label.isPresent) { + val optlabel = label.get() + put(ContextSpecificTag(TAG_LABEL), optlabel) + } + } else { + putNull(ContextSpecificTag(TAG_LABEL)) + } endStructure() } } @@ -68,27 +66,29 @@ class DescriptorClusterSemanticTagStruct ( private const val TAG_TAG = 2 private const val TAG_LABEL = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DescriptorClusterSemanticTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DescriptorClusterSemanticTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) - null - } + val mfgCode = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) + null + } val namespaceID = tlvReader.getUInt(ContextSpecificTag(TAG_NAMESPACE_I_D)) val tag = tlvReader.getUInt(ContextSpecificTag(TAG_TAG)) - val label = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) - null - } - + val label = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) + null + } + tlvReader.exitContainer() return DescriptorClusterSemanticTagStruct(mfgCode, namespaceID, tag, label) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt index b473bdd6ebe7c3..8389173d80aca7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterConstraintsStruct ( - val startTime: ULong, - val duration: ULong, - val nominalPower: Optional, - val maximumEnergy: Optional, - val loadControl: Optional) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterConstraintsStruct( + val startTime: ULong, + val duration: ULong, + val nominalPower: Optional, + val maximumEnergy: Optional, + val loadControl: Optional +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterConstraintsStruct {\n") append("\tstartTime : $startTime\n") append("\tduration : $duration\n") @@ -48,17 +46,17 @@ class DeviceEnergyManagementClusterConstraintsStruct ( put(ContextSpecificTag(TAG_START_TIME), startTime) put(ContextSpecificTag(TAG_DURATION), duration) if (nominalPower.isPresent) { - val optnominalPower = nominalPower.get() - put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) - } + val optnominalPower = nominalPower.get() + put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) + } if (maximumEnergy.isPresent) { - val optmaximumEnergy = maximumEnergy.get() - put(ContextSpecificTag(TAG_MAXIMUM_ENERGY), optmaximumEnergy) - } + val optmaximumEnergy = maximumEnergy.get() + put(ContextSpecificTag(TAG_MAXIMUM_ENERGY), optmaximumEnergy) + } if (loadControl.isPresent) { - val optloadControl = loadControl.get() - put(ContextSpecificTag(TAG_LOAD_CONTROL), optloadControl) - } + val optloadControl = loadControl.get() + put(ContextSpecificTag(TAG_LOAD_CONTROL), optloadControl) + } endStructure() } } @@ -70,29 +68,38 @@ class DeviceEnergyManagementClusterConstraintsStruct ( private const val TAG_MAXIMUM_ENERGY = 3 private const val TAG_LOAD_CONTROL = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterConstraintsStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterConstraintsStruct { tlvReader.enterStructure(tlvTag) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val maximumEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) - } else { - Optional.empty() - } - val loadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_LOAD_CONTROL))) - } else { - Optional.empty() - } - + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val maximumEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) + } else { + Optional.empty() + } + val loadControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_LOAD_CONTROL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterConstraintsStruct(startTime, duration, nominalPower, maximumEnergy, loadControl) + return DeviceEnergyManagementClusterConstraintsStruct( + startTime, + duration, + nominalPower, + maximumEnergy, + loadControl + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt index d996e8c0c944d0..1d74d861c90b76 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterCostStruct ( - val costType: UInt, - val value: Long, - val decimalPoints: UInt, - val currency: Optional) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterCostStruct( + val costType: UInt, + val value: Long, + val decimalPoints: UInt, + val currency: Optional +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterCostStruct {\n") append("\tcostType : $costType\n") append("\tvalue : $value\n") @@ -47,9 +45,9 @@ class DeviceEnergyManagementClusterCostStruct ( put(ContextSpecificTag(TAG_VALUE), value) put(ContextSpecificTag(TAG_DECIMAL_POINTS), decimalPoints) if (currency.isPresent) { - val optcurrency = currency.get() - put(ContextSpecificTag(TAG_CURRENCY), optcurrency) - } + val optcurrency = currency.get() + put(ContextSpecificTag(TAG_CURRENCY), optcurrency) + } endStructure() } } @@ -60,17 +58,18 @@ class DeviceEnergyManagementClusterCostStruct ( private const val TAG_DECIMAL_POINTS = 2 private const val TAG_CURRENCY = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterCostStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterCostStruct { tlvReader.enterStructure(tlvTag) val costType = tlvReader.getUInt(ContextSpecificTag(TAG_COST_TYPE)) val value = tlvReader.getLong(ContextSpecificTag(TAG_VALUE)) val decimalPoints = tlvReader.getUInt(ContextSpecificTag(TAG_DECIMAL_POINTS)) - val currency = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CURRENCY))) - } else { - Optional.empty() - } - + val currency = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CURRENCY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return DeviceEnergyManagementClusterCostStruct(costType, value, decimalPoints, currency) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt index a037d3ad1c7b8f..17e45fa732ea47 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt @@ -17,26 +17,25 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterForecastStruct ( - val forecastId: UInt, - val activeSlotNumber: UInt?, - val startTime: ULong, - val endTime: ULong, - val earliestStartTime: Optional?, - val latestEndTime: Optional, - val isPauseable: Boolean, - val slots: List, - val forecastUpdateReason: UInt) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterForecastStruct( + val forecastId: UInt, + val activeSlotNumber: UInt?, + val startTime: ULong, + val endTime: ULong, + val earliestStartTime: Optional?, + val latestEndTime: Optional, + val isPauseable: Boolean, + val slots: List, + val forecastUpdateReason: UInt +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterForecastStruct {\n") append("\tforecastId : $forecastId\n") append("\tactiveSlotNumber : $activeSlotNumber\n") @@ -55,24 +54,24 @@ class DeviceEnergyManagementClusterForecastStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_FORECAST_ID), forecastId) if (activeSlotNumber != null) { - put(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER), activeSlotNumber) - } else { - putNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - } + put(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER), activeSlotNumber) + } else { + putNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + } put(ContextSpecificTag(TAG_START_TIME), startTime) put(ContextSpecificTag(TAG_END_TIME), endTime) if (earliestStartTime != null) { - if (earliestStartTime.isPresent) { - val optearliestStartTime = earliestStartTime.get() - put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) - } - } else { - putNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) - } + if (earliestStartTime.isPresent) { + val optearliestStartTime = earliestStartTime.get() + put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) + } + } else { + putNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) + } if (latestEndTime.isPresent) { - val optlatestEndTime = latestEndTime.get() - put(ContextSpecificTag(TAG_LATEST_END_TIME), optlatestEndTime) - } + val optlatestEndTime = latestEndTime.get() + put(ContextSpecificTag(TAG_LATEST_END_TIME), optlatestEndTime) + } put(ContextSpecificTag(TAG_IS_PAUSEABLE), isPauseable) startArray(ContextSpecificTag(TAG_SLOTS)) for (item in slots.iterator()) { @@ -95,45 +94,59 @@ class DeviceEnergyManagementClusterForecastStruct ( private const val TAG_SLOTS = 7 private const val TAG_FORECAST_UPDATE_REASON = 8 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterForecastStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterForecastStruct { tlvReader.enterStructure(tlvTag) val forecastId = tlvReader.getUInt(ContextSpecificTag(TAG_FORECAST_ID)) - val activeSlotNumber = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - null - } + val activeSlotNumber = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + null + } val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getULong(ContextSpecificTag(TAG_END_TIME)) - val earliestStartTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EARLIEST_START_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) - null - } - val latestEndTime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_LATEST_END_TIME))) - } else { - Optional.empty() - } + val earliestStartTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_EARLIEST_START_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) + null + } + val latestEndTime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_LATEST_END_TIME))) + } else { + Optional.empty() + } val isPauseable = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_PAUSEABLE)) - val slots = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val slots = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } val forecastUpdateReason = tlvReader.getUInt(ContextSpecificTag(TAG_FORECAST_UPDATE_REASON)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterForecastStruct(forecastId, activeSlotNumber, startTime, endTime, earliestStartTime, latestEndTime, isPauseable, slots, forecastUpdateReason) + return DeviceEnergyManagementClusterForecastStruct( + forecastId, + activeSlotNumber, + startTime, + endTime, + earliestStartTime, + latestEndTime, + isPauseable, + slots, + forecastUpdateReason + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt index 20385dd1ca78e2..7021aa2720949e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterPowerAdjustStruct ( - val minPower: Long, - val maxPower: Long, - val minDuration: ULong, - val maxDuration: ULong) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterPowerAdjustStruct( + val minPower: Long, + val maxPower: Long, + val minDuration: ULong, + val maxDuration: ULong +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterPowerAdjustStruct {\n") append("\tminPower : $minPower\n") append("\tmaxPower : $maxPower\n") @@ -57,16 +54,21 @@ class DeviceEnergyManagementClusterPowerAdjustStruct ( private const val TAG_MIN_DURATION = 2 private const val TAG_MAX_DURATION = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterPowerAdjustStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterPowerAdjustStruct { tlvReader.enterStructure(tlvTag) val minPower = tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER)) val maxPower = tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER)) val minDuration = tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION)) val maxDuration = tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterPowerAdjustStruct(minPower, maxPower, minDuration, maxDuration) + return DeviceEnergyManagementClusterPowerAdjustStruct( + minPower, + maxPower, + minDuration, + maxDuration + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt index 6b6209aed1166b..11fcf975e99039 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterSlotAdjustmentStruct ( - val slotIndex: UInt, - val nominalPower: Long, - val duration: ULong) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterSlotAdjustmentStruct( + val slotIndex: UInt, + val nominalPower: Long, + val duration: ULong +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterSlotAdjustmentStruct {\n") append("\tslotIndex : $slotIndex\n") append("\tnominalPower : $nominalPower\n") @@ -53,12 +50,15 @@ class DeviceEnergyManagementClusterSlotAdjustmentStruct ( private const val TAG_NOMINAL_POWER = 1 private const val TAG_DURATION = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterSlotAdjustmentStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterSlotAdjustmentStruct { tlvReader.enterStructure(tlvTag) val slotIndex = tlvReader.getUInt(ContextSpecificTag(TAG_SLOT_INDEX)) val nominalPower = tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterSlotAdjustmentStruct(slotIndex, nominalPower, duration) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt index 63e8b90eba0cac..18759432dc2ce4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt @@ -17,35 +17,34 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DeviceEnergyManagementClusterSlotStruct ( - val minDuration: ULong, - val maxDuration: ULong, - val defaultDuration: ULong, - val elapsedSlotTime: ULong, - val remainingSlotTime: ULong, - val slotIsPauseable: Optional, - val minPauseDuration: Optional, - val maxPauseDuration: Optional, - val manufacturerESAState: Optional, - val nominalPower: Optional, - val minPower: Optional, - val maxPower: Optional, - val nominalEnergy: Optional, - val costs: Optional>, - val minPowerAdjustment: Optional, - val maxPowerAdjustment: Optional, - val minDurationAdjustment: Optional, - val maxDurationAdjustment: Optional) { - override fun toString(): String = buildString { +class DeviceEnergyManagementClusterSlotStruct( + val minDuration: ULong, + val maxDuration: ULong, + val defaultDuration: ULong, + val elapsedSlotTime: ULong, + val remainingSlotTime: ULong, + val slotIsPauseable: Optional, + val minPauseDuration: Optional, + val maxPauseDuration: Optional, + val manufacturerESAState: Optional, + val nominalPower: Optional, + val minPower: Optional, + val maxPower: Optional, + val nominalEnergy: Optional, + val costs: Optional>, + val minPowerAdjustment: Optional, + val maxPowerAdjustment: Optional, + val minDurationAdjustment: Optional, + val maxDurationAdjustment: Optional +) { + override fun toString(): String = buildString { append("DeviceEnergyManagementClusterSlotStruct {\n") append("\tminDuration : $minDuration\n") append("\tmaxDuration : $maxDuration\n") @@ -77,61 +76,61 @@ class DeviceEnergyManagementClusterSlotStruct ( put(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME), elapsedSlotTime) put(ContextSpecificTag(TAG_REMAINING_SLOT_TIME), remainingSlotTime) if (slotIsPauseable.isPresent) { - val optslotIsPauseable = slotIsPauseable.get() - put(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE), optslotIsPauseable) - } + val optslotIsPauseable = slotIsPauseable.get() + put(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE), optslotIsPauseable) + } if (minPauseDuration.isPresent) { - val optminPauseDuration = minPauseDuration.get() - put(ContextSpecificTag(TAG_MIN_PAUSE_DURATION), optminPauseDuration) - } + val optminPauseDuration = minPauseDuration.get() + put(ContextSpecificTag(TAG_MIN_PAUSE_DURATION), optminPauseDuration) + } if (maxPauseDuration.isPresent) { - val optmaxPauseDuration = maxPauseDuration.get() - put(ContextSpecificTag(TAG_MAX_PAUSE_DURATION), optmaxPauseDuration) - } + val optmaxPauseDuration = maxPauseDuration.get() + put(ContextSpecificTag(TAG_MAX_PAUSE_DURATION), optmaxPauseDuration) + } if (manufacturerESAState.isPresent) { - val optmanufacturerESAState = manufacturerESAState.get() - put(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE), optmanufacturerESAState) - } + val optmanufacturerESAState = manufacturerESAState.get() + put(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE), optmanufacturerESAState) + } if (nominalPower.isPresent) { - val optnominalPower = nominalPower.get() - put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) - } + val optnominalPower = nominalPower.get() + put(ContextSpecificTag(TAG_NOMINAL_POWER), optnominalPower) + } if (minPower.isPresent) { - val optminPower = minPower.get() - put(ContextSpecificTag(TAG_MIN_POWER), optminPower) - } + val optminPower = minPower.get() + put(ContextSpecificTag(TAG_MIN_POWER), optminPower) + } if (maxPower.isPresent) { - val optmaxPower = maxPower.get() - put(ContextSpecificTag(TAG_MAX_POWER), optmaxPower) - } + val optmaxPower = maxPower.get() + put(ContextSpecificTag(TAG_MAX_POWER), optmaxPower) + } if (nominalEnergy.isPresent) { - val optnominalEnergy = nominalEnergy.get() - put(ContextSpecificTag(TAG_NOMINAL_ENERGY), optnominalEnergy) - } + val optnominalEnergy = nominalEnergy.get() + put(ContextSpecificTag(TAG_NOMINAL_ENERGY), optnominalEnergy) + } if (costs.isPresent) { - val optcosts = costs.get() - startArray(ContextSpecificTag(TAG_COSTS)) - for (item in optcosts.iterator()) { - item.toTlv(AnonymousTag, this) + val optcosts = costs.get() + startArray(ContextSpecificTag(TAG_COSTS)) + for (item in optcosts.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } - endArray() - } if (minPowerAdjustment.isPresent) { - val optminPowerAdjustment = minPowerAdjustment.get() - put(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT), optminPowerAdjustment) - } + val optminPowerAdjustment = minPowerAdjustment.get() + put(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT), optminPowerAdjustment) + } if (maxPowerAdjustment.isPresent) { - val optmaxPowerAdjustment = maxPowerAdjustment.get() - put(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT), optmaxPowerAdjustment) - } + val optmaxPowerAdjustment = maxPowerAdjustment.get() + put(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT), optmaxPowerAdjustment) + } if (minDurationAdjustment.isPresent) { - val optminDurationAdjustment = minDurationAdjustment.get() - put(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT), optminDurationAdjustment) - } + val optminDurationAdjustment = minDurationAdjustment.get() + put(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT), optminDurationAdjustment) + } if (maxDurationAdjustment.isPresent) { - val optmaxDurationAdjustment = maxDurationAdjustment.get() - put(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT), optmaxDurationAdjustment) - } + val optmaxDurationAdjustment = maxDurationAdjustment.get() + put(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT), optmaxDurationAdjustment) + } endStructure() } } @@ -156,88 +155,122 @@ class DeviceEnergyManagementClusterSlotStruct ( private const val TAG_MIN_DURATION_ADJUSTMENT = 16 private const val TAG_MAX_DURATION_ADJUSTMENT = 17 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterSlotStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterSlotStruct { tlvReader.enterStructure(tlvTag) val minDuration = tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION)) val maxDuration = tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION)) val defaultDuration = tlvReader.getULong(ContextSpecificTag(TAG_DEFAULT_DURATION)) val elapsedSlotTime = tlvReader.getULong(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME)) val remainingSlotTime = tlvReader.getULong(ContextSpecificTag(TAG_REMAINING_SLOT_TIME)) - val slotIsPauseable = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) - } else { - Optional.empty() - } - val minPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) - } else { - Optional.empty() - } - val maxPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) - } else { - Optional.empty() - } - val manufacturerESAState = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) - } else { - Optional.empty() - } - val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val minPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) - } else { - Optional.empty() - } - val maxPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) - } else { - Optional.empty() - } - val nominalEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) - } else { - Optional.empty() - } - val costs = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val minPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val minDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - + val slotIsPauseable = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) + } else { + Optional.empty() + } + val minPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) + } else { + Optional.empty() + } + val maxPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) + } else { + Optional.empty() + } + val manufacturerESAState = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) + } else { + Optional.empty() + } + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val minPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) + } else { + Optional.empty() + } + val maxPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) + } else { + Optional.empty() + } + val nominalEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) + } else { + Optional.empty() + } + val costs = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val minPowerAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxPowerAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val minDurationAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxDurationAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterSlotStruct(minDuration, maxDuration, defaultDuration, elapsedSlotTime, remainingSlotTime, slotIsPauseable, minPauseDuration, maxPauseDuration, manufacturerESAState, nominalPower, minPower, maxPower, nominalEnergy, costs, minPowerAdjustment, maxPowerAdjustment, minDurationAdjustment, maxDurationAdjustment) + return DeviceEnergyManagementClusterSlotStruct( + minDuration, + maxDuration, + defaultDuration, + elapsedSlotTime, + remainingSlotTime, + slotIsPauseable, + minPauseDuration, + maxPauseDuration, + manufacturerESAState, + nominalPower, + minPower, + maxPower, + nominalEnergy, + costs, + minPowerAdjustment, + maxPowerAdjustment, + minDurationAdjustment, + maxDurationAdjustment + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt index 04305789265487..0cbbf8fb8c37eb 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DishwasherModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class DishwasherModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("DishwasherModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class DishwasherModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return DishwasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt index f2615f2ddeb01e..916f58bdab72e6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DishwasherModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DishwasherModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("DishwasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class DishwasherModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class DishwasherModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return DishwasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt index 108dd2b0efe922..5ee8045b4d17ed 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/DoorLockClusterCredentialStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class DoorLockClusterCredentialStruct ( - val credentialType: UInt, - val credentialIndex: UInt) { - override fun toString(): String = buildString { +class DoorLockClusterCredentialStruct(val credentialType: UInt, val credentialIndex: UInt) { + override fun toString(): String = buildString { append("DoorLockClusterCredentialStruct {\n") append("\tcredentialType : $credentialType\n") append("\tcredentialIndex : $credentialIndex\n") @@ -49,11 +43,11 @@ class DoorLockClusterCredentialStruct ( private const val TAG_CREDENTIAL_TYPE = 0 private const val TAG_CREDENTIAL_INDEX = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterCredentialStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterCredentialStruct { tlvReader.enterStructure(tlvTag) val credentialType = tlvReader.getUInt(ContextSpecificTag(TAG_CREDENTIAL_TYPE)) val credentialIndex = tlvReader.getUInt(ContextSpecificTag(TAG_CREDENTIAL_INDEX)) - + tlvReader.exitContainer() return DoorLockClusterCredentialStruct(credentialType, credentialIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt index 498c715482bd90..bbce3fc7d16ff7 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct ( - val energy: Long, - val startTimestamp: Optional, - val endTimestamp: Optional, - val startSystime: Optional, - val endSystime: Optional) { - override fun toString(): String = buildString { +class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + val energy: Long, + val startTimestamp: Optional, + val endTimestamp: Optional, + val startSystime: Optional, + val endSystime: Optional +) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterEnergyMeasurementStruct {\n") append("\tenergy : $energy\n") append("\tstartTimestamp : $startTimestamp\n") @@ -47,21 +45,21 @@ class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ENERGY), energy) if (startTimestamp.isPresent) { - val optstartTimestamp = startTimestamp.get() - put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) - } + val optstartTimestamp = startTimestamp.get() + put(ContextSpecificTag(TAG_START_TIMESTAMP), optstartTimestamp) + } if (endTimestamp.isPresent) { - val optendTimestamp = endTimestamp.get() - put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) - } + val optendTimestamp = endTimestamp.get() + put(ContextSpecificTag(TAG_END_TIMESTAMP), optendTimestamp) + } if (startSystime.isPresent) { - val optstartSystime = startSystime.get() - put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) - } + val optstartSystime = startSystime.get() + put(ContextSpecificTag(TAG_START_SYSTIME), optstartSystime) + } if (endSystime.isPresent) { - val optendSystime = endSystime.get() - put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) - } + val optendSystime = endSystime.get() + put(ContextSpecificTag(TAG_END_SYSTIME), optendSystime) + } endStructure() } } @@ -73,33 +71,46 @@ class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct ( private const val TAG_START_SYSTIME = 3 private const val TAG_END_SYSTIME = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { tlvReader.enterStructure(tlvTag) val energy = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY)) - val startTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_TIMESTAMP))) - } else { - Optional.empty() - } - val endTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_TIMESTAMP))) - } else { - Optional.empty() - } - val startSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) - } else { - Optional.empty() - } - val endSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) - } else { - Optional.empty() - } - + val startTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct(energy, startTimestamp, endTimestamp, startSystime, endSystime) + return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + energy, + startTimestamp, + endTimestamp, + startSystime, + endSystime + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt index 53795eacfd0bda..8ce0529f9cd457 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -17,25 +17,23 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct ( - val rangeMin: Long, - val rangeMax: Long, - val percentMax: Optional, - val percentMin: Optional, - val percentTypical: Optional, - val fixedMax: Optional, - val fixedMin: Optional, - val fixedTypical: Optional) { - override fun toString(): String = buildString { +class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + val rangeMin: Long, + val rangeMax: Long, + val percentMax: Optional, + val percentMin: Optional, + val percentTypical: Optional, + val fixedMax: Optional, + val fixedMin: Optional, + val fixedTypical: Optional +) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct {\n") append("\trangeMin : $rangeMin\n") append("\trangeMax : $rangeMax\n") @@ -54,29 +52,29 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct ( put(ContextSpecificTag(TAG_RANGE_MIN), rangeMin) put(ContextSpecificTag(TAG_RANGE_MAX), rangeMax) if (percentMax.isPresent) { - val optpercentMax = percentMax.get() - put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) - } + val optpercentMax = percentMax.get() + put(ContextSpecificTag(TAG_PERCENT_MAX), optpercentMax) + } if (percentMin.isPresent) { - val optpercentMin = percentMin.get() - put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) - } + val optpercentMin = percentMin.get() + put(ContextSpecificTag(TAG_PERCENT_MIN), optpercentMin) + } if (percentTypical.isPresent) { - val optpercentTypical = percentTypical.get() - put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) - } + val optpercentTypical = percentTypical.get() + put(ContextSpecificTag(TAG_PERCENT_TYPICAL), optpercentTypical) + } if (fixedMax.isPresent) { - val optfixedMax = fixedMax.get() - put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) - } + val optfixedMax = fixedMax.get() + put(ContextSpecificTag(TAG_FIXED_MAX), optfixedMax) + } if (fixedMin.isPresent) { - val optfixedMin = fixedMin.get() - put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) - } + val optfixedMin = fixedMin.get() + put(ContextSpecificTag(TAG_FIXED_MIN), optfixedMin) + } if (fixedTypical.isPresent) { - val optfixedTypical = fixedTypical.get() - put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) - } + val optfixedTypical = fixedTypical.get() + put(ContextSpecificTag(TAG_FIXED_TYPICAL), optfixedTypical) + } endStructure() } } @@ -91,44 +89,62 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct ( private const val TAG_FIXED_MIN = 6 private const val TAG_FIXED_TYPICAL = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { tlvReader.enterStructure(tlvTag) val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) - val percentMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MAX))) - } else { - Optional.empty() - } - val percentMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MIN))) - } else { - Optional.empty() - } - val percentTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_TYPICAL))) - } else { - Optional.empty() - } - val fixedMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) - } else { - Optional.empty() - } - val fixedMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) - } else { - Optional.empty() - } - val fixedTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) - } else { - Optional.empty() - } - + val percentMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct(rangeMin, rangeMax, percentMax, percentMin, percentTypical, fixedMax, fixedMin, fixedTypical) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt index 25bd74a73e38b7..3c33b23cb9e505 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt @@ -20,19 +20,17 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct ( - val measurementType: UInt, - val measured: Boolean, - val minMeasuredValue: Long, - val maxMeasuredValue: Long, - val accuracyRanges: List) { - override fun toString(): String = buildString { +class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + val measurementType: UInt, + val measured: Boolean, + val minMeasuredValue: Long, + val maxMeasuredValue: Long, + val accuracyRanges: List +) { + override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct {\n") append("\tmeasurementType : $measurementType\n") append("\tmeasured : $measured\n") @@ -65,23 +63,38 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct ( private const val TAG_MAX_MEASURED_VALUE = 3 private const val TAG_ACCURACY_RANGES = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { tlvReader.enterStructure(tlvTag) val measurementType = tlvReader.getUInt(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) - val accuracyRanges = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val accuracyRanges = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct(measurementType, measured, minMeasuredValue, maxMeasuredValue, accuracyRanges) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt index 1fe6ccedd3ae38..bddc2563640620 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterChargingTargetScheduleStruct ( - val dayOfWeekForSequence: UInt, - val chargingTargets: List) { - override fun toString(): String = buildString { +class EnergyEvseClusterChargingTargetScheduleStruct( + val dayOfWeekForSequence: UInt, + val chargingTargets: List +) { + override fun toString(): String = buildString { append("EnergyEvseClusterChargingTargetScheduleStruct {\n") append("\tdayOfWeekForSequence : $dayOfWeekForSequence\n") append("\tchargingTargets : $chargingTargets\n") @@ -53,17 +51,18 @@ class EnergyEvseClusterChargingTargetScheduleStruct ( private const val TAG_DAY_OF_WEEK_FOR_SEQUENCE = 0 private const val TAG_CHARGING_TARGETS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterChargingTargetScheduleStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetScheduleStruct { tlvReader.enterStructure(tlvTag) val dayOfWeekForSequence = tlvReader.getUInt(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) - val chargingTargets = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) - while(!tlvReader.isEndOfContainer()) { - add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val chargingTargets = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) + while (!tlvReader.isEndOfContainer()) { + add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return EnergyEvseClusterChargingTargetScheduleStruct(dayOfWeekForSequence, chargingTargets) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt index 1f87d383888f87..9e859dbdf40e53 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyEvseClusterChargingTargetStruct ( - val targetTimeMinutesPastMidnight: UInt, - val targetSoC: Optional, - val addedEnergy: Optional) { - override fun toString(): String = buildString { +class EnergyEvseClusterChargingTargetStruct( + val targetTimeMinutesPastMidnight: UInt, + val targetSoC: Optional, + val addedEnergy: Optional +) { + override fun toString(): String = buildString { append("EnergyEvseClusterChargingTargetStruct {\n") append("\ttargetTimeMinutesPastMidnight : $targetTimeMinutesPastMidnight\n") append("\ttargetSoC : $targetSoC\n") @@ -43,13 +41,13 @@ class EnergyEvseClusterChargingTargetStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT), targetTimeMinutesPastMidnight) if (targetSoC.isPresent) { - val opttargetSoC = targetSoC.get() - put(ContextSpecificTag(TAG_TARGET_SO_C), opttargetSoC) - } + val opttargetSoC = targetSoC.get() + put(ContextSpecificTag(TAG_TARGET_SO_C), opttargetSoC) + } if (addedEnergy.isPresent) { - val optaddedEnergy = addedEnergy.get() - put(ContextSpecificTag(TAG_ADDED_ENERGY), optaddedEnergy) - } + val optaddedEnergy = addedEnergy.get() + put(ContextSpecificTag(TAG_ADDED_ENERGY), optaddedEnergy) + } endStructure() } } @@ -59,23 +57,30 @@ class EnergyEvseClusterChargingTargetStruct ( private const val TAG_TARGET_SO_C = 1 private const val TAG_ADDED_ENERGY = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterChargingTargetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetStruct { tlvReader.enterStructure(tlvTag) - val targetTimeMinutesPastMidnight = tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) - val targetSoC = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SO_C))) - } else { - Optional.empty() - } - val addedEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) - } else { - Optional.empty() - } - + val targetTimeMinutesPastMidnight = + tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) + val targetSoC = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SO_C))) + } else { + Optional.empty() + } + val addedEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterChargingTargetStruct(targetTimeMinutesPastMidnight, targetSoC, addedEnergy) + return EnergyEvseClusterChargingTargetStruct( + targetTimeMinutesPastMidnight, + targetSoC, + addedEnergy + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt index 677ef98e62f19c..75f77558f0e982 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class EnergyPreferenceClusterBalanceStruct ( - val step: UInt, - val label: Optional) { - override fun toString(): String = buildString { +class EnergyPreferenceClusterBalanceStruct(val step: UInt, val label: Optional) { + override fun toString(): String = buildString { append("EnergyPreferenceClusterBalanceStruct {\n") append("\tstep : $step\n") append("\tlabel : $label\n") @@ -41,9 +36,9 @@ class EnergyPreferenceClusterBalanceStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_STEP), step) if (label.isPresent) { - val optlabel = label.get() - put(ContextSpecificTag(TAG_LABEL), optlabel) - } + val optlabel = label.get() + put(ContextSpecificTag(TAG_LABEL), optlabel) + } endStructure() } } @@ -52,15 +47,16 @@ class EnergyPreferenceClusterBalanceStruct ( private const val TAG_STEP = 0 private const val TAG_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyPreferenceClusterBalanceStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyPreferenceClusterBalanceStruct { tlvReader.enterStructure(tlvTag) val step = tlvReader.getUInt(ContextSpecificTag(TAG_STEP)) - val label = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - + val label = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return EnergyPreferenceClusterBalanceStruct(step, label) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt index 3ca4e99e618df8..258f336d66e50b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/FixedLabelClusterLabelStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class FixedLabelClusterLabelStruct ( - val label: String, - val value: String) { - override fun toString(): String = buildString { +class FixedLabelClusterLabelStruct(val label: String, val value: String) { + override fun toString(): String = buildString { append("FixedLabelClusterLabelStruct {\n") append("\tlabel : $label\n") append("\tvalue : $value\n") @@ -49,11 +43,11 @@ class FixedLabelClusterLabelStruct ( private const val TAG_LABEL = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : FixedLabelClusterLabelStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): FixedLabelClusterLabelStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return FixedLabelClusterLabelStruct(label, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt index 6ea28a8fbf75da..eb37145e36f754 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralCommissioningClusterBasicCommissioningInfo ( - val failSafeExpiryLengthSeconds: UInt, - val maxCumulativeFailsafeSeconds: UInt) { - override fun toString(): String = buildString { +class GeneralCommissioningClusterBasicCommissioningInfo( + val failSafeExpiryLengthSeconds: UInt, + val maxCumulativeFailsafeSeconds: UInt +) { + override fun toString(): String = buildString { append("GeneralCommissioningClusterBasicCommissioningInfo {\n") append("\tfailSafeExpiryLengthSeconds : $failSafeExpiryLengthSeconds\n") append("\tmaxCumulativeFailsafeSeconds : $maxCumulativeFailsafeSeconds\n") @@ -49,14 +46,22 @@ class GeneralCommissioningClusterBasicCommissioningInfo ( private const val TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS = 0 private const val TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralCommissioningClusterBasicCommissioningInfo { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralCommissioningClusterBasicCommissioningInfo { tlvReader.enterStructure(tlvTag) - val failSafeExpiryLengthSeconds = tlvReader.getUInt(ContextSpecificTag(TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS)) - val maxCumulativeFailsafeSeconds = tlvReader.getUInt(ContextSpecificTag(TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS)) - + val failSafeExpiryLengthSeconds = + tlvReader.getUInt(ContextSpecificTag(TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS)) + val maxCumulativeFailsafeSeconds = + tlvReader.getUInt(ContextSpecificTag(TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS)) + tlvReader.exitContainer() - return GeneralCommissioningClusterBasicCommissioningInfo(failSafeExpiryLengthSeconds, maxCumulativeFailsafeSeconds) + return GeneralCommissioningClusterBasicCommissioningInfo( + failSafeExpiryLengthSeconds, + maxCumulativeFailsafeSeconds + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt index 7656b672bd9058..3f310757c51e6f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt @@ -20,22 +20,20 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GeneralDiagnosticsClusterNetworkInterface ( - val name: String, - val isOperational: Boolean, - val offPremiseServicesReachableIPv4: Boolean?, - val offPremiseServicesReachableIPv6: Boolean?, - val hardwareAddress: ByteArray, - val IPv4Addresses: List, - val IPv6Addresses: List, - val type: UInt) { - override fun toString(): String = buildString { +class GeneralDiagnosticsClusterNetworkInterface( + val name: String, + val isOperational: Boolean, + val offPremiseServicesReachableIPv4: Boolean?, + val offPremiseServicesReachableIPv6: Boolean?, + val hardwareAddress: ByteArray, + val IPv4Addresses: List, + val IPv6Addresses: List, + val type: UInt +) { + override fun toString(): String = buildString { append("GeneralDiagnosticsClusterNetworkInterface {\n") append("\tname : $name\n") append("\tisOperational : $isOperational\n") @@ -54,15 +52,21 @@ class GeneralDiagnosticsClusterNetworkInterface ( put(ContextSpecificTag(TAG_NAME), name) put(ContextSpecificTag(TAG_IS_OPERATIONAL), isOperational) if (offPremiseServicesReachableIPv4 != null) { - put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), offPremiseServicesReachableIPv4) - } else { - putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - } + put( + ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), + offPremiseServicesReachableIPv4 + ) + } else { + putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + } if (offPremiseServicesReachableIPv6 != null) { - put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), offPremiseServicesReachableIPv6) - } else { - putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - } + put( + ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), + offPremiseServicesReachableIPv6 + ) + } else { + putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + } put(ContextSpecificTag(TAG_HARDWARE_ADDRESS), hardwareAddress) startArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) for (item in IPv4Addresses.iterator()) { @@ -89,42 +93,55 @@ class GeneralDiagnosticsClusterNetworkInterface ( private const val TAG_I_PV6_ADDRESSES = 6 private const val TAG_TYPE = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterNetworkInterface { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterNetworkInterface { tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val isOperational = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_OPERATIONAL)) - val offPremiseServicesReachableIPv4 = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - null - } - val offPremiseServicesReachableIPv6 = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - null - } + val offPremiseServicesReachableIPv4 = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + null + } + val offPremiseServicesReachableIPv6 = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + null + } val hardwareAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_HARDWARE_ADDRESS)) - val IPv4Addresses = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val IPv6Addresses = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val IPv4Addresses = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val IPv6Addresses = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } val type = tlvReader.getUInt(ContextSpecificTag(TAG_TYPE)) - + tlvReader.exitContainer() - return GeneralDiagnosticsClusterNetworkInterface(name, isOperational, offPremiseServicesReachableIPv4, offPremiseServicesReachableIPv6, hardwareAddress, IPv4Addresses, IPv6Addresses, type) + return GeneralDiagnosticsClusterNetworkInterface( + name, + isOperational, + offPremiseServicesReachableIPv4, + offPremiseServicesReachableIPv6, + hardwareAddress, + IPv4Addresses, + IPv6Addresses, + type + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt index 72cf67168df8e4..1549a376b4542a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt @@ -17,21 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GroupKeyManagementClusterGroupInfoMapStruct ( - val groupId: UInt, - val endpoints: List, - val groupName: Optional, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class GroupKeyManagementClusterGroupInfoMapStruct( + val groupId: UInt, + val endpoints: List, + val groupName: Optional, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("GroupKeyManagementClusterGroupInfoMapStruct {\n") append("\tgroupId : $groupId\n") append("\tendpoints : $endpoints\n") @@ -50,9 +49,9 @@ class GroupKeyManagementClusterGroupInfoMapStruct ( } endArray() if (groupName.isPresent) { - val optgroupName = groupName.get() - put(ContextSpecificTag(TAG_GROUP_NAME), optgroupName) - } + val optgroupName = groupName.get() + put(ContextSpecificTag(TAG_GROUP_NAME), optgroupName) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -64,23 +63,25 @@ class GroupKeyManagementClusterGroupInfoMapStruct ( private const val TAG_GROUP_NAME = 3 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GroupKeyManagementClusterGroupInfoMapStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupInfoMapStruct { tlvReader.enterStructure(tlvTag) val groupId = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_ID)) - val endpoints = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val groupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) - } else { - Optional.empty() - } + val endpoints = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val groupName = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupInfoMapStruct(groupId, endpoints, groupName, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt index 71d7c3ca4cb959..46f4656366bbc8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GroupKeyManagementClusterGroupKeyMapStruct ( - val groupId: UInt, - val groupKeySetID: UInt, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class GroupKeyManagementClusterGroupKeyMapStruct( + val groupId: UInt, + val groupKeySetID: UInt, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("GroupKeyManagementClusterGroupKeyMapStruct {\n") append("\tgroupId : $groupId\n") append("\tgroupKeySetID : $groupKeySetID\n") @@ -53,12 +50,12 @@ class GroupKeyManagementClusterGroupKeyMapStruct ( private const val TAG_GROUP_KEY_SET_I_D = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GroupKeyManagementClusterGroupKeyMapStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupKeyMapStruct { tlvReader.enterStructure(tlvTag) val groupId = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_ID)) val groupKeySetID = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupKeyMapStruct(groupId, groupKeySetID, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt index 2eee6ef47d3353..4d995ac2974023 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt @@ -17,25 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class GroupKeyManagementClusterGroupKeySetStruct ( - val groupKeySetID: UInt, - val groupKeySecurityPolicy: UInt, - val epochKey0: ByteArray?, - val epochStartTime0: ULong?, - val epochKey1: ByteArray?, - val epochStartTime1: ULong?, - val epochKey2: ByteArray?, - val epochStartTime2: ULong?) { - override fun toString(): String = buildString { +class GroupKeyManagementClusterGroupKeySetStruct( + val groupKeySetID: UInt, + val groupKeySecurityPolicy: UInt, + val epochKey0: ByteArray?, + val epochStartTime0: ULong?, + val epochKey1: ByteArray?, + val epochStartTime1: ULong?, + val epochKey2: ByteArray?, + val epochStartTime2: ULong? +) { + override fun toString(): String = buildString { append("GroupKeyManagementClusterGroupKeySetStruct {\n") append("\tgroupKeySetID : $groupKeySetID\n") append("\tgroupKeySecurityPolicy : $groupKeySecurityPolicy\n") @@ -54,35 +51,35 @@ class GroupKeyManagementClusterGroupKeySetStruct ( put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D), groupKeySetID) put(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY), groupKeySecurityPolicy) if (epochKey0 != null) { - put(ContextSpecificTag(TAG_EPOCH_KEY0), epochKey0) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_KEY0)) - } + put(ContextSpecificTag(TAG_EPOCH_KEY0), epochKey0) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_KEY0)) + } if (epochStartTime0 != null) { - put(ContextSpecificTag(TAG_EPOCH_START_TIME0), epochStartTime0) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - } + put(ContextSpecificTag(TAG_EPOCH_START_TIME0), epochStartTime0) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + } if (epochKey1 != null) { - put(ContextSpecificTag(TAG_EPOCH_KEY1), epochKey1) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_KEY1)) - } + put(ContextSpecificTag(TAG_EPOCH_KEY1), epochKey1) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_KEY1)) + } if (epochStartTime1 != null) { - put(ContextSpecificTag(TAG_EPOCH_START_TIME1), epochStartTime1) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - } + put(ContextSpecificTag(TAG_EPOCH_START_TIME1), epochStartTime1) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + } if (epochKey2 != null) { - put(ContextSpecificTag(TAG_EPOCH_KEY2), epochKey2) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_KEY2)) - } + put(ContextSpecificTag(TAG_EPOCH_KEY2), epochKey2) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_KEY2)) + } if (epochStartTime2 != null) { - put(ContextSpecificTag(TAG_EPOCH_START_TIME2), epochStartTime2) - } else { - putNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - } + put(ContextSpecificTag(TAG_EPOCH_START_TIME2), epochStartTime2) + } else { + putNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + } endStructure() } } @@ -97,50 +94,66 @@ class GroupKeyManagementClusterGroupKeySetStruct ( private const val TAG_EPOCH_KEY2 = 6 private const val TAG_EPOCH_START_TIME2 = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GroupKeyManagementClusterGroupKeySetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupKeySetStruct { tlvReader.enterStructure(tlvTag) val groupKeySetID = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) - val groupKeySecurityPolicy = tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) - val epochKey0 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) - null - } - val epochStartTime0 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - null - } - val epochKey1 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) - null - } - val epochStartTime1 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - null - } - val epochKey2 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) - null - } - val epochStartTime2 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - null - } - + val groupKeySecurityPolicy = + tlvReader.getUInt(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) + val epochKey0 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) + null + } + val epochStartTime0 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + null + } + val epochKey1 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) + null + } + val epochStartTime1 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + null + } + val epochKey2 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) + null + } + val epochStartTime2 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + null + } + tlvReader.exitContainer() - return GroupKeyManagementClusterGroupKeySetStruct(groupKeySetID, groupKeySecurityPolicy, epochKey0, epochStartTime0, epochKey1, epochStartTime1, epochKey2, epochStartTime2) + return GroupKeyManagementClusterGroupKeySetStruct( + groupKeySetID, + groupKeySecurityPolicy, + epochKey0, + epochStartTime0, + epochKey1, + epochStartTime1, + epochKey2, + epochStartTime2 + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt index a5e79f7e076234..b36468116ac1dd 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class HepaFilterMonitoringClusterReplacementProductStruct ( - val productIdentifierType: UInt, - val productIdentifierValue: String) { - override fun toString(): String = buildString { +class HepaFilterMonitoringClusterReplacementProductStruct( + val productIdentifierType: UInt, + val productIdentifierValue: String +) { + override fun toString(): String = buildString { append("HepaFilterMonitoringClusterReplacementProductStruct {\n") append("\tproductIdentifierType : $productIdentifierType\n") append("\tproductIdentifierValue : $productIdentifierValue\n") @@ -49,14 +46,21 @@ class HepaFilterMonitoringClusterReplacementProductStruct ( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : HepaFilterMonitoringClusterReplacementProductStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): HepaFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) val productIdentifierType = tlvReader.getUInt(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierValue = + tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return HepaFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) + return HepaFilterMonitoringClusterReplacementProductStruct( + productIdentifierType, + productIdentifierValue + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt index 73b5b688af77c2..87927430232e4e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class IcdManagementClusterMonitoringRegistrationStruct ( - val checkInNodeID: ULong, - val monitoredSubject: ULong, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class IcdManagementClusterMonitoringRegistrationStruct( + val checkInNodeID: ULong, + val monitoredSubject: ULong, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("IcdManagementClusterMonitoringRegistrationStruct {\n") append("\tcheckInNodeID : $checkInNodeID\n") append("\tmonitoredSubject : $monitoredSubject\n") @@ -53,15 +50,22 @@ class IcdManagementClusterMonitoringRegistrationStruct ( private const val TAG_MONITORED_SUBJECT = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : IcdManagementClusterMonitoringRegistrationStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): IcdManagementClusterMonitoringRegistrationStruct { tlvReader.enterStructure(tlvTag) val checkInNodeID = tlvReader.getULong(ContextSpecificTag(TAG_CHECK_IN_NODE_I_D)) val monitoredSubject = tlvReader.getULong(ContextSpecificTag(TAG_MONITORED_SUBJECT)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return IcdManagementClusterMonitoringRegistrationStruct(checkInNodeID, monitoredSubject, fabricIndex) + return IcdManagementClusterMonitoringRegistrationStruct( + checkInNodeID, + monitoredSubject, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt index 539ddd1fe657ec..f6ca291e0bb46e 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class LaundryWasherModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class LaundryWasherModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("LaundryWasherModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class LaundryWasherModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : LaundryWasherModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): LaundryWasherModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return LaundryWasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt index f5e971f19259ee..09c2915126efd6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class LaundryWasherModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("LaundryWasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class LaundryWasherModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class LaundryWasherModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : LaundryWasherModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): LaundryWasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return LaundryWasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt index a1e171a4805248..b2b26104143da8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaInputClusterInputInfoStruct.kt @@ -17,21 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MediaInputClusterInputInfoStruct ( - val index: UInt, - val inputType: UInt, - val name: String, - val description: String) { - override fun toString(): String = buildString { +class MediaInputClusterInputInfoStruct( + val index: UInt, + val inputType: UInt, + val name: String, + val description: String +) { + override fun toString(): String = buildString { append("MediaInputClusterInputInfoStruct {\n") append("\tindex : $index\n") append("\tinputType : $inputType\n") @@ -57,13 +54,13 @@ class MediaInputClusterInputInfoStruct ( private const val TAG_NAME = 2 private const val TAG_DESCRIPTION = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaInputClusterInputInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaInputClusterInputInfoStruct { tlvReader.enterStructure(tlvTag) val index = tlvReader.getUInt(ContextSpecificTag(TAG_INDEX)) val inputType = tlvReader.getUInt(ContextSpecificTag(TAG_INPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val description = tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION)) - + tlvReader.exitContainer() return MediaInputClusterInputInfoStruct(index, inputType, name, description) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt index a41c94eb25f23b..c58c381f8d6e14 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MediaPlaybackClusterPlaybackPositionStruct ( - val updatedAt: ULong, - val position: ULong?) { - override fun toString(): String = buildString { +class MediaPlaybackClusterPlaybackPositionStruct(val updatedAt: ULong, val position: ULong?) { + override fun toString(): String = buildString { append("MediaPlaybackClusterPlaybackPositionStruct {\n") append("\tupdatedAt : $updatedAt\n") append("\tposition : $position\n") @@ -41,10 +35,10 @@ class MediaPlaybackClusterPlaybackPositionStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_UPDATED_AT), updatedAt) if (position != null) { - put(ContextSpecificTag(TAG_POSITION), position) - } else { - putNull(ContextSpecificTag(TAG_POSITION)) - } + put(ContextSpecificTag(TAG_POSITION), position) + } else { + putNull(ContextSpecificTag(TAG_POSITION)) + } endStructure() } } @@ -53,16 +47,17 @@ class MediaPlaybackClusterPlaybackPositionStruct ( private const val TAG_UPDATED_AT = 0 private const val TAG_POSITION = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterPlaybackPositionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterPlaybackPositionStruct { tlvReader.enterStructure(tlvTag) val updatedAt = tlvReader.getULong(ContextSpecificTag(TAG_UPDATED_AT)) - val position = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) - null - } - + val position = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterPlaybackPositionStruct(updatedAt, position) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt index 85afda84daca8d..1b991a4a051864 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MediaPlaybackClusterTrackAttributesStruct ( - val languageCode: String, - val displayName: Optional?) { - override fun toString(): String = buildString { +class MediaPlaybackClusterTrackAttributesStruct( + val languageCode: String, + val displayName: Optional? +) { + override fun toString(): String = buildString { append("MediaPlaybackClusterTrackAttributesStruct {\n") append("\tlanguageCode : $languageCode\n") append("\tdisplayName : $displayName\n") @@ -41,13 +39,13 @@ class MediaPlaybackClusterTrackAttributesStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_LANGUAGE_CODE), languageCode) if (displayName != null) { - if (displayName.isPresent) { - val optdisplayName = displayName.get() - put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) - } - } else { - putNull(ContextSpecificTag(TAG_DISPLAY_NAME)) - } + if (displayName.isPresent) { + val optdisplayName = displayName.get() + put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) + } + } else { + putNull(ContextSpecificTag(TAG_DISPLAY_NAME)) + } endStructure() } } @@ -56,20 +54,21 @@ class MediaPlaybackClusterTrackAttributesStruct ( private const val TAG_LANGUAGE_CODE = 0 private const val TAG_DISPLAY_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterTrackAttributesStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackAttributesStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val displayName = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) - null - } - + val displayName = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackAttributesStruct(languageCode, displayName) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt index cca4fa751f8d8d..087bc437a2a754 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MediaPlaybackClusterTrackStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MediaPlaybackClusterTrackStruct ( - val id: String, - val trackAttributes: MediaPlaybackClusterTrackAttributesStruct?) { - override fun toString(): String = buildString { +class MediaPlaybackClusterTrackStruct( + val id: String, + val trackAttributes: MediaPlaybackClusterTrackAttributesStruct? +) { + override fun toString(): String = buildString { append("MediaPlaybackClusterTrackStruct {\n") append("\tid : $id\n") append("\ttrackAttributes : $trackAttributes\n") @@ -41,10 +38,10 @@ class MediaPlaybackClusterTrackStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ID), id) if (trackAttributes != null) { - trackAttributes.toTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), this) - } else { - putNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) - } + trackAttributes.toTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), this) + } else { + putNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) + } endStructure() } } @@ -53,16 +50,20 @@ class MediaPlaybackClusterTrackStruct ( private const val TAG_ID = 0 private const val TAG_TRACK_ATTRIBUTES = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterTrackStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getString(ContextSpecificTag(TAG_ID)) - val trackAttributes = if (!tlvReader.isNull()) { - MediaPlaybackClusterTrackAttributesStruct.fromTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) - null - } - + val trackAttributes = + if (!tlvReader.isNull()) { + MediaPlaybackClusterTrackAttributesStruct.fromTlv( + ContextSpecificTag(TAG_TRACK_ATTRIBUTES), + tlvReader + ) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackStruct(id, trackAttributes) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt index 504a72e24e3598..69caf35509d049 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MicrowaveOvenModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class MicrowaveOvenModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("MicrowaveOvenModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class MicrowaveOvenModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MicrowaveOvenModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MicrowaveOvenModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt index 4459562dcadcf3..bf9800a012de5f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class MicrowaveOvenModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("MicrowaveOvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class MicrowaveOvenModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class MicrowaveOvenModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MicrowaveOvenModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MicrowaveOvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt index 6613c8f6988cc6..fb74943fcd20b0 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ModeSelectClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val semanticTags: List) { - override fun toString(): String = buildString { +class ModeSelectClusterModeOptionStruct( + val label: String, + val mode: UInt, + val semanticTags: List +) { + override fun toString(): String = buildString { append("ModeSelectClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class ModeSelectClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_SEMANTIC_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ModeSelectClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ModeSelectClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val semanticTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val semanticTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ModeSelectClusterModeOptionStruct(label, mode, semanticTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt index 2b501b089a5d8e..ca14c2ebd4d8dc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ModeSelectClusterSemanticTagStruct ( - val mfgCode: UInt, - val value: UInt) { - override fun toString(): String = buildString { +class ModeSelectClusterSemanticTagStruct(val mfgCode: UInt, val value: UInt) { + override fun toString(): String = buildString { append("ModeSelectClusterSemanticTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -49,11 +43,11 @@ class ModeSelectClusterSemanticTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ModeSelectClusterSemanticTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ModeSelectClusterSemanticTagStruct { tlvReader.enterStructure(tlvTag) val mfgCode = tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE)) val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ModeSelectClusterSemanticTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt index 78e54129ba293a..82f98aeb677204 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt @@ -17,21 +17,19 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class NetworkCommissioningClusterNetworkInfoStruct ( - val networkID: ByteArray, - val connected: Boolean, - val networkIdentifier: Optional?, - val clientIdentifier: Optional?) { - override fun toString(): String = buildString { +class NetworkCommissioningClusterNetworkInfoStruct( + val networkID: ByteArray, + val connected: Boolean, + val networkIdentifier: Optional?, + val clientIdentifier: Optional? +) { + override fun toString(): String = buildString { append("NetworkCommissioningClusterNetworkInfoStruct {\n") append("\tnetworkID : $networkID\n") append("\tconnected : $connected\n") @@ -46,21 +44,21 @@ class NetworkCommissioningClusterNetworkInfoStruct ( put(ContextSpecificTag(TAG_NETWORK_I_D), networkID) put(ContextSpecificTag(TAG_CONNECTED), connected) if (networkIdentifier != null) { - if (networkIdentifier.isPresent) { - val optnetworkIdentifier = networkIdentifier.get() - put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) - } - } else { - putNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) - } + if (networkIdentifier.isPresent) { + val optnetworkIdentifier = networkIdentifier.get() + put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) + } + } else { + putNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) + } if (clientIdentifier != null) { - if (clientIdentifier.isPresent) { - val optclientIdentifier = clientIdentifier.get() - put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) - } - } else { - putNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) - } + if (clientIdentifier.isPresent) { + val optclientIdentifier = clientIdentifier.get() + put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) + } + } else { + putNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) + } endStructure() } } @@ -71,34 +69,41 @@ class NetworkCommissioningClusterNetworkInfoStruct ( private const val TAG_NETWORK_IDENTIFIER = 2 private const val TAG_CLIENT_IDENTIFIER = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : NetworkCommissioningClusterNetworkInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): NetworkCommissioningClusterNetworkInfoStruct { tlvReader.enterStructure(tlvTag) val networkID = tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_I_D)) val connected = tlvReader.getBoolean(ContextSpecificTag(TAG_CONNECTED)) - val networkIdentifier = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) - null - } - val clientIdentifier = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) - null - } - + val networkIdentifier = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) + null + } + val clientIdentifier = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) + null + } + tlvReader.exitContainer() - return NetworkCommissioningClusterNetworkInfoStruct(networkID, connected, networkIdentifier, clientIdentifier) + return NetworkCommissioningClusterNetworkInfoStruct( + networkID, + connected, + networkIdentifier, + clientIdentifier + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt index 01d987d0125f0f..c72319998ba002 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt @@ -17,25 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class NetworkCommissioningClusterThreadInterfaceScanResultStruct ( - val panId: UInt, - val extendedPanId: ULong, - val networkName: String, - val channel: UInt, - val version: UInt, - val extendedAddress: ByteArray, - val rssi: Int, - val lqi: UInt) { - override fun toString(): String = buildString { +class NetworkCommissioningClusterThreadInterfaceScanResultStruct( + val panId: UInt, + val extendedPanId: ULong, + val networkName: String, + val channel: UInt, + val version: UInt, + val extendedAddress: ByteArray, + val rssi: Int, + val lqi: UInt +) { + override fun toString(): String = buildString { append("NetworkCommissioningClusterThreadInterfaceScanResultStruct {\n") append("\tpanId : $panId\n") append("\textendedPanId : $extendedPanId\n") @@ -73,7 +70,10 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct ( private const val TAG_RSSI = 6 private const val TAG_LQI = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : NetworkCommissioningClusterThreadInterfaceScanResultStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): NetworkCommissioningClusterThreadInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val panId = tlvReader.getUInt(ContextSpecificTag(TAG_PAN_ID)) val extendedPanId = tlvReader.getULong(ContextSpecificTag(TAG_EXTENDED_PAN_ID)) @@ -83,10 +83,19 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct ( val extendedAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_EXTENDED_ADDRESS)) val rssi = tlvReader.getInt(ContextSpecificTag(TAG_RSSI)) val lqi = tlvReader.getUInt(ContextSpecificTag(TAG_LQI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterThreadInterfaceScanResultStruct(panId, extendedPanId, networkName, channel, version, extendedAddress, rssi, lqi) + return NetworkCommissioningClusterThreadInterfaceScanResultStruct( + panId, + extendedPanId, + networkName, + channel, + version, + extendedAddress, + rssi, + lqi + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt index 8bdbd11bbc322c..e3e4ef10cbce76 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt @@ -17,23 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class NetworkCommissioningClusterWiFiInterfaceScanResultStruct ( - val security: UInt, - val ssid: ByteArray, - val bssid: ByteArray, - val channel: UInt, - val wiFiBand: UInt, - val rssi: Int) { - override fun toString(): String = buildString { +class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( + val security: UInt, + val ssid: ByteArray, + val bssid: ByteArray, + val channel: UInt, + val wiFiBand: UInt, + val rssi: Int +) { + override fun toString(): String = buildString { append("NetworkCommissioningClusterWiFiInterfaceScanResultStruct {\n") append("\tsecurity : $security\n") append("\tssid : $ssid\n") @@ -65,7 +62,10 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct ( private const val TAG_WI_FI_BAND = 4 private const val TAG_RSSI = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : NetworkCommissioningClusterWiFiInterfaceScanResultStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): NetworkCommissioningClusterWiFiInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val security = tlvReader.getUInt(ContextSpecificTag(TAG_SECURITY)) val ssid = tlvReader.getByteArray(ContextSpecificTag(TAG_SSID)) @@ -73,10 +73,17 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct ( val channel = tlvReader.getUInt(ContextSpecificTag(TAG_CHANNEL)) val wiFiBand = tlvReader.getUInt(ContextSpecificTag(TAG_WI_FI_BAND)) val rssi = tlvReader.getInt(ContextSpecificTag(TAG_RSSI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterWiFiInterfaceScanResultStruct(security, ssid, bssid, channel, wiFiBand, rssi) + return NetworkCommissioningClusterWiFiInterfaceScanResultStruct( + security, + ssid, + bssid, + channel, + wiFiBand, + rssi + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt index de9d80b7482140..a1e736d1b0407c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt @@ -17,23 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalCredentialsClusterFabricDescriptorStruct ( - val rootPublicKey: ByteArray, - val vendorID: UInt, - val fabricID: ULong, - val nodeID: ULong, - val label: String, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class OperationalCredentialsClusterFabricDescriptorStruct( + val rootPublicKey: ByteArray, + val vendorID: UInt, + val fabricID: ULong, + val nodeID: ULong, + val label: String, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("OperationalCredentialsClusterFabricDescriptorStruct {\n") append("\trootPublicKey : $rootPublicKey\n") append("\tvendorID : $vendorID\n") @@ -65,7 +62,10 @@ class OperationalCredentialsClusterFabricDescriptorStruct ( private const val TAG_LABEL = 5 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalCredentialsClusterFabricDescriptorStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OperationalCredentialsClusterFabricDescriptorStruct { tlvReader.enterStructure(tlvTag) val rootPublicKey = tlvReader.getByteArray(ContextSpecificTag(TAG_ROOT_PUBLIC_KEY)) val vendorID = tlvReader.getUInt(ContextSpecificTag(TAG_VENDOR_I_D)) @@ -73,10 +73,17 @@ class OperationalCredentialsClusterFabricDescriptorStruct ( val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OperationalCredentialsClusterFabricDescriptorStruct(rootPublicKey, vendorID, fabricID, nodeID, label, fabricIndex) + return OperationalCredentialsClusterFabricDescriptorStruct( + rootPublicKey, + vendorID, + fabricID, + nodeID, + label, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt index 2013bec14e74b5..a45a68e28cf2f8 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalCredentialsClusterNOCStruct ( - val noc: ByteArray, - val icac: ByteArray?, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class OperationalCredentialsClusterNOCStruct( + val noc: ByteArray, + val icac: ByteArray?, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("OperationalCredentialsClusterNOCStruct {\n") append("\tnoc : $noc\n") append("\ticac : $icac\n") @@ -43,10 +40,10 @@ class OperationalCredentialsClusterNOCStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_NOC), noc) if (icac != null) { - put(ContextSpecificTag(TAG_ICAC), icac) - } else { - putNull(ContextSpecificTag(TAG_ICAC)) - } + put(ContextSpecificTag(TAG_ICAC), icac) + } else { + putNull(ContextSpecificTag(TAG_ICAC)) + } put(ContextSpecificTag(TAG_FABRIC_INDEX), fabricIndex) endStructure() } @@ -57,17 +54,18 @@ class OperationalCredentialsClusterNOCStruct ( private const val TAG_ICAC = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalCredentialsClusterNOCStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalCredentialsClusterNOCStruct { tlvReader.enterStructure(tlvTag) val noc = tlvReader.getByteArray(ContextSpecificTag(TAG_NOC)) - val icac = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) - null - } + val icac = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) + null + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return OperationalCredentialsClusterNOCStruct(noc, icac, fabricIndex) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt index 6078c84c862ae8..c41c0205d88d84 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterErrorStateStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalStateClusterErrorStateStruct ( - val errorStateID: UInt, - val errorStateLabel: Optional, - val errorStateDetails: Optional) { - override fun toString(): String = buildString { +class OperationalStateClusterErrorStateStruct( + val errorStateID: UInt, + val errorStateLabel: Optional, + val errorStateDetails: Optional +) { + override fun toString(): String = buildString { append("OperationalStateClusterErrorStateStruct {\n") append("\terrorStateID : $errorStateID\n") append("\terrorStateLabel : $errorStateLabel\n") @@ -43,13 +41,13 @@ class OperationalStateClusterErrorStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ERROR_STATE_I_D), errorStateID) if (errorStateLabel.isPresent) { - val opterrorStateLabel = errorStateLabel.get() - put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) - } + val opterrorStateLabel = errorStateLabel.get() + put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) + } if (errorStateDetails.isPresent) { - val opterrorStateDetails = errorStateDetails.get() - put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) - } + val opterrorStateDetails = errorStateDetails.get() + put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) + } endStructure() } } @@ -59,23 +57,29 @@ class OperationalStateClusterErrorStateStruct ( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterErrorStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return OperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt index e464504d71b4f1..3157b9c4b7dec2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OperationalStateClusterOperationalStateStruct ( - val operationalStateID: UInt, - val operationalStateLabel: Optional) { - override fun toString(): String = buildString { +class OperationalStateClusterOperationalStateStruct( + val operationalStateID: UInt, + val operationalStateLabel: Optional +) { + override fun toString(): String = buildString { append("OperationalStateClusterOperationalStateStruct {\n") append("\toperationalStateID : $operationalStateID\n") append("\toperationalStateLabel : $operationalStateLabel\n") @@ -41,9 +39,9 @@ class OperationalStateClusterOperationalStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D), operationalStateID) if (operationalStateLabel.isPresent) { - val optoperationalStateLabel = operationalStateLabel.get() - put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) - } + val optoperationalStateLabel = operationalStateLabel.get() + put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) + } endStructure() } } @@ -52,18 +50,22 @@ class OperationalStateClusterOperationalStateStruct ( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationalStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return OperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt index 7f80ca90ed8c9f..abb8f952cfce50 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OtaSoftwareUpdateRequestorClusterProviderLocation ( - val providerNodeID: ULong, - val endpoint: UInt, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class OtaSoftwareUpdateRequestorClusterProviderLocation( + val providerNodeID: ULong, + val endpoint: UInt, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("OtaSoftwareUpdateRequestorClusterProviderLocation {\n") append("\tproviderNodeID : $providerNodeID\n") append("\tendpoint : $endpoint\n") @@ -53,15 +50,22 @@ class OtaSoftwareUpdateRequestorClusterProviderLocation ( private const val TAG_ENDPOINT = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterProviderLocation { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterProviderLocation { tlvReader.enterStructure(tlvTag) val providerNodeID = tlvReader.getULong(ContextSpecificTag(TAG_PROVIDER_NODE_I_D)) val endpoint = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterProviderLocation(providerNodeID, endpoint, fabricIndex) + return OtaSoftwareUpdateRequestorClusterProviderLocation( + providerNodeID, + endpoint, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt index 8844263c96a1ce..dff5c0684a1501 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenCavityOperationalStateClusterErrorStateStruct ( - val errorStateID: UInt, - val errorStateLabel: Optional, - val errorStateDetails: Optional) { - override fun toString(): String = buildString { +class OvenCavityOperationalStateClusterErrorStateStruct( + val errorStateID: UInt, + val errorStateLabel: Optional, + val errorStateDetails: Optional +) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterErrorStateStruct {\n") append("\terrorStateID : $errorStateID\n") append("\terrorStateLabel : $errorStateLabel\n") @@ -43,13 +41,13 @@ class OvenCavityOperationalStateClusterErrorStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ERROR_STATE_I_D), errorStateID) if (errorStateLabel.isPresent) { - val opterrorStateLabel = errorStateLabel.get() - put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) - } + val opterrorStateLabel = errorStateLabel.get() + put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) + } if (errorStateDetails.isPresent) { - val opterrorStateDetails = errorStateDetails.get() - put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) - } + val opterrorStateDetails = errorStateDetails.get() + put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) + } endStructure() } } @@ -59,23 +57,32 @@ class OvenCavityOperationalStateClusterErrorStateStruct ( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterErrorStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return OvenCavityOperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt index 6d815321e7cb46..1d32c7fe4a6af2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenCavityOperationalStateClusterOperationalStateStruct ( - val operationalStateID: UInt, - val operationalStateLabel: Optional) { - override fun toString(): String = buildString { +class OvenCavityOperationalStateClusterOperationalStateStruct( + val operationalStateID: UInt, + val operationalStateLabel: Optional +) { + override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationalStateStruct {\n") append("\toperationalStateID : $operationalStateID\n") append("\toperationalStateLabel : $operationalStateLabel\n") @@ -41,9 +39,9 @@ class OvenCavityOperationalStateClusterOperationalStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D), operationalStateID) if (operationalStateLabel.isPresent) { - val optoperationalStateLabel = operationalStateLabel.get() - put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) - } + val optoperationalStateLabel = operationalStateLabel.get() + put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) + } endStructure() } } @@ -52,18 +50,25 @@ class OvenCavityOperationalStateClusterOperationalStateStruct ( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationalStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return OvenCavityOperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt index 4698441672eae2..0df558d3935e26 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class OvenModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("OvenModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class OvenModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return OvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt index 9c204fa8ecb2ea..df0465b2c3055d 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/OvenModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class OvenModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("OvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class OvenModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class OvenModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return OvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt index c24d47fe4b23ee..1d260017a0b722 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterBatChargeFaultChangeType ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterBatChargeFaultChangeType( + val current: List, + val previous: List +) { + override fun toString(): String = buildString { append("PowerSourceClusterBatChargeFaultChangeType {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +55,25 @@ class PowerSourceClusterBatChargeFaultChangeType ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatChargeFaultChangeType { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt index 789a1f0a36c47c..07ed4351bcd3a1 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt @@ -20,16 +20,11 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterBatFaultChangeType ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterBatFaultChangeType(val current: List, val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeType {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +52,25 @@ class PowerSourceClusterBatFaultChangeType ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatFaultChangeType { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt index 849c0b2edfc454..f0c80ef26ff5ad 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt @@ -20,16 +20,11 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class PowerSourceClusterWiredFaultChangeType ( - val current: List, - val previous: List) { - override fun toString(): String = buildString { +class PowerSourceClusterWiredFaultChangeType(val current: List, val previous: List) { + override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeType {\n") append("\tcurrent : $current\n") append("\tprevious : $previous\n") @@ -57,23 +52,25 @@ class PowerSourceClusterWiredFaultChangeType ( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterWiredFaultChangeType { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt index 74809e3ae5215c..85b1d995d2fd76 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,21 +55,34 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add( + RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct(label, mode, modeTags) + return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( + label, + mode, + modeTags + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt index 0831587768d6a3..db10b1db8bab30 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct( + val mfgCode: Optional, + val value: UInt +) { + override fun toString(): String = buildString { append("RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +38,9 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +50,19 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt index d4cf5dd09a6214..31f7b8adb6ac63 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcCleanModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class RvcCleanModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("RvcCleanModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class RvcCleanModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcCleanModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcCleanModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcCleanModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt index 7c293c839acb4f..a06d26774dacc6 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcCleanModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("RvcCleanModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class RvcCleanModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class RvcCleanModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcCleanModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcCleanModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcCleanModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt index 15f9250edbe478..0f8daddb5212c3 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcOperationalStateClusterErrorStateStruct ( - val errorStateID: UInt, - val errorStateLabel: Optional, - val errorStateDetails: Optional) { - override fun toString(): String = buildString { +class RvcOperationalStateClusterErrorStateStruct( + val errorStateID: UInt, + val errorStateLabel: Optional, + val errorStateDetails: Optional +) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterErrorStateStruct {\n") append("\terrorStateID : $errorStateID\n") append("\terrorStateLabel : $errorStateLabel\n") @@ -43,13 +41,13 @@ class RvcOperationalStateClusterErrorStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ERROR_STATE_I_D), errorStateID) if (errorStateLabel.isPresent) { - val opterrorStateLabel = errorStateLabel.get() - put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) - } + val opterrorStateLabel = errorStateLabel.get() + put(ContextSpecificTag(TAG_ERROR_STATE_LABEL), opterrorStateLabel) + } if (errorStateDetails.isPresent) { - val opterrorStateDetails = errorStateDetails.get() - put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) - } + val opterrorStateDetails = errorStateDetails.get() + put(ContextSpecificTag(TAG_ERROR_STATE_DETAILS), opterrorStateDetails) + } endStructure() } } @@ -59,23 +57,29 @@ class RvcOperationalStateClusterErrorStateStruct ( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterErrorStateStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUInt(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return RvcOperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt index 930daff7a6d833..cc01c472f7f71b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt @@ -17,19 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcOperationalStateClusterOperationalStateStruct ( - val operationalStateID: UInt, - val operationalStateLabel: Optional) { - override fun toString(): String = buildString { +class RvcOperationalStateClusterOperationalStateStruct( + val operationalStateID: UInt, + val operationalStateLabel: Optional +) { + override fun toString(): String = buildString { append("RvcOperationalStateClusterOperationalStateStruct {\n") append("\toperationalStateID : $operationalStateID\n") append("\toperationalStateLabel : $operationalStateLabel\n") @@ -41,9 +39,9 @@ class RvcOperationalStateClusterOperationalStateStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D), operationalStateID) if (operationalStateLabel.isPresent) { - val optoperationalStateLabel = operationalStateLabel.get() - put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) - } + val optoperationalStateLabel = operationalStateLabel.get() + put(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL), optoperationalStateLabel) + } endStructure() } } @@ -52,18 +50,25 @@ class RvcOperationalStateClusterOperationalStateStruct ( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationalStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUInt(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return RvcOperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt index 519546666e3b33..c20f7b3f626474 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt @@ -20,17 +20,15 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcRunModeClusterModeOptionStruct ( - val label: String, - val mode: UInt, - val modeTags: List) { - override fun toString(): String = buildString { +class RvcRunModeClusterModeOptionStruct( + val label: String, + val mode: UInt, + val modeTags: List +) { + override fun toString(): String = buildString { append("RvcRunModeClusterModeOptionStruct {\n") append("\tlabel : $label\n") append("\tmode : $mode\n") @@ -57,18 +55,19 @@ class RvcRunModeClusterModeOptionStruct ( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcRunModeClusterModeOptionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcRunModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUInt(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcRunModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt index c6183c3e89c585..4c32d28ee6ad67 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/RvcRunModeClusterModeTagStruct.kt @@ -17,19 +17,14 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class RvcRunModeClusterModeTagStruct ( - val mfgCode: Optional, - val value: UInt) { - override fun toString(): String = buildString { +class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: UInt) { + override fun toString(): String = buildString { append("RvcRunModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") append("\tvalue : $value\n") @@ -40,9 +35,9 @@ class RvcRunModeClusterModeTagStruct ( tlvWriter.apply { startStructure(tlvTag) if (mfgCode.isPresent) { - val optmfgCode = mfgCode.get() - put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) - } + val optmfgCode = mfgCode.get() + put(ContextSpecificTag(TAG_MFG_CODE), optmfgCode) + } put(ContextSpecificTag(TAG_VALUE), value) endStructure() } @@ -52,15 +47,16 @@ class RvcRunModeClusterModeTagStruct ( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcRunModeClusterModeTagStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcRunModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUInt(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcRunModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt index 58f02b50feda16..3cf9c98d53e6d1 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ScenesManagementClusterAttributeValuePair ( - val attributeID: ULong, - val attributeValue: ULong) { - override fun toString(): String = buildString { +class ScenesManagementClusterAttributeValuePair(val attributeID: ULong, val attributeValue: ULong) { + override fun toString(): String = buildString { append("ScenesManagementClusterAttributeValuePair {\n") append("\tattributeID : $attributeID\n") append("\tattributeValue : $attributeValue\n") @@ -49,11 +43,11 @@ class ScenesManagementClusterAttributeValuePair ( private const val TAG_ATTRIBUTE_I_D = 0 private const val TAG_ATTRIBUTE_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ScenesManagementClusterAttributeValuePair { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterAttributeValuePair { tlvReader.enterStructure(tlvTag) val attributeID = tlvReader.getULong(ContextSpecificTag(TAG_ATTRIBUTE_I_D)) val attributeValue = tlvReader.getULong(ContextSpecificTag(TAG_ATTRIBUTE_VALUE)) - + tlvReader.exitContainer() return ScenesManagementClusterAttributeValuePair(attributeID, attributeValue) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt index 6d4411c76baead..3ef60f519e09c2 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt @@ -20,16 +20,14 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ScenesManagementClusterExtensionFieldSet ( - val clusterID: ULong, - val attributeValueList: List) { - override fun toString(): String = buildString { +class ScenesManagementClusterExtensionFieldSet( + val clusterID: ULong, + val attributeValueList: List +) { + override fun toString(): String = buildString { append("ScenesManagementClusterExtensionFieldSet {\n") append("\tclusterID : $clusterID\n") append("\tattributeValueList : $attributeValueList\n") @@ -53,17 +51,18 @@ class ScenesManagementClusterExtensionFieldSet ( private const val TAG_CLUSTER_I_D = 0 private const val TAG_ATTRIBUTE_VALUE_LIST = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ScenesManagementClusterExtensionFieldSet { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterExtensionFieldSet { tlvReader.enterStructure(tlvTag) val clusterID = tlvReader.getULong(ContextSpecificTag(TAG_CLUSTER_I_D)) - val attributeValueList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val attributeValueList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ScenesManagementClusterExtensionFieldSet(clusterID, attributeValueList) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt index 3ac060b092b76a..74979432fbc571 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt @@ -17,23 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ScenesManagementClusterSceneInfoStruct ( - val sceneCount: UInt, - val currentScene: UInt, - val currentGroup: UInt, - val sceneValid: Boolean, - val remainingCapacity: UInt, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class ScenesManagementClusterSceneInfoStruct( + val sceneCount: UInt, + val currentScene: UInt, + val currentGroup: UInt, + val sceneValid: Boolean, + val remainingCapacity: UInt, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("ScenesManagementClusterSceneInfoStruct {\n") append("\tsceneCount : $sceneCount\n") append("\tcurrentScene : $currentScene\n") @@ -65,7 +62,7 @@ class ScenesManagementClusterSceneInfoStruct ( private const val TAG_REMAINING_CAPACITY = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ScenesManagementClusterSceneInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterSceneInfoStruct { tlvReader.enterStructure(tlvTag) val sceneCount = tlvReader.getUInt(ContextSpecificTag(TAG_SCENE_COUNT)) val currentScene = tlvReader.getUInt(ContextSpecificTag(TAG_CURRENT_SCENE)) @@ -73,10 +70,17 @@ class ScenesManagementClusterSceneInfoStruct ( val sceneValid = tlvReader.getBoolean(ContextSpecificTag(TAG_SCENE_VALID)) val remainingCapacity = tlvReader.getUInt(ContextSpecificTag(TAG_REMAINING_CAPACITY)) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return ScenesManagementClusterSceneInfoStruct(sceneCount, currentScene, currentGroup, sceneValid, remainingCapacity, fabricIndex) + return ScenesManagementClusterSceneInfoStruct( + sceneCount, + currentScene, + currentGroup, + sceneValid, + remainingCapacity, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt index 3ef4fc6b3bbfa6..f606a46f9fd057 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt @@ -17,22 +17,20 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class SoftwareDiagnosticsClusterThreadMetricsStruct ( - val id: ULong, - val name: Optional, - val stackFreeCurrent: Optional, - val stackFreeMinimum: Optional, - val stackSize: Optional) { - override fun toString(): String = buildString { +class SoftwareDiagnosticsClusterThreadMetricsStruct( + val id: ULong, + val name: Optional, + val stackFreeCurrent: Optional, + val stackFreeMinimum: Optional, + val stackSize: Optional +) { + override fun toString(): String = buildString { append("SoftwareDiagnosticsClusterThreadMetricsStruct {\n") append("\tid : $id\n") append("\tname : $name\n") @@ -47,21 +45,21 @@ class SoftwareDiagnosticsClusterThreadMetricsStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_ID), id) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (stackFreeCurrent.isPresent) { - val optstackFreeCurrent = stackFreeCurrent.get() - put(ContextSpecificTag(TAG_STACK_FREE_CURRENT), optstackFreeCurrent) - } + val optstackFreeCurrent = stackFreeCurrent.get() + put(ContextSpecificTag(TAG_STACK_FREE_CURRENT), optstackFreeCurrent) + } if (stackFreeMinimum.isPresent) { - val optstackFreeMinimum = stackFreeMinimum.get() - put(ContextSpecificTag(TAG_STACK_FREE_MINIMUM), optstackFreeMinimum) - } + val optstackFreeMinimum = stackFreeMinimum.get() + put(ContextSpecificTag(TAG_STACK_FREE_MINIMUM), optstackFreeMinimum) + } if (stackSize.isPresent) { - val optstackSize = stackSize.get() - put(ContextSpecificTag(TAG_STACK_SIZE), optstackSize) - } + val optstackSize = stackSize.get() + put(ContextSpecificTag(TAG_STACK_SIZE), optstackSize) + } endStructure() } } @@ -73,33 +71,43 @@ class SoftwareDiagnosticsClusterThreadMetricsStruct ( private const val TAG_STACK_FREE_MINIMUM = 3 private const val TAG_STACK_SIZE = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SoftwareDiagnosticsClusterThreadMetricsStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterThreadMetricsStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val stackFreeCurrent = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) - } else { - Optional.empty() - } - val stackFreeMinimum = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) - } else { - Optional.empty() - } - val stackSize = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_SIZE))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val stackFreeCurrent = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) + } else { + Optional.empty() + } + val stackFreeMinimum = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) + } else { + Optional.empty() + } + val stackSize = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_STACK_SIZE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return SoftwareDiagnosticsClusterThreadMetricsStruct(id, name, stackFreeCurrent, stackFreeMinimum, stackSize) + return SoftwareDiagnosticsClusterThreadMetricsStruct( + id, + name, + stackFreeCurrent, + stackFreeMinimum, + stackSize + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt index 49ebd8e74713c8..8d667ba0f94cfa 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TargetNavigatorClusterTargetInfoStruct ( - val identifier: UInt, - val name: String) { - override fun toString(): String = buildString { +class TargetNavigatorClusterTargetInfoStruct(val identifier: UInt, val name: String) { + override fun toString(): String = buildString { append("TargetNavigatorClusterTargetInfoStruct {\n") append("\tidentifier : $identifier\n") append("\tname : $name\n") @@ -49,11 +43,11 @@ class TargetNavigatorClusterTargetInfoStruct ( private const val TAG_IDENTIFIER = 0 private const val TAG_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TargetNavigatorClusterTargetInfoStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TargetNavigatorClusterTargetInfoStruct { tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getUInt(ContextSpecificTag(TAG_IDENTIFIER)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetInfoStruct(identifier, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt index 5b426e8234fc4d..cb91c04d920b9c 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetStruct.kt @@ -17,23 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterPresetStruct ( - val presetHandle: ByteArray?, - val presetScenario: UInt, - val name: Optional?, - val coolingSetpoint: Optional, - val heatingSetpoint: Optional, - val builtIn: Boolean?) { - override fun toString(): String = buildString { +class ThermostatClusterPresetStruct( + val presetHandle: ByteArray?, + val presetScenario: UInt, + val name: Optional?, + val coolingSetpoint: Optional, + val heatingSetpoint: Optional, + val builtIn: Boolean? +) { + override fun toString(): String = buildString { append("ThermostatClusterPresetStruct {\n") append("\tpresetHandle : $presetHandle\n") append("\tpresetScenario : $presetScenario\n") @@ -48,32 +46,32 @@ class ThermostatClusterPresetStruct ( tlvWriter.apply { startStructure(tlvTag) if (presetHandle != null) { - put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) - } else { - putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - } + put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) + } else { + putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + } put(ContextSpecificTag(TAG_PRESET_SCENARIO), presetScenario) if (name != null) { - if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } - } else { - putNull(ContextSpecificTag(TAG_NAME)) - } + if (name.isPresent) { + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } + } else { + putNull(ContextSpecificTag(TAG_NAME)) + } if (coolingSetpoint.isPresent) { - val optcoolingSetpoint = coolingSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) - } + val optcoolingSetpoint = coolingSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) + } if (heatingSetpoint.isPresent) { - val optheatingSetpoint = heatingSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) - } + val optheatingSetpoint = heatingSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) + } if (builtIn != null) { - put(ContextSpecificTag(TAG_BUILT_IN), builtIn) - } else { - putNull(ContextSpecificTag(TAG_BUILT_IN)) - } + put(ContextSpecificTag(TAG_BUILT_IN), builtIn) + } else { + putNull(ContextSpecificTag(TAG_BUILT_IN)) + } endStructure() } } @@ -86,45 +84,57 @@ class ThermostatClusterPresetStruct ( private const val TAG_HEATING_SETPOINT = 4 private const val TAG_BUILT_IN = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterPresetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } + val presetHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } val presetScenario = tlvReader.getUInt(ContextSpecificTag(TAG_PRESET_SCENARIO)) - val name = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NAME)) - null - } - val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - val builtIn = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NAME)) + null + } + val coolingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + val builtIn = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterPresetStruct(presetHandle, presetScenario, name, coolingSetpoint, heatingSetpoint, builtIn) + return ThermostatClusterPresetStruct( + presetHandle, + presetScenario, + name, + coolingSetpoint, + heatingSetpoint, + builtIn + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt index 26a9bab02f91e6..386af8f682e665 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterPresetTypeStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterPresetTypeStruct ( - val presetScenario: UInt, - val numberOfPresets: UInt, - val presetTypeFeatures: UInt) { - override fun toString(): String = buildString { +class ThermostatClusterPresetTypeStruct( + val presetScenario: UInt, + val numberOfPresets: UInt, + val presetTypeFeatures: UInt +) { + override fun toString(): String = buildString { append("ThermostatClusterPresetTypeStruct {\n") append("\tpresetScenario : $presetScenario\n") append("\tnumberOfPresets : $numberOfPresets\n") @@ -53,12 +50,12 @@ class ThermostatClusterPresetTypeStruct ( private const val TAG_NUMBER_OF_PRESETS = 1 private const val TAG_PRESET_TYPE_FEATURES = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterPresetTypeStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterPresetTypeStruct { tlvReader.enterStructure(tlvTag) val presetScenario = tlvReader.getUInt(ContextSpecificTag(TAG_PRESET_SCENARIO)) val numberOfPresets = tlvReader.getUInt(ContextSpecificTag(TAG_NUMBER_OF_PRESETS)) val presetTypeFeatures = tlvReader.getUInt(ContextSpecificTag(TAG_PRESET_TYPE_FEATURES)) - + tlvReader.exitContainer() return ThermostatClusterPresetTypeStruct(presetScenario, numberOfPresets, presetTypeFeatures) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt index 92e30614970dd2..4ecaecf98901dc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterQueuedPresetStruct ( - val presetHandle: ByteArray?, - val transitionTimestamp: ULong?) { - override fun toString(): String = buildString { +class ThermostatClusterQueuedPresetStruct( + val presetHandle: ByteArray?, + val transitionTimestamp: ULong? +) { + override fun toString(): String = buildString { append("ThermostatClusterQueuedPresetStruct {\n") append("\tpresetHandle : $presetHandle\n") append("\ttransitionTimestamp : $transitionTimestamp\n") @@ -40,15 +37,15 @@ class ThermostatClusterQueuedPresetStruct ( tlvWriter.apply { startStructure(tlvTag) if (presetHandle != null) { - put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) - } else { - putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - } + put(ContextSpecificTag(TAG_PRESET_HANDLE), presetHandle) + } else { + putNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + } if (transitionTimestamp != null) { - put(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP), transitionTimestamp) - } else { - putNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - } + put(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP), transitionTimestamp) + } else { + putNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + } endStructure() } } @@ -57,21 +54,23 @@ class ThermostatClusterQueuedPresetStruct ( private const val TAG_PRESET_HANDLE = 0 private const val TAG_TRANSITION_TIMESTAMP = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterQueuedPresetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterQueuedPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } - val transitionTimestamp = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - null - } - + val presetHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } + val transitionTimestamp = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + null + } + tlvReader.exitContainer() return ThermostatClusterQueuedPresetStruct(presetHandle, transitionTimestamp) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt index f07278bc4b607a..ac1ffbde1caca9 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleStruct.kt @@ -17,23 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterScheduleStruct ( - val scheduleHandle: ByteArray?, - val systemMode: UInt, - val name: Optional, - val presetHandle: Optional, - val transitions: List, - val builtIn: Optional?) { - override fun toString(): String = buildString { +class ThermostatClusterScheduleStruct( + val scheduleHandle: ByteArray?, + val systemMode: UInt, + val name: Optional, + val presetHandle: Optional, + val transitions: List, + val builtIn: Optional? +) { + override fun toString(): String = buildString { append("ThermostatClusterScheduleStruct {\n") append("\tscheduleHandle : $scheduleHandle\n") append("\tsystemMode : $systemMode\n") @@ -48,32 +47,32 @@ class ThermostatClusterScheduleStruct ( tlvWriter.apply { startStructure(tlvTag) if (scheduleHandle != null) { - put(ContextSpecificTag(TAG_SCHEDULE_HANDLE), scheduleHandle) - } else { - putNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - } + put(ContextSpecificTag(TAG_SCHEDULE_HANDLE), scheduleHandle) + } else { + putNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + } put(ContextSpecificTag(TAG_SYSTEM_MODE), systemMode) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } if (presetHandle.isPresent) { - val optpresetHandle = presetHandle.get() - put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) - } + val optpresetHandle = presetHandle.get() + put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) + } startArray(ContextSpecificTag(TAG_TRANSITIONS)) for (item in transitions.iterator()) { item.toTlv(AnonymousTag, this) } endArray() if (builtIn != null) { - if (builtIn.isPresent) { - val optbuiltIn = builtIn.get() - put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) - } - } else { - putNull(ContextSpecificTag(TAG_BUILT_IN)) - } + if (builtIn.isPresent) { + val optbuiltIn = builtIn.get() + put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) + } + } else { + putNull(ContextSpecificTag(TAG_BUILT_IN)) + } endStructure() } } @@ -86,46 +85,58 @@ class ThermostatClusterScheduleStruct ( private const val TAG_TRANSITIONS = 4 private const val TAG_BUILT_IN = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterScheduleStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleStruct { tlvReader.enterStructure(tlvTag) - val scheduleHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - null - } + val scheduleHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + null + } val systemMode = tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val transitions = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val builtIn = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val presetHandle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val transitions = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val builtIn = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterScheduleStruct(scheduleHandle, systemMode, name, presetHandle, transitions, builtIn) + return ThermostatClusterScheduleStruct( + scheduleHandle, + systemMode, + name, + presetHandle, + transitions, + builtIn + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt index e429994e90d20a..aabb3b6418da7b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt @@ -17,23 +17,21 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterScheduleTransitionStruct ( - val dayOfWeek: UInt, - val transitionTime: UInt, - val presetHandle: Optional, - val systemMode: Optional, - val coolingSetpoint: Optional, - val heatingSetpoint: Optional) { - override fun toString(): String = buildString { +class ThermostatClusterScheduleTransitionStruct( + val dayOfWeek: UInt, + val transitionTime: UInt, + val presetHandle: Optional, + val systemMode: Optional, + val coolingSetpoint: Optional, + val heatingSetpoint: Optional +) { + override fun toString(): String = buildString { append("ThermostatClusterScheduleTransitionStruct {\n") append("\tdayOfWeek : $dayOfWeek\n") append("\ttransitionTime : $transitionTime\n") @@ -50,21 +48,21 @@ class ThermostatClusterScheduleTransitionStruct ( put(ContextSpecificTag(TAG_DAY_OF_WEEK), dayOfWeek) put(ContextSpecificTag(TAG_TRANSITION_TIME), transitionTime) if (presetHandle.isPresent) { - val optpresetHandle = presetHandle.get() - put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) - } + val optpresetHandle = presetHandle.get() + put(ContextSpecificTag(TAG_PRESET_HANDLE), optpresetHandle) + } if (systemMode.isPresent) { - val optsystemMode = systemMode.get() - put(ContextSpecificTag(TAG_SYSTEM_MODE), optsystemMode) - } + val optsystemMode = systemMode.get() + put(ContextSpecificTag(TAG_SYSTEM_MODE), optsystemMode) + } if (coolingSetpoint.isPresent) { - val optcoolingSetpoint = coolingSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) - } + val optcoolingSetpoint = coolingSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_SETPOINT), optcoolingSetpoint) + } if (heatingSetpoint.isPresent) { - val optheatingSetpoint = heatingSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) - } + val optheatingSetpoint = heatingSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_SETPOINT), optheatingSetpoint) + } endStructure() } } @@ -77,34 +75,45 @@ class ThermostatClusterScheduleTransitionStruct ( private const val TAG_COOLING_SETPOINT = 4 private const val TAG_HEATING_SETPOINT = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterScheduleTransitionStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleTransitionStruct { tlvReader.enterStructure(tlvTag) val dayOfWeek = tlvReader.getUInt(ContextSpecificTag(TAG_DAY_OF_WEEK)) val transitionTime = tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIME)) - val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val systemMode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE))) - } else { - Optional.empty() - } - val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - + val presetHandle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val systemMode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE))) + } else { + Optional.empty() + } + val coolingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getInt(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ThermostatClusterScheduleTransitionStruct(dayOfWeek, transitionTime, presetHandle, systemMode, coolingSetpoint, heatingSetpoint) + return ThermostatClusterScheduleTransitionStruct( + dayOfWeek, + transitionTime, + presetHandle, + systemMode, + coolingSetpoint, + heatingSetpoint + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt index 02b2c88e6c9d01..eb62cbf32b28a4 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterScheduleTypeStruct ( - val systemMode: UInt, - val numberOfSchedules: UInt, - val scheduleTypeFeatures: UInt) { - override fun toString(): String = buildString { +class ThermostatClusterScheduleTypeStruct( + val systemMode: UInt, + val numberOfSchedules: UInt, + val scheduleTypeFeatures: UInt +) { + override fun toString(): String = buildString { append("ThermostatClusterScheduleTypeStruct {\n") append("\tsystemMode : $systemMode\n") append("\tnumberOfSchedules : $numberOfSchedules\n") @@ -53,15 +50,19 @@ class ThermostatClusterScheduleTypeStruct ( private const val TAG_NUMBER_OF_SCHEDULES = 1 private const val TAG_SCHEDULE_TYPE_FEATURES = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterScheduleTypeStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleTypeStruct { tlvReader.enterStructure(tlvTag) val systemMode = tlvReader.getUInt(ContextSpecificTag(TAG_SYSTEM_MODE)) val numberOfSchedules = tlvReader.getUInt(ContextSpecificTag(TAG_NUMBER_OF_SCHEDULES)) val scheduleTypeFeatures = tlvReader.getUInt(ContextSpecificTag(TAG_SCHEDULE_TYPE_FEATURES)) - + tlvReader.exitContainer() - return ThermostatClusterScheduleTypeStruct(systemMode, numberOfSchedules, scheduleTypeFeatures) + return ThermostatClusterScheduleTypeStruct( + systemMode, + numberOfSchedules, + scheduleTypeFeatures + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt index b033662cbf23b2..343952b9a54a79 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThermostatClusterWeeklyScheduleTransitionStruct ( - val transitionTime: UInt, - val heatSetpoint: Int?, - val coolSetpoint: Int?) { - override fun toString(): String = buildString { +class ThermostatClusterWeeklyScheduleTransitionStruct( + val transitionTime: UInt, + val heatSetpoint: Int?, + val coolSetpoint: Int? +) { + override fun toString(): String = buildString { append("ThermostatClusterWeeklyScheduleTransitionStruct {\n") append("\ttransitionTime : $transitionTime\n") append("\theatSetpoint : $heatSetpoint\n") @@ -43,15 +40,15 @@ class ThermostatClusterWeeklyScheduleTransitionStruct ( startStructure(tlvTag) put(ContextSpecificTag(TAG_TRANSITION_TIME), transitionTime) if (heatSetpoint != null) { - put(ContextSpecificTag(TAG_HEAT_SETPOINT), heatSetpoint) - } else { - putNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } + put(ContextSpecificTag(TAG_HEAT_SETPOINT), heatSetpoint) + } else { + putNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) + } if (coolSetpoint != null) { - put(ContextSpecificTag(TAG_COOL_SETPOINT), coolSetpoint) - } else { - putNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - } + put(ContextSpecificTag(TAG_COOL_SETPOINT), coolSetpoint) + } else { + putNull(ContextSpecificTag(TAG_COOL_SETPOINT)) + } endStructure() } } @@ -61,25 +58,34 @@ class ThermostatClusterWeeklyScheduleTransitionStruct ( private const val TAG_HEAT_SETPOINT = 1 private const val TAG_COOL_SETPOINT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThermostatClusterWeeklyScheduleTransitionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThermostatClusterWeeklyScheduleTransitionStruct { tlvReader.enterStructure(tlvTag) val transitionTime = tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIME)) - val heatSetpoint = if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - null - } - val coolSetpoint = if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_COOL_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - null - } - + val heatSetpoint = + if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_HEAT_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) + null + } + val coolSetpoint = + if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_COOL_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) + null + } + tlvReader.exitContainer() - return ThermostatClusterWeeklyScheduleTransitionStruct(transitionTime, heatSetpoint, coolSetpoint) + return ThermostatClusterWeeklyScheduleTransitionStruct( + transitionTime, + heatSetpoint, + coolSetpoint + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt index 40156c06651284..84733d5bd9d5fc 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt @@ -17,31 +17,28 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterNeighborTableStruct ( - val extAddress: ULong, - val age: ULong, - val rloc16: UInt, - val linkFrameCounter: ULong, - val mleFrameCounter: ULong, - val lqi: UInt, - val averageRssi: Int?, - val lastRssi: Int?, - val frameErrorRate: UInt, - val messageErrorRate: UInt, - val rxOnWhenIdle: Boolean, - val fullThreadDevice: Boolean, - val fullNetworkData: Boolean, - val isChild: Boolean) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterNeighborTableStruct( + val extAddress: ULong, + val age: ULong, + val rloc16: UInt, + val linkFrameCounter: ULong, + val mleFrameCounter: ULong, + val lqi: UInt, + val averageRssi: Int?, + val lastRssi: Int?, + val frameErrorRate: UInt, + val messageErrorRate: UInt, + val rxOnWhenIdle: Boolean, + val fullThreadDevice: Boolean, + val fullNetworkData: Boolean, + val isChild: Boolean +) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterNeighborTableStruct {\n") append("\textAddress : $extAddress\n") append("\tage : $age\n") @@ -70,15 +67,15 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct ( put(ContextSpecificTag(TAG_MLE_FRAME_COUNTER), mleFrameCounter) put(ContextSpecificTag(TAG_LQI), lqi) if (averageRssi != null) { - put(ContextSpecificTag(TAG_AVERAGE_RSSI), averageRssi) - } else { - putNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) - } + put(ContextSpecificTag(TAG_AVERAGE_RSSI), averageRssi) + } else { + putNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) + } if (lastRssi != null) { - put(ContextSpecificTag(TAG_LAST_RSSI), lastRssi) - } else { - putNull(ContextSpecificTag(TAG_LAST_RSSI)) - } + put(ContextSpecificTag(TAG_LAST_RSSI), lastRssi) + } else { + putNull(ContextSpecificTag(TAG_LAST_RSSI)) + } put(ContextSpecificTag(TAG_FRAME_ERROR_RATE), frameErrorRate) put(ContextSpecificTag(TAG_MESSAGE_ERROR_RATE), messageErrorRate) put(ContextSpecificTag(TAG_RX_ON_WHEN_IDLE), rxOnWhenIdle) @@ -105,7 +102,10 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct ( private const val TAG_FULL_NETWORK_DATA = 12 private const val TAG_IS_CHILD = 13 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterNeighborTableStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterNeighborTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val age = tlvReader.getULong(ContextSpecificTag(TAG_AGE)) @@ -113,28 +113,45 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct ( val linkFrameCounter = tlvReader.getULong(ContextSpecificTag(TAG_LINK_FRAME_COUNTER)) val mleFrameCounter = tlvReader.getULong(ContextSpecificTag(TAG_MLE_FRAME_COUNTER)) val lqi = tlvReader.getUInt(ContextSpecificTag(TAG_LQI)) - val averageRssi = if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_AVERAGE_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) - null - } - val lastRssi = if (!tlvReader.isNull()) { - tlvReader.getInt(ContextSpecificTag(TAG_LAST_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) - null - } + val averageRssi = + if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_AVERAGE_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) + null + } + val lastRssi = + if (!tlvReader.isNull()) { + tlvReader.getInt(ContextSpecificTag(TAG_LAST_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) + null + } val frameErrorRate = tlvReader.getUInt(ContextSpecificTag(TAG_FRAME_ERROR_RATE)) val messageErrorRate = tlvReader.getUInt(ContextSpecificTag(TAG_MESSAGE_ERROR_RATE)) val rxOnWhenIdle = tlvReader.getBoolean(ContextSpecificTag(TAG_RX_ON_WHEN_IDLE)) val fullThreadDevice = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_THREAD_DEVICE)) val fullNetworkData = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_NETWORK_DATA)) val isChild = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_CHILD)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterNeighborTableStruct(extAddress, age, rloc16, linkFrameCounter, mleFrameCounter, lqi, averageRssi, lastRssi, frameErrorRate, messageErrorRate, rxOnWhenIdle, fullThreadDevice, fullNetworkData, isChild) + return ThreadNetworkDiagnosticsClusterNeighborTableStruct( + extAddress, + age, + rloc16, + linkFrameCounter, + mleFrameCounter, + lqi, + averageRssi, + lastRssi, + frameErrorRate, + messageErrorRate, + rxOnWhenIdle, + fullThreadDevice, + fullNetworkData, + isChild + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt index b236dab6cb1906..39938fd1ee6403 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt @@ -17,29 +17,26 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents ( - val activeTimestampPresent: Boolean, - val pendingTimestampPresent: Boolean, - val masterKeyPresent: Boolean, - val networkNamePresent: Boolean, - val extendedPanIdPresent: Boolean, - val meshLocalPrefixPresent: Boolean, - val delayPresent: Boolean, - val panIdPresent: Boolean, - val channelPresent: Boolean, - val pskcPresent: Boolean, - val securityPolicyPresent: Boolean, - val channelMaskPresent: Boolean) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( + val activeTimestampPresent: Boolean, + val pendingTimestampPresent: Boolean, + val masterKeyPresent: Boolean, + val networkNamePresent: Boolean, + val extendedPanIdPresent: Boolean, + val meshLocalPrefixPresent: Boolean, + val delayPresent: Boolean, + val panIdPresent: Boolean, + val channelPresent: Boolean, + val pskcPresent: Boolean, + val securityPolicyPresent: Boolean, + val channelMaskPresent: Boolean +) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterOperationalDatasetComponents {\n") append("\tactiveTimestampPresent : $activeTimestampPresent\n") append("\tpendingTimestampPresent : $pendingTimestampPresent\n") @@ -89,24 +86,45 @@ class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents ( private const val TAG_SECURITY_POLICY_PRESENT = 10 private const val TAG_CHANNEL_MASK_PRESENT = 11 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { tlvReader.enterStructure(tlvTag) - val activeTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) - val pendingTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) + val activeTimestampPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) + val pendingTimestampPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) val masterKeyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MASTER_KEY_PRESENT)) val networkNamePresent = tlvReader.getBoolean(ContextSpecificTag(TAG_NETWORK_NAME_PRESENT)) - val extendedPanIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) - val meshLocalPrefixPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) + val extendedPanIdPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) + val meshLocalPrefixPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) val delayPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_DELAY_PRESENT)) val panIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PAN_ID_PRESENT)) val channelPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_PRESENT)) val pskcPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PSKC_PRESENT)) - val securityPolicyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) + val securityPolicyPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) val channelMaskPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_MASK_PRESENT)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents(activeTimestampPresent, pendingTimestampPresent, masterKeyPresent, networkNamePresent, extendedPanIdPresent, meshLocalPrefixPresent, delayPresent, panIdPresent, channelPresent, pskcPresent, securityPolicyPresent, channelMaskPresent) + return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( + activeTimestampPresent, + pendingTimestampPresent, + masterKeyPresent, + networkNamePresent, + extendedPanIdPresent, + meshLocalPrefixPresent, + delayPresent, + panIdPresent, + channelPresent, + pskcPresent, + securityPolicyPresent, + channelMaskPresent + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt index 3d5edad134669d..d1bbbec7592462 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt @@ -17,27 +17,24 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterRouteTableStruct ( - val extAddress: ULong, - val rloc16: UInt, - val routerId: UInt, - val nextHop: UInt, - val pathCost: UInt, - val LQIIn: UInt, - val LQIOut: UInt, - val age: UInt, - val allocated: Boolean, - val linkEstablished: Boolean) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterRouteTableStruct( + val extAddress: ULong, + val rloc16: UInt, + val routerId: UInt, + val nextHop: UInt, + val pathCost: UInt, + val LQIIn: UInt, + val LQIOut: UInt, + val age: UInt, + val allocated: Boolean, + val linkEstablished: Boolean +) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterRouteTableStruct {\n") append("\textAddress : $extAddress\n") append("\trloc16 : $rloc16\n") @@ -81,7 +78,10 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct ( private const val TAG_ALLOCATED = 8 private const val TAG_LINK_ESTABLISHED = 9 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterRouteTableStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterRouteTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val rloc16 = tlvReader.getUInt(ContextSpecificTag(TAG_RLOC16)) @@ -93,10 +93,21 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct ( val age = tlvReader.getUInt(ContextSpecificTag(TAG_AGE)) val allocated = tlvReader.getBoolean(ContextSpecificTag(TAG_ALLOCATED)) val linkEstablished = tlvReader.getBoolean(ContextSpecificTag(TAG_LINK_ESTABLISHED)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterRouteTableStruct(extAddress, rloc16, routerId, nextHop, pathCost, LQIIn, LQIOut, age, allocated, linkEstablished) + return ThreadNetworkDiagnosticsClusterRouteTableStruct( + extAddress, + rloc16, + routerId, + nextHop, + pathCost, + LQIIn, + LQIOut, + age, + allocated, + linkEstablished + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt index 44eec2ff64ab26..c0d8b857424511 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class ThreadNetworkDiagnosticsClusterSecurityPolicy ( - val rotationTime: UInt, - val flags: UInt) { - override fun toString(): String = buildString { +class ThreadNetworkDiagnosticsClusterSecurityPolicy(val rotationTime: UInt, val flags: UInt) { + override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterSecurityPolicy {\n") append("\trotationTime : $rotationTime\n") append("\tflags : $flags\n") @@ -49,11 +43,11 @@ class ThreadNetworkDiagnosticsClusterSecurityPolicy ( private const val TAG_ROTATION_TIME = 0 private const val TAG_FLAGS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterSecurityPolicy { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterSecurityPolicy { tlvReader.enterStructure(tlvTag) val rotationTime = tlvReader.getUInt(ContextSpecificTag(TAG_ROTATION_TIME)) val flags = tlvReader.getUInt(ContextSpecificTag(TAG_FLAGS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterSecurityPolicy(rotationTime, flags) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt index c960f8a3d1e069..6df9767939dcef 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterDSTOffsetStruct ( - val offset: Long, - val validStarting: ULong, - val validUntil: ULong?) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterDSTOffsetStruct( + val offset: Long, + val validStarting: ULong, + val validUntil: ULong? +) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterDSTOffsetStruct {\n") append("\toffset : $offset\n") append("\tvalidStarting : $validStarting\n") @@ -44,10 +41,10 @@ class TimeSynchronizationClusterDSTOffsetStruct ( put(ContextSpecificTag(TAG_OFFSET), offset) put(ContextSpecificTag(TAG_VALID_STARTING), validStarting) if (validUntil != null) { - put(ContextSpecificTag(TAG_VALID_UNTIL), validUntil) - } else { - putNull(ContextSpecificTag(TAG_VALID_UNTIL)) - } + put(ContextSpecificTag(TAG_VALID_UNTIL), validUntil) + } else { + putNull(ContextSpecificTag(TAG_VALID_UNTIL)) + } endStructure() } } @@ -57,17 +54,18 @@ class TimeSynchronizationClusterDSTOffsetStruct ( private const val TAG_VALID_STARTING = 1 private const val TAG_VALID_UNTIL = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterDSTOffsetStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterDSTOffsetStruct { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getLong(ContextSpecificTag(TAG_OFFSET)) val validStarting = tlvReader.getULong(ContextSpecificTag(TAG_VALID_STARTING)) - val validUntil = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) - null - } - + val validUntil = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) + null + } + tlvReader.exitContainer() return TimeSynchronizationClusterDSTOffsetStruct(offset, validStarting, validUntil) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt index 956908c9cd381d..cca59a20972c7b 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt @@ -17,19 +17,16 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct ( - val nodeID: ULong, - val endpoint: UInt) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct( + val nodeID: ULong, + val endpoint: UInt +) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct {\n") append("\tnodeID : $nodeID\n") append("\tendpoint : $endpoint\n") @@ -49,11 +46,14 @@ class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct ( private const val TAG_NODE_I_D = 0 private const val TAG_ENDPOINT = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct(nodeID, endpoint) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt index d972f05dbd528a..0d870bb1aa4b11 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt @@ -17,20 +17,18 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag +import java.util.Optional import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterTimeZoneStruct ( - val offset: Long, - val validAt: ULong, - val name: Optional) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterTimeZoneStruct( + val offset: Long, + val validAt: ULong, + val name: Optional +) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterTimeZoneStruct {\n") append("\toffset : $offset\n") append("\tvalidAt : $validAt\n") @@ -44,9 +42,9 @@ class TimeSynchronizationClusterTimeZoneStruct ( put(ContextSpecificTag(TAG_OFFSET), offset) put(ContextSpecificTag(TAG_VALID_AT), validAt) if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } endStructure() } } @@ -56,16 +54,17 @@ class TimeSynchronizationClusterTimeZoneStruct ( private const val TAG_VALID_AT = 1 private const val TAG_NAME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTimeZoneStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTimeZoneStruct { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getLong(ContextSpecificTag(TAG_OFFSET)) val validAt = tlvReader.getULong(ContextSpecificTag(TAG_VALID_AT)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStruct(offset, validAt, name) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt index 16685608686cb7..db6786d49ee802 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class TimeSynchronizationClusterTrustedTimeSourceStruct ( - val fabricIndex: UInt, - val nodeID: ULong, - val endpoint: UInt) { - override fun toString(): String = buildString { +class TimeSynchronizationClusterTrustedTimeSourceStruct( + val fabricIndex: UInt, + val nodeID: ULong, + val endpoint: UInt +) { + override fun toString(): String = buildString { append("TimeSynchronizationClusterTrustedTimeSourceStruct {\n") append("\tfabricIndex : $fabricIndex\n") append("\tnodeID : $nodeID\n") @@ -53,12 +50,15 @@ class TimeSynchronizationClusterTrustedTimeSourceStruct ( private const val TAG_NODE_I_D = 1 private const val TAG_ENDPOINT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTrustedTimeSourceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): TimeSynchronizationClusterTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUInt(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterTrustedTimeSourceStruct(fabricIndex, nodeID, endpoint) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt index 4ae6ee1b7692ff..46ebbe20eb1528 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt @@ -20,15 +20,11 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterDoubleNestedStructList ( - val a: List) { - override fun toString(): String = buildString { +class UnitTestingClusterDoubleNestedStructList(val a: List) { + override fun toString(): String = buildString { append("UnitTestingClusterDoubleNestedStructList {\n") append("\ta : $a\n") append("}\n") @@ -49,16 +45,17 @@ class UnitTestingClusterDoubleNestedStructList ( companion object { private const val TAG_A = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterDoubleNestedStructList { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterDoubleNestedStructList { tlvReader.enterStructure(tlvTag) - val a = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_A)) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val a = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_A)) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterDoubleNestedStructList(a) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt index 0a3799929a49c6..cd2c6a5d251fe9 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStruct.kt @@ -17,20 +17,17 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterNestedStruct ( - val a: UInt, - val b: Boolean, - val c: UnitTestingClusterSimpleStruct) { - override fun toString(): String = buildString { +class UnitTestingClusterNestedStruct( + val a: UInt, + val b: Boolean, + val c: UnitTestingClusterSimpleStruct +) { + override fun toString(): String = buildString { append("UnitTestingClusterNestedStruct {\n") append("\ta : $a\n") append("\tb : $b\n") @@ -53,12 +50,12 @@ class UnitTestingClusterNestedStruct ( private const val TAG_B = 1 private const val TAG_C = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterNestedStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNestedStruct { tlvReader.enterStructure(tlvTag) val a = tlvReader.getUInt(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - + tlvReader.exitContainer() return UnitTestingClusterNestedStruct(a, b, c) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt index 425b1753d17039..9b32b5343204c5 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNestedStructList.kt @@ -20,21 +20,19 @@ import chip.devicecontroller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterNestedStructList ( - val a: UInt, - val b: Boolean, - val c: UnitTestingClusterSimpleStruct, - val d: List, - val e: List, - val f: List, - val g: List) { - override fun toString(): String = buildString { +class UnitTestingClusterNestedStructList( + val a: UInt, + val b: Boolean, + val c: UnitTestingClusterSimpleStruct, + val d: List, + val e: List, + val f: List, + val g: List +) { + override fun toString(): String = buildString { append("UnitTestingClusterNestedStructList {\n") append("\ta : $a\n") append("\tb : $b\n") @@ -85,40 +83,44 @@ class UnitTestingClusterNestedStructList ( private const val TAG_F = 5 private const val TAG_G = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterNestedStructList { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNestedStructList { tlvReader.enterStructure(tlvTag) val a = tlvReader.getUInt(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - val d = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_D)) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val e = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_E)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getULong(AnonymousTag)) - } - tlvReader.exitContainer() - } - val f = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_F)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val g = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_G)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val d = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_D)) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val e = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_E)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getULong(AnonymousTag)) + } + tlvReader.exitContainer() + } + val f = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_F)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val g = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_G)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterNestedStructList(a, b, c, d, e, f, g) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt index 4758e679ca22cb..e8f12057027054 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt @@ -17,29 +17,28 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterNullablesAndOptionalsStruct ( - val nullableInt: UInt?, - val optionalInt: Optional, - val nullableOptionalInt: Optional?, - val nullableString: String?, - val optionalString: Optional, - val nullableOptionalString: Optional?, - val nullableStruct: UnitTestingClusterSimpleStruct?, - val optionalStruct: Optional, - val nullableOptionalStruct: Optional?, - val nullableList: List?, - val optionalList: Optional>, - val nullableOptionalList: Optional>?) { - override fun toString(): String = buildString { +class UnitTestingClusterNullablesAndOptionalsStruct( + val nullableInt: UInt?, + val optionalInt: Optional, + val nullableOptionalInt: Optional?, + val nullableString: String?, + val optionalString: Optional, + val nullableOptionalString: Optional?, + val nullableStruct: UnitTestingClusterSimpleStruct?, + val optionalStruct: Optional, + val nullableOptionalStruct: Optional?, + val nullableList: List?, + val optionalList: Optional>, + val nullableOptionalList: Optional>? +) { + override fun toString(): String = buildString { append("UnitTestingClusterNullablesAndOptionalsStruct {\n") append("\tnullableInt : $nullableInt\n") append("\toptionalInt : $optionalInt\n") @@ -60,85 +59,85 @@ class UnitTestingClusterNullablesAndOptionalsStruct ( tlvWriter.apply { startStructure(tlvTag) if (nullableInt != null) { - put(ContextSpecificTag(TAG_NULLABLE_INT), nullableInt) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_INT)) - } + put(ContextSpecificTag(TAG_NULLABLE_INT), nullableInt) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_INT)) + } if (optionalInt.isPresent) { - val optoptionalInt = optionalInt.get() - put(ContextSpecificTag(TAG_OPTIONAL_INT), optoptionalInt) - } + val optoptionalInt = optionalInt.get() + put(ContextSpecificTag(TAG_OPTIONAL_INT), optoptionalInt) + } if (nullableOptionalInt != null) { - if (nullableOptionalInt.isPresent) { - val optnullableOptionalInt = nullableOptionalInt.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) - } + if (nullableOptionalInt.isPresent) { + val optnullableOptionalInt = nullableOptionalInt.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) + } if (nullableString != null) { - put(ContextSpecificTag(TAG_NULLABLE_STRING), nullableString) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_STRING)) - } + put(ContextSpecificTag(TAG_NULLABLE_STRING), nullableString) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_STRING)) + } if (optionalString.isPresent) { - val optoptionalString = optionalString.get() - put(ContextSpecificTag(TAG_OPTIONAL_STRING), optoptionalString) - } + val optoptionalString = optionalString.get() + put(ContextSpecificTag(TAG_OPTIONAL_STRING), optoptionalString) + } if (nullableOptionalString != null) { - if (nullableOptionalString.isPresent) { - val optnullableOptionalString = nullableOptionalString.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) - } + if (nullableOptionalString.isPresent) { + val optnullableOptionalString = nullableOptionalString.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) + } if (nullableStruct != null) { - nullableStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), this) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) - } + nullableStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), this) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) + } if (optionalStruct.isPresent) { - val optoptionalStruct = optionalStruct.get() - optoptionalStruct.toTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), this) - } + val optoptionalStruct = optionalStruct.get() + optoptionalStruct.toTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), this) + } if (nullableOptionalStruct != null) { - if (nullableOptionalStruct.isPresent) { - val optnullableOptionalStruct = nullableOptionalStruct.get() - optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) - } + if (nullableOptionalStruct.isPresent) { + val optnullableOptionalStruct = nullableOptionalStruct.get() + optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) + } if (nullableList != null) { - startArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - for (item in nullableList.iterator()) { - put(AnonymousTag, item) + startArray(ContextSpecificTag(TAG_NULLABLE_LIST)) + for (item in nullableList.iterator()) { + put(AnonymousTag, item) + } + endArray() + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_LIST)) } - endArray() - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_LIST)) - } if (optionalList.isPresent) { - val optoptionalList = optionalList.get() - startArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - for (item in optoptionalList.iterator()) { - put(AnonymousTag, item) + val optoptionalList = optionalList.get() + startArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) + for (item in optoptionalList.iterator()) { + put(AnonymousTag, item) + } + endArray() } - endArray() - } if (nullableOptionalList != null) { - if (nullableOptionalList.isPresent) { - val optnullableOptionalList = nullableOptionalList.get() - startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - for (item in optnullableOptionalList.iterator()) { - put(AnonymousTag, item) + if (nullableOptionalList.isPresent) { + val optnullableOptionalList = nullableOptionalList.get() + startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + for (item in optnullableOptionalList.iterator()) { + put(AnonymousTag, item) + } + endArray() + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) } - endArray() - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - } endStructure() } } @@ -157,114 +156,153 @@ class UnitTestingClusterNullablesAndOptionalsStruct ( private const val TAG_OPTIONAL_LIST = 10 private const val TAG_NULLABLE_OPTIONAL_LIST = 11 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterNullablesAndOptionalsStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNullablesAndOptionalsStruct { tlvReader.enterStructure(tlvTag) - val nullableInt = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_INT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) - null - } - val optionalInt = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_INT))) - } else { - Optional.empty() - } - val nullableOptionalInt = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) - null - } - val nullableString = if (!tlvReader.isNull()) { - tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) - null - } - val optionalString = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) - } else { - Optional.empty() - } - val nullableOptionalString = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) - null - } - val nullableStruct = if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) - null - } - val optionalStruct = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { - Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), tlvReader)) - } else { - Optional.empty() - } - val nullableOptionalStruct = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { - Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) - null - } - val nullableList = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) - null - } - val optionalList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val nullableOptionalList = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - null - } - + val nullableInt = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_INT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) + null + } + val optionalInt = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_INT))) + } else { + Optional.empty() + } + val nullableOptionalInt = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) + null + } + val nullableString = + if (!tlvReader.isNull()) { + tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) + null + } + val optionalString = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) + } else { + Optional.empty() + } + val nullableOptionalString = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) + null + } + val nullableStruct = + if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) + null + } + val optionalStruct = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { + Optional.of( + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_OPTIONAL_STRUCT), + tlvReader + ) + ) + } else { + Optional.empty() + } + val nullableOptionalStruct = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { + Optional.of( + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), + tlvReader + ) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) + null + } + val nullableList = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) + null + } + val optionalList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val nullableOptionalList = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + null + } + tlvReader.exitContainer() - return UnitTestingClusterNullablesAndOptionalsStruct(nullableInt, optionalInt, nullableOptionalInt, nullableString, optionalString, nullableOptionalString, nullableStruct, optionalStruct, nullableOptionalStruct, nullableList, optionalList, nullableOptionalList) + return UnitTestingClusterNullablesAndOptionalsStruct( + nullableInt, + optionalInt, + nullableOptionalInt, + nullableString, + optionalString, + nullableOptionalString, + nullableStruct, + optionalStruct, + nullableOptionalStruct, + nullableList, + optionalList, + nullableOptionalList + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt index 3026a55dc4380c..217991a38b634a 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterSimpleStruct.kt @@ -17,25 +17,22 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterSimpleStruct ( - val a: UInt, - val b: Boolean, - val c: UInt, - val d: ByteArray, - val e: String, - val f: UInt, - val g: Float, - val h: Double) { - override fun toString(): String = buildString { +class UnitTestingClusterSimpleStruct( + val a: UInt, + val b: Boolean, + val c: UInt, + val d: ByteArray, + val e: String, + val f: UInt, + val g: Float, + val h: Double +) { + override fun toString(): String = buildString { append("UnitTestingClusterSimpleStruct {\n") append("\ta : $a\n") append("\tb : $b\n") @@ -73,7 +70,7 @@ class UnitTestingClusterSimpleStruct ( private const val TAG_G = 6 private const val TAG_H = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterSimpleStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterSimpleStruct { tlvReader.enterStructure(tlvTag) val a = tlvReader.getUInt(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) @@ -83,7 +80,7 @@ class UnitTestingClusterSimpleStruct ( val f = tlvReader.getUInt(ContextSpecificTag(TAG_F)) val g = tlvReader.getFloat(ContextSpecificTag(TAG_G)) val h = tlvReader.getDouble(ContextSpecificTag(TAG_H)) - + tlvReader.exitContainer() return UnitTestingClusterSimpleStruct(a, b, c, d, e, f, g, h) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt index 22970640c5eb3c..36da8ea1549865 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestFabricScoped.kt @@ -17,25 +17,24 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* +import java.util.Optional import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterTestFabricScoped ( - val fabricSensitiveInt8u: UInt, - val optionalFabricSensitiveInt8u: Optional, - val nullableFabricSensitiveInt8u: UInt?, - val nullableOptionalFabricSensitiveInt8u: Optional?, - val fabricSensitiveCharString: String, - val fabricSensitiveStruct: UnitTestingClusterSimpleStruct, - val fabricSensitiveInt8uList: List, - val fabricIndex: UInt) { - override fun toString(): String = buildString { +class UnitTestingClusterTestFabricScoped( + val fabricSensitiveInt8u: UInt, + val optionalFabricSensitiveInt8u: Optional, + val nullableFabricSensitiveInt8u: UInt?, + val nullableOptionalFabricSensitiveInt8u: Optional?, + val fabricSensitiveCharString: String, + val fabricSensitiveStruct: UnitTestingClusterSimpleStruct, + val fabricSensitiveInt8uList: List, + val fabricIndex: UInt +) { + override fun toString(): String = buildString { append("UnitTestingClusterTestFabricScoped {\n") append("\tfabricSensitiveInt8u : $fabricSensitiveInt8u\n") append("\toptionalFabricSensitiveInt8u : $optionalFabricSensitiveInt8u\n") @@ -53,22 +52,28 @@ class UnitTestingClusterTestFabricScoped ( startStructure(tlvTag) put(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U), fabricSensitiveInt8u) if (optionalFabricSensitiveInt8u.isPresent) { - val optoptionalFabricSensitiveInt8u = optionalFabricSensitiveInt8u.get() - put(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), optoptionalFabricSensitiveInt8u) - } + val optoptionalFabricSensitiveInt8u = optionalFabricSensitiveInt8u.get() + put( + ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), + optoptionalFabricSensitiveInt8u + ) + } if (nullableFabricSensitiveInt8u != null) { - put(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U), nullableFabricSensitiveInt8u) - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - } + put(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U), nullableFabricSensitiveInt8u) + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + } if (nullableOptionalFabricSensitiveInt8u != null) { - if (nullableOptionalFabricSensitiveInt8u.isPresent) { - val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), optnullableOptionalFabricSensitiveInt8u) - } - } else { - putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - } + if (nullableOptionalFabricSensitiveInt8u.isPresent) { + val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() + put( + ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), + optnullableOptionalFabricSensitiveInt8u + ) + } + } else { + putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + } put(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING), fabricSensitiveCharString) fabricSensitiveStruct.toTlv(ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), this) startArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) @@ -91,44 +96,66 @@ class UnitTestingClusterTestFabricScoped ( private const val TAG_FABRIC_SENSITIVE_INT8U_LIST = 7 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestFabricScoped { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScoped { tlvReader.enterStructure(tlvTag) val fabricSensitiveInt8u = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U)) - val optionalFabricSensitiveInt8u = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) - } else { - Optional.empty() - } - val nullableFabricSensitiveInt8u = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - null - } - val nullableOptionalFabricSensitiveInt8u = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - null - } - val fabricSensitiveCharString = tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) - val fabricSensitiveStruct = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), tlvReader) - val fabricSensitiveInt8uList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val optionalFabricSensitiveInt8u = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) + } else { + Optional.empty() + } + val nullableFabricSensitiveInt8u = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + null + } + val nullableOptionalFabricSensitiveInt8u = + if (!tlvReader.isNull()) { + if ( + tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + ) { + Optional.of( + tlvReader.getUInt(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + null + } + val fabricSensitiveCharString = + tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) + val fabricSensitiveStruct = + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), + tlvReader + ) + val fabricSensitiveInt8uList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } val fabricIndex = tlvReader.getUInt(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return UnitTestingClusterTestFabricScoped(fabricSensitiveInt8u, optionalFabricSensitiveInt8u, nullableFabricSensitiveInt8u, nullableOptionalFabricSensitiveInt8u, fabricSensitiveCharString, fabricSensitiveStruct, fabricSensitiveInt8uList, fabricIndex) + return UnitTestingClusterTestFabricScoped( + fabricSensitiveInt8u, + optionalFabricSensitiveInt8u, + nullableFabricSensitiveInt8u, + nullableOptionalFabricSensitiveInt8u, + fabricSensitiveCharString, + fabricSensitiveStruct, + fabricSensitiveInt8uList, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt index 1f823ba5cb92f9..91afedb93a404f 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UnitTestingClusterTestListStructOctet.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UnitTestingClusterTestListStructOctet ( - val member1: ULong, - val member2: ByteArray) { - override fun toString(): String = buildString { +class UnitTestingClusterTestListStructOctet(val member1: ULong, val member2: ByteArray) { + override fun toString(): String = buildString { append("UnitTestingClusterTestListStructOctet {\n") append("\tmember1 : $member1\n") append("\tmember2 : $member2\n") @@ -49,11 +43,11 @@ class UnitTestingClusterTestListStructOctet ( private const val TAG_MEMBER1 = 0 private const val TAG_MEMBER2 = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestListStructOctet { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestListStructOctet { tlvReader.enterStructure(tlvTag) val member1 = tlvReader.getULong(ContextSpecificTag(TAG_MEMBER1)) val member2 = tlvReader.getByteArray(ContextSpecificTag(TAG_MEMBER2)) - + tlvReader.exitContainer() return UnitTestingClusterTestListStructOctet(member1, member2) diff --git a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt index 02509a81a9dbbc..1cfbb532f5abaf 100644 --- a/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/chip/devicecontroller/cluster/structs/UserLabelClusterLabelStruct.kt @@ -17,19 +17,13 @@ package chip.devicecontroller.cluster.structs import chip.devicecontroller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -import java.util.Optional - -class UserLabelClusterLabelStruct ( - val label: String, - val value: String) { - override fun toString(): String = buildString { +class UserLabelClusterLabelStruct(val label: String, val value: String) { + override fun toString(): String = buildString { append("UserLabelClusterLabelStruct {\n") append("\tlabel : $label\n") append("\tvalue : $value\n") @@ -49,11 +43,11 @@ class UserLabelClusterLabelStruct ( private const val TAG_LABEL = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UserLabelClusterLabelStruct { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UserLabelClusterLabelStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return UserLabelClusterLabelStruct(label, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt index 6c02e602d0f2cf..c42cda3ef21f13 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccessControlCluster.kt @@ -17,195 +17,154 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccessControlCluster(private val controller: MatterController, private val endpointId: UShort) {class AclAttribute( - val value: List - ) +class AccessControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AclAttribute(val value: List) sealed class AclAttributeSubscriptionState { - data class Success( - val value: List - ) : AclAttributeSubscriptionState() - + data class Success(val value: List) : + AclAttributeSubscriptionState() + data class Error(val exception: Exception) : AclAttributeSubscriptionState() - object SubscriptionEstablished : AclAttributeSubscriptionState() - } -class ExtensionAttribute( - val value: List? - ) + object SubscriptionEstablished : AclAttributeSubscriptionState() + } + + class ExtensionAttribute(val value: List?) sealed class ExtensionAttributeSubscriptionState { - data class Success( - val value: List? - ) : ExtensionAttributeSubscriptionState() - + data class Success(val value: List?) : + ExtensionAttributeSubscriptionState() + data class Error(val exception: Exception) : ExtensionAttributeSubscriptionState() - object SubscriptionEstablished : ExtensionAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ExtensionAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readAclAttribute(): AclAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readAclAttribute(): AclAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acl attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acl attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AclAttribute(decodedValue) } suspend fun writeAclAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -227,7 +186,7 @@ suspend fun readAclAttribute(): AclAttribute {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAclAttribute( @@ -235,45 +194,48 @@ suspend fun readAclAttribute(): AclAttribute {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AclAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AclAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acl attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Acl attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlEntryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(AclAttributeSubscriptionState.Success(decodedValue)) } @@ -281,81 +243,74 @@ suspend fun readAclAttribute(): AclAttribute {val ATTRIBUTE_ID: UInt = 0u emit(AclAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readExtensionAttribute(): ExtensionAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readExtensionAttribute(): ExtensionAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Extension attribute not found in response" - } + } + + requireNotNull(attributeData) { "Extension attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlExtensionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlExtensionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ExtensionAttribute(decodedValue) } suspend fun writeExtensionAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -377,7 +332,7 @@ suspend fun readExtensionAttribute(): ExtensionAttribute {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeExtensionAttribute( @@ -385,97 +340,97 @@ suspend fun readExtensionAttribute(): ExtensionAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ExtensionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ExtensionAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Extension attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Extension attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlExtensionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ExtensionAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + AccessControlClusterAccessControlExtensionStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ExtensionAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ExtensionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Subjectsperaccesscontrolentry attribute not found in response" + } + + requireNotNull(attributeData) { + "Subjectsperaccesscontrolentry attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -484,34 +439,38 @@ suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Subjectsperaccesscontrolentry attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Subjectsperaccesscontrolentry attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -524,44 +483,37 @@ suspend fun readSubjectsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_ emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTargetsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTargetsPerAccessControlEntryAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetsperaccesscontrolentry attribute not found in response" - } + } + + requireNotNull(attributeData) { "Targetsperaccesscontrolentry attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -570,34 +522,38 @@ suspend fun readTargetsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetsperaccesscontrolentry attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Targetsperaccesscontrolentry attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -610,44 +566,39 @@ suspend fun readTargetsPerAccessControlEntryAttribute(): UShort {val ATTRIBUTE_I emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAccessControlEntriesPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAccessControlEntriesPerFabricAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accesscontrolentriesperfabric attribute not found in response" + } + + requireNotNull(attributeData) { + "Accesscontrolentriesperfabric attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -656,34 +607,38 @@ suspend fun readAccessControlEntriesPerFabricAttribute(): UShort {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accesscontrolentriesperfabric attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accesscontrolentriesperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -696,49 +651,43 @@ suspend fun readAccessControlEntriesPerFabricAttribute(): UShort {val ATTRIBUTE_ emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -748,45 +697,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -794,49 +748,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -846,45 +794,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -892,49 +845,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -944,45 +891,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -990,49 +940,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1042,45 +986,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1088,44 +1035,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1134,35 +1074,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1174,44 +1116,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1220,34 +1155,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1260,7 +1199,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt index 8bd65be952b931..d7dcb095c61498 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AccountLoginCluster.kt @@ -17,114 +17,85 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccountLoginCluster(private val controller: MatterController, private val endpointId: UShort) { - class GetSetupPINResponse( - val setupPIN: String - ) -class GeneratedCommandListAttribute( - val value: List - ) +class AccountLoginCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GetSetupPINResponse(val setupPIN: String) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun getSetupPIN(tempAccountIdentifier: String - ,timedInvokeTimeout: Duration): GetSetupPINResponse { + suspend fun getSetupPIN( + tempAccountIdentifier: String, + timedInvokeTimeout: Duration + ): GetSetupPINResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TEMP_ACCOUNT_IDENTIFIER_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TEMP_ACCOUNT_IDENTIFIER_REQ), tempAccountIdentifier) + tlvWriter.put(ContextSpecificTag(TAG_TEMP_ACCOUNT_IDENTIFIER_REQ), tempAccountIdentifier) tlvWriter.endStructure() val request: InvokeRequest = @@ -141,38 +112,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_SETUP_P_I_N: Int = 0 var setupPIN_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_SETUP_P_I_N)) {setupPIN_decoded = tlvReader.getString(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_SETUP_P_I_N)) { + setupPIN_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (setupPIN_decoded == null) { - throw IllegalStateException("setupPIN not found in TLV") + throw IllegalStateException("setupPIN not found in TLV") } - tlvReader.exitContainer() - return GetSetupPINResponse( - setupPIN_decoded - ) + return GetSetupPINResponse(setupPIN_decoded) } - suspend fun login(tempAccountIdentifier: String - ,setupPIN: String - ,node: ULong? - ,timedInvokeTimeout: Duration) { + suspend fun login( + tempAccountIdentifier: String, + setupPIN: String, + node: ULong?, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -185,9 +150,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_SETUP_P_I_N_REQ), setupPIN) val TAG_NODE_REQ: Int = 2 - node?.let { - tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) - } + node?.let { tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) } tlvWriter.endStructure() val request: InvokeRequest = @@ -201,17 +164,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun logout(node: ULong? - ,timedInvokeTimeout: Duration) { + suspend fun logout(node: ULong?, timedInvokeTimeout: Duration) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NODE_REQ: Int = 0 - node?.let { - tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) - } + node?.let { tlvWriter.put(ContextSpecificTag(TAG_NODE_REQ), node) } tlvWriter.endStructure() val request: InvokeRequest = @@ -224,47 +184,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -274,45 +228,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -320,49 +279,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -372,45 +325,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -418,49 +376,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -470,45 +422,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -516,49 +471,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -568,45 +517,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -614,44 +566,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -660,35 +605,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -700,44 +647,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -746,34 +686,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -786,7 +730,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt index 77cb5b4c8feca0..5f44f5c6a99747 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActionsCluster.kt @@ -17,130 +17,97 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ActionsCluster(private val controller: MatterController, private val endpointId: UShort) {class ActionListAttribute( - val value: List - ) +class ActionsCluster(private val controller: MatterController, private val endpointId: UShort) { + class ActionListAttribute(val value: List) sealed class ActionListAttributeSubscriptionState { - data class Success( - val value: List - ) : ActionListAttributeSubscriptionState() - + data class Success(val value: List) : + ActionListAttributeSubscriptionState() + data class Error(val exception: Exception) : ActionListAttributeSubscriptionState() - object SubscriptionEstablished : ActionListAttributeSubscriptionState() - } -class EndpointListsAttribute( - val value: List - ) + object SubscriptionEstablished : ActionListAttributeSubscriptionState() + } + + class EndpointListsAttribute(val value: List) sealed class EndpointListsAttributeSubscriptionState { - data class Success( - val value: List - ) : EndpointListsAttributeSubscriptionState() - + data class Success(val value: List) : + EndpointListsAttributeSubscriptionState() + data class Error(val exception: Exception) : EndpointListsAttributeSubscriptionState() - object SubscriptionEstablished : EndpointListsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : EndpointListsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun instantAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun instantAction( + actionID: UShort, + invokeID: UInt?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -150,9 +117,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -166,10 +131,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun instantActionWithTransition(actionID: UShort - ,invokeID: UInt? - ,transitionTime: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun instantActionWithTransition( + actionID: UShort, + invokeID: UInt?, + transitionTime: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -179,12 +146,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } val TAG_TRANSITION_TIME_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) + tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -198,9 +163,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun startAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -210,9 +173,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -226,10 +187,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startActionWithDuration(actionID: UShort - ,invokeID: UInt? - ,duration: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun startActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -239,12 +202,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -258,9 +219,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stopAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun stopAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -270,9 +229,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -286,9 +243,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun pauseAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun pauseAction(actionID: UShort, invokeID: UInt?, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -298,9 +253,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -314,10 +267,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun pauseActionWithDuration(actionID: UShort - ,invokeID: UInt? - ,duration: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun pauseActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -327,12 +282,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -346,9 +299,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun resumeAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun resumeAction( + actionID: UShort, + invokeID: UInt?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -358,9 +313,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -374,9 +327,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun enableAction( + actionID: UShort, + invokeID: UInt?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 8u val tlvWriter = TlvWriter() @@ -386,9 +341,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -402,10 +355,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableActionWithDuration(actionID: UShort - ,invokeID: UInt? - ,duration: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun enableActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -415,12 +370,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -434,9 +387,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun disableAction(actionID: UShort - ,invokeID: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun disableAction( + actionID: UShort, + invokeID: UInt?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 10u val tlvWriter = TlvWriter() @@ -446,9 +401,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } tlvWriter.endStructure() val request: InvokeRequest = @@ -462,10 +415,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun disableActionWithDuration(actionID: UShort - ,invokeID: UInt? - ,duration: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun disableActionWithDuration( + actionID: UShort, + invokeID: UInt?, + duration: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 11u val tlvWriter = TlvWriter() @@ -475,12 +430,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ACTION_I_D_REQ), actionID) val TAG_INVOKE_I_D_REQ: Int = 1 - invokeID?.let { - tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) - } + invokeID?.let { tlvWriter.put(ContextSpecificTag(TAG_INVOKE_I_D_REQ), invokeID) } val TAG_DURATION_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) + tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) tlvWriter.endStructure() val request: InvokeRequest = @@ -493,47 +446,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readActionListAttribute(): ActionListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActionListAttribute(): ActionListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actionlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Actionlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ActionListAttribute(decodedValue) } @@ -543,45 +490,48 @@ suspend fun readActionListAttribute(): ActionListAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActionListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActionListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actionlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Actionlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ActionsClusterActionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ActionListAttributeSubscriptionState.Success(decodedValue)) } @@ -589,49 +539,43 @@ suspend fun readActionListAttribute(): ActionListAttribute {val ATTRIBUTE_ID: UI emit(ActionListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEndpointListsAttribute(): EndpointListsAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEndpointListsAttribute(): EndpointListsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endpointlists attribute not found in response" - } + } + + requireNotNull(attributeData) { "Endpointlists attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EndpointListsAttribute(decodedValue) } @@ -641,45 +585,48 @@ suspend fun readEndpointListsAttribute(): EndpointListsAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EndpointListsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EndpointListsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endpointlists attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Endpointlists attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ActionsClusterEndpointListStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(EndpointListsAttributeSubscriptionState.Success(decodedValue)) } @@ -687,47 +634,41 @@ suspend fun readEndpointListsAttribute(): EndpointListsAttribute {val ATTRIBUTE_ emit(EndpointListsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSetupURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSetupURLAttribute(): String? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setupurl attribute not found in response" - } + } + + requireNotNull(attributeData) { "Setupurl attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -737,96 +678,90 @@ suspend fun readSetupURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setupurl attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Setupurl attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -836,45 +771,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -882,49 +822,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -934,45 +868,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -980,49 +919,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1032,45 +965,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1078,49 +1014,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1130,45 +1060,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1176,44 +1109,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1222,35 +1148,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1262,44 +1190,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1308,34 +1229,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1348,7 +1273,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt index 73fbba68b06ac4..daa2d6a7bdf0f6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ActivatedCarbonFilterMonitoringCluster.kt @@ -17,132 +17,105 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ActivatedCarbonFilterMonitoringCluster(private val controller: MatterController, private val endpointId: UShort) {class LastChangedTimeAttribute( - val value: UInt? - ) +class ActivatedCarbonFilterMonitoringCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LastChangedTimeAttribute(val value: UInt?) sealed class LastChangedTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LastChangedTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : LastChangedTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : LastChangedTimeAttributeSubscriptionState() - object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() - } -class ReplacementProductListAttribute( + object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() + } + + class ReplacementProductListAttribute( val value: List? ) sealed class ReplacementProductListAttributeSubscriptionState { data class Success( - val value: List? + val value: List? ) : ReplacementProductListAttributeSubscriptionState() - + data class Error(val exception: Exception) : ReplacementProductListAttributeSubscriptionState() - object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCondition(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,45 +128,39 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readConditionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readConditionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Condition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Condition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -203,94 +170,88 @@ suspend fun readConditionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Condition attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Condition attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDegradationDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDegradationDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Degradationdirection attribute not found in response" - } + } + + requireNotNull(attributeData) { "Degradationdirection attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -300,91 +261,86 @@ suspend fun readDegradationDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Degradationdirection attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Degradationdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readChangeIndicationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Changeindication attribute not found in response" - } + } + + requireNotNull(attributeData) { "Changeindication attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -393,34 +349,38 @@ suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Changeindication attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Changeindication attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -433,47 +393,41 @@ suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInPlaceIndicatorAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInPlaceIndicatorAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inplaceindicator attribute not found in response" - } + } + + requireNotNull(attributeData) { "Inplaceindicator attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -483,123 +437,115 @@ suspend fun readInPlaceIndicatorAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inplaceindicator attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Inplaceindicator attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastchangedtime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastchangedtime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastChangedTimeAttribute(decodedValue) } - suspend fun writeLastChangedTimeAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -621,7 +567,7 @@ suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLastChangedTimeAttribute( @@ -629,105 +575,106 @@ suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastChangedTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastChangedTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastchangedtime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lastchangedtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LastChangedTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LastChangedTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastChangedTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Replacementproductlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Replacementproductlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ReplacementProductListAttribute(decodedValue) } @@ -737,102 +684,103 @@ suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ReplacementProductListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ReplacementProductListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Replacementproductlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Replacementproductlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ReplacementProductListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ReplacementProductListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ReplacementProductListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -842,45 +790,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -888,49 +841,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -940,45 +887,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -986,49 +938,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1038,45 +984,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1084,49 +1033,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1136,45 +1079,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1182,44 +1128,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1228,35 +1167,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1268,44 +1209,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1314,34 +1248,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1354,7 +1292,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt index 0d51abdb78e597..4fd1bd91dacbe3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AdministratorCommissioningCluster.kt @@ -17,133 +17,101 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AdministratorCommissioningCluster(private val controller: MatterController, private val endpointId: UShort) {class AdminFabricIndexAttribute( - val value: UByte? - ) +class AdministratorCommissioningCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AdminFabricIndexAttribute(val value: UByte?) sealed class AdminFabricIndexAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : AdminFabricIndexAttributeSubscriptionState() - + data class Success(val value: UByte?) : AdminFabricIndexAttributeSubscriptionState() + data class Error(val exception: Exception) : AdminFabricIndexAttributeSubscriptionState() - object SubscriptionEstablished : AdminFabricIndexAttributeSubscriptionState() - } -class AdminVendorIdAttribute( - val value: UShort? - ) + object SubscriptionEstablished : AdminFabricIndexAttributeSubscriptionState() + } + + class AdminVendorIdAttribute(val value: UShort?) sealed class AdminVendorIdAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : AdminVendorIdAttributeSubscriptionState() - + data class Success(val value: UShort?) : AdminVendorIdAttributeSubscriptionState() + data class Error(val exception: Exception) : AdminVendorIdAttributeSubscriptionState() - object SubscriptionEstablished : AdminVendorIdAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AdminVendorIdAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun openCommissioningWindow(commissioningTimeout: UShort - ,PAKEPasscodeVerifier: ByteArray - ,discriminator: UShort - ,iterations: UInt - ,salt: ByteArray - ,timedInvokeTimeout: Duration) { + suspend fun openCommissioningWindow( + commissioningTimeout: UShort, + PAKEPasscodeVerifier: ByteArray, + discriminator: UShort, + iterations: UInt, + salt: ByteArray, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -162,7 +130,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ITERATIONS_REQ), iterations) val TAG_SALT_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_SALT_REQ), salt) + tlvWriter.put(ContextSpecificTag(TAG_SALT_REQ), salt) tlvWriter.endStructure() val request: InvokeRequest = @@ -176,15 +144,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun openBasicCommissioningWindow(commissioningTimeout: UShort - ,timedInvokeTimeout: Duration) { + suspend fun openBasicCommissioningWindow( + commissioningTimeout: UShort, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_COMMISSIONING_TIMEOUT_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_COMMISSIONING_TIMEOUT_REQ), commissioningTimeout) + tlvWriter.put(ContextSpecificTag(TAG_COMMISSIONING_TIMEOUT_REQ), commissioningTimeout) tlvWriter.endStructure() val request: InvokeRequest = @@ -202,7 +172,7 @@ class AttributeListAttribute( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -215,42 +185,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readWindowStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readWindowStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windowstatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Windowstatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -259,35 +222,37 @@ suspend fun readWindowStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windowstatus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Windowstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -299,48 +264,42 @@ suspend fun readWindowStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAdminFabricIndexAttribute(): AdminFabricIndexAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAdminFabricIndexAttribute(): AdminFabricIndexAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Adminfabricindex attribute not found in response" - } + } + + requireNotNull(attributeData) { "Adminfabricindex attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return AdminFabricIndexAttribute(decodedValue) } @@ -350,96 +309,92 @@ suspend fun readAdminFabricIndexAttribute(): AdminFabricIndexAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AdminFabricIndexAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AdminFabricIndexAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Adminfabricindex attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Adminfabricindex attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AdminFabricIndexAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AdminFabricIndexAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AdminFabricIndexAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAdminVendorIdAttribute(): AdminVendorIdAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAdminVendorIdAttribute(): AdminVendorIdAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Adminvendorid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Adminvendorid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return AdminVendorIdAttribute(decodedValue) } @@ -449,97 +404,91 @@ suspend fun readAdminVendorIdAttribute(): AdminVendorIdAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AdminVendorIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AdminVendorIdAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Adminvendorid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Adminvendorid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AdminVendorIdAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AdminVendorIdAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AdminVendorIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -549,45 +498,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -595,49 +549,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -647,45 +595,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -693,49 +646,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -745,45 +692,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -791,49 +741,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -843,45 +787,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -889,44 +836,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -935,35 +875,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -975,44 +917,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1021,34 +956,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1061,7 +1000,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt index 7622ac8f893d32..b2c558f45df037 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AirQualityCluster.kt @@ -17,136 +17,93 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class AirQualityCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class AirQualityCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readAirQualityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readAirQualityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Airquality attribute not found in response" - } + } + + requireNotNull(attributeData) { "Airquality attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -155,35 +112,37 @@ suspend fun readAirQualityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Airquality attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Airquality attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -195,49 +154,43 @@ suspend fun readAirQualityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -247,45 +200,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -293,49 +251,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -345,45 +297,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -391,49 +348,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -443,45 +394,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -489,49 +443,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -541,45 +489,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -587,44 +538,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -633,35 +577,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -673,44 +619,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -719,34 +658,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -759,7 +702,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt index 880e6385833234..ed62272114e72a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationBasicCluster.kt @@ -17,165 +17,122 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class ApplicationBasicCluster(private val controller: MatterController, private val endpointId: UShort) {class ApplicationAttribute( - val value: ApplicationBasicClusterApplicationStruct - ) +class ApplicationBasicCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ApplicationAttribute(val value: ApplicationBasicClusterApplicationStruct) sealed class ApplicationAttributeSubscriptionState { - data class Success( - val value: ApplicationBasicClusterApplicationStruct - ) : ApplicationAttributeSubscriptionState() - + data class Success(val value: ApplicationBasicClusterApplicationStruct) : + ApplicationAttributeSubscriptionState() + data class Error(val exception: Exception) : ApplicationAttributeSubscriptionState() - object SubscriptionEstablished : ApplicationAttributeSubscriptionState() - } -class AllowedVendorListAttribute( - val value: List - ) + object SubscriptionEstablished : ApplicationAttributeSubscriptionState() + } + + class AllowedVendorListAttribute(val value: List) sealed class AllowedVendorListAttributeSubscriptionState { - data class Success( - val value: List - ) : AllowedVendorListAttributeSubscriptionState() - + data class Success(val value: List) : AllowedVendorListAttributeSubscriptionState() + data class Error(val exception: Exception) : AllowedVendorListAttributeSubscriptionState() - object SubscriptionEstablished : AllowedVendorListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AllowedVendorListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readVendorNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readVendorNameAttribute(): String? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -185,94 +142,88 @@ suspend fun readVendorNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVendorIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readVendorIDAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -282,91 +233,84 @@ suspend fun readVendorIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApplicationNameAttribute(): String {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readApplicationNameAttribute(): String { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Applicationname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -375,34 +319,38 @@ suspend fun readApplicationNameAttribute(): String {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationname attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Applicationname attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -415,47 +363,41 @@ suspend fun readApplicationNameAttribute(): String {val ATTRIBUTE_ID: UInt = 2u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readProductIDAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -465,90 +407,84 @@ suspend fun readProductIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApplicationAttribute(): ApplicationAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readApplicationAttribute(): ApplicationAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Application attribute not found in response" - } + } + + requireNotNull(attributeData) { "Application attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationBasicClusterApplicationStruct = ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: ApplicationBasicClusterApplicationStruct = + ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) return ApplicationAttribute(decodedValue) } @@ -558,39 +494,42 @@ suspend fun readApplicationAttribute(): ApplicationAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ApplicationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ApplicationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Application attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Application attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationBasicClusterApplicationStruct = ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: ApplicationBasicClusterApplicationStruct = + ApplicationBasicClusterApplicationStruct.fromTlv(AnonymousTag, tlvReader) emit(ApplicationAttributeSubscriptionState.Success(decodedValue)) } @@ -598,44 +537,37 @@ suspend fun readApplicationAttribute(): ApplicationAttribute {val ATTRIBUTE_ID: emit(ApplicationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Status attribute not found in response" - } + } + + requireNotNull(attributeData) { "Status attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -644,35 +576,37 @@ suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Status attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Status attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -684,44 +618,37 @@ suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApplicationVersionAttribute(): String {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readApplicationVersionAttribute(): String { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Applicationversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -730,34 +657,38 @@ suspend fun readApplicationVersionAttribute(): String {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Applicationversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -770,49 +701,43 @@ suspend fun readApplicationVersionAttribute(): String {val ATTRIBUTE_ID: UInt = emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Allowedvendorlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Allowedvendorlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AllowedVendorListAttribute(decodedValue) } @@ -822,45 +747,50 @@ suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AllowedVendorListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AllowedVendorListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Allowedvendorlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Allowedvendorlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AllowedVendorListAttributeSubscriptionState.Success(decodedValue)) } @@ -868,49 +798,43 @@ suspend fun readAllowedVendorListAttribute(): AllowedVendorListAttribute {val AT emit(AllowedVendorListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -920,45 +844,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -966,49 +895,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1018,45 +941,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1064,49 +992,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1116,45 +1038,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1162,49 +1087,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1214,45 +1133,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1260,44 +1182,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1306,35 +1221,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1346,44 +1263,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1392,34 +1302,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1432,7 +1346,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt index 5045bf8de2e5ee..7d9f650c50480b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ApplicationLauncherCluster.kt @@ -17,149 +17,110 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ApplicationLauncherCluster(private val controller: MatterController, private val endpointId: UShort) { - class LauncherResponse( - val status: UByte, - val data: ByteArray? - ) -class CatalogListAttribute( - val value: List? - ) +class ApplicationLauncherCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LauncherResponse(val status: UByte, val data: ByteArray?) + + class CatalogListAttribute(val value: List?) sealed class CatalogListAttributeSubscriptionState { - data class Success( - val value: List? - ) : CatalogListAttributeSubscriptionState() - + data class Success(val value: List?) : CatalogListAttributeSubscriptionState() + data class Error(val exception: Exception) : CatalogListAttributeSubscriptionState() - object SubscriptionEstablished : CatalogListAttributeSubscriptionState() - } -class CurrentAppAttribute( - val value: ApplicationLauncherClusterApplicationEPStruct? - ) + object SubscriptionEstablished : CatalogListAttributeSubscriptionState() + } + + class CurrentAppAttribute(val value: ApplicationLauncherClusterApplicationEPStruct?) sealed class CurrentAppAttributeSubscriptionState { - data class Success( - val value: ApplicationLauncherClusterApplicationEPStruct? - ) : CurrentAppAttributeSubscriptionState() - + data class Success(val value: ApplicationLauncherClusterApplicationEPStruct?) : + CurrentAppAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentAppAttributeSubscriptionState() - object SubscriptionEstablished : CurrentAppAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : CurrentAppAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun launchApp(application: ApplicationLauncherClusterApplicationStruct? - ,data: ByteArray? - ,timedInvokeTimeout: Duration? = null): LauncherResponse { + suspend fun launchApp( + application: ApplicationLauncherClusterApplicationStruct?, + data: ByteArray?, + timedInvokeTimeout: Duration? = null + ): LauncherResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_APPLICATION_REQ: Int = 0 - application?.let { - application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) - } + application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } val TAG_DATA_REQ: Int = 1 - data?.let { - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) - } + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } tlvWriter.endStructure() val request: InvokeRequest = @@ -176,63 +137,54 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return LauncherResponse( - status_decoded, - data_decoded - ) + return LauncherResponse(status_decoded, data_decoded) } - suspend fun stopApp(application: ApplicationLauncherClusterApplicationStruct? - ,timedInvokeTimeout: Duration? = null): LauncherResponse { + suspend fun stopApp( + application: ApplicationLauncherClusterApplicationStruct?, + timedInvokeTimeout: Duration? = null + ): LauncherResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_APPLICATION_REQ: Int = 0 - application?.let { - application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) - } + application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } tlvWriter.endStructure() val request: InvokeRequest = @@ -249,63 +201,54 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return LauncherResponse( - status_decoded, - data_decoded - ) + return LauncherResponse(status_decoded, data_decoded) } - suspend fun hideApp(application: ApplicationLauncherClusterApplicationStruct? - ,timedInvokeTimeout: Duration? = null): LauncherResponse { + suspend fun hideApp( + application: ApplicationLauncherClusterApplicationStruct?, + timedInvokeTimeout: Duration? = null + ): LauncherResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_APPLICATION_REQ: Int = 0 - application?.let { - application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) - } + application?.let { application.toTlv(ContextSpecificTag(TAG_APPLICATION_REQ), tlvWriter) } tlvWriter.endStructure() val request: InvokeRequest = @@ -322,96 +265,81 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return LauncherResponse( - status_decoded, - data_decoded - ) + return LauncherResponse(status_decoded, data_decoded) } -suspend fun readCatalogListAttribute(): CatalogListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCatalogListAttribute(): CatalogListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cataloglist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Cataloglist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return CatalogListAttribute(decodedValue) } @@ -421,105 +349,99 @@ suspend fun readCatalogListAttribute(): CatalogListAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CatalogListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CatalogListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cataloglist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Cataloglist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(CatalogListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(CatalogListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CatalogListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentAppAttribute(): CurrentAppAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentAppAttribute(): CurrentAppAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentapp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentapp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentAppAttribute(decodedValue) } @@ -529,101 +451,95 @@ suspend fun readCurrentAppAttribute(): CurrentAppAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentAppAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentAppAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentapp attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentapp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentAppAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ApplicationLauncherClusterApplicationEPStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ApplicationLauncherClusterApplicationEPStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentAppAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentAppAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -633,45 +549,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -679,49 +600,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -731,45 +646,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -777,49 +697,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -829,45 +743,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -875,49 +792,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -927,45 +838,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -973,44 +887,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1019,35 +926,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1059,44 +968,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1105,34 +1007,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1145,7 +1051,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt index c038970d786898..d5a58d5c07ca1f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/AudioOutputCluster.kt @@ -17,123 +17,89 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AudioOutputCluster(private val controller: MatterController, private val endpointId: UShort) {class OutputListAttribute( - val value: List - ) +class AudioOutputCluster(private val controller: MatterController, private val endpointId: UShort) { + class OutputListAttribute(val value: List) sealed class OutputListAttributeSubscriptionState { - data class Success( - val value: List - ) : OutputListAttributeSubscriptionState() - + data class Success(val value: List) : + OutputListAttributeSubscriptionState() + data class Error(val exception: Exception) : OutputListAttributeSubscriptionState() - object SubscriptionEstablished : OutputListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OutputListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun selectOutput(index: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun selectOutput(index: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) + tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) tlvWriter.endStructure() val request: InvokeRequest = @@ -147,9 +113,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun renameOutput(index: UByte - ,name: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun renameOutput(index: UByte, name: String, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -159,7 +123,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) val TAG_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) + tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) tlvWriter.endStructure() val request: InvokeRequest = @@ -172,47 +136,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readOutputListAttribute(): OutputListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOutputListAttribute(): OutputListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outputlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Outputlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return OutputListAttribute(decodedValue) } @@ -222,45 +180,48 @@ suspend fun readOutputListAttribute(): OutputListAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OutputListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OutputListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outputlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Outputlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(AudioOutputClusterOutputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(OutputListAttributeSubscriptionState.Success(decodedValue)) } @@ -268,44 +229,37 @@ suspend fun readOutputListAttribute(): OutputListAttribute {val ATTRIBUTE_ID: UI emit(OutputListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentOutputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentOutputAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentoutput attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentoutput attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -314,35 +268,37 @@ suspend fun readCurrentOutputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentoutput attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentoutput attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -354,49 +310,43 @@ suspend fun readCurrentOutputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -406,45 +356,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -452,49 +407,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -504,45 +453,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -550,49 +504,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -602,45 +550,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -648,49 +599,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -700,45 +645,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -746,44 +694,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -792,35 +733,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -832,44 +775,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -878,34 +814,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -918,7 +858,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt index e733a38744d421..a0b361cdbb2400 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BallastConfigurationCluster.kt @@ -17,201 +17,152 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BallastConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class IntrinsicBallastFactorAttribute( - val value: UByte? - ) +class BallastConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class IntrinsicBallastFactorAttribute(val value: UByte?) sealed class IntrinsicBallastFactorAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : IntrinsicBallastFactorAttributeSubscriptionState() - + data class Success(val value: UByte?) : IntrinsicBallastFactorAttributeSubscriptionState() + data class Error(val exception: Exception) : IntrinsicBallastFactorAttributeSubscriptionState() - object SubscriptionEstablished : IntrinsicBallastFactorAttributeSubscriptionState() - } -class BallastFactorAdjustmentAttribute( - val value: UByte? - ) + object SubscriptionEstablished : IntrinsicBallastFactorAttributeSubscriptionState() + } + + class BallastFactorAdjustmentAttribute(val value: UByte?) sealed class BallastFactorAdjustmentAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : BallastFactorAdjustmentAttributeSubscriptionState() - - data class Error(val exception: Exception) : BallastFactorAdjustmentAttributeSubscriptionState() - - object SubscriptionEstablished : BallastFactorAdjustmentAttributeSubscriptionState() - } -class LampRatedHoursAttribute( - val value: UInt? - ) + data class Success(val value: UByte?) : BallastFactorAdjustmentAttributeSubscriptionState() + + data class Error(val exception: Exception) : + BallastFactorAdjustmentAttributeSubscriptionState() + + object SubscriptionEstablished : BallastFactorAdjustmentAttributeSubscriptionState() + } + + class LampRatedHoursAttribute(val value: UInt?) sealed class LampRatedHoursAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LampRatedHoursAttributeSubscriptionState() - + data class Success(val value: UInt?) : LampRatedHoursAttributeSubscriptionState() + data class Error(val exception: Exception) : LampRatedHoursAttributeSubscriptionState() - object SubscriptionEstablished : LampRatedHoursAttributeSubscriptionState() - } -class LampBurnHoursAttribute( - val value: UInt? - ) + object SubscriptionEstablished : LampRatedHoursAttributeSubscriptionState() + } + + class LampBurnHoursAttribute(val value: UInt?) sealed class LampBurnHoursAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LampBurnHoursAttributeSubscriptionState() - + data class Success(val value: UInt?) : LampBurnHoursAttributeSubscriptionState() + data class Error(val exception: Exception) : LampBurnHoursAttributeSubscriptionState() - object SubscriptionEstablished : LampBurnHoursAttributeSubscriptionState() - } -class LampBurnHoursTripPointAttribute( - val value: UInt? - ) + object SubscriptionEstablished : LampBurnHoursAttributeSubscriptionState() + } + + class LampBurnHoursTripPointAttribute(val value: UInt?) sealed class LampBurnHoursTripPointAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LampBurnHoursTripPointAttributeSubscriptionState() - + data class Success(val value: UInt?) : LampBurnHoursTripPointAttributeSubscriptionState() + data class Error(val exception: Exception) : LampBurnHoursTripPointAttributeSubscriptionState() - object SubscriptionEstablished : LampBurnHoursTripPointAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LampBurnHoursTripPointAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readPhysicalMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readPhysicalMinLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalminlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Physicalminlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -220,34 +171,38 @@ suspend fun readPhysicalMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalminlevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalminlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -260,44 +215,37 @@ suspend fun readPhysicalMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhysicalMaxLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalmaxlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Physicalmaxlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -306,34 +254,38 @@ suspend fun readPhysicalMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalmaxlevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalmaxlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -346,47 +298,41 @@ suspend fun readPhysicalMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBallastStatusAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBallastStatusAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ballaststatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ballaststatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -396,114 +342,103 @@ suspend fun readBallastStatusAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ballaststatus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Ballaststatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeMinLevelAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeMinLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -525,7 +460,7 @@ suspend fun readMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinLevelAttribute( @@ -533,35 +468,37 @@ suspend fun readMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -573,67 +510,56 @@ suspend fun readMinLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxLevelAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeMaxLevelAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeMaxLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -655,7 +581,7 @@ suspend fun readMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMaxLevelAttribute( @@ -663,35 +589,37 @@ suspend fun readMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -703,76 +631,69 @@ suspend fun readMaxLevelAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribute {val ATTRIBUTE_ID: UInt = 20u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Intrinsicballastfactor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Intrinsicballastfactor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return IntrinsicBallastFactorAttribute(decodedValue) } suspend fun writeIntrinsicBallastFactorAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -794,7 +715,7 @@ suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribu throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeIntrinsicBallastFactorAttribute( @@ -802,128 +723,123 @@ suspend fun readIntrinsicBallastFactorAttribute(): IntrinsicBallastFactorAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(IntrinsicBallastFactorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + IntrinsicBallastFactorAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Intrinsicballastfactor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Intrinsicballastfactor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(IntrinsicBallastFactorAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(IntrinsicBallastFactorAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(IntrinsicBallastFactorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttribute {val ATTRIBUTE_ID: UInt = 21u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttribute { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ballastfactoradjustment attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ballastfactoradjustment attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BallastFactorAdjustmentAttribute(decodedValue) } suspend fun writeBallastFactorAdjustmentAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -945,7 +861,7 @@ suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttri throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBallastFactorAdjustmentAttribute( @@ -953,96 +869,91 @@ suspend fun readBallastFactorAdjustmentAttribute(): BallastFactorAdjustmentAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BallastFactorAdjustmentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BallastFactorAdjustmentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ballastfactoradjustment attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ballastfactoradjustment attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BallastFactorAdjustmentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BallastFactorAdjustmentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BallastFactorAdjustmentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampQuantityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampQuantityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampquantity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampquantity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1051,35 +962,37 @@ suspend fun readLampQuantityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampquantity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lampquantity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1091,71 +1004,61 @@ suspend fun readLampQuantityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampTypeAttribute(): String? {val ATTRIBUTE_ID: UInt = 48u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampTypeAttribute(): String? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lamptype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lamptype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeLampTypeAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeLampTypeAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1177,7 +1080,7 @@ suspend fun readLampTypeAttribute(): String? {val ATTRIBUTE_ID: UInt = 48u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampTypeAttribute( @@ -1185,118 +1088,108 @@ suspend fun readLampTypeAttribute(): String? {val ATTRIBUTE_ID: UInt = 48u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lamptype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lamptype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampManufacturerAttribute(): String? {val ATTRIBUTE_ID: UInt = 49u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampManufacturerAttribute(): String? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampmanufacturer attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampmanufacturer attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeLampManufacturerAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeLampManufacturerAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1318,7 +1211,7 @@ suspend fun readLampManufacturerAttribute(): String? {val ATTRIBUTE_ID: UInt = 4 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampManufacturerAttribute( @@ -1326,123 +1219,115 @@ suspend fun readLampManufacturerAttribute(): String? {val ATTRIBUTE_ID: UInt = 4 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampmanufacturer attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lampmanufacturer attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute {val ATTRIBUTE_ID: UInt = 50u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampratedhours attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampratedhours attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LampRatedHoursAttribute(decodedValue) } - suspend fun writeLampRatedHoursAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeLampRatedHoursAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1464,7 +1349,7 @@ suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampRatedHoursAttribute( @@ -1472,128 +1357,120 @@ suspend fun readLampRatedHoursAttribute(): LampRatedHoursAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LampRatedHoursAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LampRatedHoursAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampratedhours attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lampratedhours attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LampRatedHoursAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LampRatedHoursAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LampRatedHoursAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute {val ATTRIBUTE_ID: UInt = 51u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampburnhours attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampburnhours attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LampBurnHoursAttribute(decodedValue) } - suspend fun writeLampBurnHoursAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeLampBurnHoursAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 51u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1615,7 +1492,7 @@ suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampBurnHoursAttribute( @@ -1623,123 +1500,113 @@ suspend fun readLampBurnHoursAttribute(): LampBurnHoursAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LampBurnHoursAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LampBurnHoursAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampburnhours attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lampburnhours attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LampBurnHoursAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LampBurnHoursAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LampBurnHoursAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampAlarmModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 52u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampAlarmModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampalarmmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampalarmmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeLampAlarmModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeLampAlarmModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 52u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1761,7 +1628,7 @@ suspend fun readLampAlarmModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 52u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampAlarmModeAttribute( @@ -1769,123 +1636,116 @@ suspend fun readLampAlarmModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 52u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampalarmmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lampalarmmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribute {val ATTRIBUTE_ID: UInt = 53u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribute { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampburnhourstrippoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lampburnhourstrippoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LampBurnHoursTripPointAttribute(decodedValue) } suspend fun writeLampBurnHoursTripPointAttribute( value: UInt, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 53u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1907,7 +1767,7 @@ suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribu throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLampBurnHoursTripPointAttribute( @@ -1915,101 +1775,97 @@ suspend fun readLampBurnHoursTripPointAttribute(): LampBurnHoursTripPointAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LampBurnHoursTripPointAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LampBurnHoursTripPointAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lampburnhourstrippoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lampburnhourstrippoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LampBurnHoursTripPointAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LampBurnHoursTripPointAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LampBurnHoursTripPointAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2019,45 +1875,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2065,49 +1926,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2117,45 +1972,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2163,49 +2023,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2215,45 +2069,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2261,49 +2118,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2313,45 +2164,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2359,44 +2213,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2405,35 +2252,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2445,44 +2294,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2491,34 +2333,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2531,7 +2377,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt index 01b8f509d4f7af..baddce34338c61 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BarrierControlCluster.kt @@ -17,110 +17,84 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BarrierControlCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class BarrierControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun barrierControlGoToPercent(percentOpen: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun barrierControlGoToPercent(percentOpen: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_PERCENT_OPEN_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_PERCENT_OPEN_REQ), percentOpen) + tlvWriter.put(ContextSpecificTag(TAG_PERCENT_OPEN_REQ), percentOpen) tlvWriter.endStructure() val request: InvokeRequest = @@ -138,7 +112,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -151,42 +125,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readBarrierMovingStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierMovingStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriermovingstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriermovingstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -195,34 +162,38 @@ suspend fun readBarrierMovingStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriermovingstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriermovingstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -235,44 +206,37 @@ suspend fun readBarrierMovingStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierSafetyStatusAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierSafetyStatusAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriersafetystatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriersafetystatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -281,34 +245,38 @@ suspend fun readBarrierSafetyStatusAttribute(): UShort {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriersafetystatus attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriersafetystatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -321,44 +289,37 @@ suspend fun readBarrierSafetyStatusAttribute(): UShort {val ATTRIBUTE_ID: UInt = emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierCapabilitiesAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierCapabilitiesAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercapabilities attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriercapabilities attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -367,34 +328,38 @@ suspend fun readBarrierCapabilitiesAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercapabilities attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriercapabilities attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -407,71 +372,61 @@ suspend fun readBarrierCapabilitiesAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierOpenEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrieropenevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barrieropenevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeBarrierOpenEventsAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierOpenEventsAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -493,7 +448,7 @@ suspend fun readBarrierOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierOpenEventsAttribute( @@ -501,118 +456,110 @@ suspend fun readBarrierOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrieropenevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barrieropenevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierCloseEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercloseevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriercloseevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeBarrierCloseEventsAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierCloseEventsAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -634,7 +581,7 @@ suspend fun readBarrierCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierCloseEventsAttribute( @@ -642,118 +589,113 @@ suspend fun readBarrierCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercloseevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriercloseevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierCommandOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierCommandOpenEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercommandopenevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriercommandopenevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeBarrierCommandOpenEventsAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -775,7 +717,7 @@ suspend fun readBarrierCommandOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierCommandOpenEventsAttribute( @@ -783,118 +725,113 @@ suspend fun readBarrierCommandOpenEventsAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercommandopenevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriercommandopenevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierCommandCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierCommandCloseEventsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercommandcloseevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriercommandcloseevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeBarrierCommandCloseEventsAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -916,7 +853,7 @@ suspend fun readBarrierCommandCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierCommandCloseEventsAttribute( @@ -924,118 +861,110 @@ suspend fun readBarrierCommandCloseEventsAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercommandcloseevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriercommandcloseevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierOpenPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrieropenperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barrieropenperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeBarrierOpenPeriodAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierOpenPeriodAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1057,7 +986,7 @@ suspend fun readBarrierOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierOpenPeriodAttribute( @@ -1065,118 +994,110 @@ suspend fun readBarrierOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrieropenperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barrieropenperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierClosePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierClosePeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercloseperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barriercloseperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeBarrierClosePeriodAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeBarrierClosePeriodAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1198,7 +1119,7 @@ suspend fun readBarrierClosePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBarrierClosePeriodAttribute( @@ -1206,91 +1127,86 @@ suspend fun readBarrierClosePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barriercloseperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barriercloseperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBarrierPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBarrierPositionAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrierposition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Barrierposition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1299,34 +1215,38 @@ suspend fun readBarrierPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Barrierposition attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Barrierposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1339,49 +1259,43 @@ suspend fun readBarrierPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1391,45 +1305,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1437,49 +1356,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1489,45 +1402,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1535,49 +1453,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1587,45 +1499,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1633,49 +1548,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1685,45 +1594,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1731,44 +1643,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1777,35 +1682,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1817,44 +1724,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1863,34 +1763,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1903,7 +1807,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt index 02d2f9bea9084e..0a669f0fddd221 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BasicInformationCluster.kt @@ -17,132 +17,103 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationCluster(private val controller: MatterController, private val endpointId: UShort) {class CapabilityMinimaAttribute( - val value: BasicInformationClusterCapabilityMinimaStruct - ) +class BasicInformationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class CapabilityMinimaAttribute(val value: BasicInformationClusterCapabilityMinimaStruct) sealed class CapabilityMinimaAttributeSubscriptionState { - data class Success( - val value: BasicInformationClusterCapabilityMinimaStruct - ) : CapabilityMinimaAttributeSubscriptionState() - + data class Success(val value: BasicInformationClusterCapabilityMinimaStruct) : + CapabilityMinimaAttributeSubscriptionState() + data class Error(val exception: Exception) : CapabilityMinimaAttributeSubscriptionState() - object SubscriptionEstablished : CapabilityMinimaAttributeSubscriptionState() - } -class ProductAppearanceAttribute( - val value: BasicInformationClusterProductAppearanceStruct? - ) + object SubscriptionEstablished : CapabilityMinimaAttributeSubscriptionState() + } + + class ProductAppearanceAttribute(val value: BasicInformationClusterProductAppearanceStruct?) sealed class ProductAppearanceAttributeSubscriptionState { - data class Success( - val value: BasicInformationClusterProductAppearanceStruct? - ) : ProductAppearanceAttributeSubscriptionState() - + data class Success(val value: BasicInformationClusterProductAppearanceStruct?) : + ProductAppearanceAttributeSubscriptionState() + data class Error(val exception: Exception) : ProductAppearanceAttributeSubscriptionState() - object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun mfgSpecificPing(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,42 +126,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readDataModelRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDataModelRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Datamodelrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Datamodelrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -199,34 +163,38 @@ suspend fun readDataModelRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Datamodelrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Datamodelrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -239,44 +207,37 @@ suspend fun readDataModelRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVendorNameAttribute(): String {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readVendorNameAttribute(): String { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -285,35 +246,37 @@ suspend fun readVendorNameAttribute(): String {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -325,44 +288,37 @@ suspend fun readVendorNameAttribute(): String {val ATTRIBUTE_ID: UInt = 1u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVendorIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readVendorIDAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -371,35 +327,37 @@ suspend fun readVendorIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -411,44 +369,37 @@ suspend fun readVendorIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductNameAttribute(): String {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readProductNameAttribute(): String { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -457,35 +408,37 @@ suspend fun readProductNameAttribute(): String {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -497,44 +450,37 @@ suspend fun readProductNameAttribute(): String {val ATTRIBUTE_ID: UInt = 3u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readProductIDAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -543,35 +489,37 @@ suspend fun readProductIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -583,67 +531,56 @@ suspend fun readProductIDAttribute(): UShort {val ATTRIBUTE_ID: UInt = 4u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNodeLabelAttribute(): String {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNodeLabelAttribute(): String { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nodelabel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nodelabel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } - suspend fun writeNodeLabelAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeNodeLabelAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -665,7 +602,7 @@ suspend fun readNodeLabelAttribute(): String {val ATTRIBUTE_ID: UInt = 5u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNodeLabelAttribute( @@ -673,35 +610,37 @@ suspend fun readNodeLabelAttribute(): String {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nodelabel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nodelabel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -713,67 +652,56 @@ suspend fun readNodeLabelAttribute(): String {val ATTRIBUTE_ID: UInt = 5u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocationAttribute(): String {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLocationAttribute(): String { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Location attribute not found in response" - } + } + + requireNotNull(attributeData) { "Location attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } - suspend fun writeLocationAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeLocationAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -795,7 +723,7 @@ suspend fun readLocationAttribute(): String {val ATTRIBUTE_ID: UInt = 6u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocationAttribute( @@ -803,35 +731,37 @@ suspend fun readLocationAttribute(): String {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Location attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Location attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -843,44 +773,37 @@ suspend fun readLocationAttribute(): String {val ATTRIBUTE_ID: UInt = 6u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHardwareVersionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readHardwareVersionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hardwareversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -889,34 +812,38 @@ suspend fun readHardwareVersionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hardwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -929,44 +856,37 @@ suspend fun readHardwareVersionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 7u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHardwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readHardwareVersionStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversionstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hardwareversionstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -975,34 +895,38 @@ suspend fun readHardwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hardwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1015,44 +939,37 @@ suspend fun readHardwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSoftwareVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSoftwareVersionAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Softwareversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1061,34 +978,38 @@ suspend fun readSoftwareVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Softwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1101,44 +1022,37 @@ suspend fun readSoftwareVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = 9u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSoftwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSoftwareVersionStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversionstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Softwareversionstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -1147,34 +1061,38 @@ suspend fun readSoftwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Softwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1187,47 +1105,41 @@ suspend fun readSoftwareVersionStringAttribute(): String {val ATTRIBUTE_ID: UInt emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readManufacturingDateAttribute(): String? {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readManufacturingDateAttribute(): String? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Manufacturingdate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Manufacturingdate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1237,94 +1149,90 @@ suspend fun readManufacturingDateAttribute(): String? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Manufacturingdate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Manufacturingdate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPartNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPartNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partnumber attribute not found in response" - } + } + + requireNotNull(attributeData) { "Partnumber attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1334,94 +1242,88 @@ suspend fun readPartNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 12u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partnumber attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Partnumber attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 13u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readProductURLAttribute(): String? { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Producturl attribute not found in response" - } + } + + requireNotNull(attributeData) { "Producturl attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1431,94 +1333,88 @@ suspend fun readProductURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 13u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Producturl attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Producturl attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 14u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readProductLabelAttribute(): String? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productlabel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productlabel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1528,94 +1424,88 @@ suspend fun readProductLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 14u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productlabel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productlabel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSerialNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSerialNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serialnumber attribute not found in response" - } + } + + requireNotNull(attributeData) { "Serialnumber attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1625,118 +1515,111 @@ suspend fun readSerialNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serialnumber attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Serialnumber attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocalConfigDisabledAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLocalConfigDisabledAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localconfigdisabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Localconfigdisabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeLocalConfigDisabledAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1758,7 +1641,7 @@ suspend fun readLocalConfigDisabledAttribute(): Boolean? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocalConfigDisabledAttribute( @@ -1766,94 +1649,90 @@ suspend fun readLocalConfigDisabledAttribute(): Boolean? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localconfigdisabled attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Localconfigdisabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReachableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReachableAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reachable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reachable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -1863,94 +1742,88 @@ suspend fun readReachableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reachable attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Reachable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUniqueIDAttribute(): String? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUniqueIDAttribute(): String? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uniqueid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uniqueid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1960,90 +1833,84 @@ suspend fun readUniqueIDAttribute(): String? {val ATTRIBUTE_ID: UInt = 18u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uniqueid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uniqueid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Capabilityminima attribute not found in response" - } + } + + requireNotNull(attributeData) { "Capabilityminima attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterCapabilityMinimaStruct = BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: BasicInformationClusterCapabilityMinimaStruct = + BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) return CapabilityMinimaAttribute(decodedValue) } @@ -2053,39 +1920,44 @@ suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CapabilityMinimaAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CapabilityMinimaAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Capabilityminima attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Capabilityminima attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterCapabilityMinimaStruct = BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: BasicInformationClusterCapabilityMinimaStruct = + BasicInformationClusterCapabilityMinimaStruct.fromTlv(AnonymousTag, tlvReader) emit(CapabilityMinimaAttributeSubscriptionState.Success(decodedValue)) } @@ -2093,47 +1965,41 @@ suspend fun readCapabilityMinimaAttribute(): CapabilityMinimaAttribute {val ATTR emit(CapabilityMinimaAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productappearance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productappearance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { - BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - + val decodedValue: BasicInformationClusterProductAppearanceStruct? = + if (tlvReader.isNextTag(AnonymousTag)) { + BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } return ProductAppearanceAttribute(decodedValue) } @@ -2143,91 +2009,86 @@ suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ProductAppearanceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ProductAppearanceAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productappearance attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Productappearance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { - BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } + val decodedValue: BasicInformationClusterProductAppearanceStruct? = + if (tlvReader.isNextTag(AnonymousTag)) { + BasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } - decodedValue?.let { - emit(ProductAppearanceAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ProductAppearanceAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ProductAppearanceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpecificationVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSpecificationVersionAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Specificationversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Specificationversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2236,34 +2097,38 @@ suspend fun readSpecificationVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Specificationversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Specificationversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2276,44 +2141,37 @@ suspend fun readSpecificationVersionAttribute(): UInt {val ATTRIBUTE_ID: UInt = emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxPathsPerInvokeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxPathsPerInvokeAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpathsperinvoke attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxpathsperinvoke attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2322,34 +2180,38 @@ suspend fun readMaxPathsPerInvokeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpathsperinvoke attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxpathsperinvoke attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2362,49 +2224,43 @@ suspend fun readMaxPathsPerInvokeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2414,45 +2270,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2460,49 +2321,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2512,45 +2367,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2558,49 +2418,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2610,45 +2464,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2656,49 +2513,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2708,45 +2559,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2754,44 +2608,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2800,35 +2647,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2840,44 +2689,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2886,34 +2728,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2926,7 +2772,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt index 6573eb5ba275c1..89769881291daf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BinaryInputBasicCluster.kt @@ -17,163 +17,126 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BinaryInputBasicCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class BinaryInputBasicCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readActiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readActiveTextAttribute(): String? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetext attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activetext attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeActiveTextAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeActiveTextAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -195,7 +158,7 @@ suspend fun readActiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 4u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeActiveTextAttribute( @@ -203,118 +166,108 @@ suspend fun readActiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetext attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activetext attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDescriptionAttribute(): String? {val ATTRIBUTE_ID: UInt = 28u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDescriptionAttribute(): String? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in response" - } + } + + requireNotNull(attributeData) { "Description attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeDescriptionAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeDescriptionAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 28u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -336,7 +289,7 @@ suspend fun readDescriptionAttribute(): String? {val ATTRIBUTE_ID: UInt = 28u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDescriptionAttribute( @@ -344,118 +297,108 @@ suspend fun readDescriptionAttribute(): String? {val ATTRIBUTE_ID: UInt = 28u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Description attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInactiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 46u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInactiveTextAttribute(): String? { + val ATTRIBUTE_ID: UInt = 46u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inactivetext attribute not found in response" - } + } + + requireNotNull(attributeData) { "Inactivetext attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeInactiveTextAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeInactiveTextAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 46u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -477,7 +420,7 @@ suspend fun readInactiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 46u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInactiveTextAttribute( @@ -485,114 +428,103 @@ suspend fun readInactiveTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 46u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 46u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inactivetext attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Inactivetext attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOutOfServiceAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 81u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOutOfServiceAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 81u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outofservice attribute not found in response" - } + } + + requireNotNull(attributeData) { "Outofservice attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writeOutOfServiceAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeOutOfServiceAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 81u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -614,7 +546,7 @@ suspend fun readOutOfServiceAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 81u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOutOfServiceAttribute( @@ -622,35 +554,37 @@ suspend fun readOutOfServiceAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 81u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 81u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outofservice attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Outofservice attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -662,47 +596,41 @@ suspend fun readOutOfServiceAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 81u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPolarityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 84u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPolarityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 84u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Polarity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Polarity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -712,114 +640,103 @@ suspend fun readPolarityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 84u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 84u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Polarity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Polarity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPresentValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 85u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPresentValueAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 85u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presentvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Presentvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writePresentValueAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writePresentValueAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 85u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -841,7 +758,7 @@ suspend fun readPresentValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 85u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePresentValueAttribute( @@ -849,35 +766,37 @@ suspend fun readPresentValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 85u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 85u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presentvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Presentvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -889,71 +808,61 @@ suspend fun readPresentValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 85u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReliabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 103u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readReliabilityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 103u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reliability attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reliability attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeReliabilityAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeReliabilityAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 103u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -975,7 +884,7 @@ suspend fun readReliabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 103u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeReliabilityAttribute( @@ -983,91 +892,84 @@ suspend fun readReliabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 103u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 103u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reliability attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Reliability attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStatusFlagsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 111u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStatusFlagsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 111u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Statusflags attribute not found in response" - } + } + + requireNotNull(attributeData) { "Statusflags attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1076,35 +978,37 @@ suspend fun readStatusFlagsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 111u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 111u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Statusflags attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Statusflags attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1116,47 +1020,41 @@ suspend fun readStatusFlagsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 111u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApplicationTypeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 256u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readApplicationTypeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 256u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationtype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Applicationtype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -1166,96 +1064,92 @@ suspend fun readApplicationTypeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 256u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 256u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Applicationtype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Applicationtype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1265,45 +1159,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1311,49 +1210,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1363,45 +1256,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1409,49 +1307,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1461,45 +1353,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1507,49 +1402,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1559,45 +1448,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1605,44 +1497,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1651,35 +1536,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1691,44 +1578,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1737,34 +1617,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1777,7 +1661,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt index a29864051af0d1..a5cb5193c9c37d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BindingCluster.kt @@ -17,182 +17,140 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BindingCluster(private val controller: MatterController, private val endpointId: UShort) {class BindingAttribute( - val value: List - ) +class BindingCluster(private val controller: MatterController, private val endpointId: UShort) { + class BindingAttribute(val value: List) sealed class BindingAttributeSubscriptionState { - data class Success( - val value: List - ) : BindingAttributeSubscriptionState() - + data class Success(val value: List) : + BindingAttributeSubscriptionState() + data class Error(val exception: Exception) : BindingAttributeSubscriptionState() - object SubscriptionEstablished : BindingAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : BindingAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readBindingAttribute(): BindingAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readBindingAttribute(): BindingAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Binding attribute not found in response" - } + } + + requireNotNull(attributeData) { "Binding attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return BindingAttribute(decodedValue) } suspend fun writeBindingAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -214,7 +172,7 @@ suspend fun readBindingAttribute(): BindingAttribute {val ATTRIBUTE_ID: UInt = 0 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBindingAttribute( @@ -222,45 +180,48 @@ suspend fun readBindingAttribute(): BindingAttribute {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BindingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BindingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Binding attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Binding attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(BindingClusterTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(BindingAttributeSubscriptionState.Success(decodedValue)) } @@ -268,49 +229,43 @@ suspend fun readBindingAttribute(): BindingAttribute {val ATTRIBUTE_ID: UInt = 0 emit(BindingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -320,45 +275,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -366,49 +326,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -418,45 +372,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -464,49 +423,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -516,45 +469,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -562,49 +518,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -614,45 +564,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -660,44 +613,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -706,35 +652,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -746,44 +694,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -792,34 +733,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -832,7 +777,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt index 0c44c4bb081d4a..7530f3afc9c7cb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateCluster.kt @@ -17,136 +17,96 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class BooleanStateCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class BooleanStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readStateValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readStateValueAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Statevalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Statevalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -155,35 +115,37 @@ suspend fun readStateValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Statevalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Statevalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -195,49 +157,43 @@ suspend fun readStateValueAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -247,45 +203,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -293,49 +254,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -345,45 +300,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -391,49 +351,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -443,45 +397,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -489,49 +446,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -541,45 +492,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -587,44 +541,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -633,35 +580,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -673,44 +622,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -719,34 +661,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -759,7 +705,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt index a92edf5556e383..3cbd118dac1c2e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BooleanStateConfigurationCluster.kt @@ -17,110 +17,84 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class BooleanStateConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun suppressAlarm(alarmsToSuppress: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun suppressAlarm(alarmsToSuppress: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ALARMS_TO_SUPPRESS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_SUPPRESS_REQ), alarmsToSuppress) + tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_SUPPRESS_REQ), alarmsToSuppress) tlvWriter.endStructure() val request: InvokeRequest = @@ -134,15 +108,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableDisableAlarm(alarmsToEnableDisable: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun enableDisableAlarm( + alarmsToEnableDisable: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ALARMS_TO_ENABLE_DISABLE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_ENABLE_DISABLE_REQ), alarmsToEnableDisable) + tlvWriter.put(ContextSpecificTag(TAG_ALARMS_TO_ENABLE_DISABLE_REQ), alarmsToEnableDisable) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,69 +131,62 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readCurrentSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentSensitivityLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentsensitivitylevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentsensitivitylevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeCurrentSensitivityLevelAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -239,7 +208,7 @@ suspend fun readCurrentSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCurrentSensitivityLevelAttribute( @@ -247,94 +216,90 @@ suspend fun readCurrentSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentsensitivitylevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentsensitivitylevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedSensitivityLevelsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedSensitivityLevelsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedsensitivitylevels attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedsensitivitylevels attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -344,94 +309,90 @@ suspend fun readSupportedSensitivityLevelsAttribute(): UByte? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedsensitivitylevels attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedsensitivitylevels attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultSensitivityLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultsensitivitylevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultsensitivitylevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -441,94 +402,90 @@ suspend fun readDefaultSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultsensitivitylevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultsensitivitylevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAlarmsActiveAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAlarmsActiveAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmsactive attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alarmsactive attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -538,94 +495,88 @@ suspend fun readAlarmsActiveAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmsactive attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Alarmsactive attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAlarmsSuppressedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAlarmsSuppressedAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmssuppressed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alarmssuppressed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -635,94 +586,90 @@ suspend fun readAlarmsSuppressedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmssuppressed attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Alarmssuppressed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAlarmsEnabledAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAlarmsEnabledAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmsenabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alarmsenabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -732,94 +679,88 @@ suspend fun readAlarmsEnabledAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmsenabled attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Alarmsenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAlarmsSupportedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAlarmsSupportedAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmssupported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alarmssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -829,94 +770,90 @@ suspend fun readAlarmsSupportedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alarmssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Alarmssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSensorFaultAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSensorFaultAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sensorfault attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sensorfault attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -926,96 +863,90 @@ suspend fun readSensorFaultAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sensorfault attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Sensorfault attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1025,45 +956,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1071,49 +1007,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1123,45 +1053,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1169,49 +1104,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1221,45 +1150,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1267,49 +1199,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1319,45 +1245,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1365,44 +1294,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1411,35 +1333,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1451,44 +1375,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1497,34 +1414,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1537,7 +1458,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt index 463def619140dc..e867b53a3b8e24 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/BridgedDeviceBasicInformationCluster.kt @@ -17,152 +17,118 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationCluster(private val controller: MatterController, private val endpointId: UShort) {class ProductAppearanceAttribute( +class BridgedDeviceBasicInformationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ProductAppearanceAttribute( val value: BridgedDeviceBasicInformationClusterProductAppearanceStruct? ) sealed class ProductAppearanceAttributeSubscriptionState { - data class Success( - val value: BridgedDeviceBasicInformationClusterProductAppearanceStruct? - ) : ProductAppearanceAttributeSubscriptionState() - + data class Success(val value: BridgedDeviceBasicInformationClusterProductAppearanceStruct?) : + ProductAppearanceAttributeSubscriptionState() + data class Error(val exception: Exception) : ProductAppearanceAttributeSubscriptionState() - object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ProductAppearanceAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readVendorNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readVendorNameAttribute(): String? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -172,94 +138,88 @@ suspend fun readVendorNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVendorIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readVendorIDAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -269,94 +229,88 @@ suspend fun readVendorIDAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readProductNameAttribute(): String? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -366,118 +320,108 @@ suspend fun readProductNameAttribute(): String? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNodeLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNodeLabelAttribute(): String? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nodelabel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nodelabel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeNodeLabelAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeNodeLabelAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +443,7 @@ suspend fun readNodeLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 5u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNodeLabelAttribute( @@ -507,94 +451,88 @@ suspend fun readNodeLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nodelabel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nodelabel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHardwareVersionAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readHardwareVersionAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hardwareversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -604,94 +542,90 @@ suspend fun readHardwareVersionAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hardwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHardwareVersionStringAttribute(): String? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readHardwareVersionStringAttribute(): String? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversionstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hardwareversionstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -701,94 +635,90 @@ suspend fun readHardwareVersionStringAttribute(): String? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hardwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSoftwareVersionAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSoftwareVersionAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Softwareversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -798,94 +728,90 @@ suspend fun readSoftwareVersionAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Softwareversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSoftwareVersionStringAttribute(): String? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSoftwareVersionStringAttribute(): String? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversionstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Softwareversionstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -895,94 +821,90 @@ suspend fun readSoftwareVersionStringAttribute(): String? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Softwareversionstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Softwareversionstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readManufacturingDateAttribute(): String? {val ATTRIBUTE_ID: UInt = 11u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readManufacturingDateAttribute(): String? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Manufacturingdate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Manufacturingdate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -992,94 +914,90 @@ suspend fun readManufacturingDateAttribute(): String? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Manufacturingdate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Manufacturingdate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPartNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 12u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPartNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partnumber attribute not found in response" - } + } + + requireNotNull(attributeData) { "Partnumber attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1089,94 +1007,88 @@ suspend fun readPartNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 12u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partnumber attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Partnumber attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 13u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readProductURLAttribute(): String? { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Producturl attribute not found in response" - } + } + + requireNotNull(attributeData) { "Producturl attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1186,94 +1098,88 @@ suspend fun readProductURLAttribute(): String? {val ATTRIBUTE_ID: UInt = 13u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Producturl attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Producturl attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 14u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readProductLabelAttribute(): String? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productlabel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productlabel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1283,94 +1189,88 @@ suspend fun readProductLabelAttribute(): String? {val ATTRIBUTE_ID: UInt = 14u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productlabel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Productlabel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSerialNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 15u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSerialNumberAttribute(): String? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serialnumber attribute not found in response" - } + } + + requireNotNull(attributeData) { "Serialnumber attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1380,91 +1280,84 @@ suspend fun readSerialNumberAttribute(): String? {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serialnumber attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Serialnumber attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReachableAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 17u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readReachableAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reachable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reachable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -1473,35 +1366,37 @@ suspend fun readReachableAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reachable attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Reachable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1513,47 +1408,41 @@ suspend fun readReachableAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 17u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUniqueIDAttribute(): String? {val ATTRIBUTE_ID: UInt = 18u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUniqueIDAttribute(): String? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uniqueid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uniqueid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1563,94 +1452,88 @@ suspend fun readUniqueIDAttribute(): String? {val ATTRIBUTE_ID: UInt = 18u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uniqueid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uniqueid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute {val ATTRIBUTE_ID: UInt = 20u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productappearance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Productappearance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { - BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - + val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = + if (tlvReader.isNextTag(AnonymousTag)) { + BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } return ProductAppearanceAttribute(decodedValue) } @@ -1660,96 +1543,95 @@ suspend fun readProductAppearanceAttribute(): ProductAppearanceAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ProductAppearanceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ProductAppearanceAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Productappearance attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Productappearance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = if (tlvReader.isNextTag(AnonymousTag)) { - BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - - decodedValue?.let { - emit(ProductAppearanceAttributeSubscriptionState.Success(it)) - } - + val decodedValue: BridgedDeviceBasicInformationClusterProductAppearanceStruct? = + if (tlvReader.isNextTag(AnonymousTag)) { + BridgedDeviceBasicInformationClusterProductAppearanceStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + + decodedValue?.let { emit(ProductAppearanceAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ProductAppearanceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1759,45 +1641,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1805,49 +1692,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1857,45 +1738,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1903,49 +1789,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1955,45 +1835,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2001,49 +1884,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2053,45 +1930,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2099,44 +1979,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2145,35 +2018,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2185,44 +2060,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2231,34 +2099,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2271,7 +2143,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt index 32fbbb01553d32..d2f974c4550a9b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonDioxideConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class CarbonDioxideConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class CarbonDioxideConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,11 +1742,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(CarbonDioxideConcentrationMeasurementCluster::class.java.name) + private val logger = + Logger.getLogger(CarbonDioxideConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1037u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt index c97c2f69df0087..93341731a25b70 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/CarbonMonoxideConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class CarbonMonoxideConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class CarbonMonoxideConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,11 +1742,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(CarbonMonoxideConcentrationMeasurementCluster::class.java.name) + private val logger = + Logger.getLogger(CarbonMonoxideConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1036u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt index ce6d28c380c36b..653f118fc66440 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ChannelCluster.kt @@ -17,159 +17,120 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class ChannelCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeChannelResponse( - val status: UByte, - val data: String? - ) + class ChangeChannelResponse(val status: UByte, val data: String?) class ProgramGuideResponse( - val paging: ChannelClusterChannelPagingStruct, + val paging: ChannelClusterChannelPagingStruct, val programList: List ) -class ChannelListAttribute( - val value: List? - ) + + class ChannelListAttribute(val value: List?) sealed class ChannelListAttributeSubscriptionState { - data class Success( - val value: List? - ) : ChannelListAttributeSubscriptionState() - + data class Success(val value: List?) : + ChannelListAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelListAttributeSubscriptionState() - object SubscriptionEstablished : ChannelListAttributeSubscriptionState() - } -class LineupAttribute( - val value: ChannelClusterLineupInfoStruct? - ) + object SubscriptionEstablished : ChannelListAttributeSubscriptionState() + } + + class LineupAttribute(val value: ChannelClusterLineupInfoStruct?) sealed class LineupAttributeSubscriptionState { - data class Success( - val value: ChannelClusterLineupInfoStruct? - ) : LineupAttributeSubscriptionState() - + data class Success(val value: ChannelClusterLineupInfoStruct?) : + LineupAttributeSubscriptionState() + data class Error(val exception: Exception) : LineupAttributeSubscriptionState() - object SubscriptionEstablished : LineupAttributeSubscriptionState() - } -class CurrentChannelAttribute( - val value: ChannelClusterChannelInfoStruct? - ) + object SubscriptionEstablished : LineupAttributeSubscriptionState() + } + + class CurrentChannelAttribute(val value: ChannelClusterChannelInfoStruct?) sealed class CurrentChannelAttributeSubscriptionState { - data class Success( - val value: ChannelClusterChannelInfoStruct? - ) : CurrentChannelAttributeSubscriptionState() - + data class Success(val value: ChannelClusterChannelInfoStruct?) : + CurrentChannelAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentChannelAttributeSubscriptionState() - object SubscriptionEstablished : CurrentChannelAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : CurrentChannelAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeChannel(match: String - ,timedInvokeTimeout: Duration? = null): ChangeChannelResponse { + suspend fun changeChannel( + match: String, + timedInvokeTimeout: Duration? = null + ): ChangeChannelResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_MATCH_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_MATCH_REQ), match) + tlvWriter.put(ContextSpecificTag(TAG_MATCH_REQ), match) tlvWriter.endStructure() val request: InvokeRequest = @@ -186,55 +147,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeChannelResponse( - status_decoded, - data_decoded - ) + return ChangeChannelResponse(status_decoded, data_decoded) } - suspend fun changeChannelByNumber(majorNumber: UShort - ,minorNumber: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun changeChannelByNumber( + majorNumber: UShort, + minorNumber: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -244,7 +198,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_MAJOR_NUMBER_REQ), majorNumber) val TAG_MINOR_NUMBER_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_MINOR_NUMBER_REQ), minorNumber) + tlvWriter.put(ContextSpecificTag(TAG_MINOR_NUMBER_REQ), minorNumber) tlvWriter.endStructure() val request: InvokeRequest = @@ -258,15 +212,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun skipChannel(count: Short - ,timedInvokeTimeout: Duration? = null) { + suspend fun skipChannel(count: Short, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_COUNT_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_COUNT_REQ), count) + tlvWriter.put(ContextSpecificTag(TAG_COUNT_REQ), count) tlvWriter.endStructure() val request: InvokeRequest = @@ -280,28 +233,26 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getProgramGuide(startTime: UInt? - ,endTime: UInt? - ,channelList: List? - ,pageToken: ChannelClusterPageTokenStruct? - ,recordingFlag: UInt? - ,externalIDList: List? - ,data: ByteArray? - ,timedInvokeTimeout: Duration? = null): ProgramGuideResponse { + suspend fun getProgramGuide( + startTime: UInt?, + endTime: UInt?, + channelList: List?, + pageToken: ChannelClusterPageTokenStruct?, + recordingFlag: UInt?, + externalIDList: List?, + data: ByteArray?, + timedInvokeTimeout: Duration? = null + ): ProgramGuideResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_START_TIME_REQ: Int = 0 - startTime?.let { - tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) - } + startTime?.let { tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) } val TAG_END_TIME_REQ: Int = 1 - endTime?.let { - tlvWriter.put(ContextSpecificTag(TAG_END_TIME_REQ), endTime) - } + endTime?.let { tlvWriter.put(ContextSpecificTag(TAG_END_TIME_REQ), endTime) } val TAG_CHANNEL_LIST_REQ: Int = 2 channelList?.let { @@ -313,14 +264,10 @@ class AttributeListAttribute( } val TAG_PAGE_TOKEN_REQ: Int = 3 - pageToken?.let { - pageToken.toTlv(ContextSpecificTag(TAG_PAGE_TOKEN_REQ), tlvWriter) - } + pageToken?.let { pageToken.toTlv(ContextSpecificTag(TAG_PAGE_TOKEN_REQ), tlvWriter) } val TAG_RECORDING_FLAG_REQ: Int = 4 - recordingFlag?.let { - tlvWriter.put(ContextSpecificTag(TAG_RECORDING_FLAG_REQ), recordingFlag) - } + recordingFlag?.let { tlvWriter.put(ContextSpecificTag(TAG_RECORDING_FLAG_REQ), recordingFlag) } val TAG_EXTERNAL_I_D_LIST_REQ: Int = 5 externalIDList?.let { @@ -332,9 +279,7 @@ class AttributeListAttribute( } val TAG_DATA_REQ: Int = 6 - data?.let { - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) - } + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } tlvWriter.endStructure() val request: InvokeRequest = @@ -351,56 +296,51 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_PAGING: Int = 0 var paging_decoded: ChannelClusterChannelPagingStruct? = null - + val TAG_PROGRAM_LIST: Int = 1 var programList_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_PAGING)) {paging_decoded = ChannelClusterChannelPagingStruct.fromTlv(tag, tlvReader)} - - if (tag == ContextSpecificTag(TAG_PROGRAM_LIST)) {programList_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramStruct.fromTlv(AnonymousTag, tlvReader)) + if (tag == ContextSpecificTag(TAG_PAGING)) { + paging_decoded = ChannelClusterChannelPagingStruct.fromTlv(tag, tlvReader) } - tlvReader.exitContainer() - }} - - else { + if (tag == ContextSpecificTag(TAG_PROGRAM_LIST)) { + programList_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - if (paging_decoded == null) { - throw IllegalStateException("paging not found in TLV") + throw IllegalStateException("paging not found in TLV") } - - + if (programList_decoded == null) { - throw IllegalStateException("programList not found in TLV") + throw IllegalStateException("programList not found in TLV") } - tlvReader.exitContainer() - return ProgramGuideResponse( - paging_decoded, - programList_decoded - ) + return ProgramGuideResponse(paging_decoded, programList_decoded) } - suspend fun recordProgram(programIdentifier: String - ,shouldRecordSeries: Boolean - ,externalIDList: List - ,data: ByteArray - ,timedInvokeTimeout: Duration? = null) { + suspend fun recordProgram( + programIdentifier: String, + shouldRecordSeries: Boolean, + externalIDList: List, + data: ByteArray, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -414,13 +354,13 @@ class AttributeListAttribute( val TAG_EXTERNAL_I_D_LIST_REQ: Int = 2 tlvWriter.startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST_REQ)) - for (item in externalIDList.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in externalIDList.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_DATA_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) tlvWriter.endStructure() val request: InvokeRequest = @@ -434,11 +374,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun cancelRecordProgram(programIdentifier: String - ,shouldRecordSeries: Boolean - ,externalIDList: List - ,data: ByteArray - ,timedInvokeTimeout: Duration? = null) { + suspend fun cancelRecordProgram( + programIdentifier: String, + shouldRecordSeries: Boolean, + externalIDList: List, + data: ByteArray, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -452,13 +394,13 @@ class AttributeListAttribute( val TAG_EXTERNAL_I_D_LIST_REQ: Int = 2 tlvWriter.startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST_REQ)) - for (item in externalIDList.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in externalIDList.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_DATA_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) + tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) tlvWriter.endStructure() val request: InvokeRequest = @@ -471,51 +413,45 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readChannelListAttribute(): ChannelListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readChannelListAttribute(): ChannelListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channellist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Channellist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ChannelListAttribute(decodedValue) } @@ -525,105 +461,99 @@ suspend fun readChannelListAttribute(): ChannelListAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ChannelListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ChannelListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channellist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Channellist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ChannelListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ChannelListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ChannelListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLineupAttribute(): LineupAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLineupAttribute(): LineupAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lineup attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lineup attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterLineupInfoStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ChannelClusterLineupInfoStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LineupAttribute(decodedValue) } @@ -633,104 +563,98 @@ suspend fun readLineupAttribute(): LineupAttribute {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LineupAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LineupAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lineup attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lineup attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterLineupInfoStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LineupAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ChannelClusterLineupInfoStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterLineupInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LineupAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LineupAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentChannelAttribute(): CurrentChannelAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentChannelAttribute(): CurrentChannelAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentchannel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentchannel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterChannelInfoStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ChannelClusterChannelInfoStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentChannelAttribute(decodedValue) } @@ -740,101 +664,97 @@ suspend fun readCurrentChannelAttribute(): CurrentChannelAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentChannelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentChannelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentchannel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentchannel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ChannelClusterChannelInfoStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentChannelAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ChannelClusterChannelInfoStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ChannelClusterChannelInfoStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentChannelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentChannelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -844,45 +764,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -890,49 +815,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -942,45 +861,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -988,49 +912,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1040,45 +958,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1086,49 +1007,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1138,45 +1053,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1184,44 +1102,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1230,35 +1141,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1270,44 +1183,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1316,34 +1222,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1356,7 +1266,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt index 22dd04f551f5f8..29633f95e9ab20 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ColorControlCluster.kt @@ -17,250 +17,197 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ColorControlCluster(private val controller: MatterController, private val endpointId: UShort) {class NumberOfPrimariesAttribute( - val value: UByte? - ) +class ColorControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class NumberOfPrimariesAttribute(val value: UByte?) sealed class NumberOfPrimariesAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NumberOfPrimariesAttributeSubscriptionState() - + data class Success(val value: UByte?) : NumberOfPrimariesAttributeSubscriptionState() + data class Error(val exception: Exception) : NumberOfPrimariesAttributeSubscriptionState() - object SubscriptionEstablished : NumberOfPrimariesAttributeSubscriptionState() - } -class Primary1IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : NumberOfPrimariesAttributeSubscriptionState() + } + + class Primary1IntensityAttribute(val value: UByte?) sealed class Primary1IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary1IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary1IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary1IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary1IntensityAttributeSubscriptionState() - } -class Primary2IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary1IntensityAttributeSubscriptionState() + } + + class Primary2IntensityAttribute(val value: UByte?) sealed class Primary2IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary2IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary2IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary2IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary2IntensityAttributeSubscriptionState() - } -class Primary3IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary2IntensityAttributeSubscriptionState() + } + + class Primary3IntensityAttribute(val value: UByte?) sealed class Primary3IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary3IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary3IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary3IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary3IntensityAttributeSubscriptionState() - } -class Primary4IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary3IntensityAttributeSubscriptionState() + } + + class Primary4IntensityAttribute(val value: UByte?) sealed class Primary4IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary4IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary4IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary4IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary4IntensityAttributeSubscriptionState() - } -class Primary5IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary4IntensityAttributeSubscriptionState() + } + + class Primary5IntensityAttribute(val value: UByte?) sealed class Primary5IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary5IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary5IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary5IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary5IntensityAttributeSubscriptionState() - } -class Primary6IntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary5IntensityAttributeSubscriptionState() + } + + class Primary6IntensityAttribute(val value: UByte?) sealed class Primary6IntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : Primary6IntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : Primary6IntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : Primary6IntensityAttributeSubscriptionState() - object SubscriptionEstablished : Primary6IntensityAttributeSubscriptionState() - } -class ColorPointRIntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : Primary6IntensityAttributeSubscriptionState() + } + + class ColorPointRIntensityAttribute(val value: UByte?) sealed class ColorPointRIntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : ColorPointRIntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : ColorPointRIntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : ColorPointRIntensityAttributeSubscriptionState() - object SubscriptionEstablished : ColorPointRIntensityAttributeSubscriptionState() - } -class ColorPointGIntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : ColorPointRIntensityAttributeSubscriptionState() + } + + class ColorPointGIntensityAttribute(val value: UByte?) sealed class ColorPointGIntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : ColorPointGIntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : ColorPointGIntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : ColorPointGIntensityAttributeSubscriptionState() - object SubscriptionEstablished : ColorPointGIntensityAttributeSubscriptionState() - } -class ColorPointBIntensityAttribute( - val value: UByte? - ) + object SubscriptionEstablished : ColorPointGIntensityAttributeSubscriptionState() + } + + class ColorPointBIntensityAttribute(val value: UByte?) sealed class ColorPointBIntensityAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : ColorPointBIntensityAttributeSubscriptionState() - + data class Success(val value: UByte?) : ColorPointBIntensityAttributeSubscriptionState() + data class Error(val exception: Exception) : ColorPointBIntensityAttributeSubscriptionState() - object SubscriptionEstablished : ColorPointBIntensityAttributeSubscriptionState() - } -class StartUpColorTemperatureMiredsAttribute( - val value: UShort? - ) + object SubscriptionEstablished : ColorPointBIntensityAttributeSubscriptionState() + } + + class StartUpColorTemperatureMiredsAttribute(val value: UShort?) sealed class StartUpColorTemperatureMiredsAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : StartUpColorTemperatureMiredsAttributeSubscriptionState() - - data class Error(val exception: Exception) : StartUpColorTemperatureMiredsAttributeSubscriptionState() - - object SubscriptionEstablished : StartUpColorTemperatureMiredsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: UShort?) : + StartUpColorTemperatureMiredsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + StartUpColorTemperatureMiredsAttributeSubscriptionState() + + object SubscriptionEstablished : StartUpColorTemperatureMiredsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun moveToHue(hue: UByte - ,direction: UByte - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToHue( + hue: UByte, + direction: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -279,7 +226,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -293,11 +240,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveHue(moveMode: UByte - ,rate: UByte - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveHue( + moveMode: UByte, + rate: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -313,7 +262,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -327,12 +276,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepHue(stepMode: UByte - ,stepSize: UByte - ,transitionTime: UByte - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stepHue( + stepMode: UByte, + stepSize: UByte, + transitionTime: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -351,7 +302,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -365,11 +316,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToSaturation(saturation: UByte - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToSaturation( + saturation: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -385,7 +338,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -399,11 +352,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveSaturation(moveMode: UByte - ,rate: UByte - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveSaturation( + moveMode: UByte, + rate: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -419,7 +374,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -433,12 +388,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepSaturation(stepMode: UByte - ,stepSize: UByte - ,transitionTime: UByte - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stepSaturation( + stepMode: UByte, + stepSize: UByte, + transitionTime: UByte, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -457,7 +414,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -471,12 +428,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToHueAndSaturation(hue: UByte - ,saturation: UByte - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToHueAndSaturation( + hue: UByte, + saturation: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -495,7 +454,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -509,12 +468,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToColor(colorX: UShort - ,colorY: UShort - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToColor( + colorX: UShort, + colorY: UShort, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -533,7 +494,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -547,11 +508,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveColor(rateX: Short - ,rateY: Short - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveColor( + rateX: Short, + rateY: Short, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 8u val tlvWriter = TlvWriter() @@ -567,7 +530,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -581,12 +544,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepColor(stepX: Short - ,stepY: Short - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stepColor( + stepX: Short, + stepY: Short, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -605,7 +570,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -619,11 +584,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToColorTemperature(colorTemperatureMireds: UShort - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToColorTemperature( + colorTemperatureMireds: UShort, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 10u val tlvWriter = TlvWriter() @@ -639,7 +606,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -653,12 +620,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedMoveToHue(enhancedHue: UShort - ,direction: UByte - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun enhancedMoveToHue( + enhancedHue: UShort, + direction: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -677,7 +646,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -691,11 +660,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedMoveHue(moveMode: UByte - ,rate: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun enhancedMoveHue( + moveMode: UByte, + rate: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 65u val tlvWriter = TlvWriter() @@ -711,7 +682,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -725,12 +696,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedStepHue(stepMode: UByte - ,stepSize: UShort - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun enhancedStepHue( + stepMode: UByte, + stepSize: UShort, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 66u val tlvWriter = TlvWriter() @@ -749,7 +722,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -763,12 +736,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enhancedMoveToHueAndSaturation(enhancedHue: UShort - ,saturation: UByte - ,transitionTime: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun enhancedMoveToHueAndSaturation( + enhancedHue: UShort, + saturation: UByte, + transitionTime: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 67u val tlvWriter = TlvWriter() @@ -787,7 +762,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -801,14 +776,16 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun colorLoopSet(updateFlags: UByte - ,action: UByte - ,direction: UByte - ,time: UShort - ,startHue: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun colorLoopSet( + updateFlags: UByte, + action: UByte, + direction: UByte, + time: UShort, + startHue: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 68u val tlvWriter = TlvWriter() @@ -833,7 +810,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 6 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -847,9 +824,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stopMoveStep(optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stopMoveStep( + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 71u val tlvWriter = TlvWriter() @@ -859,7 +838,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -873,13 +852,15 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveColorTemperature(moveMode: UByte - ,rate: UShort - ,colorTemperatureMinimumMireds: UShort - ,colorTemperatureMaximumMireds: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveColorTemperature( + moveMode: UByte, + rate: UShort, + colorTemperatureMinimumMireds: UShort, + colorTemperatureMaximumMireds: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 75u val tlvWriter = TlvWriter() @@ -892,16 +873,22 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) val TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), colorTemperatureMinimumMireds) + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), + colorTemperatureMinimumMireds + ) val TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), colorTemperatureMaximumMireds) + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), + colorTemperatureMaximumMireds + ) val TAG_OPTIONS_MASK_REQ: Int = 4 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 5 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -915,14 +902,16 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepColorTemperature(stepMode: UByte - ,stepSize: UShort - ,transitionTime: UShort - ,colorTemperatureMinimumMireds: UShort - ,colorTemperatureMaximumMireds: UShort - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stepColorTemperature( + stepMode: UByte, + stepSize: UShort, + transitionTime: UShort, + colorTemperatureMinimumMireds: UShort, + colorTemperatureMaximumMireds: UShort, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 76u val tlvWriter = TlvWriter() @@ -938,16 +927,22 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) val TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), colorTemperatureMinimumMireds) + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MINIMUM_MIREDS_REQ), + colorTemperatureMinimumMireds + ) val TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), colorTemperatureMaximumMireds) + tlvWriter.put( + ContextSpecificTag(TAG_COLOR_TEMPERATURE_MAXIMUM_MIREDS_REQ), + colorTemperatureMaximumMireds + ) val TAG_OPTIONS_MASK_REQ: Int = 5 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 6 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -960,45 +955,39 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readCurrentHueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentHueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenthue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currenthue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1008,94 +997,88 @@ suspend fun readCurrentHueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenthue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currenthue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentSaturationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentSaturationAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentsaturation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentsaturation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1105,94 +1088,90 @@ suspend fun readCurrentSaturationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentsaturation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentsaturation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRemainingTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRemainingTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingtime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Remainingtime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1202,94 +1181,88 @@ suspend fun readRemainingTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingtime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Remainingtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentx attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentx attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1299,94 +1272,88 @@ suspend fun readCurrentXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentx attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentx attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currenty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1396,94 +1363,88 @@ suspend fun readCurrentYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currenty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDriftCompensationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDriftCompensationAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Driftcompensation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Driftcompensation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1493,94 +1454,90 @@ suspend fun readDriftCompensationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Driftcompensation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Driftcompensation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCompensationTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCompensationTextAttribute(): String? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Compensationtext attribute not found in response" - } + } + + requireNotNull(attributeData) { "Compensationtext attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -1590,94 +1547,90 @@ suspend fun readCompensationTextAttribute(): String? {val ATTRIBUTE_ID: UInt = 6 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Compensationtext attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Compensationtext attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorTemperatureMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorTemperatureMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortemperaturemireds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colortemperaturemireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1687,91 +1640,86 @@ suspend fun readColorTemperatureMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortemperaturemireds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colortemperaturemireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colormode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colormode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1780,35 +1728,37 @@ suspend fun readColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colormode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colormode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1820,67 +1770,56 @@ suspend fun readColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 8u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOptionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Options attribute not found in response" - } + } + + requireNotNull(attributeData) { "Options attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeOptionsAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOptionsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 15u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1902,7 +1841,7 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOptionsAttribute( @@ -1910,35 +1849,37 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Options attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Options attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1950,48 +1891,42 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfPrimariesAttribute(): NumberOfPrimariesAttribute {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfPrimariesAttribute(): NumberOfPrimariesAttribute { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofprimaries attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofprimaries attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NumberOfPrimariesAttribute(decodedValue) } @@ -2001,95 +1936,91 @@ suspend fun readNumberOfPrimariesAttribute(): NumberOfPrimariesAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NumberOfPrimariesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NumberOfPrimariesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofprimaries attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofprimaries attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NumberOfPrimariesAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NumberOfPrimariesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NumberOfPrimariesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary1XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary1XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary1x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2099,94 +2030,88 @@ suspend fun readPrimary1XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary1x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary1YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary1YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary1y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2196,99 +2121,93 @@ suspend fun readPrimary1YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary1y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary1IntensityAttribute(): Primary1IntensityAttribute {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary1IntensityAttribute(): Primary1IntensityAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary1intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary1IntensityAttribute(decodedValue) } @@ -2298,99 +2217,95 @@ suspend fun readPrimary1IntensityAttribute(): Primary1IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary1IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary1IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary1intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary1intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary1IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary1IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary1IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary2XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary2XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary2x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2400,94 +2315,88 @@ suspend fun readPrimary2XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 21u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary2x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary2YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary2YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary2y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2497,99 +2406,93 @@ suspend fun readPrimary2YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 22u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary2y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary2IntensityAttribute(): Primary2IntensityAttribute {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary2IntensityAttribute(): Primary2IntensityAttribute { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary2intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary2IntensityAttribute(decodedValue) } @@ -2599,99 +2502,95 @@ suspend fun readPrimary2IntensityAttribute(): Primary2IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary2IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary2IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary2intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary2intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary2IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary2IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary2IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary3XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary3XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary3x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2701,94 +2600,88 @@ suspend fun readPrimary3XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 25u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary3x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary3YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary3YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary3y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2798,99 +2691,93 @@ suspend fun readPrimary3YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 26u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary3y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary3IntensityAttribute(): Primary3IntensityAttribute {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary3IntensityAttribute(): Primary3IntensityAttribute { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary3intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary3IntensityAttribute(decodedValue) } @@ -2900,99 +2787,95 @@ suspend fun readPrimary3IntensityAttribute(): Primary3IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary3IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary3IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary3intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary3intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary3IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary3IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary3IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary4XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 32u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary4XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary4x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3002,94 +2885,88 @@ suspend fun readPrimary4XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary4x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary4YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary4YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary4y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3099,99 +2976,93 @@ suspend fun readPrimary4YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 33u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary4y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary4IntensityAttribute(): Primary4IntensityAttribute {val ATTRIBUTE_ID: UInt = 34u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary4IntensityAttribute(): Primary4IntensityAttribute { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary4intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary4IntensityAttribute(decodedValue) } @@ -3201,99 +3072,95 @@ suspend fun readPrimary4IntensityAttribute(): Primary4IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary4IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary4IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary4intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary4intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary4IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary4IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary4IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary5XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary5XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary5x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3303,94 +3170,88 @@ suspend fun readPrimary5XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 36u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary5x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary5YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary5YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary5y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3400,99 +3261,93 @@ suspend fun readPrimary5YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 37u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary5y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary5IntensityAttribute(): Primary5IntensityAttribute {val ATTRIBUTE_ID: UInt = 38u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary5IntensityAttribute(): Primary5IntensityAttribute { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary5intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary5IntensityAttribute(decodedValue) } @@ -3502,99 +3357,95 @@ suspend fun readPrimary5IntensityAttribute(): Primary5IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary5IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary5IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary5intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary5intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary5IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary5IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary5IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary6XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 40u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary6XAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6x attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary6x attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3604,94 +3455,88 @@ suspend fun readPrimary6XAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 40u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6x attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary6x attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary6YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 41u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary6YAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6y attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary6y attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3701,99 +3546,93 @@ suspend fun readPrimary6YAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 41u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6y attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Primary6y attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPrimary6IntensityAttribute(): Primary6IntensityAttribute {val ATTRIBUTE_ID: UInt = 42u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPrimary6IntensityAttribute(): Primary6IntensityAttribute { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6intensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Primary6intensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return Primary6IntensityAttribute(decodedValue) } @@ -3803,123 +3642,115 @@ suspend fun readPrimary6IntensityAttribute(): Primary6IntensityAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(Primary6IntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + Primary6IntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Primary6intensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Primary6intensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(Primary6IntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(Primary6IntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(Primary6IntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWhitePointXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWhitePointXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Whitepointx attribute not found in response" - } + } + + requireNotNull(attributeData) { "Whitepointx attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeWhitePointXAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeWhitePointXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3941,7 +3772,7 @@ suspend fun readWhitePointXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 48u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWhitePointXAttribute( @@ -3949,118 +3780,108 @@ suspend fun readWhitePointXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 48u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Whitepointx attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Whitepointx attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWhitePointYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWhitePointYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Whitepointy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Whitepointy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeWhitePointYAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeWhitePointYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4082,7 +3903,7 @@ suspend fun readWhitePointYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 49u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWhitePointYAttribute( @@ -4090,118 +3911,108 @@ suspend fun readWhitePointYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 49u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Whitepointy attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Whitepointy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointRXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointRXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointrx attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointrx attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointRXAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointRXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4223,7 +4034,7 @@ suspend fun readColorPointRXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 50u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointRXAttribute( @@ -4231,118 +4042,108 @@ suspend fun readColorPointRXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 50u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointrx attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointrx attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointRYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 51u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointRYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointry attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointry attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointRYAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointRYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 51u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4364,7 +4165,7 @@ suspend fun readColorPointRYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 51u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointRYAttribute( @@ -4372,123 +4173,116 @@ suspend fun readColorPointRYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 51u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointry attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointry attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute {val ATTRIBUTE_ID: UInt = 52u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointrintensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointrintensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ColorPointRIntensityAttribute(decodedValue) } suspend fun writeColorPointRIntensityAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 52u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4510,7 +4304,7 @@ suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute { throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointRIntensityAttribute( @@ -4518,123 +4312,115 @@ suspend fun readColorPointRIntensityAttribute(): ColorPointRIntensityAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ColorPointRIntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ColorPointRIntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointrintensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorpointrintensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ColorPointRIntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ColorPointRIntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ColorPointRIntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointGXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 54u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointGXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 54u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgx attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointgx attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointGXAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointGXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 54u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4656,7 +4442,7 @@ suspend fun readColorPointGXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 54u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointGXAttribute( @@ -4664,118 +4450,108 @@ suspend fun readColorPointGXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 54u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 54u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgx attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointgx attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointGYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 55u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointGYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 55u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointgy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointGYAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointGYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 55u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4797,7 +4573,7 @@ suspend fun readColorPointGYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 55u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointGYAttribute( @@ -4805,123 +4581,116 @@ suspend fun readColorPointGYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 55u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 55u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgy attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointgy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute {val ATTRIBUTE_ID: UInt = 56u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute { + val ATTRIBUTE_ID: UInt = 56u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgintensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointgintensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ColorPointGIntensityAttribute(decodedValue) } suspend fun writeColorPointGIntensityAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 56u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4943,7 +4712,7 @@ suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute { throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointGIntensityAttribute( @@ -4951,123 +4720,115 @@ suspend fun readColorPointGIntensityAttribute(): ColorPointGIntensityAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 56u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ColorPointGIntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ColorPointGIntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointgintensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorpointgintensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ColorPointGIntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ColorPointGIntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ColorPointGIntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointBXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 58u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointBXAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 58u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointbx attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointbx attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointBXAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointBXAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 58u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5089,7 +4850,7 @@ suspend fun readColorPointBXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 58u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointBXAttribute( @@ -5097,118 +4858,108 @@ suspend fun readColorPointBXAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 58u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 58u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointbx attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointbx attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointBYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 59u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointBYAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 59u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointby attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointby attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeColorPointBYAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeColorPointBYAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 59u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5230,7 +4981,7 @@ suspend fun readColorPointBYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 59u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointBYAttribute( @@ -5238,123 +4989,116 @@ suspend fun readColorPointBYAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 59u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 59u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointby attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorpointby attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute {val ATTRIBUTE_ID: UInt = 60u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute { + val ATTRIBUTE_ID: UInt = 60u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointbintensity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorpointbintensity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ColorPointBIntensityAttribute(decodedValue) } suspend fun writeColorPointBIntensityAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 60u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5376,7 +5120,7 @@ suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute { throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeColorPointBIntensityAttribute( @@ -5384,99 +5128,95 @@ suspend fun readColorPointBIntensityAttribute(): ColorPointBIntensityAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 60u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ColorPointBIntensityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ColorPointBIntensityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorpointbintensity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorpointbintensity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ColorPointBIntensityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ColorPointBIntensityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ColorPointBIntensityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnhancedCurrentHueAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16384u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnhancedCurrentHueAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enhancedcurrenthue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enhancedcurrenthue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5486,91 +5226,86 @@ suspend fun readEnhancedCurrentHueAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enhancedcurrenthue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enhancedcurrenthue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnhancedColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16385u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnhancedColorModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 16385u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enhancedcolormode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enhancedcolormode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -5579,34 +5314,38 @@ suspend fun readEnhancedColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16385u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enhancedcolormode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enhancedcolormode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -5619,47 +5358,41 @@ suspend fun readEnhancedColorModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorLoopActiveAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16386u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorLoopActiveAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16386u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopactive attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorloopactive attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -5669,94 +5402,90 @@ suspend fun readColorLoopActiveAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 163 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16386u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopactive attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorloopactive attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorLoopDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16387u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorLoopDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16387u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopdirection attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorloopdirection attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -5766,94 +5495,90 @@ suspend fun readColorLoopDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16387u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopdirection attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorloopdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorLoopTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16388u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorLoopTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16388u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorlooptime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorlooptime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5863,94 +5588,88 @@ suspend fun readColorLoopTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1638 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16388u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorlooptime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Colorlooptime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorLoopStartEnhancedHueAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16389u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorLoopStartEnhancedHueAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16389u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopstartenhancedhue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorloopstartenhancedhue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5960,94 +5679,90 @@ suspend fun readColorLoopStartEnhancedHueAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16389u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopstartenhancedhue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorloopstartenhancedhue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorLoopStoredEnhancedHueAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16390u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorLoopStoredEnhancedHueAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16390u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopstoredenhancedhue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorloopstoredenhancedhue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6057,91 +5772,86 @@ suspend fun readColorLoopStoredEnhancedHueAttribute(): UShort? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16390u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorloopstoredenhancedhue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorloopstoredenhancedhue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorCapabilitiesAttribute(): UShort {val ATTRIBUTE_ID: UInt = 16394u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorCapabilitiesAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 16394u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorcapabilities attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colorcapabilities attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -6150,34 +5860,38 @@ suspend fun readColorCapabilitiesAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16394u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colorcapabilities attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colorcapabilities attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -6190,47 +5904,41 @@ suspend fun readColorCapabilitiesAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorTempPhysicalMinMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16395u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorTempPhysicalMinMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16395u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortempphysicalminmireds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colortempphysicalminmireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6240,94 +5948,90 @@ suspend fun readColorTempPhysicalMinMiredsAttribute(): UShort? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16395u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortempphysicalminmireds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colortempphysicalminmireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readColorTempPhysicalMaxMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16396u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readColorTempPhysicalMaxMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16396u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortempphysicalmaxmireds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Colortempphysicalmaxmireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6337,94 +6041,92 @@ suspend fun readColorTempPhysicalMaxMiredsAttribute(): UShort? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16396u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Colortempphysicalmaxmireds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Colortempphysicalmaxmireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCoupleColorTempToLevelMinMiredsAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16397u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCoupleColorTempToLevelMinMiredsAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16397u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Couplecolortemptolevelminmireds attribute not found in response" + } + + requireNotNull(attributeData) { + "Couplecolortemptolevelminmireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6434,123 +6136,120 @@ suspend fun readCoupleColorTempToLevelMinMiredsAttribute(): UShort? {val ATTRIBU maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16397u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Couplecolortemptolevelminmireds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Couplecolortemptolevelminmireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatureMiredsAttribute {val ATTRIBUTE_ID: UInt = 16400u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatureMiredsAttribute { + val ATTRIBUTE_ID: UInt = 16400u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupcolortemperaturemireds attribute not found in response" + } + + requireNotNull(attributeData) { + "Startupcolortemperaturemireds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpColorTemperatureMiredsAttribute(decodedValue) } suspend fun writeStartUpColorTemperatureMiredsAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16400u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6572,7 +6271,7 @@ suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatur throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpColorTemperatureMiredsAttribute( @@ -6580,101 +6279,99 @@ suspend fun readStartUpColorTemperatureMiredsAttribute(): StartUpColorTemperatur maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16400u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpColorTemperatureMiredsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpColorTemperatureMiredsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupcolortemperaturemireds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Startupcolortemperaturemireds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(StartUpColorTemperatureMiredsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(StartUpColorTemperatureMiredsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -6684,45 +6381,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6730,49 +6432,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -6782,45 +6478,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6828,49 +6529,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -6880,45 +6575,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -6926,49 +6624,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -6978,45 +6670,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -7024,44 +6719,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -7070,35 +6758,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7110,44 +6800,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -7156,34 +6839,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7196,7 +6883,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt index 034e54bd0d2c5a..4c08eb6499a918 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentAppObserverCluster.kt @@ -17,122 +17,89 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentAppObserverCluster(private val controller: MatterController, private val endpointId: UShort) { - class ContentAppMessageResponse( - val status: UByte, - val data: String?, - val encodingHint: String? - ) -class GeneratedCommandListAttribute( - val value: List - ) +class ContentAppObserverCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ContentAppMessageResponse(val status: UByte, val data: String?, val encodingHint: String?) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun contentAppMessage(data: String? - ,encodingHint: String - ,timedInvokeTimeout: Duration? = null): ContentAppMessageResponse { + suspend fun contentAppMessage( + data: String?, + encodingHint: String, + timedInvokeTimeout: Duration? = null + ): ContentAppMessageResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DATA_REQ: Int = 0 - data?.let { - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) - } + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } val TAG_ENCODING_HINT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ENCODING_HINT_REQ), encodingHint) + tlvWriter.put(ContextSpecificTag(TAG_ENCODING_HINT_REQ), encodingHint) tlvWriter.endStructure() val request: InvokeRequest = @@ -149,110 +116,94 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - + val TAG_ENCODING_HINT: Int = 2 var encodingHint_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_ENCODING_HINT)) {encodingHint_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_ENCODING_HINT)) { + encodingHint_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - - tlvReader.exitContainer() - return ContentAppMessageResponse( - status_decoded, - data_decoded, - encodingHint_decoded - ) + return ContentAppMessageResponse(status_decoded, data_decoded, encodingHint_decoded) } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -262,45 +213,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -308,49 +264,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -360,45 +310,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -406,49 +361,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -458,45 +407,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -504,49 +456,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -556,45 +502,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -602,44 +551,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -648,35 +590,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -688,44 +632,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -734,34 +671,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -774,7 +715,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt index 8da8313c8caed0..327d7b9645c408 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentControlCluster.kt @@ -17,146 +17,110 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentControlCluster(private val controller: MatterController, private val endpointId: UShort) { - class ResetPINResponse( - val PINCode: String - ) -class OnDemandRatingsAttribute( - val value: List? - ) +class ContentControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ResetPINResponse(val PINCode: String) + + class OnDemandRatingsAttribute(val value: List?) sealed class OnDemandRatingsAttributeSubscriptionState { - data class Success( - val value: List? - ) : OnDemandRatingsAttributeSubscriptionState() - + data class Success(val value: List?) : + OnDemandRatingsAttributeSubscriptionState() + data class Error(val exception: Exception) : OnDemandRatingsAttributeSubscriptionState() - object SubscriptionEstablished : OnDemandRatingsAttributeSubscriptionState() - } -class ScheduledContentRatingsAttribute( - val value: List? - ) + object SubscriptionEstablished : OnDemandRatingsAttributeSubscriptionState() + } + + class ScheduledContentRatingsAttribute(val value: List?) sealed class ScheduledContentRatingsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ScheduledContentRatingsAttributeSubscriptionState() - - data class Error(val exception: Exception) : ScheduledContentRatingsAttributeSubscriptionState() - - object SubscriptionEstablished : ScheduledContentRatingsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List?) : + ScheduledContentRatingsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + ScheduledContentRatingsAttributeSubscriptionState() + + object SubscriptionEstablished : ScheduledContentRatingsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun updatePIN(oldPIN: String? - ,newPIN: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun updatePIN(oldPIN: String?, newPIN: String, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_OLD_P_I_N_REQ: Int = 0 - oldPIN?.let { - tlvWriter.put(ContextSpecificTag(TAG_OLD_P_I_N_REQ), oldPIN) - } + oldPIN?.let { tlvWriter.put(ContextSpecificTag(TAG_OLD_P_I_N_REQ), oldPIN) } val TAG_NEW_P_I_N_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NEW_P_I_N_REQ), newPIN) + tlvWriter.put(ContextSpecificTag(TAG_NEW_P_I_N_REQ), newPIN) tlvWriter.endStructure() val request: InvokeRequest = @@ -174,7 +138,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -191,39 +155,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_P_I_N_CODE: Int = 0 var PINCode_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_P_I_N_CODE)) {PINCode_decoded = tlvReader.getString(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_P_I_N_CODE)) { + PINCode_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (PINCode_decoded == null) { - throw IllegalStateException("PINCode not found in TLV") + throw IllegalStateException("PINCode not found in TLV") } - tlvReader.exitContainer() - return ResetPINResponse( - PINCode_decoded - ) + return ResetPINResponse(PINCode_decoded) } suspend fun enable(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -241,7 +197,7 @@ class AttributeListAttribute( val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -255,23 +211,21 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addBonusTime(PINCode: String? - ,bonusTime: UInt? - ,timedInvokeTimeout: Duration? = null) { + suspend fun addBonusTime( + PINCode: String?, + bonusTime: UInt?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { - tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) - } + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } val TAG_BONUS_TIME_REQ: Int = 1 - bonusTime?.let { - tlvWriter.put(ContextSpecificTag(TAG_BONUS_TIME_REQ), bonusTime) - } + bonusTime?.let { tlvWriter.put(ContextSpecificTag(TAG_BONUS_TIME_REQ), bonusTime) } tlvWriter.endStructure() val request: InvokeRequest = @@ -285,15 +239,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setScreenDailyTime(screenTime: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun setScreenDailyTime(screenTime: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 6u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SCREEN_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_SCREEN_TIME_REQ), screenTime) + tlvWriter.put(ContextSpecificTag(TAG_SCREEN_TIME_REQ), screenTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -311,7 +264,7 @@ class AttributeListAttribute( val commandId: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -329,7 +282,7 @@ class AttributeListAttribute( val commandId: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -343,15 +296,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setOnDemandRatingThreshold(rating: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun setOnDemandRatingThreshold(rating: String, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 9u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_RATING_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) + tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) tlvWriter.endStructure() val request: InvokeRequest = @@ -365,15 +317,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setScheduledContentRatingThreshold(rating: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun setScheduledContentRatingThreshold( + rating: String, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 10u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_RATING_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) + tlvWriter.put(ContextSpecificTag(TAG_RATING_REQ), rating) tlvWriter.endStructure() val request: InvokeRequest = @@ -386,42 +340,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -430,35 +377,37 @@ suspend fun readEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enabled attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Enabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -470,53 +419,47 @@ suspend fun readEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnDemandRatingsAttribute(): OnDemandRatingsAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnDemandRatingsAttribute(): OnDemandRatingsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ondemandratings attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ondemandratings attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return OnDemandRatingsAttribute(decodedValue) } @@ -526,100 +469,96 @@ suspend fun readOnDemandRatingsAttribute(): OnDemandRatingsAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnDemandRatingsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnDemandRatingsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ondemandratings attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ondemandratings attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(OnDemandRatingsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(OnDemandRatingsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnDemandRatingsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnDemandRatingThresholdAttribute(): String? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnDemandRatingThresholdAttribute(): String? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ondemandratingthreshold attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ondemandratingthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -629,100 +568,96 @@ suspend fun readOnDemandRatingThresholdAttribute(): String? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ondemandratingthreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ondemandratingthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScheduledContentRatingsAttribute(): ScheduledContentRatingsAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScheduledContentRatingsAttribute(): ScheduledContentRatingsAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduledcontentratings attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scheduledcontentratings attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ScheduledContentRatingsAttribute(decodedValue) } @@ -732,100 +667,98 @@ suspend fun readScheduledContentRatingsAttribute(): ScheduledContentRatingsAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ScheduledContentRatingsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ScheduledContentRatingsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduledcontentratings attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scheduledcontentratings attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ScheduledContentRatingsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ContentControlClusterRatingNameStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ScheduledContentRatingsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ScheduledContentRatingsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScheduledContentRatingThresholdAttribute(): String? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScheduledContentRatingThresholdAttribute(): String? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduledcontentratingthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Scheduledcontentratingthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -835,94 +768,90 @@ suspend fun readScheduledContentRatingThresholdAttribute(): String? {val ATTRIBU maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduledcontentratingthreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scheduledcontentratingthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScreenDailyTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScreenDailyTimeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Screendailytime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Screendailytime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -932,94 +861,90 @@ suspend fun readScreenDailyTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Screendailytime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Screendailytime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRemainingScreenTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRemainingScreenTimeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingscreentime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Remainingscreentime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -1029,91 +954,86 @@ suspend fun readRemainingScreenTimeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingscreentime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Remainingscreentime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBlockUnratedAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBlockUnratedAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Blockunrated attribute not found in response" - } + } + + requireNotNull(attributeData) { "Blockunrated attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -1122,35 +1042,37 @@ suspend fun readBlockUnratedAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Blockunrated attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Blockunrated attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1162,49 +1084,43 @@ suspend fun readBlockUnratedAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 7u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1214,45 +1130,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1260,49 +1181,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1312,45 +1227,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1358,49 +1278,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1410,45 +1324,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1456,49 +1373,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1508,45 +1419,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1554,44 +1468,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1600,35 +1507,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1640,44 +1549,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1686,34 +1588,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1726,7 +1632,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt index e9cc7486518443..ae50ff527a8e2c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ContentLauncherCluster.kt @@ -17,125 +17,92 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherCluster(private val controller: MatterController, private val endpointId: UShort) { - class LauncherResponse( - val status: UByte, - val data: String? - ) -class AcceptHeaderAttribute( - val value: List? - ) +class ContentLauncherCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LauncherResponse(val status: UByte, val data: String?) + + class AcceptHeaderAttribute(val value: List?) sealed class AcceptHeaderAttributeSubscriptionState { - data class Success( - val value: List? - ) : AcceptHeaderAttributeSubscriptionState() - + data class Success(val value: List?) : AcceptHeaderAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptHeaderAttributeSubscriptionState() - object SubscriptionEstablished : AcceptHeaderAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptHeaderAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun launchContent(search: ContentLauncherClusterContentSearchStruct - ,autoPlay: Boolean - ,data: String? - ,playbackPreferences: ContentLauncherClusterPlaybackPreferencesStruct? - ,useCurrentContext: Boolean? - ,timedInvokeTimeout: Duration? = null): LauncherResponse { + suspend fun launchContent( + search: ContentLauncherClusterContentSearchStruct, + autoPlay: Boolean, + data: String?, + playbackPreferences: ContentLauncherClusterPlaybackPreferencesStruct?, + useCurrentContext: Boolean?, + timedInvokeTimeout: Duration? = null + ): LauncherResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -148,9 +115,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_AUTO_PLAY_REQ), autoPlay) val TAG_DATA_REQ: Int = 2 - data?.let { - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) - } + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } val TAG_PLAYBACK_PREFERENCES_REQ: Int = 3 playbackPreferences?.let { @@ -160,7 +125,7 @@ class AttributeListAttribute( val TAG_USE_CURRENT_CONTEXT_REQ: Int = 4 useCurrentContext?.let { tlvWriter.put(ContextSpecificTag(TAG_USE_CURRENT_CONTEXT_REQ), useCurrentContext) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -177,56 +142,49 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return LauncherResponse( - status_decoded, - data_decoded - ) + return LauncherResponse(status_decoded, data_decoded) } - suspend fun launchURL(contentURL: String - ,displayString: String? - ,brandingInformation: ContentLauncherClusterBrandingInformationStruct? - ,timedInvokeTimeout: Duration? = null): LauncherResponse { + suspend fun launchURL( + contentURL: String, + displayString: String?, + brandingInformation: ContentLauncherClusterBrandingInformationStruct?, + timedInvokeTimeout: Duration? = null + ): LauncherResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -236,14 +194,12 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_CONTENT_U_R_L_REQ), contentURL) val TAG_DISPLAY_STRING_REQ: Int = 1 - displayString?.let { - tlvWriter.put(ContextSpecificTag(TAG_DISPLAY_STRING_REQ), displayString) - } + displayString?.let { tlvWriter.put(ContextSpecificTag(TAG_DISPLAY_STRING_REQ), displayString) } val TAG_BRANDING_INFORMATION_REQ: Int = 2 brandingInformation?.let { brandingInformation.toTlv(ContextSpecificTag(TAG_BRANDING_INFORMATION_REQ), tlvWriter) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -260,96 +216,81 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return LauncherResponse( - status_decoded, - data_decoded - ) + return LauncherResponse(status_decoded, data_decoded) } -suspend fun readAcceptHeaderAttribute(): AcceptHeaderAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptHeaderAttribute(): AcceptHeaderAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptheader attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptheader attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return AcceptHeaderAttribute(decodedValue) } @@ -359,100 +300,94 @@ suspend fun readAcceptHeaderAttribute(): AcceptHeaderAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptHeaderAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptHeaderAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptheader attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Acceptheader attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(AcceptHeaderAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(AcceptHeaderAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AcceptHeaderAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedStreamingProtocolsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedStreamingProtocolsAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedstreamingprotocols attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedstreamingprotocols attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -462,96 +397,92 @@ suspend fun readSupportedStreamingProtocolsAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedstreamingprotocols attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedstreamingprotocols attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -561,45 +492,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -607,49 +543,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -659,45 +589,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -705,49 +640,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -757,45 +686,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -803,49 +735,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -855,45 +781,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -901,44 +830,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -947,35 +869,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -987,44 +911,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1033,34 +950,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1073,7 +994,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt index 6eba50d64ec9c8..af0c8860f08d12 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DemandResponseLoadControlCluster.kt @@ -17,149 +17,124 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlCluster(private val controller: MatterController, private val endpointId: UShort) {class LoadControlProgramsAttribute( +class DemandResponseLoadControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LoadControlProgramsAttribute( val value: List ) sealed class LoadControlProgramsAttributeSubscriptionState { - data class Success( - val value: List - ) : LoadControlProgramsAttributeSubscriptionState() - + data class Success(val value: List) : + LoadControlProgramsAttributeSubscriptionState() + data class Error(val exception: Exception) : LoadControlProgramsAttributeSubscriptionState() - object SubscriptionEstablished : LoadControlProgramsAttributeSubscriptionState() - } -class EventsAttribute( - val value: List - ) + object SubscriptionEstablished : LoadControlProgramsAttributeSubscriptionState() + } + + class EventsAttribute(val value: List) sealed class EventsAttributeSubscriptionState { - data class Success( - val value: List - ) : EventsAttributeSubscriptionState() - + data class Success(val value: List) : + EventsAttributeSubscriptionState() + data class Error(val exception: Exception) : EventsAttributeSubscriptionState() - object SubscriptionEstablished : EventsAttributeSubscriptionState() - } -class ActiveEventsAttribute( + object SubscriptionEstablished : EventsAttributeSubscriptionState() + } + + class ActiveEventsAttribute( val value: List ) sealed class ActiveEventsAttributeSubscriptionState { - data class Success( - val value: List - ) : ActiveEventsAttributeSubscriptionState() - + data class Success(val value: List) : + ActiveEventsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveEventsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveEventsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ActiveEventsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun registerLoadControlProgramRequest(loadControlProgram: DemandResponseLoadControlClusterLoadControlProgramStruct - ,timedInvokeTimeout: Duration? = null) { + suspend fun registerLoadControlProgramRequest( + loadControlProgram: DemandResponseLoadControlClusterLoadControlProgramStruct, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LOAD_CONTROL_PROGRAM_REQ: Int = 0 - loadControlProgram.toTlv(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_REQ), tlvWriter) + loadControlProgram.toTlv(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -173,15 +148,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unregisterLoadControlProgramRequest(loadControlProgramID: ByteArray - ,timedInvokeTimeout: Duration? = null) { + suspend fun unregisterLoadControlProgramRequest( + loadControlProgramID: ByteArray, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LOAD_CONTROL_PROGRAM_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_I_D_REQ), loadControlProgramID) + tlvWriter.put(ContextSpecificTag(TAG_LOAD_CONTROL_PROGRAM_I_D_REQ), loadControlProgramID) tlvWriter.endStructure() val request: InvokeRequest = @@ -195,15 +172,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addLoadControlEventRequest(event: DemandResponseLoadControlClusterLoadControlEventStruct - ,timedInvokeTimeout: Duration? = null) { + suspend fun addLoadControlEventRequest( + event: DemandResponseLoadControlClusterLoadControlEventStruct, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_EVENT_REQ: Int = 0 - event.toTlv(ContextSpecificTag(TAG_EVENT_REQ), tlvWriter) + event.toTlv(ContextSpecificTag(TAG_EVENT_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -217,9 +196,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun removeLoadControlEventRequest(eventID: ByteArray - ,cancelControl: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun removeLoadControlEventRequest( + eventID: ByteArray, + cancelControl: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -229,7 +210,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_EVENT_I_D_REQ), eventID) val TAG_CANCEL_CONTROL_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CANCEL_CONTROL_REQ), cancelControl) + tlvWriter.put(ContextSpecificTag(TAG_CANCEL_CONTROL_REQ), cancelControl) tlvWriter.endStructure() val request: InvokeRequest = @@ -247,7 +228,7 @@ class AttributeListAttribute( val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -260,47 +241,46 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Loadcontrolprograms attribute not found in response" - } + } + + requireNotNull(attributeData) { "Loadcontrolprograms attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return LoadControlProgramsAttribute(decodedValue) } @@ -310,45 +290,55 @@ suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LoadControlProgramsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LoadControlProgramsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Loadcontrolprograms attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Loadcontrolprograms attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlProgramStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(LoadControlProgramsAttributeSubscriptionState.Success(decodedValue)) } @@ -356,44 +346,37 @@ suspend fun readLoadControlProgramsAttribute(): LoadControlProgramsAttribute {va emit(LoadControlProgramsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfLoadControlProgramsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNumberOfLoadControlProgramsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofloadcontrolprograms attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofloadcontrolprograms attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -402,34 +385,38 @@ suspend fun readNumberOfLoadControlProgramsAttribute(): UByte {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofloadcontrolprograms attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofloadcontrolprograms attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -442,49 +429,45 @@ suspend fun readNumberOfLoadControlProgramsAttribute(): UByte {val ATTRIBUTE_ID: emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventsAttribute(): EventsAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventsAttribute(): EventsAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Events attribute not found in response" - } + } + + requireNotNull(attributeData) { "Events attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventsAttribute(decodedValue) } @@ -494,45 +477,53 @@ suspend fun readEventsAttribute(): EventsAttribute {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Events attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Events attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(EventsAttributeSubscriptionState.Success(decodedValue)) } @@ -540,49 +531,45 @@ suspend fun readEventsAttribute(): EventsAttribute {val ATTRIBUTE_ID: UInt = 2u emit(EventsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveEventsAttribute(): ActiveEventsAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveEventsAttribute(): ActiveEventsAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activeevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ActiveEventsAttribute(decodedValue) } @@ -592,45 +579,53 @@ suspend fun readActiveEventsAttribute(): ActiveEventsAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveEventsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveEventsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeevents attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activeevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(ActiveEventsAttributeSubscriptionState.Success(decodedValue)) } @@ -638,44 +633,37 @@ suspend fun readActiveEventsAttribute(): ActiveEventsAttribute {val ATTRIBUTE_ID emit(ActiveEventsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfEventsPerProgramAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNumberOfEventsPerProgramAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofeventsperprogram attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofeventsperprogram attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -684,34 +672,38 @@ suspend fun readNumberOfEventsPerProgramAttribute(): UByte {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofeventsperprogram attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofeventsperprogram attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -724,44 +716,37 @@ suspend fun readNumberOfEventsPerProgramAttribute(): UByte {val ATTRIBUTE_ID: UI emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfTransitionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNumberOfTransitionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberoftransitions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberoftransitions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -770,34 +755,38 @@ suspend fun readNumberOfTransitionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberoftransitions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberoftransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -810,67 +799,56 @@ suspend fun readNumberOfTransitionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultRandomStartAttribute(): UByte {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultRandomStartAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultrandomstart attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultrandomstart attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeDefaultRandomStartAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultRandomStartAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -892,7 +870,7 @@ suspend fun readDefaultRandomStartAttribute(): UByte {val ATTRIBUTE_ID: UInt = 6 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultRandomStartAttribute( @@ -900,34 +878,38 @@ suspend fun readDefaultRandomStartAttribute(): UByte {val ATTRIBUTE_ID: UInt = 6 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultrandomstart attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultrandomstart attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -940,67 +922,59 @@ suspend fun readDefaultRandomStartAttribute(): UByte {val ATTRIBUTE_ID: UInt = 6 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultRandomDurationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultRandomDurationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultrandomduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultrandomduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } suspend fun writeDefaultRandomDurationAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1022,7 +996,7 @@ suspend fun readDefaultRandomDurationAttribute(): UByte {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultRandomDurationAttribute( @@ -1030,34 +1004,38 @@ suspend fun readDefaultRandomDurationAttribute(): UByte {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultrandomduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultrandomduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1070,49 +1048,43 @@ suspend fun readDefaultRandomDurationAttribute(): UByte {val ATTRIBUTE_ID: UInt emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1122,45 +1094,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1168,49 +1145,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1220,45 +1191,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1266,49 +1242,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1318,45 +1288,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1364,49 +1337,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1416,45 +1383,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1462,44 +1432,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1508,35 +1471,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1548,44 +1513,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1594,34 +1552,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1634,7 +1596,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt index e5b5a887fd60b2..5ff9420be9baf0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DescriptorCluster.kt @@ -17,206 +17,150 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class DescriptorCluster(private val controller: MatterController, private val endpointId: UShort) {class DeviceTypeListAttribute( - val value: List - ) +class DescriptorCluster(private val controller: MatterController, private val endpointId: UShort) { + class DeviceTypeListAttribute(val value: List) sealed class DeviceTypeListAttributeSubscriptionState { - data class Success( - val value: List - ) : DeviceTypeListAttributeSubscriptionState() - + data class Success(val value: List) : + DeviceTypeListAttributeSubscriptionState() + data class Error(val exception: Exception) : DeviceTypeListAttributeSubscriptionState() - object SubscriptionEstablished : DeviceTypeListAttributeSubscriptionState() - } -class ServerListAttribute( - val value: List - ) + object SubscriptionEstablished : DeviceTypeListAttributeSubscriptionState() + } + + class ServerListAttribute(val value: List) sealed class ServerListAttributeSubscriptionState { - data class Success( - val value: List - ) : ServerListAttributeSubscriptionState() - + data class Success(val value: List) : ServerListAttributeSubscriptionState() + data class Error(val exception: Exception) : ServerListAttributeSubscriptionState() - object SubscriptionEstablished : ServerListAttributeSubscriptionState() - } -class ClientListAttribute( - val value: List - ) + object SubscriptionEstablished : ServerListAttributeSubscriptionState() + } + + class ClientListAttribute(val value: List) sealed class ClientListAttributeSubscriptionState { - data class Success( - val value: List - ) : ClientListAttributeSubscriptionState() - + data class Success(val value: List) : ClientListAttributeSubscriptionState() + data class Error(val exception: Exception) : ClientListAttributeSubscriptionState() - object SubscriptionEstablished : ClientListAttributeSubscriptionState() - } -class PartsListAttribute( - val value: List - ) + object SubscriptionEstablished : ClientListAttributeSubscriptionState() + } + + class PartsListAttribute(val value: List) sealed class PartsListAttributeSubscriptionState { - data class Success( - val value: List - ) : PartsListAttributeSubscriptionState() - + data class Success(val value: List) : PartsListAttributeSubscriptionState() + data class Error(val exception: Exception) : PartsListAttributeSubscriptionState() - object SubscriptionEstablished : PartsListAttributeSubscriptionState() - } -class TagListAttribute( - val value: List? - ) + object SubscriptionEstablished : PartsListAttributeSubscriptionState() + } + + class TagListAttribute(val value: List?) sealed class TagListAttributeSubscriptionState { - data class Success( - val value: List? - ) : TagListAttributeSubscriptionState() - + data class Success(val value: List?) : + TagListAttributeSubscriptionState() + data class Error(val exception: Exception) : TagListAttributeSubscriptionState() - object SubscriptionEstablished : TagListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : TagListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Devicetypelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Devicetypelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return DeviceTypeListAttribute(decodedValue) } @@ -226,45 +170,50 @@ suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DeviceTypeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DeviceTypeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Devicetypelist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Devicetypelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DescriptorClusterDeviceTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(DeviceTypeListAttributeSubscriptionState.Success(decodedValue)) } @@ -272,49 +221,43 @@ suspend fun readDeviceTypeListAttribute(): DeviceTypeListAttribute {val ATTRIBUT emit(DeviceTypeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readServerListAttribute(): ServerListAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readServerListAttribute(): ServerListAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serverlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Serverlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ServerListAttribute(decodedValue) } @@ -324,45 +267,48 @@ suspend fun readServerListAttribute(): ServerListAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ServerListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ServerListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Serverlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Serverlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ServerListAttributeSubscriptionState.Success(decodedValue)) } @@ -370,49 +316,43 @@ suspend fun readServerListAttribute(): ServerListAttribute {val ATTRIBUTE_ID: UI emit(ServerListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClientListAttribute(): ClientListAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClientListAttribute(): ClientListAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clientlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clientlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ClientListAttribute(decodedValue) } @@ -422,45 +362,48 @@ suspend fun readClientListAttribute(): ClientListAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ClientListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ClientListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clientlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Clientlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ClientListAttributeSubscriptionState.Success(decodedValue)) } @@ -468,49 +411,43 @@ suspend fun readClientListAttribute(): ClientListAttribute {val ATTRIBUTE_ID: UI emit(ClientListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPartsListAttribute(): PartsListAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPartsListAttribute(): PartsListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partslist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Partslist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return PartsListAttribute(decodedValue) } @@ -520,45 +457,48 @@ suspend fun readPartsListAttribute(): PartsListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PartsListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PartsListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partslist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Partslist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(PartsListAttributeSubscriptionState.Success(decodedValue)) } @@ -566,53 +506,47 @@ suspend fun readPartsListAttribute(): PartsListAttribute {val ATTRIBUTE_ID: UInt emit(PartsListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTagListAttribute(): TagListAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTagListAttribute(): TagListAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Taglist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Taglist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return TagListAttribute(decodedValue) } @@ -622,102 +556,96 @@ suspend fun readTagListAttribute(): TagListAttribute {val ATTRIBUTE_ID: UInt = 4 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TagListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TagListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Taglist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Taglist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(TagListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DescriptorClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(TagListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(TagListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -727,45 +655,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -773,49 +706,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -825,45 +752,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -871,49 +803,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -923,45 +849,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -969,49 +898,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1021,45 +944,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1067,44 +993,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1113,35 +1032,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1153,44 +1074,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1199,34 +1113,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1239,7 +1157,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt index 701eae9cc163a1..eb68ec47c75ee1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DeviceEnergyManagementCluster.kt @@ -17,131 +17,106 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.LongSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementCluster(private val controller: MatterController, private val endpointId: UShort) {class PowerAdjustmentCapabilityAttribute( +class DeviceEnergyManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class PowerAdjustmentCapabilityAttribute( val value: List? ) sealed class PowerAdjustmentCapabilityAttributeSubscriptionState { - data class Success( - val value: List? - ) : PowerAdjustmentCapabilityAttributeSubscriptionState() - - data class Error(val exception: Exception) : PowerAdjustmentCapabilityAttributeSubscriptionState() - - object SubscriptionEstablished : PowerAdjustmentCapabilityAttributeSubscriptionState() - } -class ForecastAttribute( - val value: DeviceEnergyManagementClusterForecastStruct? - ) + data class Success(val value: List?) : + PowerAdjustmentCapabilityAttributeSubscriptionState() + + data class Error(val exception: Exception) : + PowerAdjustmentCapabilityAttributeSubscriptionState() + + object SubscriptionEstablished : PowerAdjustmentCapabilityAttributeSubscriptionState() + } + + class ForecastAttribute(val value: DeviceEnergyManagementClusterForecastStruct?) sealed class ForecastAttributeSubscriptionState { - data class Success( - val value: DeviceEnergyManagementClusterForecastStruct? - ) : ForecastAttributeSubscriptionState() - + data class Success(val value: DeviceEnergyManagementClusterForecastStruct?) : + ForecastAttributeSubscriptionState() + data class Error(val exception: Exception) : ForecastAttributeSubscriptionState() - object SubscriptionEstablished : ForecastAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ForecastAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun powerAdjustRequest(power: Long - ,duration: UInt - ,cause: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun powerAdjustRequest( + power: Long, + duration: UInt, + cause: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -154,7 +129,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) val TAG_CAUSE_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -172,7 +147,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -186,9 +161,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startTimeAdjustRequest(requestedStartTime: UInt - ,cause: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun startTimeAdjustRequest( + requestedStartTime: UInt, + cause: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -198,7 +175,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_REQUESTED_START_TIME_REQ), requestedStartTime) val TAG_CAUSE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -212,9 +189,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun pauseRequest(duration: UInt - ,cause: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun pauseRequest(duration: UInt, cause: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -224,7 +199,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_DURATION_REQ), duration) val TAG_CAUSE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -242,7 +217,7 @@ class AttributeListAttribute( val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -256,10 +231,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun modifyForecastRequest(forecastId: UInt - ,slotAdjustments: List - ,cause: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun modifyForecastRequest( + forecastId: UInt, + slotAdjustments: List, + cause: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -270,13 +247,13 @@ class AttributeListAttribute( val TAG_SLOT_ADJUSTMENTS_REQ: Int = 1 tlvWriter.startArray(ContextSpecificTag(TAG_SLOT_ADJUSTMENTS_REQ)) - for (item in slotAdjustments.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in slotAdjustments.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_CAUSE_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -290,9 +267,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun requestConstraintBasedForecast(constraints: List - ,cause: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun requestConstraintBasedForecast( + constraints: List, + cause: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -300,13 +279,13 @@ class AttributeListAttribute( val TAG_CONSTRAINTS_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_CONSTRAINTS_REQ)) - for (item in constraints.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in constraints.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_CAUSE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) + tlvWriter.put(ContextSpecificTag(TAG_CAUSE_REQ), cause) tlvWriter.endStructure() val request: InvokeRequest = @@ -324,7 +303,7 @@ class AttributeListAttribute( val commandId: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -337,42 +316,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readESATypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readESATypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esatype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Esatype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -381,35 +353,37 @@ suspend fun readESATypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esatype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Esatype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -421,44 +395,37 @@ suspend fun readESATypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readESACanGenerateAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readESACanGenerateAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esacangenerate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Esacangenerate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -467,34 +434,38 @@ suspend fun readESACanGenerateAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esacangenerate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Esacangenerate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -507,44 +478,37 @@ suspend fun readESACanGenerateAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readESAStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readESAStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esastate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Esastate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -553,35 +517,37 @@ suspend fun readESAStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Esastate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Esastate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -593,44 +559,37 @@ suspend fun readESAStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMinPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAbsMinPowerAttribute(): Long { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absminpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absminpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } @@ -639,35 +598,37 @@ suspend fun readAbsMinPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absminpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Absminpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -679,44 +640,37 @@ suspend fun readAbsMinPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 3u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMaxPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAbsMaxPowerAttribute(): Long { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absmaxpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } @@ -725,35 +679,37 @@ suspend fun readAbsMaxPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Absmaxpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -765,58 +721,52 @@ suspend fun readAbsMaxPowerAttribute(): Long {val ATTRIBUTE_ID: UInt = 4u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerAdjustmentCapabilityAttribute(): PowerAdjustmentCapabilityAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPowerAdjustmentCapabilityAttribute(): PowerAdjustmentCapabilityAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Poweradjustmentcapability attribute not found in response" - } + } + + requireNotNull(attributeData) { "Poweradjustmentcapability attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return PowerAdjustmentCapabilityAttribute(decodedValue) } @@ -826,110 +776,113 @@ suspend fun readPowerAdjustmentCapabilityAttribute(): PowerAdjustmentCapabilityA maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PowerAdjustmentCapabilityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PowerAdjustmentCapabilityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Poweradjustmentcapability attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Poweradjustmentcapability attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + DeviceEnergyManagementClusterPowerAdjustStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(PowerAdjustmentCapabilityAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(PowerAdjustmentCapabilityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readForecastAttribute(): ForecastAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readForecastAttribute(): ForecastAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Forecast attribute not found in response" - } + } + + requireNotNull(attributeData) { "Forecast attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: DeviceEnergyManagementClusterForecastStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: DeviceEnergyManagementClusterForecastStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ForecastAttribute(decodedValue) } @@ -939,99 +892,93 @@ suspend fun readForecastAttribute(): ForecastAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ForecastAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ForecastAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Forecast attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Forecast attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: DeviceEnergyManagementClusterForecastStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ForecastAttributeSubscriptionState.Success(it)) - } - + val decodedValue: DeviceEnergyManagementClusterForecastStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + DeviceEnergyManagementClusterForecastStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ForecastAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ForecastAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOptOutStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOptOutStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Optoutstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Optoutstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1041,96 +988,90 @@ suspend fun readOptOutStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Optoutstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Optoutstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1140,45 +1081,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1186,49 +1132,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1238,45 +1178,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1284,49 +1229,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1336,45 +1275,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1382,49 +1324,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1434,45 +1370,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1480,44 +1419,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1526,35 +1458,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1566,44 +1500,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1612,34 +1539,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1652,7 +1583,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt index 3c04515cd4c86d..0838a9e113ed40 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DiagnosticLogsCluster.kt @@ -17,112 +17,85 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DiagnosticLogsCluster(private val controller: MatterController, private val endpointId: UShort) { +class DiagnosticLogsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class RetrieveLogsResponse( - val status: UByte, - val logContent: ByteArray, - val UTCTimeStamp: ULong?, + val status: UByte, + val logContent: ByteArray, + val UTCTimeStamp: ULong?, val timeSinceBoot: ULong? ) -class GeneratedCommandListAttribute( - val value: List - ) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun retrieveLogsRequest(intent: UByte - ,requestedProtocol: UByte - ,transferFileDesignator: String? - ,timedInvokeTimeout: Duration? = null): RetrieveLogsResponse { + suspend fun retrieveLogsRequest( + intent: UByte, + requestedProtocol: UByte, + transferFileDesignator: String?, + timedInvokeTimeout: Duration? = null + ): RetrieveLogsResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -137,7 +110,7 @@ class AttributeListAttribute( val TAG_TRANSFER_FILE_DESIGNATOR_REQ: Int = 2 transferFileDesignator?.let { tlvWriter.put(ContextSpecificTag(TAG_TRANSFER_FILE_DESIGNATOR_REQ), transferFileDesignator) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -154,70 +127,65 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_LOG_CONTENT: Int = 1 var logContent_decoded: ByteArray? = null - + val TAG_U_T_C_TIME_STAMP: Int = 2 var UTCTimeStamp_decoded: ULong? = null - + val TAG_TIME_SINCE_BOOT: Int = 3 var timeSinceBoot_decoded: ULong? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_LOG_CONTENT)) {logContent_decoded = tlvReader.getByteArray(tag)} - - if (tag == ContextSpecificTag(TAG_U_T_C_TIME_STAMP)) {UTCTimeStamp_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_LOG_CONTENT)) { + logContent_decoded = tlvReader.getByteArray(tag) + } + + if (tag == ContextSpecificTag(TAG_U_T_C_TIME_STAMP)) { + UTCTimeStamp_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getULong(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_TIME_SINCE_BOOT)) {timeSinceBoot_decoded = + tlvReader.getULong(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_TIME_SINCE_BOOT)) { + timeSinceBoot_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getULong(tag) - } else { - null - } - }} - - - else { + tlvReader.getULong(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (logContent_decoded == null) { - throw IllegalStateException("logContent not found in TLV") + throw IllegalStateException("logContent not found in TLV") } - - - - - tlvReader.exitContainer() @@ -228,47 +196,41 @@ class AttributeListAttribute( timeSinceBoot_decoded ) } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -278,45 +240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -324,49 +291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -376,45 +337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -422,49 +388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -474,45 +434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -520,49 +483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -572,45 +529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -618,44 +578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -664,35 +617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -704,44 +659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -750,34 +698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -790,7 +742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt index 75b1724e213003..b13261710a3be1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherAlarmCluster.kt @@ -17,110 +17,80 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherAlarmCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class DishwasherAlarmCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun reset(alarms: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun reset(alarms: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ALARMS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ALARMS_REQ), alarms) + tlvWriter.put(ContextSpecificTag(TAG_ALARMS_REQ), alarms) tlvWriter.endStructure() val request: InvokeRequest = @@ -134,15 +104,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun modifyEnabledAlarms(mask: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun modifyEnabledAlarms(mask: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_MASK_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_MASK_REQ), mask) + tlvWriter.put(ContextSpecificTag(TAG_MASK_REQ), mask) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,42 +124,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaskAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mask attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mask attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -199,35 +161,37 @@ suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mask attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Mask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -239,47 +203,41 @@ suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLatchAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLatchAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Latch attribute not found in response" - } + } + + requireNotNull(attributeData) { "Latch attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -289,91 +247,84 @@ suspend fun readLatchAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Latch attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Latch attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStateAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in response" - } + } + + requireNotNull(attributeData) { "State attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -382,35 +333,37 @@ suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "State attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -422,44 +375,37 @@ suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -468,35 +414,37 @@ suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supported attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Supported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -508,49 +456,43 @@ suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -560,45 +502,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -606,49 +553,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -658,45 +599,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -704,49 +650,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -756,45 +696,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -802,49 +745,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -854,45 +791,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -900,44 +840,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -946,35 +879,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -986,44 +921,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1032,34 +960,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1072,7 +1004,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt index b9223830ec6740..84be2a10cc560a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DishwasherModeCluster.kt @@ -17,154 +17,120 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) +class DishwasherModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -181,92 +147,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -276,45 +227,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -322,44 +278,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -368,35 +317,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -408,76 +359,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +440,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -507,128 +448,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -650,7 +581,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -658,101 +589,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -762,45 +687,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -808,49 +738,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -860,45 +784,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -906,49 +835,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -958,45 +881,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1004,49 +930,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1056,45 +976,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,44 +1025,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1148,35 +1064,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1188,44 +1106,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1234,34 +1145,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1274,7 +1189,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt index 3a8cd092c9d620..f0a27f30273c39 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/DoorLockCluster.kt @@ -17,257 +17,218 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class DoorLockCluster(private val controller: MatterController, private val endpointId: UShort) { class GetWeekDayScheduleResponse( - val weekDayIndex: UByte, - val userIndex: UShort, - val status: UByte, - val daysMask: UByte?, - val startHour: UByte?, - val startMinute: UByte?, - val endHour: UByte?, + val weekDayIndex: UByte, + val userIndex: UShort, + val status: UByte, + val daysMask: UByte?, + val startHour: UByte?, + val startMinute: UByte?, + val endHour: UByte?, val endMinute: UByte? ) class GetYearDayScheduleResponse( - val yearDayIndex: UByte, - val userIndex: UShort, - val status: UByte, - val localStartTime: UInt?, + val yearDayIndex: UByte, + val userIndex: UShort, + val status: UByte, + val localStartTime: UInt?, val localEndTime: UInt? ) class GetHolidayScheduleResponse( - val holidayIndex: UByte, - val status: UByte, - val localStartTime: UInt?, - val localEndTime: UInt?, + val holidayIndex: UByte, + val status: UByte, + val localStartTime: UInt?, + val localEndTime: UInt?, val operatingMode: UByte? ) class GetUserResponse( - val userIndex: UShort, - val userName: String?, - val userUniqueID: UInt?, - val userStatus: UByte?, - val userType: UByte?, - val credentialRule: UByte?, - val credentials: List?, - val creatorFabricIndex: UByte?, - val lastModifiedFabricIndex: UByte?, + val userIndex: UShort, + val userName: String?, + val userUniqueID: UInt?, + val userStatus: UByte?, + val userType: UByte?, + val credentialRule: UByte?, + val credentials: List?, + val creatorFabricIndex: UByte?, + val lastModifiedFabricIndex: UByte?, val nextUserIndex: UShort? ) class SetCredentialResponse( - val status: UByte, - val userIndex: UShort?, + val status: UByte, + val userIndex: UShort?, val nextCredentialIndex: UShort? ) class GetCredentialStatusResponse( - val credentialExists: Boolean, - val userIndex: UShort?, - val creatorFabricIndex: UByte?, - val lastModifiedFabricIndex: UByte?, + val credentialExists: Boolean, + val userIndex: UShort?, + val creatorFabricIndex: UByte?, + val lastModifiedFabricIndex: UByte?, val nextCredentialIndex: UShort? ) -class LockStateAttribute( - val value: UByte? - ) + + class LockStateAttribute(val value: UByte?) sealed class LockStateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : LockStateAttributeSubscriptionState() - + data class Success(val value: UByte?) : LockStateAttributeSubscriptionState() + data class Error(val exception: Exception) : LockStateAttributeSubscriptionState() - object SubscriptionEstablished : LockStateAttributeSubscriptionState() - } -class DoorStateAttribute( - val value: UByte? - ) + object SubscriptionEstablished : LockStateAttributeSubscriptionState() + } + + class DoorStateAttribute(val value: UByte?) sealed class DoorStateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : DoorStateAttributeSubscriptionState() - + data class Success(val value: UByte?) : DoorStateAttributeSubscriptionState() + data class Error(val exception: Exception) : DoorStateAttributeSubscriptionState() - object SubscriptionEstablished : DoorStateAttributeSubscriptionState() - } -class AliroReaderVerificationKeyAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : DoorStateAttributeSubscriptionState() + } + + class AliroReaderVerificationKeyAttribute(val value: ByteArray?) sealed class AliroReaderVerificationKeyAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : AliroReaderVerificationKeyAttributeSubscriptionState() - - data class Error(val exception: Exception) : AliroReaderVerificationKeyAttributeSubscriptionState() - - object SubscriptionEstablished : AliroReaderVerificationKeyAttributeSubscriptionState() - } -class AliroReaderGroupIdentifierAttribute( - val value: ByteArray? - ) + data class Success(val value: ByteArray?) : + AliroReaderVerificationKeyAttributeSubscriptionState() + + data class Error(val exception: Exception) : + AliroReaderVerificationKeyAttributeSubscriptionState() + + object SubscriptionEstablished : AliroReaderVerificationKeyAttributeSubscriptionState() + } + + class AliroReaderGroupIdentifierAttribute(val value: ByteArray?) sealed class AliroReaderGroupIdentifierAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : AliroReaderGroupIdentifierAttributeSubscriptionState() - - data class Error(val exception: Exception) : AliroReaderGroupIdentifierAttributeSubscriptionState() - - object SubscriptionEstablished : AliroReaderGroupIdentifierAttributeSubscriptionState() - } -class AliroExpeditedTransactionSupportedProtocolVersionsAttribute( - val value: List? - ) + data class Success(val value: ByteArray?) : + AliroReaderGroupIdentifierAttributeSubscriptionState() + + data class Error(val exception: Exception) : + AliroReaderGroupIdentifierAttributeSubscriptionState() + + object SubscriptionEstablished : AliroReaderGroupIdentifierAttributeSubscriptionState() + } + + class AliroExpeditedTransactionSupportedProtocolVersionsAttribute(val value: List?) sealed class AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState { - data class Success( - val value: List? - ) : AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() - - data class Error(val exception: Exception) : AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() - - object SubscriptionEstablished : AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() - } -class AliroGroupResolvingKeyAttribute( - val value: ByteArray? - ) + data class Success(val value: List?) : + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() + + object SubscriptionEstablished : + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState() + } + + class AliroGroupResolvingKeyAttribute(val value: ByteArray?) sealed class AliroGroupResolvingKeyAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : AliroGroupResolvingKeyAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : AliroGroupResolvingKeyAttributeSubscriptionState() + data class Error(val exception: Exception) : AliroGroupResolvingKeyAttributeSubscriptionState() - object SubscriptionEstablished : AliroGroupResolvingKeyAttributeSubscriptionState() - } -class AliroSupportedBLEUWBProtocolVersionsAttribute( - val value: List? - ) + object SubscriptionEstablished : AliroGroupResolvingKeyAttributeSubscriptionState() + } + + class AliroSupportedBLEUWBProtocolVersionsAttribute(val value: List?) sealed class AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState { - data class Success( - val value: List? - ) : AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() - - data class Error(val exception: Exception) : AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() - - object SubscriptionEstablished : AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List?) : + AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() + + object SubscriptionEstablished : + AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun lockDoor(PINCode: ByteArray? - ,timedInvokeTimeout: Duration) { + suspend fun lockDoor(PINCode: ByteArray?, timedInvokeTimeout: Duration) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { - tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) - } + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } tlvWriter.endStructure() val request: InvokeRequest = @@ -281,17 +242,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unlockDoor(PINCode: ByteArray? - ,timedInvokeTimeout: Duration) { + suspend fun unlockDoor(PINCode: ByteArray?, timedInvokeTimeout: Duration) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { - tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) - } + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } tlvWriter.endStructure() val request: InvokeRequest = @@ -305,9 +263,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unlockWithTimeout(timeout: UShort - ,PINCode: ByteArray? - ,timedInvokeTimeout: Duration) { + suspend fun unlockWithTimeout( + timeout: UShort, + PINCode: ByteArray?, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -317,9 +277,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_TIMEOUT_REQ), timeout) val TAG_P_I_N_CODE_REQ: Int = 1 - PINCode?.let { - tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) - } + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } tlvWriter.endStructure() val request: InvokeRequest = @@ -333,14 +291,16 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setWeekDaySchedule(weekDayIndex: UByte - ,userIndex: UShort - ,daysMask: UByte - ,startHour: UByte - ,startMinute: UByte - ,endHour: UByte - ,endMinute: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun setWeekDaySchedule( + weekDayIndex: UByte, + userIndex: UShort, + daysMask: UByte, + startHour: UByte, + startMinute: UByte, + endHour: UByte, + endMinute: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 11u val tlvWriter = TlvWriter() @@ -365,7 +325,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_END_HOUR_REQ), endHour) val TAG_END_MINUTE_REQ: Int = 6 - tlvWriter.put(ContextSpecificTag(TAG_END_MINUTE_REQ), endMinute) + tlvWriter.put(ContextSpecificTag(TAG_END_MINUTE_REQ), endMinute) tlvWriter.endStructure() val request: InvokeRequest = @@ -379,9 +339,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getWeekDaySchedule(weekDayIndex: UByte - ,userIndex: UShort - ,timedInvokeTimeout: Duration? = null): GetWeekDayScheduleResponse { + suspend fun getWeekDaySchedule( + weekDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeout: Duration? = null + ): GetWeekDayScheduleResponse { val commandId: UInt = 12u val tlvWriter = TlvWriter() @@ -391,7 +353,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_WEEK_DAY_INDEX_REQ), weekDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -408,131 +370,127 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_WEEK_DAY_INDEX: Int = 0 var weekDayIndex_decoded: UByte? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_STATUS: Int = 2 var status_decoded: UByte? = null - + val TAG_DAYS_MASK: Int = 3 var daysMask_decoded: UByte? = null - + val TAG_START_HOUR: Int = 4 var startHour_decoded: UByte? = null - + val TAG_START_MINUTE: Int = 5 var startMinute_decoded: UByte? = null - + val TAG_END_HOUR: Int = 6 var endHour_decoded: UByte? = null - + val TAG_END_MINUTE: Int = 7 var endMinute_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_WEEK_DAY_INDEX)) {weekDayIndex_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DAYS_MASK)) {daysMask_decoded = + if (tag == ContextSpecificTag(TAG_WEEK_DAY_INDEX)) { + weekDayIndex_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DAYS_MASK)) { + daysMask_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_START_HOUR)) {startHour_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_START_HOUR)) { + startHour_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_START_MINUTE)) {startMinute_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_START_MINUTE)) { + startMinute_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_END_HOUR)) {endHour_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_END_HOUR)) { + endHour_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_END_MINUTE)) {endMinute_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_END_MINUTE)) { + endMinute_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - - else { + tlvReader.getUByte(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (weekDayIndex_decoded == null) { - throw IllegalStateException("weekDayIndex not found in TLV") + throw IllegalStateException("weekDayIndex not found in TLV") } - - + if (userIndex_decoded == null) { - throw IllegalStateException("userIndex not found in TLV") + throw IllegalStateException("userIndex not found in TLV") } - - + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") - } - - - - - - - - - - - + throw IllegalStateException("status not found in TLV") + } tlvReader.exitContainer() @@ -548,9 +506,11 @@ class AttributeListAttribute( ) } - suspend fun clearWeekDaySchedule(weekDayIndex: UByte - ,userIndex: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun clearWeekDaySchedule( + weekDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 13u val tlvWriter = TlvWriter() @@ -560,7 +520,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_WEEK_DAY_INDEX_REQ), weekDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -574,11 +534,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setYearDaySchedule(yearDayIndex: UByte - ,userIndex: UShort - ,localStartTime: UInt - ,localEndTime: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun setYearDaySchedule( + yearDayIndex: UByte, + userIndex: UShort, + localStartTime: UInt, + localEndTime: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 14u val tlvWriter = TlvWriter() @@ -594,7 +556,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_LOCAL_START_TIME_REQ), localStartTime) val TAG_LOCAL_END_TIME_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_LOCAL_END_TIME_REQ), localEndTime) + tlvWriter.put(ContextSpecificTag(TAG_LOCAL_END_TIME_REQ), localEndTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -608,9 +570,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getYearDaySchedule(yearDayIndex: UByte - ,userIndex: UShort - ,timedInvokeTimeout: Duration? = null): GetYearDayScheduleResponse { + suspend fun getYearDaySchedule( + yearDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeout: Duration? = null + ): GetYearDayScheduleResponse { val commandId: UInt = 15u val tlvWriter = TlvWriter() @@ -620,7 +584,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_YEAR_DAY_INDEX_REQ), yearDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -637,80 +601,76 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_YEAR_DAY_INDEX: Int = 0 var yearDayIndex_decoded: UByte? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_STATUS: Int = 2 var status_decoded: UByte? = null - + val TAG_LOCAL_START_TIME: Int = 3 var localStartTime_decoded: UInt? = null - + val TAG_LOCAL_END_TIME: Int = 4 var localEndTime_decoded: UInt? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_YEAR_DAY_INDEX)) {yearDayIndex_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) {localStartTime_decoded = + if (tag == ContextSpecificTag(TAG_YEAR_DAY_INDEX)) { + yearDayIndex_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) { + localStartTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) {localEndTime_decoded = + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) { + localEndTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - - else { + tlvReader.getUInt(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (yearDayIndex_decoded == null) { - throw IllegalStateException("yearDayIndex not found in TLV") + throw IllegalStateException("yearDayIndex not found in TLV") } - - + if (userIndex_decoded == null) { - throw IllegalStateException("userIndex not found in TLV") + throw IllegalStateException("userIndex not found in TLV") } - - + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - - tlvReader.exitContainer() @@ -723,9 +683,11 @@ class AttributeListAttribute( ) } - suspend fun clearYearDaySchedule(yearDayIndex: UByte - ,userIndex: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun clearYearDaySchedule( + yearDayIndex: UByte, + userIndex: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 16u val tlvWriter = TlvWriter() @@ -735,7 +697,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_YEAR_DAY_INDEX_REQ), yearDayIndex) val TAG_USER_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -749,11 +711,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setHolidaySchedule(holidayIndex: UByte - ,localStartTime: UInt - ,localEndTime: UInt - ,operatingMode: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun setHolidaySchedule( + holidayIndex: UByte, + localStartTime: UInt, + localEndTime: UInt, + operatingMode: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 17u val tlvWriter = TlvWriter() @@ -769,7 +733,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_LOCAL_END_TIME_REQ), localEndTime) val TAG_OPERATING_MODE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPERATING_MODE_REQ), operatingMode) + tlvWriter.put(ContextSpecificTag(TAG_OPERATING_MODE_REQ), operatingMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -783,15 +747,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getHolidaySchedule(holidayIndex: UByte - ,timedInvokeTimeout: Duration? = null): GetHolidayScheduleResponse { + suspend fun getHolidaySchedule( + holidayIndex: UByte, + timedInvokeTimeout: Duration? = null + ): GetHolidayScheduleResponse { val commandId: UInt = 18u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_HOLIDAY_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) + tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -808,87 +774,82 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_HOLIDAY_INDEX: Int = 0 var holidayIndex_decoded: UByte? = null - + val TAG_STATUS: Int = 1 var status_decoded: UByte? = null - + val TAG_LOCAL_START_TIME: Int = 2 var localStartTime_decoded: UInt? = null - + val TAG_LOCAL_END_TIME: Int = 3 var localEndTime_decoded: UInt? = null - + val TAG_OPERATING_MODE: Int = 4 var operatingMode_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_HOLIDAY_INDEX)) {holidayIndex_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) {localStartTime_decoded = + if (tag == ContextSpecificTag(TAG_HOLIDAY_INDEX)) { + holidayIndex_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_LOCAL_START_TIME)) { + localStartTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) {localEndTime_decoded = + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LOCAL_END_TIME)) { + localEndTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_OPERATING_MODE)) {operatingMode_decoded = + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPERATING_MODE)) { + operatingMode_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - - else { + tlvReader.getUByte(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (holidayIndex_decoded == null) { - throw IllegalStateException("holidayIndex not found in TLV") + throw IllegalStateException("holidayIndex not found in TLV") } - - + if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - - - - tlvReader.exitContainer() @@ -901,15 +862,14 @@ class AttributeListAttribute( ) } - suspend fun clearHolidaySchedule(holidayIndex: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun clearHolidaySchedule(holidayIndex: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 19u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_HOLIDAY_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) + tlvWriter.put(ContextSpecificTag(TAG_HOLIDAY_INDEX_REQ), holidayIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -923,14 +883,16 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setUser(operationType: UByte - ,userIndex: UShort - ,userName: String? - ,userUniqueID: UInt? - ,userStatus: UByte? - ,userType: UByte? - ,credentialRule: UByte? - ,timedInvokeTimeout: Duration) { + suspend fun setUser( + operationType: UByte, + userIndex: UShort, + userName: String?, + userUniqueID: UInt?, + userStatus: UByte?, + userType: UByte?, + credentialRule: UByte?, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 26u val tlvWriter = TlvWriter() @@ -943,29 +905,21 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) val TAG_USER_NAME_REQ: Int = 2 - userName?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_NAME_REQ), userName) - } + userName?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_NAME_REQ), userName) } val TAG_USER_UNIQUE_I_D_REQ: Int = 3 - userUniqueID?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_UNIQUE_I_D_REQ), userUniqueID) - } + userUniqueID?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_UNIQUE_I_D_REQ), userUniqueID) } val TAG_USER_STATUS_REQ: Int = 4 - userStatus?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) - } + userStatus?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) } val TAG_USER_TYPE_REQ: Int = 5 - userType?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) - } + userType?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) } val TAG_CREDENTIAL_RULE_REQ: Int = 6 credentialRule?.let { tlvWriter.put(ContextSpecificTag(TAG_CREDENTIAL_RULE_REQ), credentialRule) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -979,15 +933,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getUser(userIndex: UShort - ,timedInvokeTimeout: Duration? = null): GetUserResponse { + suspend fun getUser(userIndex: UShort, timedInvokeTimeout: Duration? = null): GetUserResponse { val commandId: UInt = 27u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_USER_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -1004,194 +957,188 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_USER_INDEX: Int = 0 var userIndex_decoded: UShort? = null - + val TAG_USER_NAME: Int = 1 var userName_decoded: String? = null - + val TAG_USER_UNIQUE_I_D: Int = 2 var userUniqueID_decoded: UInt? = null - + val TAG_USER_STATUS: Int = 3 var userStatus_decoded: UByte? = null - + val TAG_USER_TYPE: Int = 4 var userType_decoded: UByte? = null - + val TAG_CREDENTIAL_RULE: Int = 5 var credentialRule_decoded: UByte? = null - + val TAG_CREDENTIALS: Int = 6 var credentials_decoded: List? = null - + val TAG_CREATOR_FABRIC_INDEX: Int = 7 var creatorFabricIndex_decoded: UByte? = null - + val TAG_LAST_MODIFIED_FABRIC_INDEX: Int = 8 var lastModifiedFabricIndex_decoded: UByte? = null - + val TAG_NEXT_USER_INDEX: Int = 9 var nextUserIndex_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_USER_NAME)) {userName_decoded = + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_NAME)) { + userName_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getString(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_USER_UNIQUE_I_D)) {userUniqueID_decoded = + tlvReader.getString(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_UNIQUE_I_D)) { + userUniqueID_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUInt(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_USER_STATUS)) {userStatus_decoded = + tlvReader.getUInt(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_STATUS)) { + userStatus_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_USER_TYPE)) {userType_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_TYPE)) { + userType_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_CREDENTIAL_RULE)) {credentialRule_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREDENTIAL_RULE)) { + credentialRule_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_CREDENTIALS)) {credentials_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREDENTIALS)) { + credentials_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) {creatorFabricIndex_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) { + creatorFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) {lastModifiedFabricIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) { + lastModifiedFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_NEXT_USER_INDEX)) {nextUserIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NEXT_USER_INDEX)) { + nextUserIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (userIndex_decoded == null) { - throw IllegalStateException("userIndex not found in TLV") - } - - - - - - - - - - - - - - - - - - - + throw IllegalStateException("userIndex not found in TLV") + } tlvReader.exitContainer() @@ -1209,15 +1156,14 @@ class AttributeListAttribute( ) } - suspend fun clearUser(userIndex: UShort - ,timedInvokeTimeout: Duration) { + suspend fun clearUser(userIndex: UShort, timedInvokeTimeout: Duration) { val commandId: UInt = 29u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_USER_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) + tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -1231,13 +1177,15 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setCredential(operationType: UByte - ,credential: DoorLockClusterCredentialStruct - ,credentialData: ByteArray - ,userIndex: UShort? - ,userStatus: UByte? - ,userType: UByte? - ,timedInvokeTimeout: Duration): SetCredentialResponse { + suspend fun setCredential( + operationType: UByte, + credential: DoorLockClusterCredentialStruct, + credentialData: ByteArray, + userIndex: UShort?, + userStatus: UByte?, + userType: UByte?, + timedInvokeTimeout: Duration + ): SetCredentialResponse { val commandId: UInt = 34u val tlvWriter = TlvWriter() @@ -1253,19 +1201,13 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_CREDENTIAL_DATA_REQ), credentialData) val TAG_USER_INDEX_REQ: Int = 3 - userIndex?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) - } + userIndex?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_INDEX_REQ), userIndex) } val TAG_USER_STATUS_REQ: Int = 4 - userStatus?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) - } + userStatus?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_STATUS_REQ), userStatus) } val TAG_USER_TYPE_REQ: Int = 5 - userType?.let { - tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) - } + userType?.let { tlvWriter.put(ContextSpecificTag(TAG_USER_TYPE_REQ), userType) } tlvWriter.endStructure() val request: InvokeRequest = @@ -1282,81 +1224,73 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_NEXT_CREDENTIAL_INDEX: Int = 2 var nextCredentialIndex_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) {nextCredentialIndex_decoded = + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) { + nextCredentialIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - - tlvReader.exitContainer() - return SetCredentialResponse( - status_decoded, - userIndex_decoded, - nextCredentialIndex_decoded - ) + return SetCredentialResponse(status_decoded, userIndex_decoded, nextCredentialIndex_decoded) } - suspend fun getCredentialStatus(credential: DoorLockClusterCredentialStruct - ,timedInvokeTimeout: Duration? = null): GetCredentialStatusResponse { + suspend fun getCredentialStatus( + credential: DoorLockClusterCredentialStruct, + timedInvokeTimeout: Duration? = null + ): GetCredentialStatusResponse { val commandId: UInt = 36u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_CREDENTIAL_REQ: Int = 0 - credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) + credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -1373,98 +1307,92 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_CREDENTIAL_EXISTS: Int = 0 var credentialExists_decoded: Boolean? = null - + val TAG_USER_INDEX: Int = 1 var userIndex_decoded: UShort? = null - + val TAG_CREATOR_FABRIC_INDEX: Int = 2 var creatorFabricIndex_decoded: UByte? = null - + val TAG_LAST_MODIFIED_FABRIC_INDEX: Int = 3 var lastModifiedFabricIndex_decoded: UByte? = null - + val TAG_NEXT_CREDENTIAL_INDEX: Int = 4 var nextCredentialIndex_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_CREDENTIAL_EXISTS)) {credentialExists_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_USER_INDEX)) {userIndex_decoded = + if (tag == ContextSpecificTag(TAG_CREDENTIAL_EXISTS)) { + credentialExists_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_USER_INDEX)) { + userIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) {creatorFabricIndex_decoded = + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CREATOR_FABRIC_INDEX)) { + creatorFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) {lastModifiedFabricIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_LAST_MODIFIED_FABRIC_INDEX)) { + lastModifiedFabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) {nextCredentialIndex_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NEXT_CREDENTIAL_INDEX)) { + nextCredentialIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUShort(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + tlvReader.getUShort(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (credentialExists_decoded == null) { - throw IllegalStateException("credentialExists not found in TLV") - } - - - - - - - - - + throw IllegalStateException("credentialExists not found in TLV") + } tlvReader.exitContainer() @@ -1477,17 +1405,17 @@ class AttributeListAttribute( ) } - suspend fun clearCredential(credential: DoorLockClusterCredentialStruct? - ,timedInvokeTimeout: Duration) { + suspend fun clearCredential( + credential: DoorLockClusterCredentialStruct?, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 38u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_CREDENTIAL_REQ: Int = 0 - credential?.let { - credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) - } + credential?.let { credential.toTlv(ContextSpecificTag(TAG_CREDENTIAL_REQ), tlvWriter) } tlvWriter.endStructure() val request: InvokeRequest = @@ -1501,17 +1429,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun unboltDoor(PINCode: ByteArray? - ,timedInvokeTimeout: Duration) { + suspend fun unboltDoor(PINCode: ByteArray?, timedInvokeTimeout: Duration) { val commandId: UInt = 39u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_P_I_N_CODE_REQ: Int = 0 - PINCode?.let { - tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) - } + PINCode?.let { tlvWriter.put(ContextSpecificTag(TAG_P_I_N_CODE_REQ), PINCode) } tlvWriter.endStructure() val request: InvokeRequest = @@ -1525,11 +1450,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setAliroReaderConfig(signingKey: ByteArray - ,verificationKey: ByteArray - ,groupIdentifier: ByteArray - ,groupResolvingKey: ByteArray? - ,timedInvokeTimeout: Duration) { + suspend fun setAliroReaderConfig( + signingKey: ByteArray, + verificationKey: ByteArray, + groupIdentifier: ByteArray, + groupResolvingKey: ByteArray?, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 40u val tlvWriter = TlvWriter() @@ -1547,7 +1474,7 @@ class AttributeListAttribute( val TAG_GROUP_RESOLVING_KEY_REQ: Int = 3 groupResolvingKey?.let { tlvWriter.put(ContextSpecificTag(TAG_GROUP_RESOLVING_KEY_REQ), groupResolvingKey) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1565,7 +1492,7 @@ class AttributeListAttribute( val commandId: UInt = 41u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -1578,46 +1505,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readLockStateAttribute(): LockStateAttribute {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLockStateAttribute(): LockStateAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lockstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lockstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LockStateAttribute(decodedValue) } @@ -1627,92 +1548,85 @@ suspend fun readLockStateAttribute(): LockStateAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LockStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LockStateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lockstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lockstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LockStateAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LockStateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LockStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLockTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLockTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Locktype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Locktype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1721,35 +1635,37 @@ suspend fun readLockTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Locktype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Locktype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1761,44 +1677,37 @@ suspend fun readLockTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActuatorEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActuatorEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 2u - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - - val response = controller.read(readRequest) + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actuatorenabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Actuatorenabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -1807,34 +1716,38 @@ suspend fun readActuatorEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actuatorenabled attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Actuatorenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1847,52 +1760,46 @@ suspend fun readActuatorEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 2u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDoorStateAttribute(): DoorStateAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDoorStateAttribute(): DoorStateAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Doorstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Doorstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DoorStateAttribute(decodedValue) } @@ -1902,123 +1809,113 @@ suspend fun readDoorStateAttribute(): DoorStateAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DoorStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DoorStateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Doorstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Doorstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DoorStateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DoorStateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DoorStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDoorOpenEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDoorOpenEventsAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dooropenevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dooropenevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeDoorOpenEventsAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeDoorOpenEventsAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2040,7 +1937,7 @@ suspend fun readDoorOpenEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDoorOpenEventsAttribute( @@ -2048,118 +1945,110 @@ suspend fun readDoorOpenEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dooropenevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dooropenevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDoorClosedEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDoorClosedEventsAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Doorclosedevents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Doorclosedevents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeDoorClosedEventsAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeDoorClosedEventsAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2181,7 +2070,7 @@ suspend fun readDoorClosedEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDoorClosedEventsAttribute( @@ -2189,118 +2078,110 @@ suspend fun readDoorClosedEventsAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Doorclosedevents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Doorclosedevents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOpenPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Openperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Openperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeOpenPeriodAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeOpenPeriodAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2322,7 +2203,7 @@ suspend fun readOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOpenPeriodAttribute( @@ -2330,94 +2211,88 @@ suspend fun readOpenPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Openperiod attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Openperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfTotalUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfTotalUsersSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberoftotaluserssupported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberoftotaluserssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2427,94 +2302,90 @@ suspend fun readNumberOfTotalUsersSupportedAttribute(): UShort? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberoftotaluserssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberoftotaluserssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfPINUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfPINUsersSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpinuserssupported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofpinuserssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2524,94 +2395,90 @@ suspend fun readNumberOfPINUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpinuserssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofpinuserssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfRFIDUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfRFIDUsersSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofrfiduserssupported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofrfiduserssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2621,94 +2488,92 @@ suspend fun readNumberOfRFIDUsersSupportedAttribute(): UShort? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofrfiduserssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofrfiduserssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfWeekDaySchedulesSupportedPerUserAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfWeekDaySchedulesSupportedPerUserAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofweekdayschedulessupportedperuser attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofweekdayschedulessupportedperuser attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -2718,94 +2583,92 @@ suspend fun readNumberOfWeekDaySchedulesSupportedPerUserAttribute(): UByte? {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofweekdayschedulessupportedperuser attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofweekdayschedulessupportedperuser attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfYearDaySchedulesSupportedPerUserAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfYearDaySchedulesSupportedPerUserAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofyeardayschedulessupportedperuser attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofyeardayschedulessupportedperuser attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -2815,94 +2678,92 @@ suspend fun readNumberOfYearDaySchedulesSupportedPerUserAttribute(): UByte? {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofyeardayschedulessupportedperuser attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofyeardayschedulessupportedperuser attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfHolidaySchedulesSupportedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfHolidaySchedulesSupportedAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofholidayschedulessupported attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofholidayschedulessupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -2912,94 +2773,90 @@ suspend fun readNumberOfHolidaySchedulesSupportedAttribute(): UByte? {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofholidayschedulessupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofholidayschedulessupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxPINCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxPINCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpincodelength attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxpincodelength attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3009,94 +2866,90 @@ suspend fun readMaxPINCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 23 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpincodelength attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxpincodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinPINCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 24u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinPINCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minpincodelength attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minpincodelength attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3106,94 +2959,90 @@ suspend fun readMinPINCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 24 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minpincodelength attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minpincodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxRFIDCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxRFIDCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxrfidcodelength attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxrfidcodelength attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3203,94 +3052,90 @@ suspend fun readMaxRFIDCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxrfidcodelength attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxrfidcodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinRFIDCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinRFIDCodeLengthAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minrfidcodelength attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minrfidcodelength attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3300,94 +3145,90 @@ suspend fun readMinRFIDCodeLengthAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minrfidcodelength attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minrfidcodelength attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCredentialRulesSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCredentialRulesSupportAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Credentialrulessupport attribute not found in response" - } + } + + requireNotNull(attributeData) { "Credentialrulessupport attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3397,94 +3238,92 @@ suspend fun readCredentialRulesSupportAttribute(): UByte? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Credentialrulessupport attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Credentialrulessupport attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfCredentialsSupportedPerUserAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 28u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfCredentialsSupportedPerUserAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofcredentialssupportedperuser attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofcredentialssupportedperuser attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3494,118 +3333,110 @@ suspend fun readNumberOfCredentialsSupportedPerUserAttribute(): UByte? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofcredentialssupportedperuser attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofcredentialssupportedperuser attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLanguageAttribute(): String? {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLanguageAttribute(): String? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Language attribute not found in response" - } + } + + requireNotNull(attributeData) { "Language attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeLanguageAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeLanguageAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3627,7 +3458,7 @@ suspend fun readLanguageAttribute(): String? {val ATTRIBUTE_ID: UInt = 33u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLanguageAttribute( @@ -3635,118 +3466,108 @@ suspend fun readLanguageAttribute(): String? {val ATTRIBUTE_ID: UInt = 33u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Language attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Language attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLEDSettingsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLEDSettingsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ledsettings attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ledsettings attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeLEDSettingsAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeLEDSettingsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 34u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3768,7 +3589,7 @@ suspend fun readLEDSettingsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLEDSettingsAttribute( @@ -3776,114 +3597,103 @@ suspend fun readLEDSettingsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ledsettings attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Ledsettings attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAutoRelockTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 35u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAutoRelockTimeAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Autorelocktime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Autorelocktime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } - suspend fun writeAutoRelockTimeAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeAutoRelockTimeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 35u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3905,7 +3715,7 @@ suspend fun readAutoRelockTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 35u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAutoRelockTimeAttribute( @@ -3913,34 +3723,38 @@ suspend fun readAutoRelockTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 35u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Autorelocktime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Autorelocktime attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3953,71 +3767,61 @@ suspend fun readAutoRelockTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 35u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSoundVolumeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSoundVolumeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Soundvolume attribute not found in response" - } + } + + requireNotNull(attributeData) { "Soundvolume attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeSoundVolumeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeSoundVolumeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 36u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4039,7 +3843,7 @@ suspend fun readSoundVolumeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 36u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSoundVolumeAttribute( @@ -4047,114 +3851,103 @@ suspend fun readSoundVolumeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 36u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Soundvolume attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Soundvolume attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperatingModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOperatingModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operatingmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operatingmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeOperatingModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOperatingModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 37u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4176,7 +3969,7 @@ suspend fun readOperatingModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 37u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOperatingModeAttribute( @@ -4184,35 +3977,37 @@ suspend fun readOperatingModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 37u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operatingmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Operatingmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4224,44 +4019,37 @@ suspend fun readOperatingModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 37u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedOperatingModesAttribute(): UShort {val ATTRIBUTE_ID: UInt = 38u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSupportedOperatingModesAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedoperatingmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedoperatingmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -4270,34 +4058,38 @@ suspend fun readSupportedOperatingModesAttribute(): UShort {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedoperatingmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedoperatingmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -4310,47 +4102,41 @@ suspend fun readSupportedOperatingModesAttribute(): UShort {val ATTRIBUTE_ID: UI emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultConfigurationRegisterAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 39u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDefaultConfigurationRegisterAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultconfigurationregister attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultconfigurationregister attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4360,118 +4146,113 @@ suspend fun readDefaultConfigurationRegisterAttribute(): UShort? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultconfigurationregister attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultconfigurationregister attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnableLocalProgrammingAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 40u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnableLocalProgrammingAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enablelocalprogramming attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enablelocalprogramming attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeEnableLocalProgrammingAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 40u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4493,7 +4274,7 @@ suspend fun readEnableLocalProgrammingAttribute(): Boolean? {val ATTRIBUTE_ID: U throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnableLocalProgrammingAttribute( @@ -4501,118 +4282,113 @@ suspend fun readEnableLocalProgrammingAttribute(): Boolean? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enablelocalprogramming attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enablelocalprogramming attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnableOneTouchLockingAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 41u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnableOneTouchLockingAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableonetouchlocking attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enableonetouchlocking attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeEnableOneTouchLockingAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 41u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4634,7 +4410,7 @@ suspend fun readEnableOneTouchLockingAttribute(): Boolean? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnableOneTouchLockingAttribute( @@ -4642,118 +4418,113 @@ suspend fun readEnableOneTouchLockingAttribute(): Boolean? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableonetouchlocking attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enableonetouchlocking attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnableInsideStatusLEDAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 42u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnableInsideStatusLEDAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableinsidestatusled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enableinsidestatusled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeEnableInsideStatusLEDAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 42u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4775,7 +4546,7 @@ suspend fun readEnableInsideStatusLEDAttribute(): Boolean? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnableInsideStatusLEDAttribute( @@ -4783,118 +4554,113 @@ suspend fun readEnableInsideStatusLEDAttribute(): Boolean? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableinsidestatusled attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enableinsidestatusled attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnablePrivacyModeButtonAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 43u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnablePrivacyModeButtonAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 43u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableprivacymodebutton attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enableprivacymodebutton attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeEnablePrivacyModeButtonAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 43u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4916,7 +4682,7 @@ suspend fun readEnablePrivacyModeButtonAttribute(): Boolean? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnablePrivacyModeButtonAttribute( @@ -4924,118 +4690,113 @@ suspend fun readEnablePrivacyModeButtonAttribute(): Boolean? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 43u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enableprivacymodebutton attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Enableprivacymodebutton attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocalProgrammingFeaturesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 44u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLocalProgrammingFeaturesAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 44u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localprogrammingfeatures attribute not found in response" - } + } + + requireNotNull(attributeData) { "Localprogrammingfeatures attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeLocalProgrammingFeaturesAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 44u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5057,7 +4818,7 @@ suspend fun readLocalProgrammingFeaturesAttribute(): UByte? {val ATTRIBUTE_ID: U throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocalProgrammingFeaturesAttribute( @@ -5065,118 +4826,110 @@ suspend fun readLocalProgrammingFeaturesAttribute(): UByte? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 44u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localprogrammingfeatures attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Localprogrammingfeatures attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWrongCodeEntryLimitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWrongCodeEntryLimitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wrongcodeentrylimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wrongcodeentrylimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeWrongCodeEntryLimitAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeWrongCodeEntryLimitAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5198,7 +4951,7 @@ suspend fun readWrongCodeEntryLimitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWrongCodeEntryLimitAttribute( @@ -5206,118 +4959,113 @@ suspend fun readWrongCodeEntryLimitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wrongcodeentrylimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wrongcodeentrylimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Usercodetemporarydisabletime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Usercodetemporarydisabletime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUserCodeTemporaryDisableTimeAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5339,7 +5087,7 @@ suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte? {val ATTRIBUTE_I throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUserCodeTemporaryDisableTimeAttribute( @@ -5347,118 +5095,110 @@ suspend fun readUserCodeTemporaryDisableTimeAttribute(): UByte? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Usercodetemporarydisabletime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Usercodetemporarydisabletime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSendPINOverTheAirAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSendPINOverTheAirAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sendpinovertheair attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sendpinovertheair attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeSendPINOverTheAirAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeSendPINOverTheAirAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5480,7 +5220,7 @@ suspend fun readSendPINOverTheAirAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSendPINOverTheAirAttribute( @@ -5488,118 +5228,113 @@ suspend fun readSendPINOverTheAirAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sendpinovertheair attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Sendpinovertheair attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRequirePINforRemoteOperationAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 51u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRequirePINforRemoteOperationAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Requirepinforremoteoperation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Requirepinforremoteoperation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRequirePINforRemoteOperationAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 51u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5621,7 +5356,7 @@ suspend fun readRequirePINforRemoteOperationAttribute(): Boolean? {val ATTRIBUTE throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRequirePINforRemoteOperationAttribute( @@ -5629,118 +5364,113 @@ suspend fun readRequirePINforRemoteOperationAttribute(): Boolean? {val ATTRIBUTE maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Requirepinforremoteoperation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Requirepinforremoteoperation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readExpiringUserTimeoutAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 53u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readExpiringUserTimeoutAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expiringusertimeout attribute not found in response" - } + } + + requireNotNull(attributeData) { "Expiringusertimeout attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeExpiringUserTimeoutAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 53u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5762,7 +5492,7 @@ suspend fun readExpiringUserTimeoutAttribute(): UShort? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeExpiringUserTimeoutAttribute( @@ -5770,99 +5500,95 @@ suspend fun readExpiringUserTimeoutAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expiringusertimeout attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Expiringusertimeout attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAliroReaderVerificationKeyAttribute(): AliroReaderVerificationKeyAttribute {val ATTRIBUTE_ID: UInt = 128u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroReaderVerificationKeyAttribute(): AliroReaderVerificationKeyAttribute { + val ATTRIBUTE_ID: UInt = 128u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreaderverificationkey attribute not found in response" - } + } + + requireNotNull(attributeData) { "Aliroreaderverificationkey attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AliroReaderVerificationKeyAttribute(decodedValue) } @@ -5872,104 +5598,102 @@ suspend fun readAliroReaderVerificationKeyAttribute(): AliroReaderVerificationKe maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 128u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AliroReaderVerificationKeyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AliroReaderVerificationKeyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreaderverificationkey attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Aliroreaderverificationkey attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(AliroReaderVerificationKeyAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(AliroReaderVerificationKeyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAliroReaderGroupIdentifierAttribute(): AliroReaderGroupIdentifierAttribute {val ATTRIBUTE_ID: UInt = 129u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroReaderGroupIdentifierAttribute(): AliroReaderGroupIdentifierAttribute { + val ATTRIBUTE_ID: UInt = 129u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreadergroupidentifier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Aliroreadergroupidentifier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AliroReaderGroupIdentifierAttribute(decodedValue) } @@ -5979,99 +5703,99 @@ suspend fun readAliroReaderGroupIdentifierAttribute(): AliroReaderGroupIdentifie maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 129u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AliroReaderGroupIdentifierAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AliroReaderGroupIdentifierAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreadergroupidentifier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Aliroreadergroupidentifier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(AliroReaderGroupIdentifierAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(AliroReaderGroupIdentifierAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAliroReaderGroupSubIdentifierAttribute(): ByteArray? {val ATTRIBUTE_ID: UInt = 130u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroReaderGroupSubIdentifierAttribute(): ByteArray? { + val ATTRIBUTE_ID: UInt = 130u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreadergroupsubidentifier attribute not found in response" + } + + requireNotNull(attributeData) { + "Aliroreadergroupsubidentifier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - + val decodedValue: ByteArray? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } return decodedValue } @@ -6081,100 +5805,99 @@ suspend fun readAliroReaderGroupSubIdentifierAttribute(): ByteArray? {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 130u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteArraySubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroreadergroupsubidentifier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Aliroreadergroupsubidentifier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } + val decodedValue: ByteArray? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteArraySubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteArraySubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAliroExpeditedTransactionSupportedProtocolVersionsAttribute(): AliroExpeditedTransactionSupportedProtocolVersionsAttribute {val ATTRIBUTE_ID: UInt = 131u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroExpeditedTransactionSupportedProtocolVersionsAttribute(): + AliroExpeditedTransactionSupportedProtocolVersionsAttribute { + val ATTRIBUTE_ID: UInt = 131u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in response" + } + + requireNotNull(attributeData) { + "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return AliroExpeditedTransactionSupportedProtocolVersionsAttribute(decodedValue) } @@ -6184,105 +5907,110 @@ suspend fun readAliroExpeditedTransactionSupportedProtocolVersionsAttribute(): A maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 131u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Aliroexpeditedtransactionsupportedprotocolversions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { - emit(AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Success(it)) + emit( + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.Success( + it + ) + ) } - } SubscriptionState.SubscriptionEstablished -> { - emit(AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState.SubscriptionEstablished) + emit( + AliroExpeditedTransactionSupportedProtocolVersionsAttributeSubscriptionState + .SubscriptionEstablished + ) } } - } + } } -suspend fun readAliroGroupResolvingKeyAttribute(): AliroGroupResolvingKeyAttribute {val ATTRIBUTE_ID: UInt = 132u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroGroupResolvingKeyAttribute(): AliroGroupResolvingKeyAttribute { + val ATTRIBUTE_ID: UInt = 132u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirogroupresolvingkey attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alirogroupresolvingkey attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AliroGroupResolvingKeyAttribute(decodedValue) } @@ -6292,105 +6020,104 @@ suspend fun readAliroGroupResolvingKeyAttribute(): AliroGroupResolvingKeyAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 132u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AliroGroupResolvingKeyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AliroGroupResolvingKeyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirogroupresolvingkey attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Alirogroupresolvingkey attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AliroGroupResolvingKeyAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AliroGroupResolvingKeyAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AliroGroupResolvingKeyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAliroSupportedBLEUWBProtocolVersionsAttribute(): AliroSupportedBLEUWBProtocolVersionsAttribute {val ATTRIBUTE_ID: UInt = 133u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroSupportedBLEUWBProtocolVersionsAttribute(): + AliroSupportedBLEUWBProtocolVersionsAttribute { + val ATTRIBUTE_ID: UInt = 133u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirosupportedbleuwbprotocolversions attribute not found in response" + } + + requireNotNull(attributeData) { + "Alirosupportedbleuwbprotocolversions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return AliroSupportedBLEUWBProtocolVersionsAttribute(decodedValue) } @@ -6400,100 +6127,100 @@ suspend fun readAliroSupportedBLEUWBProtocolVersionsAttribute(): AliroSupportedB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 133u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirosupportedbleuwbprotocolversions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Alirosupportedbleuwbprotocolversions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { emit(AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { - emit(AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.SubscriptionEstablished) + emit( + AliroSupportedBLEUWBProtocolVersionsAttributeSubscriptionState.SubscriptionEstablished + ) } } - } + } } -suspend fun readAliroBLEAdvertisingVersionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 134u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAliroBLEAdvertisingVersionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 134u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirobleadvertisingversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Alirobleadvertisingversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -6503,94 +6230,92 @@ suspend fun readAliroBLEAdvertisingVersionAttribute(): UByte? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 134u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Alirobleadvertisingversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Alirobleadvertisingversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfAliroCredentialIssuerKeysSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 135u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfAliroCredentialIssuerKeysSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 135u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofalirocredentialissuerkeyssupported attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofalirocredentialissuerkeyssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6600,94 +6325,92 @@ suspend fun readNumberOfAliroCredentialIssuerKeysSupportedAttribute(): UShort? { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 135u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofalirocredentialissuerkeyssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofalirocredentialissuerkeyssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfAliroEndpointKeysSupportedAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 136u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfAliroEndpointKeysSupportedAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 136u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofaliroendpointkeyssupported attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofaliroendpointkeyssupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6697,96 +6420,92 @@ suspend fun readNumberOfAliroEndpointKeysSupportedAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 136u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofaliroendpointkeyssupported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofaliroendpointkeyssupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -6796,45 +6515,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6842,49 +6566,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -6894,45 +6612,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6940,49 +6663,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -6992,45 +6709,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -7038,49 +6758,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -7090,45 +6804,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -7136,44 +6853,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -7182,35 +6892,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7222,44 +6934,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -7268,34 +6973,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7308,7 +7017,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt index ef3d5e33dd62a4..8be25c67fbcda4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalEnergyMeasurementCluster.kt @@ -17,200 +17,160 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class ElectricalEnergyMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class AccuracyAttribute( - val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct - ) +class ElectricalEnergyMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AccuracyAttribute(val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct) sealed class AccuracyAttributeSubscriptionState { - data class Success( - val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct - ) : AccuracyAttributeSubscriptionState() - + data class Success(val value: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct) : + AccuracyAttributeSubscriptionState() + data class Error(val exception: Exception) : AccuracyAttributeSubscriptionState() - object SubscriptionEstablished : AccuracyAttributeSubscriptionState() - } -class CumulativeEnergyImportedAttribute( + object SubscriptionEstablished : AccuracyAttributeSubscriptionState() + } + + class CumulativeEnergyImportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class CumulativeEnergyImportedAttributeSubscriptionState { - data class Success( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) : CumulativeEnergyImportedAttributeSubscriptionState() - - data class Error(val exception: Exception) : CumulativeEnergyImportedAttributeSubscriptionState() + data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : + CumulativeEnergyImportedAttributeSubscriptionState() + + data class Error(val exception: Exception) : + CumulativeEnergyImportedAttributeSubscriptionState() + + object SubscriptionEstablished : CumulativeEnergyImportedAttributeSubscriptionState() + } - object SubscriptionEstablished : CumulativeEnergyImportedAttributeSubscriptionState() - } -class CumulativeEnergyExportedAttribute( + class CumulativeEnergyExportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class CumulativeEnergyExportedAttributeSubscriptionState { - data class Success( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) : CumulativeEnergyExportedAttributeSubscriptionState() - - data class Error(val exception: Exception) : CumulativeEnergyExportedAttributeSubscriptionState() + data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : + CumulativeEnergyExportedAttributeSubscriptionState() + + data class Error(val exception: Exception) : + CumulativeEnergyExportedAttributeSubscriptionState() + + object SubscriptionEstablished : CumulativeEnergyExportedAttributeSubscriptionState() + } - object SubscriptionEstablished : CumulativeEnergyExportedAttributeSubscriptionState() - } -class PeriodicEnergyImportedAttribute( + class PeriodicEnergyImportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class PeriodicEnergyImportedAttributeSubscriptionState { - data class Success( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) : PeriodicEnergyImportedAttributeSubscriptionState() - + data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : + PeriodicEnergyImportedAttributeSubscriptionState() + data class Error(val exception: Exception) : PeriodicEnergyImportedAttributeSubscriptionState() - object SubscriptionEstablished : PeriodicEnergyImportedAttributeSubscriptionState() - } -class PeriodicEnergyExportedAttribute( + object SubscriptionEstablished : PeriodicEnergyImportedAttributeSubscriptionState() + } + + class PeriodicEnergyExportedAttribute( val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? ) sealed class PeriodicEnergyExportedAttributeSubscriptionState { - data class Success( - val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? - ) : PeriodicEnergyExportedAttributeSubscriptionState() - + data class Success(val value: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct?) : + PeriodicEnergyExportedAttributeSubscriptionState() + data class Error(val exception: Exception) : PeriodicEnergyExportedAttributeSubscriptionState() - object SubscriptionEstablished : PeriodicEnergyExportedAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : PeriodicEnergyExportedAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readAccuracyAttribute(): AccuracyAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readAccuracyAttribute(): AccuracyAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accuracy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accuracy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = + ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader) return AccuracyAttribute(decodedValue) } @@ -220,39 +180,45 @@ suspend fun readAccuracyAttribute(): AccuracyAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AccuracyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AccuracyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accuracy attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Accuracy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct = + ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.fromTlv( + AnonymousTag, + tlvReader + ) emit(AccuracyAttributeSubscriptionState.Success(decodedValue)) } @@ -260,52 +226,46 @@ suspend fun readAccuracyAttribute(): AccuracyAttribute {val ATTRIBUTE_ID: UInt = emit(AccuracyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCumulativeEnergyImportedAttribute(): CumulativeEnergyImportedAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCumulativeEnergyImportedAttribute(): CumulativeEnergyImportedAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cumulativeenergyimported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Cumulativeenergyimported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CumulativeEnergyImportedAttribute(decodedValue) } @@ -315,104 +275,103 @@ suspend fun readCumulativeEnergyImportedAttribute(): CumulativeEnergyImportedAtt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CumulativeEnergyImportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CumulativeEnergyImportedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cumulativeenergyimported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Cumulativeenergyimported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CumulativeEnergyImportedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CumulativeEnergyImportedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CumulativeEnergyImportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCumulativeEnergyExportedAttribute(): CumulativeEnergyExportedAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCumulativeEnergyExportedAttribute(): CumulativeEnergyExportedAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cumulativeenergyexported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Cumulativeenergyexported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CumulativeEnergyExportedAttribute(decodedValue) } @@ -422,104 +381,103 @@ suspend fun readCumulativeEnergyExportedAttribute(): CumulativeEnergyExportedAtt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CumulativeEnergyExportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CumulativeEnergyExportedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cumulativeenergyexported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Cumulativeenergyexported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CumulativeEnergyExportedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CumulativeEnergyExportedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CumulativeEnergyExportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeriodicEnergyImportedAttribute(): PeriodicEnergyImportedAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeriodicEnergyImportedAttribute(): PeriodicEnergyImportedAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Periodicenergyimported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Periodicenergyimported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeriodicEnergyImportedAttribute(decodedValue) } @@ -529,104 +487,103 @@ suspend fun readPeriodicEnergyImportedAttribute(): PeriodicEnergyImportedAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeriodicEnergyImportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeriodicEnergyImportedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Periodicenergyimported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Periodicenergyimported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeriodicEnergyImportedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeriodicEnergyImportedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeriodicEnergyImportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeriodicEnergyExportedAttribute(): PeriodicEnergyExportedAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeriodicEnergyExportedAttribute(): PeriodicEnergyExportedAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Periodicenergyexported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Periodicenergyexported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeriodicEnergyExportedAttribute(decodedValue) } @@ -636,101 +593,100 @@ suspend fun readPeriodicEnergyExportedAttribute(): PeriodicEnergyExportedAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeriodicEnergyExportedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeriodicEnergyExportedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Periodicenergyexported attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Periodicenergyexported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeriodicEnergyExportedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ElectricalEnergyMeasurementClusterEnergyMeasurementStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeriodicEnergyExportedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeriodicEnergyExportedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -740,45 +696,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -786,49 +747,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -838,45 +793,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -884,49 +844,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -936,45 +890,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -982,49 +939,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1034,45 +985,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1080,44 +1034,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1126,35 +1073,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1166,44 +1115,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1212,34 +1154,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1252,7 +1198,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt index 0fec4dc6624459..a44e1544733646 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ElectricalMeasurementCluster.kt @@ -17,106 +17,84 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.ByteSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.ShortSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ElectricalMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class ElectricalMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun getProfileInfoCommand(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -130,10 +108,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getMeasurementProfileCommand(attributeId: UShort - ,startTime: UInt - ,numberOfIntervals: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun getMeasurementProfileCommand( + attributeId: UShort, + startTime: UInt, + numberOfIntervals: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -146,7 +126,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_START_TIME_REQ), startTime) val TAG_NUMBER_OF_INTERVALS_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_NUMBER_OF_INTERVALS_REQ), numberOfIntervals) + tlvWriter.put(ContextSpecificTag(TAG_NUMBER_OF_INTERVALS_REQ), numberOfIntervals) tlvWriter.endStructure() val request: InvokeRequest = @@ -159,45 +139,39 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readMeasurementTypeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasurementTypeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementtype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementtype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -207,94 +181,90 @@ suspend fun readMeasurementTypeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementtype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementtype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 256u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 256u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -304,94 +274,88 @@ suspend fun readDcVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 256u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 256u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltage attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcVoltageMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 257u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcVoltageMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 257u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcvoltagemin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -401,94 +365,88 @@ suspend fun readDcVoltageMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 257u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 257u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemin attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcvoltagemin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcVoltageMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 258u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcVoltageMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 258u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcvoltagemax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -498,94 +456,88 @@ suspend fun readDcVoltageMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 258u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 258u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcvoltagemax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 259u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 259u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -595,94 +547,88 @@ suspend fun readDcCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 259u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 259u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcCurrentMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 260u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcCurrentMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 260u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dccurrentmin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -692,94 +638,88 @@ suspend fun readDcCurrentMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 260u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 260u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmin attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dccurrentmin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcCurrentMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 261u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcCurrentMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 261u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dccurrentmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -789,94 +729,88 @@ suspend fun readDcCurrentMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 261u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 261u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dccurrentmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcPowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 262u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcPowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 262u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -886,94 +820,88 @@ suspend fun readDcPowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 262u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 262u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcPowerMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 263u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcPowerMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 263u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcpowermin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -983,94 +911,88 @@ suspend fun readDcPowerMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 263u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 263u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermin attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcpowermin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcPowerMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 264u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcPowerMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 264u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcpowermax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1080,94 +1002,88 @@ suspend fun readDcPowerMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 264u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 264u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dcpowermax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcVoltageMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 512u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcVoltageMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 512u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcvoltagemultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1177,94 +1093,90 @@ suspend fun readDcVoltageMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 512u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagemultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dcvoltagemultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcVoltageDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 513u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcVoltageDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 513u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagedivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcvoltagedivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1274,94 +1186,90 @@ suspend fun readDcVoltageDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 513u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcvoltagedivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dcvoltagedivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcCurrentMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 514u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcCurrentMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 514u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dccurrentmultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1371,94 +1279,90 @@ suspend fun readDcCurrentMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 514u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dccurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcCurrentDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 515u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcCurrentDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 515u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentdivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dccurrentdivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1468,94 +1372,90 @@ suspend fun readDcCurrentDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 515u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dccurrentdivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dccurrentdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcPowerMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 516u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcPowerMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 516u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcpowermultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1565,94 +1465,90 @@ suspend fun readDcPowerMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 516u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowermultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dcpowermultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDcPowerDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 517u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDcPowerDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 517u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowerdivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dcpowerdivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1662,94 +1558,90 @@ suspend fun readDcPowerDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 517 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 517u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dcpowerdivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dcpowerdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 768u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 768u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acfrequency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1759,94 +1651,88 @@ suspend fun readAcFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 768u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 768u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequency attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Acfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcFrequencyMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 769u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcFrequencyMinAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 769u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acfrequencymin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1856,94 +1742,90 @@ suspend fun readAcFrequencyMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 769 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 769u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymin attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acfrequencymin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcFrequencyMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 770u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcFrequencyMaxAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 770u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acfrequencymax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1953,94 +1835,90 @@ suspend fun readAcFrequencyMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 770 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 770u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymax attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acfrequencymax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNeutralCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 771u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNeutralCurrentAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 771u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Neutralcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Neutralcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2050,94 +1928,90 @@ suspend fun readNeutralCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 771 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 771u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Neutralcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Neutralcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTotalActivePowerAttribute(): Int? {val ATTRIBUTE_ID: UInt = 772u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTotalActivePowerAttribute(): Int? { + val ATTRIBUTE_ID: UInt = 772u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalactivepower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Totalactivepower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } - + val decodedValue: Int? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2147,94 +2021,90 @@ suspend fun readTotalActivePowerAttribute(): Int? {val ATTRIBUTE_ID: UInt = 772u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 772u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + IntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalactivepower attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Totalactivepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } + val decodedValue: Int? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(IntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(IntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTotalReactivePowerAttribute(): Int? {val ATTRIBUTE_ID: UInt = 773u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTotalReactivePowerAttribute(): Int? { + val ATTRIBUTE_ID: UInt = 773u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalreactivepower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Totalreactivepower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } - + val decodedValue: Int? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2244,94 +2114,90 @@ suspend fun readTotalReactivePowerAttribute(): Int? {val ATTRIBUTE_ID: UInt = 77 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 773u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + IntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalreactivepower attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Totalreactivepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getInt(AnonymousTag) - } else { - null - } + val decodedValue: Int? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(IntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(IntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTotalApparentPowerAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 774u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTotalApparentPowerAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 774u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalapparentpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Totalapparentpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2341,94 +2207,90 @@ suspend fun readTotalApparentPowerAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 7 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 774u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totalapparentpower attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Totalapparentpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured1stHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 775u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured1stHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 775u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured1stharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured1stharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2438,94 +2300,90 @@ suspend fun readMeasured1stHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 775u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured1stharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured1stharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured3rdHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 776u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured3rdHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 776u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured3rdharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured3rdharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2535,94 +2393,90 @@ suspend fun readMeasured3rdHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 776u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured3rdharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured3rdharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured5thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 777u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured5thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 777u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured5thharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured5thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2632,94 +2486,90 @@ suspend fun readMeasured5thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 777u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured5thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured5thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured7thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 778u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured7thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 778u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured7thharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured7thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2729,94 +2579,90 @@ suspend fun readMeasured7thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 778u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured7thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured7thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured9thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 779u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured9thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 779u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured9thharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured9thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2826,94 +2672,90 @@ suspend fun readMeasured9thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 779u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured9thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured9thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasured11thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 780u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasured11thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 780u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured11thharmoniccurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measured11thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2923,94 +2765,92 @@ suspend fun readMeasured11thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 780u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measured11thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measured11thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase1stHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 781u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase1stHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 781u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase1stharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase1stharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3020,94 +2860,92 @@ suspend fun readMeasuredPhase1stHarmonicCurrentAttribute(): Short? {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 781u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase1stharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase1stharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase3rdHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 782u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase3rdHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 782u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase3rdharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase3rdharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3117,94 +2955,92 @@ suspend fun readMeasuredPhase3rdHarmonicCurrentAttribute(): Short? {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 782u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase3rdharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase3rdharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase5thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 783u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase5thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 783u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase5thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase5thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3214,94 +3050,92 @@ suspend fun readMeasuredPhase5thHarmonicCurrentAttribute(): Short? {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 783u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase5thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase5thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase7thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 784u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase7thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 784u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase7thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase7thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3311,94 +3145,92 @@ suspend fun readMeasuredPhase7thHarmonicCurrentAttribute(): Short? {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 784u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase7thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase7thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase9thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 785u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase9thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 785u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase9thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase9thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3408,94 +3240,92 @@ suspend fun readMeasuredPhase9thHarmonicCurrentAttribute(): Short? {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 785u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase9thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase9thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasuredPhase11thHarmonicCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 786u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeasuredPhase11thHarmonicCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 786u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase11thharmoniccurrent attribute not found in response" + } + + requireNotNull(attributeData) { + "Measuredphase11thharmoniccurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3505,94 +3335,90 @@ suspend fun readMeasuredPhase11thHarmonicCurrentAttribute(): Short? {val ATTRIBU maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 786u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredphase11thharmoniccurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measuredphase11thharmoniccurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcFrequencyMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1024u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcFrequencyMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1024u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acfrequencymultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3602,94 +3428,90 @@ suspend fun readAcFrequencyMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1024u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencymultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acfrequencymultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcFrequencyDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1025u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcFrequencyDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1025u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencydivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acfrequencydivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -3699,94 +3521,90 @@ suspend fun readAcFrequencyDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1025u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acfrequencydivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acfrequencydivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerMultiplierAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1026u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerMultiplierAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1026u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powermultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powermultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3796,94 +3614,90 @@ suspend fun readPowerMultiplierAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1026 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1026u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powermultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Powermultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerDivisorAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1027u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerDivisorAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 1027u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerdivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powerdivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3893,94 +3707,88 @@ suspend fun readPowerDivisorAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 1027u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1027u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerdivisor attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powerdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHarmonicCurrentMultiplierAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 1028u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readHarmonicCurrentMultiplierAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 1028u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Harmoniccurrentmultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Harmoniccurrentmultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3990,94 +3798,92 @@ suspend fun readHarmonicCurrentMultiplierAttribute(): Byte? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1028u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Harmoniccurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Harmoniccurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhaseHarmonicCurrentMultiplierAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 1029u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPhaseHarmonicCurrentMultiplierAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 1029u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaseharmoniccurrentmultiplier attribute not found in response" + } + + requireNotNull(attributeData) { + "Phaseharmoniccurrentmultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -4087,94 +3893,90 @@ suspend fun readPhaseHarmonicCurrentMultiplierAttribute(): Byte? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1029u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaseharmoniccurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Phaseharmoniccurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstantaneousVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1280u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstantaneousVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1280u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Instantaneousvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4184,94 +3986,90 @@ suspend fun readInstantaneousVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1280u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousvoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Instantaneousvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstantaneousLineCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1281u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstantaneousLineCurrentAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1281u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneouslinecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Instantaneouslinecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4281,94 +4079,90 @@ suspend fun readInstantaneousLineCurrentAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1281u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneouslinecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Instantaneouslinecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstantaneousActiveCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1282u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstantaneousActiveCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1282u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousactivecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Instantaneousactivecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4378,94 +4172,90 @@ suspend fun readInstantaneousActiveCurrentAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1282u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousactivecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Instantaneousactivecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstantaneousReactiveCurrentAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1283u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstantaneousReactiveCurrentAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1283u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousreactivecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Instantaneousreactivecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4475,94 +4265,90 @@ suspend fun readInstantaneousReactiveCurrentAttribute(): Short? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1283u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneousreactivecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Instantaneousreactivecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstantaneousPowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1284u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstantaneousPowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1284u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneouspower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Instantaneouspower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4572,94 +4358,90 @@ suspend fun readInstantaneousPowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1284u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Instantaneouspower attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Instantaneouspower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1285u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1285u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4669,94 +4451,88 @@ suspend fun readRmsVoltageAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1285u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1285u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltage attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmsvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1286u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMinAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1286u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagemin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4766,94 +4542,88 @@ suspend fun readRmsVoltageMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1286 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1286u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemin attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmsvoltagemin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1287u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMaxAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1287u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagemax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4863,94 +4633,88 @@ suspend fun readRmsVoltageMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1287 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1287u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmsvoltagemax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1288u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1288u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4960,94 +4724,88 @@ suspend fun readRmsCurrentAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1288u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1288u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmscurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1289u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMinAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1289u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentmin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5057,94 +4815,88 @@ suspend fun readRmsCurrentMinAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1289 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1289u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmin attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmscurrentmin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1290u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMaxAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1290u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5154,94 +4906,88 @@ suspend fun readRmsCurrentMaxAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1290 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1290u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmscurrentmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1291u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1291u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5251,94 +4997,88 @@ suspend fun readActivePowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1291u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1291u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1292u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMinAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1292u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowermin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5348,94 +5088,90 @@ suspend fun readActivePowerMinAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1292 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1292u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermin attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowermin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1293u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMaxAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1293u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowermax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5445,94 +5181,90 @@ suspend fun readActivePowerMaxAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1293 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1293u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermax attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowermax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactivePowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1294u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactivePowerAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1294u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivepower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5542,94 +5274,88 @@ suspend fun readReactivePowerAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1294u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1294u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Reactivepower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApparentPowerAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1295u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readApparentPowerAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1295u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Apparentpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -5639,94 +5365,88 @@ suspend fun readApparentPowerAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1295 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1295u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Apparentpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerFactorAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 1296u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerFactorAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 1296u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powerfactor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -5736,118 +5456,113 @@ suspend fun readPowerFactorAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 1296u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1296u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactor attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powerfactor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1297u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1297u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiod attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeAverageRmsVoltageMeasurementPeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1297u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5869,7 +5584,7 @@ suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort? {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAverageRmsVoltageMeasurementPeriodAttribute( @@ -5877,118 +5592,115 @@ suspend fun readAverageRmsVoltageMeasurementPeriodAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1297u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1299u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1299u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounter attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounter attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeAverageRmsUnderVoltageCounterAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1299u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6010,7 +5722,7 @@ suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort? {val ATTRIBUTE throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAverageRmsUnderVoltageCounterAttribute( @@ -6018,118 +5730,113 @@ suspend fun readAverageRmsUnderVoltageCounterAttribute(): UShort? {val ATTRIBUTE maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1299u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounter attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounter attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1300u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1300u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsextremeovervoltageperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRmsExtremeOverVoltagePeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1300u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6151,7 +5858,7 @@ suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_I throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsExtremeOverVoltagePeriodAttribute( @@ -6159,118 +5866,113 @@ suspend fun readRmsExtremeOverVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1300u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1301u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1301u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsextremeundervoltageperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRmsExtremeUnderVoltagePeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1301u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6292,7 +5994,7 @@ suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsExtremeUnderVoltagePeriodAttribute( @@ -6300,118 +6002,113 @@ suspend fun readRmsExtremeUnderVoltagePeriodAttribute(): UShort? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1301u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSagPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1302u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSagPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1302u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagesagperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRmsVoltageSagPeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1302u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6433,7 +6130,7 @@ suspend fun readRmsVoltageSagPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsVoltageSagPeriodAttribute( @@ -6441,118 +6138,113 @@ suspend fun readRmsVoltageSagPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1302u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSwellPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1303u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSwellPeriodAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1303u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiod attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageswellperiod attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRmsVoltageSwellPeriodAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1303u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6574,7 +6266,7 @@ suspend fun readRmsVoltageSwellPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UIn throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRmsVoltageSwellPeriodAttribute( @@ -6582,94 +6274,90 @@ suspend fun readRmsVoltageSwellPeriodAttribute(): UShort? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1303u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiod attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiod attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcVoltageMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1536u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcVoltageMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1536u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltagemultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acvoltagemultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6679,94 +6367,90 @@ suspend fun readAcVoltageMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1536u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltagemultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acvoltagemultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcVoltageDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1537u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcVoltageDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1537u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltagedivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acvoltagedivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6776,94 +6460,90 @@ suspend fun readAcVoltageDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1537u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltagedivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acvoltagedivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcCurrentMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1538u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcCurrentMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1538u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentmultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accurrentmultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6873,94 +6553,90 @@ suspend fun readAcCurrentMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1538u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentmultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accurrentmultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcCurrentDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1539u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcCurrentDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1539u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentdivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accurrentdivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -6970,94 +6646,90 @@ suspend fun readAcCurrentDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1539u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentdivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accurrentdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcPowerMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1540u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcPowerMultiplierAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1540u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acpowermultiplier attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acpowermultiplier attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7067,94 +6739,90 @@ suspend fun readAcPowerMultiplierAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1540u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acpowermultiplier attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acpowermultiplier attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcPowerDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1541u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcPowerDivisorAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1541u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acpowerdivisor attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acpowerdivisor attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7164,118 +6832,110 @@ suspend fun readAcPowerDivisorAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 154 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1541u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acpowerdivisor attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acpowerdivisor attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOverloadAlarmsMaskAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1792u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOverloadAlarmsMaskAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1792u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overloadalarmsmask attribute not found in response" - } + } + + requireNotNull(attributeData) { "Overloadalarmsmask attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeOverloadAlarmsMaskAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOverloadAlarmsMaskAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1792u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7297,7 +6957,7 @@ suspend fun readOverloadAlarmsMaskAttribute(): UByte? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOverloadAlarmsMaskAttribute( @@ -7305,94 +6965,90 @@ suspend fun readOverloadAlarmsMaskAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1792u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overloadalarmsmask attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Overloadalarmsmask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVoltageOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1793u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readVoltageOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1793u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Voltageoverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Voltageoverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7402,94 +7058,90 @@ suspend fun readVoltageOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 179 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1793u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Voltageoverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Voltageoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1794u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1794u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentoverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentoverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7499,118 +7151,113 @@ suspend fun readCurrentOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 179 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1794u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentoverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcOverloadAlarmsMaskAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2048u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcOverloadAlarmsMaskAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2048u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acoverloadalarmsmask attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acoverloadalarmsmask attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeAcOverloadAlarmsMaskAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 2048u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7632,7 +7279,7 @@ suspend fun readAcOverloadAlarmsMaskAttribute(): UShort? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAcOverloadAlarmsMaskAttribute( @@ -7640,94 +7287,90 @@ suspend fun readAcOverloadAlarmsMaskAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2048u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acoverloadalarmsmask attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acoverloadalarmsmask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcVoltageOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2049u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcVoltageOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2049u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltageoverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acvoltageoverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7737,94 +7380,90 @@ suspend fun readAcVoltageOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2049u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acvoltageoverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acvoltageoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcCurrentOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2050u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcCurrentOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2050u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentoverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accurrentoverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7834,94 +7473,90 @@ suspend fun readAcCurrentOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2050u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accurrentoverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accurrentoverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcActivePowerOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2051u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcActivePowerOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2051u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acactivepoweroverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acactivepoweroverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -7931,94 +7566,90 @@ suspend fun readAcActivePowerOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2051u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acactivepoweroverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acactivepoweroverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcReactivePowerOverloadAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2052u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcReactivePowerOverloadAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2052u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acreactivepoweroverload attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acreactivepoweroverload attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8028,94 +7659,90 @@ suspend fun readAcReactivePowerOverloadAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2052u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acreactivepoweroverload attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acreactivepoweroverload attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsOverVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2053u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsOverVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2053u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagermsovervoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8125,94 +7752,90 @@ suspend fun readAverageRmsOverVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2053u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsovervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsUnderVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2054u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsUnderVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2054u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagermsundervoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8222,94 +7845,90 @@ suspend fun readAverageRmsUnderVoltageAttribute(): Short? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2054u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsundervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeOverVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2055u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeOverVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2055u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsextremeovervoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8319,94 +7938,90 @@ suspend fun readRmsExtremeOverVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2055u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeovervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeUnderVoltageAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2056u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeUnderVoltageAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2056u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsextremeundervoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8416,94 +8031,90 @@ suspend fun readRmsExtremeUnderVoltageAttribute(): Short? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2056u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeundervoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSagAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2057u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSagAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2057u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesag attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagesag attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8513,94 +8124,88 @@ suspend fun readRmsVoltageSagAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2057u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2057u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesag attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rmsvoltagesag attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSwellAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2058u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSwellAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2058u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswell attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageswell attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8610,94 +8215,90 @@ suspend fun readRmsVoltageSwellAttribute(): Short? {val ATTRIBUTE_ID: UInt = 205 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2058u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswell attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageswell attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLineCurrentPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2305u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLineCurrentPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2305u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linecurrentphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Linecurrentphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8707,94 +8308,90 @@ suspend fun readLineCurrentPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2305u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linecurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Linecurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveCurrentPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2306u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveCurrentPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2306u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecurrentphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activecurrentphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8804,94 +8401,90 @@ suspend fun readActiveCurrentPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2306u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activecurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactiveCurrentPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2307u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactiveCurrentPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2307u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivecurrentphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivecurrentphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8901,94 +8494,90 @@ suspend fun readReactiveCurrentPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2307u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivecurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Reactivecurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltagePhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2309u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltagePhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2309u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagephaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagephaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -8998,94 +8587,90 @@ suspend fun readRmsVoltagePhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2309u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagephaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagephaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMinPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2310u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMinPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2310u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageminphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageminphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9095,94 +8680,90 @@ suspend fun readRmsVoltageMinPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2310u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageminphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageminphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMaxPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2311u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMaxPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2311u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemaxphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagemaxphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9192,94 +8773,90 @@ suspend fun readRmsVoltageMaxPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2311u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemaxphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagemaxphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2312u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2312u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9289,94 +8866,90 @@ suspend fun readRmsCurrentPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2312u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMinPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2313u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMinPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2313u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentminphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentminphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9386,94 +8959,90 @@ suspend fun readRmsCurrentMinPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2313u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentminphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentminphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMaxPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2314u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMaxPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2314u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmaxphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentmaxphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9483,94 +9052,90 @@ suspend fun readRmsCurrentMaxPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2314u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmaxphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentmaxphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2315u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2315u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowerphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9580,94 +9145,90 @@ suspend fun readActivePowerPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2315u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowerphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMinPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2316u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMinPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2316u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerminphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowerminphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9677,94 +9238,90 @@ suspend fun readActivePowerMinPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2316u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerminphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowerminphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMaxPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2317u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMaxPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2317u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermaxphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowermaxphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9774,94 +9331,90 @@ suspend fun readActivePowerMaxPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2317u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermaxphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowermaxphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactivePowerPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2318u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactivePowerPhaseBAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2318u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepowerphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivepowerphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9871,94 +9424,90 @@ suspend fun readReactivePowerPhaseBAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2318u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepowerphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Reactivepowerphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApparentPowerPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2319u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readApparentPowerPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2319u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpowerphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Apparentpowerphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -9968,94 +9517,90 @@ suspend fun readApparentPowerPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2319u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpowerphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Apparentpowerphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerFactorPhaseBAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 2320u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerFactorPhaseBAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 2320u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactorphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powerfactorphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -10065,94 +9610,92 @@ suspend fun readPowerFactorPhaseBAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 23 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2320u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactorphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Powerfactorphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsVoltageMeasurementPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2321u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsVoltageMeasurementPeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2321u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10162,94 +9705,92 @@ suspend fun readAverageRmsVoltageMeasurementPeriodPhaseBAttribute(): UShort? {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2321u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsOverVoltageCounterPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2322u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsOverVoltageCounterPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2322u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10259,94 +9800,92 @@ suspend fun readAverageRmsOverVoltageCounterPhaseBAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2322u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsUnderVoltageCounterPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2323u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsUnderVoltageCounterPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2323u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10356,94 +9895,92 @@ suspend fun readAverageRmsUnderVoltageCounterPhaseBAttribute(): UShort? {val ATT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2323u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeOverVoltagePeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2324u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeOverVoltagePeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2324u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10453,94 +9990,92 @@ suspend fun readRmsExtremeOverVoltagePeriodPhaseBAttribute(): UShort? {val ATTRI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2324u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeUnderVoltagePeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2325u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeUnderVoltagePeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2325u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphaseb attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10550,94 +10085,90 @@ suspend fun readRmsExtremeUnderVoltagePeriodPhaseBAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2325u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSagPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2326u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSagPeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2326u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiodphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagesagperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10647,94 +10178,90 @@ suspend fun readRmsVoltageSagPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2326u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSwellPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2327u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSwellPeriodPhaseBAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2327u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiodphaseb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageswellperiodphaseb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10744,94 +10271,90 @@ suspend fun readRmsVoltageSwellPeriodPhaseBAttribute(): UShort? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2327u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiodphaseb attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiodphaseb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLineCurrentPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2561u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLineCurrentPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2561u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linecurrentphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Linecurrentphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10841,94 +10364,90 @@ suspend fun readLineCurrentPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2561u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linecurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Linecurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveCurrentPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2562u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveCurrentPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2562u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecurrentphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activecurrentphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -10938,94 +10457,90 @@ suspend fun readActiveCurrentPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2562u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activecurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactiveCurrentPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2563u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactiveCurrentPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2563u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivecurrentphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivecurrentphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11035,94 +10550,90 @@ suspend fun readReactiveCurrentPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2563u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivecurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Reactivecurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltagePhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2565u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltagePhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2565u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagephasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagephasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11132,94 +10643,90 @@ suspend fun readRmsVoltagePhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2565u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagephasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagephasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMinPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2566u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMinPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2566u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageminphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageminphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11229,94 +10736,90 @@ suspend fun readRmsVoltageMinPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2566u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageminphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageminphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageMaxPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2567u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageMaxPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2567u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemaxphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagemaxphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11326,94 +10829,90 @@ suspend fun readRmsVoltageMaxPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2567u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagemaxphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagemaxphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2568u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2568u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11423,94 +10922,90 @@ suspend fun readRmsCurrentPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2568u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMinPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2569u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMinPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2569u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentminphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentminphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11520,94 +11015,90 @@ suspend fun readRmsCurrentMinPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2569u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentminphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentminphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsCurrentMaxPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2570u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsCurrentMaxPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2570u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmaxphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmscurrentmaxphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11617,94 +11108,90 @@ suspend fun readRmsCurrentMaxPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2570u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmscurrentmaxphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmscurrentmaxphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2571u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2571u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowerphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11714,94 +11201,90 @@ suspend fun readActivePowerPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2571u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowerphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMinPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2572u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMinPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2572u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerminphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowerminphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11811,94 +11294,90 @@ suspend fun readActivePowerMinPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2572u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowerminphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowerminphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePowerMaxPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2573u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePowerMaxPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2573u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermaxphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepowermaxphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -11908,94 +11387,90 @@ suspend fun readActivePowerMaxPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2573u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepowermaxphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepowermaxphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReactivePowerPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2574u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readReactivePowerPhaseCAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2574u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepowerphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Reactivepowerphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12005,94 +11480,90 @@ suspend fun readReactivePowerPhaseCAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2574u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Reactivepowerphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Reactivepowerphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApparentPowerPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2575u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readApparentPowerPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2575u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpowerphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Apparentpowerphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12102,94 +11573,90 @@ suspend fun readApparentPowerPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2575u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Apparentpowerphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Apparentpowerphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerFactorPhaseCAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 2576u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerFactorPhaseCAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 2576u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactorphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powerfactorphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -12199,94 +11666,92 @@ suspend fun readPowerFactorPhaseCAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 25 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2576u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerfactorphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Powerfactorphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsVoltageMeasurementPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2577u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsVoltageMeasurementPeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2577u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12296,94 +11761,92 @@ suspend fun readAverageRmsVoltageMeasurementPeriodPhaseCAttribute(): UShort? {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2577u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsvoltagemeasurementperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsvoltagemeasurementperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsOverVoltageCounterPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2578u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsOverVoltageCounterPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2578u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12393,94 +11856,92 @@ suspend fun readAverageRmsOverVoltageCounterPhaseCAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2578u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsovervoltagecounterphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsovervoltagecounterphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageRmsUnderVoltageCounterPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2579u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAverageRmsUnderVoltageCounterPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2579u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12490,94 +11951,92 @@ suspend fun readAverageRmsUnderVoltageCounterPhaseCAttribute(): UShort? {val ATT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2579u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagermsundervoltagecounterphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagermsundervoltagecounterphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeOverVoltagePeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2580u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeOverVoltagePeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2580u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12587,94 +12046,92 @@ suspend fun readRmsExtremeOverVoltagePeriodPhaseCAttribute(): UShort? {val ATTRI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2580u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeovervoltageperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeovervoltageperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsExtremeUnderVoltagePeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2581u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsExtremeUnderVoltagePeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2581u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphasec attribute not found in response" + } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12684,94 +12141,90 @@ suspend fun readRmsExtremeUnderVoltagePeriodPhaseCAttribute(): UShort? {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2581u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsextremeundervoltageperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsextremeundervoltageperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSagPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2582u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSagPeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2582u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiodphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltagesagperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12781,94 +12234,90 @@ suspend fun readRmsVoltageSagPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2582u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltagesagperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltagesagperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRmsVoltageSwellPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2583u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRmsVoltageSwellPeriodPhaseCAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2583u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiodphasec attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rmsvoltageswellperiodphasec attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -12878,96 +12327,92 @@ suspend fun readRmsVoltageSwellPeriodPhaseCAttribute(): UShort? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2583u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rmsvoltageswellperiodphasec attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rmsvoltageswellperiodphasec attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -12977,45 +12422,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -13023,49 +12473,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -13075,45 +12519,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -13121,49 +12570,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -13173,45 +12616,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -13219,49 +12665,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -13271,45 +12711,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -13317,44 +12760,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -13363,35 +12799,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -13403,44 +12841,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -13449,34 +12880,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -13489,7 +12924,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt index 0d532702cc4872..20363bff38ec5a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyEvseCluster.kt @@ -17,45 +17,30 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.LongSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter @@ -63,259 +48,206 @@ class EnergyEvseCluster(private val controller: MatterController, private val en class GetTargetsResponse( val chargingTargetSchedules: List ) -class StateAttribute( - val value: UByte? - ) + + class StateAttribute(val value: UByte?) sealed class StateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StateAttributeSubscriptionState() - + data class Success(val value: UByte?) : StateAttributeSubscriptionState() + data class Error(val exception: Exception) : StateAttributeSubscriptionState() - object SubscriptionEstablished : StateAttributeSubscriptionState() - } -class ChargingEnabledUntilAttribute( - val value: UInt? - ) + object SubscriptionEstablished : StateAttributeSubscriptionState() + } + + class ChargingEnabledUntilAttribute(val value: UInt?) sealed class ChargingEnabledUntilAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : ChargingEnabledUntilAttributeSubscriptionState() - + data class Success(val value: UInt?) : ChargingEnabledUntilAttributeSubscriptionState() + data class Error(val exception: Exception) : ChargingEnabledUntilAttributeSubscriptionState() - object SubscriptionEstablished : ChargingEnabledUntilAttributeSubscriptionState() - } -class DischargingEnabledUntilAttribute( - val value: UInt? - ) + object SubscriptionEstablished : ChargingEnabledUntilAttributeSubscriptionState() + } + + class DischargingEnabledUntilAttribute(val value: UInt?) sealed class DischargingEnabledUntilAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : DischargingEnabledUntilAttributeSubscriptionState() - - data class Error(val exception: Exception) : DischargingEnabledUntilAttributeSubscriptionState() - - object SubscriptionEstablished : DischargingEnabledUntilAttributeSubscriptionState() - } -class NextChargeStartTimeAttribute( - val value: UInt? - ) + data class Success(val value: UInt?) : DischargingEnabledUntilAttributeSubscriptionState() + + data class Error(val exception: Exception) : + DischargingEnabledUntilAttributeSubscriptionState() + + object SubscriptionEstablished : DischargingEnabledUntilAttributeSubscriptionState() + } + + class NextChargeStartTimeAttribute(val value: UInt?) sealed class NextChargeStartTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : NextChargeStartTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : NextChargeStartTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : NextChargeStartTimeAttributeSubscriptionState() - object SubscriptionEstablished : NextChargeStartTimeAttributeSubscriptionState() - } -class NextChargeTargetTimeAttribute( - val value: UInt? - ) + object SubscriptionEstablished : NextChargeStartTimeAttributeSubscriptionState() + } + + class NextChargeTargetTimeAttribute(val value: UInt?) sealed class NextChargeTargetTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : NextChargeTargetTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : NextChargeTargetTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : NextChargeTargetTimeAttributeSubscriptionState() - object SubscriptionEstablished : NextChargeTargetTimeAttributeSubscriptionState() - } -class NextChargeRequiredEnergyAttribute( - val value: Long? - ) + object SubscriptionEstablished : NextChargeTargetTimeAttributeSubscriptionState() + } + + class NextChargeRequiredEnergyAttribute(val value: Long?) sealed class NextChargeRequiredEnergyAttributeSubscriptionState { - data class Success( - val value: Long? - ) : NextChargeRequiredEnergyAttributeSubscriptionState() - - data class Error(val exception: Exception) : NextChargeRequiredEnergyAttributeSubscriptionState() - - object SubscriptionEstablished : NextChargeRequiredEnergyAttributeSubscriptionState() - } -class NextChargeTargetSoCAttribute( - val value: UByte? - ) + data class Success(val value: Long?) : NextChargeRequiredEnergyAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NextChargeRequiredEnergyAttributeSubscriptionState() + + object SubscriptionEstablished : NextChargeRequiredEnergyAttributeSubscriptionState() + } + + class NextChargeTargetSoCAttribute(val value: UByte?) sealed class NextChargeTargetSoCAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NextChargeTargetSoCAttributeSubscriptionState() - + data class Success(val value: UByte?) : NextChargeTargetSoCAttributeSubscriptionState() + data class Error(val exception: Exception) : NextChargeTargetSoCAttributeSubscriptionState() - object SubscriptionEstablished : NextChargeTargetSoCAttributeSubscriptionState() - } -class ApproximateEVEfficiencyAttribute( - val value: UShort? - ) + object SubscriptionEstablished : NextChargeTargetSoCAttributeSubscriptionState() + } + + class ApproximateEVEfficiencyAttribute(val value: UShort?) sealed class ApproximateEVEfficiencyAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : ApproximateEVEfficiencyAttributeSubscriptionState() - - data class Error(val exception: Exception) : ApproximateEVEfficiencyAttributeSubscriptionState() - - object SubscriptionEstablished : ApproximateEVEfficiencyAttributeSubscriptionState() - } -class StateOfChargeAttribute( - val value: UByte? - ) + data class Success(val value: UShort?) : ApproximateEVEfficiencyAttributeSubscriptionState() + + data class Error(val exception: Exception) : + ApproximateEVEfficiencyAttributeSubscriptionState() + + object SubscriptionEstablished : ApproximateEVEfficiencyAttributeSubscriptionState() + } + + class StateOfChargeAttribute(val value: UByte?) sealed class StateOfChargeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StateOfChargeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StateOfChargeAttributeSubscriptionState() + data class Error(val exception: Exception) : StateOfChargeAttributeSubscriptionState() - object SubscriptionEstablished : StateOfChargeAttributeSubscriptionState() - } -class BatteryCapacityAttribute( - val value: Long? - ) + object SubscriptionEstablished : StateOfChargeAttributeSubscriptionState() + } + + class BatteryCapacityAttribute(val value: Long?) sealed class BatteryCapacityAttributeSubscriptionState { - data class Success( - val value: Long? - ) : BatteryCapacityAttributeSubscriptionState() - + data class Success(val value: Long?) : BatteryCapacityAttributeSubscriptionState() + data class Error(val exception: Exception) : BatteryCapacityAttributeSubscriptionState() - object SubscriptionEstablished : BatteryCapacityAttributeSubscriptionState() - } -class VehicleIDAttribute( - val value: String? - ) + object SubscriptionEstablished : BatteryCapacityAttributeSubscriptionState() + } + + class VehicleIDAttribute(val value: String?) sealed class VehicleIDAttributeSubscriptionState { - data class Success( - val value: String? - ) : VehicleIDAttributeSubscriptionState() - + data class Success(val value: String?) : VehicleIDAttributeSubscriptionState() + data class Error(val exception: Exception) : VehicleIDAttributeSubscriptionState() - object SubscriptionEstablished : VehicleIDAttributeSubscriptionState() - } -class SessionIDAttribute( - val value: UInt? - ) + object SubscriptionEstablished : VehicleIDAttributeSubscriptionState() + } + + class SessionIDAttribute(val value: UInt?) sealed class SessionIDAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : SessionIDAttributeSubscriptionState() - + data class Success(val value: UInt?) : SessionIDAttributeSubscriptionState() + data class Error(val exception: Exception) : SessionIDAttributeSubscriptionState() - object SubscriptionEstablished : SessionIDAttributeSubscriptionState() - } -class SessionDurationAttribute( - val value: UInt? - ) + object SubscriptionEstablished : SessionIDAttributeSubscriptionState() + } + + class SessionDurationAttribute(val value: UInt?) sealed class SessionDurationAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : SessionDurationAttributeSubscriptionState() - + data class Success(val value: UInt?) : SessionDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : SessionDurationAttributeSubscriptionState() - object SubscriptionEstablished : SessionDurationAttributeSubscriptionState() - } -class SessionEnergyChargedAttribute( - val value: Long? - ) + object SubscriptionEstablished : SessionDurationAttributeSubscriptionState() + } + + class SessionEnergyChargedAttribute(val value: Long?) sealed class SessionEnergyChargedAttributeSubscriptionState { - data class Success( - val value: Long? - ) : SessionEnergyChargedAttributeSubscriptionState() - + data class Success(val value: Long?) : SessionEnergyChargedAttributeSubscriptionState() + data class Error(val exception: Exception) : SessionEnergyChargedAttributeSubscriptionState() - object SubscriptionEstablished : SessionEnergyChargedAttributeSubscriptionState() - } -class SessionEnergyDischargedAttribute( - val value: Long? - ) + object SubscriptionEstablished : SessionEnergyChargedAttributeSubscriptionState() + } + + class SessionEnergyDischargedAttribute(val value: Long?) sealed class SessionEnergyDischargedAttributeSubscriptionState { - data class Success( - val value: Long? - ) : SessionEnergyDischargedAttributeSubscriptionState() - - data class Error(val exception: Exception) : SessionEnergyDischargedAttributeSubscriptionState() - - object SubscriptionEstablished : SessionEnergyDischargedAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: Long?) : SessionEnergyDischargedAttributeSubscriptionState() + + data class Error(val exception: Exception) : + SessionEnergyDischargedAttributeSubscriptionState() + + object SubscriptionEstablished : SessionEnergyDischargedAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun disable(timedInvokeTimeout: Duration) { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -329,10 +261,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableCharging(chargingEnabledUntil: UInt? - ,minimumChargeCurrent: Long - ,maximumChargeCurrent: Long - ,timedInvokeTimeout: Duration) { + suspend fun enableCharging( + chargingEnabledUntil: UInt?, + minimumChargeCurrent: Long, + maximumChargeCurrent: Long, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -347,7 +281,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_MINIMUM_CHARGE_CURRENT_REQ), minimumChargeCurrent) val TAG_MAXIMUM_CHARGE_CURRENT_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_CHARGE_CURRENT_REQ), maximumChargeCurrent) + tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_CHARGE_CURRENT_REQ), maximumChargeCurrent) tlvWriter.endStructure() val request: InvokeRequest = @@ -361,9 +295,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun enableDischarging(dischargingEnabledUntil: UInt? - ,maximumDischargeCurrent: Long - ,timedInvokeTimeout: Duration) { + suspend fun enableDischarging( + dischargingEnabledUntil: UInt?, + maximumDischargeCurrent: Long, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -375,7 +311,7 @@ class AttributeListAttribute( } val TAG_MAXIMUM_DISCHARGE_CURRENT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_DISCHARGE_CURRENT_REQ), maximumDischargeCurrent) + tlvWriter.put(ContextSpecificTag(TAG_MAXIMUM_DISCHARGE_CURRENT_REQ), maximumDischargeCurrent) tlvWriter.endStructure() val request: InvokeRequest = @@ -393,7 +329,7 @@ class AttributeListAttribute( val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -407,8 +343,10 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTargets(chargingTargetSchedules: List - ,timedInvokeTimeout: Duration) { + suspend fun setTargets( + chargingTargetSchedules: List, + timedInvokeTimeout: Duration + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -416,10 +354,10 @@ class AttributeListAttribute( val TAG_CHARGING_TARGET_SCHEDULES_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_CHARGING_TARGET_SCHEDULES_REQ)) - for (item in chargingTargetSchedules.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in chargingTargetSchedules.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -437,7 +375,7 @@ class AttributeListAttribute( val commandId: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -454,45 +392,38 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_CHARGING_TARGET_SCHEDULES: Int = 0 var chargingTargetSchedules_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_CHARGING_TARGET_SCHEDULES)) {chargingTargetSchedules_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyEvseClusterChargingTargetScheduleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }} - - - else { + if (tag == ContextSpecificTag(TAG_CHARGING_TARGET_SCHEDULES)) { + chargingTargetSchedules_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyEvseClusterChargingTargetScheduleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - if (chargingTargetSchedules_decoded == null) { - throw IllegalStateException("chargingTargetSchedules not found in TLV") + throw IllegalStateException("chargingTargetSchedules not found in TLV") } - tlvReader.exitContainer() - return GetTargetsResponse( - chargingTargetSchedules_decoded - ) + return GetTargetsResponse(chargingTargetSchedules_decoded) } suspend fun clearTargets(timedInvokeTimeout: Duration) { val commandId: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -505,46 +436,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readStateAttribute(): StateAttribute {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStateAttribute(): StateAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in response" - } + } + + requireNotNull(attributeData) { "State attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return StateAttribute(decodedValue) } @@ -554,92 +479,85 @@ suspend fun readStateAttribute(): StateAttribute {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "State attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(StateAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupplyStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSupplyStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supplystate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supplystate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -648,35 +566,37 @@ suspend fun readSupplyStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supplystate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Supplystate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -688,44 +608,37 @@ suspend fun readSupplyStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFaultStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFaultStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Faultstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Faultstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -734,35 +647,37 @@ suspend fun readFaultStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Faultstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Faultstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -774,48 +689,42 @@ suspend fun readFaultStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChargingEnabledUntilAttribute(): ChargingEnabledUntilAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readChargingEnabledUntilAttribute(): ChargingEnabledUntilAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Chargingenableduntil attribute not found in response" - } + } + + requireNotNull(attributeData) { "Chargingenableduntil attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ChargingEnabledUntilAttribute(decodedValue) } @@ -825,100 +734,96 @@ suspend fun readChargingEnabledUntilAttribute(): ChargingEnabledUntilAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ChargingEnabledUntilAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ChargingEnabledUntilAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Chargingenableduntil attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Chargingenableduntil attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(ChargingEnabledUntilAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ChargingEnabledUntilAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ChargingEnabledUntilAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDischargingEnabledUntilAttribute(): DischargingEnabledUntilAttribute {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDischargingEnabledUntilAttribute(): DischargingEnabledUntilAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dischargingenableduntil attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dischargingenableduntil attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DischargingEnabledUntilAttribute(decodedValue) } @@ -928,96 +833,91 @@ suspend fun readDischargingEnabledUntilAttribute(): DischargingEnabledUntilAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DischargingEnabledUntilAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DischargingEnabledUntilAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dischargingenableduntil attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dischargingenableduntil attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DischargingEnabledUntilAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DischargingEnabledUntilAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DischargingEnabledUntilAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCircuitCapacityAttribute(): Long {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCircuitCapacityAttribute(): Long { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Circuitcapacity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Circuitcapacity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } @@ -1026,34 +926,38 @@ suspend fun readCircuitCapacityAttribute(): Long {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Circuitcapacity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Circuitcapacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1066,44 +970,37 @@ suspend fun readCircuitCapacityAttribute(): Long {val ATTRIBUTE_ID: UInt = 5u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinimumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinimumChargeCurrentAttribute(): Long { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minimumchargecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minimumchargecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } @@ -1112,34 +1009,38 @@ suspend fun readMinimumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minimumchargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minimumchargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1152,44 +1053,37 @@ suspend fun readMinimumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaximumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaximumChargeCurrentAttribute(): Long { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maximumchargecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maximumchargecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } @@ -1198,34 +1092,38 @@ suspend fun readMaximumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maximumchargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maximumchargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1238,47 +1136,41 @@ suspend fun readMaximumChargeCurrentAttribute(): Long {val ATTRIBUTE_ID: UInt = emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaximumDischargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaximumDischargeCurrentAttribute(): Long? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maximumdischargecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maximumdischargecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - + val decodedValue: Long? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } return decodedValue } @@ -1288,118 +1180,113 @@ suspend fun readMaximumDischargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maximumdischargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maximumdischargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } + val decodedValue: Long? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(LongSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUserMaximumChargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUserMaximumChargeCurrentAttribute(): Long? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Usermaximumchargecurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Usermaximumchargecurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - + val decodedValue: Long? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUserMaximumChargeCurrentAttribute( value: Long, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1421,7 +1308,7 @@ suspend fun readUserMaximumChargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUserMaximumChargeCurrentAttribute( @@ -1429,118 +1316,113 @@ suspend fun readUserMaximumChargeCurrentAttribute(): Long? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Usermaximumchargecurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Usermaximumchargecurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } + val decodedValue: Long? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(LongSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRandomizationDelayWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRandomizationDelayWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Randomizationdelaywindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Randomizationdelaywindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeRandomizationDelayWindowAttribute( value: UInt, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1562,7 +1444,7 @@ suspend fun readRandomizationDelayWindowAttribute(): UInt? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRandomizationDelayWindowAttribute( @@ -1570,99 +1452,95 @@ suspend fun readRandomizationDelayWindowAttribute(): UInt? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Randomizationdelaywindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Randomizationdelaywindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNextChargeStartTimeAttribute(): NextChargeStartTimeAttribute {val ATTRIBUTE_ID: UInt = 35u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNextChargeStartTimeAttribute(): NextChargeStartTimeAttribute { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargestarttime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nextchargestarttime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return NextChargeStartTimeAttribute(decodedValue) } @@ -1672,104 +1550,100 @@ suspend fun readNextChargeStartTimeAttribute(): NextChargeStartTimeAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NextChargeStartTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NextChargeStartTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargestarttime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nextchargestarttime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(NextChargeStartTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NextChargeStartTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeStartTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNextChargeTargetTimeAttribute(): NextChargeTargetTimeAttribute {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNextChargeTargetTimeAttribute(): NextChargeTargetTimeAttribute { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargetargettime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nextchargetargettime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return NextChargeTargetTimeAttribute(decodedValue) } @@ -1779,104 +1653,100 @@ suspend fun readNextChargeTargetTimeAttribute(): NextChargeTargetTimeAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NextChargeTargetTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NextChargeTargetTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargetargettime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nextchargetargettime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(NextChargeTargetTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NextChargeTargetTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeTargetTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNextChargeRequiredEnergyAttribute(): NextChargeRequiredEnergyAttribute {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNextChargeRequiredEnergyAttribute(): NextChargeRequiredEnergyAttribute { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargerequiredenergy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nextchargerequiredenergy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return NextChargeRequiredEnergyAttribute(decodedValue) } @@ -1886,104 +1756,100 @@ suspend fun readNextChargeRequiredEnergyAttribute(): NextChargeRequiredEnergyAtt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NextChargeRequiredEnergyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NextChargeRequiredEnergyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargerequiredenergy attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nextchargerequiredenergy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(NextChargeRequiredEnergyAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NextChargeRequiredEnergyAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeRequiredEnergyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNextChargeTargetSoCAttribute(): NextChargeTargetSoCAttribute {val ATTRIBUTE_ID: UInt = 38u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNextChargeTargetSoCAttribute(): NextChargeTargetSoCAttribute { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargetargetsoc attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nextchargetargetsoc attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return NextChargeTargetSoCAttribute(decodedValue) } @@ -1993,128 +1859,123 @@ suspend fun readNextChargeTargetSoCAttribute(): NextChargeTargetSoCAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NextChargeTargetSoCAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NextChargeTargetSoCAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nextchargetargetsoc attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nextchargetargetsoc attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(NextChargeTargetSoCAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(NextChargeTargetSoCAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NextChargeTargetSoCAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttribute {val ATTRIBUTE_ID: UInt = 39u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttribute { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Approximateevefficiency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Approximateevefficiency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ApproximateEVEfficiencyAttribute(decodedValue) } suspend fun writeApproximateEVEfficiencyAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 39u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2136,7 +1997,7 @@ suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttri throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeApproximateEVEfficiencyAttribute( @@ -2144,104 +2005,100 @@ suspend fun readApproximateEVEfficiencyAttribute(): ApproximateEVEfficiencyAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ApproximateEVEfficiencyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ApproximateEVEfficiencyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Approximateevefficiency attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Approximateevefficiency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ApproximateEVEfficiencyAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ApproximateEVEfficiencyAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ApproximateEVEfficiencyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStateOfChargeAttribute(): StateOfChargeAttribute {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStateOfChargeAttribute(): StateOfChargeAttribute { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Stateofcharge attribute not found in response" - } + } + + requireNotNull(attributeData) { "Stateofcharge attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StateOfChargeAttribute(decodedValue) } @@ -2251,104 +2108,98 @@ suspend fun readStateOfChargeAttribute(): StateOfChargeAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StateOfChargeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StateOfChargeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Stateofcharge attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Stateofcharge attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StateOfChargeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StateOfChargeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StateOfChargeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatteryCapacityAttribute(): BatteryCapacityAttribute {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatteryCapacityAttribute(): BatteryCapacityAttribute { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batterycapacity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batterycapacity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatteryCapacityAttribute(decodedValue) } @@ -2358,104 +2209,100 @@ suspend fun readBatteryCapacityAttribute(): BatteryCapacityAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatteryCapacityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatteryCapacityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batterycapacity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batterycapacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatteryCapacityAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatteryCapacityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatteryCapacityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVehicleIDAttribute(): VehicleIDAttribute {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readVehicleIDAttribute(): VehicleIDAttribute { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vehicleid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vehicleid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return VehicleIDAttribute(decodedValue) } @@ -2465,100 +2312,94 @@ suspend fun readVehicleIDAttribute(): VehicleIDAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(VehicleIDAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + VehicleIDAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vehicleid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vehicleid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(VehicleIDAttributeSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(VehicleIDAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(VehicleIDAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSessionIDAttribute(): SessionIDAttribute {val ATTRIBUTE_ID: UInt = 64u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSessionIDAttribute(): SessionIDAttribute { + val ATTRIBUTE_ID: UInt = 64u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sessionid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SessionIDAttribute(decodedValue) } @@ -2568,96 +2409,90 @@ suspend fun readSessionIDAttribute(): SessionIDAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 64u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SessionIDAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SessionIDAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Sessionid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(SessionIDAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(SessionIDAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SessionIDAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSessionDurationAttribute(): SessionDurationAttribute {val ATTRIBUTE_ID: UInt = 65u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSessionDurationAttribute(): SessionDurationAttribute { + val ATTRIBUTE_ID: UInt = 65u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sessionduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SessionDurationAttribute(decodedValue) } @@ -2667,96 +2502,92 @@ suspend fun readSessionDurationAttribute(): SessionDurationAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SessionDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SessionDurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Sessionduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(SessionDurationAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(SessionDurationAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SessionDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSessionEnergyChargedAttribute(): SessionEnergyChargedAttribute {val ATTRIBUTE_ID: UInt = 66u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSessionEnergyChargedAttribute(): SessionEnergyChargedAttribute { + val ATTRIBUTE_ID: UInt = 66u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionenergycharged attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sessionenergycharged attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SessionEnergyChargedAttribute(decodedValue) } @@ -2766,100 +2597,96 @@ suspend fun readSessionEnergyChargedAttribute(): SessionEnergyChargedAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 66u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SessionEnergyChargedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SessionEnergyChargedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionenergycharged attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Sessionenergycharged attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(SessionEnergyChargedAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(SessionEnergyChargedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SessionEnergyChargedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSessionEnergyDischargedAttribute(): SessionEnergyDischargedAttribute {val ATTRIBUTE_ID: UInt = 67u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSessionEnergyDischargedAttribute(): SessionEnergyDischargedAttribute { + val ATTRIBUTE_ID: UInt = 67u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionenergydischarged attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sessionenergydischarged attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SessionEnergyDischargedAttribute(decodedValue) } @@ -2869,101 +2696,97 @@ suspend fun readSessionEnergyDischargedAttribute(): SessionEnergyDischargedAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 67u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SessionEnergyDischargedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SessionEnergyDischargedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sessionenergydischarged attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Sessionenergydischarged attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getLong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SessionEnergyDischargedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getLong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SessionEnergyDischargedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SessionEnergyDischargedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2973,45 +2796,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3019,49 +2847,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -3071,45 +2893,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3117,49 +2944,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -3169,45 +2990,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -3215,49 +3039,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -3267,45 +3085,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -3313,44 +3134,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -3359,35 +3173,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3399,44 +3215,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -3445,34 +3254,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3485,7 +3298,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt index 0ac2734058b8eb..8030bbd3cf96d0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EnergyPreferenceCluster.kt @@ -17,184 +17,143 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyPreferenceCluster(private val controller: MatterController, private val endpointId: UShort) {class EnergyBalancesAttribute( - val value: List? - ) +class EnergyPreferenceCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class EnergyBalancesAttribute(val value: List?) sealed class EnergyBalancesAttributeSubscriptionState { - data class Success( - val value: List? - ) : EnergyBalancesAttributeSubscriptionState() - + data class Success(val value: List?) : + EnergyBalancesAttributeSubscriptionState() + data class Error(val exception: Exception) : EnergyBalancesAttributeSubscriptionState() - object SubscriptionEstablished : EnergyBalancesAttributeSubscriptionState() - } -class EnergyPrioritiesAttribute( - val value: List? - ) + object SubscriptionEstablished : EnergyBalancesAttributeSubscriptionState() + } + + class EnergyPrioritiesAttribute(val value: List?) sealed class EnergyPrioritiesAttributeSubscriptionState { - data class Success( - val value: List? - ) : EnergyPrioritiesAttributeSubscriptionState() - + data class Success(val value: List?) : EnergyPrioritiesAttributeSubscriptionState() + data class Error(val exception: Exception) : EnergyPrioritiesAttributeSubscriptionState() - object SubscriptionEstablished : EnergyPrioritiesAttributeSubscriptionState() - } -class LowPowerModeSensitivitiesAttribute( - val value: List? - ) + object SubscriptionEstablished : EnergyPrioritiesAttributeSubscriptionState() + } + + class LowPowerModeSensitivitiesAttribute(val value: List?) sealed class LowPowerModeSensitivitiesAttributeSubscriptionState { - data class Success( - val value: List? - ) : LowPowerModeSensitivitiesAttributeSubscriptionState() - - data class Error(val exception: Exception) : LowPowerModeSensitivitiesAttributeSubscriptionState() - - object SubscriptionEstablished : LowPowerModeSensitivitiesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List?) : + LowPowerModeSensitivitiesAttributeSubscriptionState() + + data class Error(val exception: Exception) : + LowPowerModeSensitivitiesAttributeSubscriptionState() + + object SubscriptionEstablished : LowPowerModeSensitivitiesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readEnergyBalancesAttribute(): EnergyBalancesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readEnergyBalancesAttribute(): EnergyBalancesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Energybalances attribute not found in response" - } + } + + requireNotNull(attributeData) { "Energybalances attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return EnergyBalancesAttribute(decodedValue) } @@ -204,124 +163,119 @@ suspend fun readEnergyBalancesAttribute(): EnergyBalancesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EnergyBalancesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EnergyBalancesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Energybalances attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Energybalances attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(EnergyBalancesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(EnergyBalancesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(EnergyBalancesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentEnergyBalanceAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentEnergyBalanceAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentenergybalance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentenergybalance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeCurrentEnergyBalanceAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -343,7 +297,7 @@ suspend fun readCurrentEnergyBalanceAttribute(): UByte? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCurrentEnergyBalanceAttribute( @@ -351,100 +305,96 @@ suspend fun readCurrentEnergyBalanceAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentenergybalance attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentenergybalance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnergyPrioritiesAttribute(): EnergyPrioritiesAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEnergyPrioritiesAttribute(): EnergyPrioritiesAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Energypriorities attribute not found in response" - } + } + + requireNotNull(attributeData) { "Energypriorities attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return EnergyPrioritiesAttribute(decodedValue) } @@ -454,106 +404,102 @@ suspend fun readEnergyPrioritiesAttribute(): EnergyPrioritiesAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EnergyPrioritiesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EnergyPrioritiesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Energypriorities attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Energypriorities attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(EnergyPrioritiesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(EnergyPrioritiesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(EnergyPrioritiesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLowPowerModeSensitivitiesAttribute(): LowPowerModeSensitivitiesAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLowPowerModeSensitivitiesAttribute(): LowPowerModeSensitivitiesAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lowpowermodesensitivities attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lowpowermodesensitivities attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return LowPowerModeSensitivitiesAttribute(decodedValue) } @@ -563,124 +509,123 @@ suspend fun readLowPowerModeSensitivitiesAttribute(): LowPowerModeSensitivitiesA maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LowPowerModeSensitivitiesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LowPowerModeSensitivitiesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lowpowermodesensitivities attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lowpowermodesensitivities attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(EnergyPreferenceClusterBalanceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { emit(LowPowerModeSensitivitiesAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(LowPowerModeSensitivitiesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentLowPowerModeSensitivityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentLowPowerModeSensitivityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlowpowermodesensitivity attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentlowpowermodesensitivity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeCurrentLowPowerModeSensitivityAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -702,7 +647,7 @@ suspend fun readCurrentLowPowerModeSensitivityAttribute(): UByte? {val ATTRIBUTE throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCurrentLowPowerModeSensitivityAttribute( @@ -710,96 +655,92 @@ suspend fun readCurrentLowPowerModeSensitivityAttribute(): UByte? {val ATTRIBUTE maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlowpowermodesensitivity attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentlowpowermodesensitivity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -809,45 +750,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -855,49 +801,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -907,45 +847,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -953,49 +898,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1005,45 +944,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1051,49 +993,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1103,45 +1039,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1149,44 +1088,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1195,35 +1127,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1235,44 +1169,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1281,34 +1208,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1321,7 +1252,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt index 296db7e7974d5b..42447fc0dc649a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/EthernetNetworkDiagnosticsCluster.kt @@ -17,145 +17,107 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EthernetNetworkDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class PHYRateAttribute( - val value: UByte? - ) +class EthernetNetworkDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class PHYRateAttribute(val value: UByte?) sealed class PHYRateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : PHYRateAttributeSubscriptionState() - + data class Success(val value: UByte?) : PHYRateAttributeSubscriptionState() + data class Error(val exception: Exception) : PHYRateAttributeSubscriptionState() - object SubscriptionEstablished : PHYRateAttributeSubscriptionState() - } -class FullDuplexAttribute( - val value: Boolean? - ) + object SubscriptionEstablished : PHYRateAttributeSubscriptionState() + } + + class FullDuplexAttribute(val value: Boolean?) sealed class FullDuplexAttributeSubscriptionState { - data class Success( - val value: Boolean? - ) : FullDuplexAttributeSubscriptionState() - + data class Success(val value: Boolean?) : FullDuplexAttributeSubscriptionState() + data class Error(val exception: Exception) : FullDuplexAttributeSubscriptionState() - object SubscriptionEstablished : FullDuplexAttributeSubscriptionState() - } -class CarrierDetectAttribute( - val value: Boolean? - ) + object SubscriptionEstablished : FullDuplexAttributeSubscriptionState() + } + + class CarrierDetectAttribute(val value: Boolean?) sealed class CarrierDetectAttributeSubscriptionState { - data class Success( - val value: Boolean? - ) : CarrierDetectAttributeSubscriptionState() - + data class Success(val value: Boolean?) : CarrierDetectAttributeSubscriptionState() + data class Error(val exception: Exception) : CarrierDetectAttributeSubscriptionState() - object SubscriptionEstablished : CarrierDetectAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : CarrierDetectAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCounts(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -168,50 +130,44 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readPHYRateAttribute(): PHYRateAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPHYRateAttribute(): PHYRateAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phyrate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Phyrate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PHYRateAttribute(decodedValue) } @@ -221,104 +177,98 @@ suspend fun readPHYRateAttribute(): PHYRateAttribute {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PHYRateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PHYRateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phyrate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Phyrate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PHYRateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PHYRateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PHYRateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFullDuplexAttribute(): FullDuplexAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFullDuplexAttribute(): FullDuplexAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fullduplex attribute not found in response" - } + } + + requireNotNull(attributeData) { "Fullduplex attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return FullDuplexAttribute(decodedValue) } @@ -328,99 +278,93 @@ suspend fun readFullDuplexAttribute(): FullDuplexAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FullDuplexAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FullDuplexAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fullduplex attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Fullduplex attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(FullDuplexAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(FullDuplexAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FullDuplexAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketRxCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketRxCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetrxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packetrxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -430,94 +374,88 @@ suspend fun readPacketRxCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetrxcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Packetrxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketTxCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketTxCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packettxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packettxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -527,94 +465,88 @@ suspend fun readPacketTxCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packettxcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Packettxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxErrCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTxErrCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txerrcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -624,94 +556,88 @@ suspend fun readTxErrCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txerrcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCollisionCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCollisionCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Collisioncount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Collisioncount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -721,94 +647,90 @@ suspend fun readCollisionCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Collisioncount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Collisioncount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOverrunCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOverrunCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Overruncount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -818,99 +740,93 @@ suspend fun readOverrunCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Overruncount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCarrierDetectAttribute(): CarrierDetectAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCarrierDetectAttribute(): CarrierDetectAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Carrierdetect attribute not found in response" - } + } + + requireNotNull(attributeData) { "Carrierdetect attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CarrierDetectAttribute(decodedValue) } @@ -920,99 +836,93 @@ suspend fun readCarrierDetectAttribute(): CarrierDetectAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CarrierDetectAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CarrierDetectAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Carrierdetect attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Carrierdetect attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CarrierDetectAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CarrierDetectAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CarrierDetectAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeSinceResetAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeSinceResetAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timesincereset attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timesincereset attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -1022,96 +932,92 @@ suspend fun readTimeSinceResetAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timesincereset attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Timesincereset attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1121,45 +1027,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1167,49 +1078,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1219,45 +1124,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1265,49 +1175,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1317,45 +1221,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1363,49 +1270,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1415,45 +1316,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1461,44 +1365,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1507,35 +1404,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1547,44 +1446,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1593,34 +1485,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1633,7 +1529,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt index 6d0e58a6d5b9b2..12baa895406dac 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FanControlCluster.kt @@ -17,131 +17,99 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class FanControlCluster(private val controller: MatterController, private val endpointId: UShort) {class PercentSettingAttribute( - val value: UByte? - ) +class FanControlCluster(private val controller: MatterController, private val endpointId: UShort) { + class PercentSettingAttribute(val value: UByte?) sealed class PercentSettingAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : PercentSettingAttributeSubscriptionState() - + data class Success(val value: UByte?) : PercentSettingAttributeSubscriptionState() + data class Error(val exception: Exception) : PercentSettingAttributeSubscriptionState() - object SubscriptionEstablished : PercentSettingAttributeSubscriptionState() - } -class SpeedSettingAttribute( - val value: UByte? - ) + object SubscriptionEstablished : PercentSettingAttributeSubscriptionState() + } + + class SpeedSettingAttribute(val value: UByte?) sealed class SpeedSettingAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : SpeedSettingAttributeSubscriptionState() - + data class Success(val value: UByte?) : SpeedSettingAttributeSubscriptionState() + data class Error(val exception: Exception) : SpeedSettingAttributeSubscriptionState() - object SubscriptionEstablished : SpeedSettingAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SpeedSettingAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun step(direction: UByte - ,wrap: Boolean? - ,lowestOff: Boolean? - ,timedInvokeTimeout: Duration? = null) { + suspend fun step( + direction: UByte, + wrap: Boolean?, + lowestOff: Boolean?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -151,14 +119,10 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_DIRECTION_REQ), direction) val TAG_WRAP_REQ: Int = 1 - wrap?.let { - tlvWriter.put(ContextSpecificTag(TAG_WRAP_REQ), wrap) - } + wrap?.let { tlvWriter.put(ContextSpecificTag(TAG_WRAP_REQ), wrap) } val TAG_LOWEST_OFF_REQ: Int = 2 - lowestOff?.let { - tlvWriter.put(ContextSpecificTag(TAG_LOWEST_OFF_REQ), lowestOff) - } + lowestOff?.let { tlvWriter.put(ContextSpecificTag(TAG_LOWEST_OFF_REQ), lowestOff) } tlvWriter.endStructure() val request: InvokeRequest = @@ -171,65 +135,54 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readFanModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFanModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fanmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Fanmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeFanModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeFanModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -251,7 +204,7 @@ suspend fun readFanModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFanModeAttribute( @@ -259,35 +212,37 @@ suspend fun readFanModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fanmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Fanmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -299,44 +254,37 @@ suspend fun readFanModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFanModeSequenceAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFanModeSequenceAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fanmodesequence attribute not found in response" - } + } + + requireNotNull(attributeData) { "Fanmodesequence attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -345,34 +293,38 @@ suspend fun readFanModeSequenceAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fanmodesequence attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Fanmodesequence attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -385,72 +337,62 @@ suspend fun readFanModeSequenceAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPercentSettingAttribute(): PercentSettingAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPercentSettingAttribute(): PercentSettingAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Percentsetting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Percentsetting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return PercentSettingAttribute(decodedValue) } - suspend fun writePercentSettingAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writePercentSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -472,7 +414,7 @@ suspend fun readPercentSettingAttribute(): PercentSettingAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePercentSettingAttribute( @@ -480,92 +422,87 @@ suspend fun readPercentSettingAttribute(): PercentSettingAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PercentSettingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PercentSettingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Percentsetting attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Percentsetting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PercentSettingAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PercentSettingAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PercentSettingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPercentCurrentAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPercentCurrentAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Percentcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Percentcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -574,34 +511,38 @@ suspend fun readPercentCurrentAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Percentcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Percentcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -614,47 +555,41 @@ suspend fun readPercentCurrentAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpeedMaxAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSpeedMaxAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Speedmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -664,123 +599,113 @@ suspend fun readSpeedMaxAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedmax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Speedmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedsetting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Speedsetting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SpeedSettingAttribute(decodedValue) } - suspend fun writeSpeedSettingAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeSpeedSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -802,7 +727,7 @@ suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute {val ATTRIBUTE_ID throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSpeedSettingAttribute( @@ -810,99 +735,93 @@ suspend fun readSpeedSettingAttribute(): SpeedSettingAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SpeedSettingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SpeedSettingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedsetting attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Speedsetting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SpeedSettingAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SpeedSettingAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SpeedSettingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpeedCurrentAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSpeedCurrentAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Speedcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -912,94 +831,88 @@ suspend fun readSpeedCurrentAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speedcurrent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Speedcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRockSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRockSupportAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rocksupport attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rocksupport attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1009,118 +922,108 @@ suspend fun readRockSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rocksupport attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rocksupport attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRockSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRockSettingAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rocksetting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rocksetting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeRockSettingAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeRockSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1142,7 +1045,7 @@ suspend fun readRockSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRockSettingAttribute( @@ -1150,94 +1053,88 @@ suspend fun readRockSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rocksetting attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rocksetting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWindSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readWindSupportAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windsupport attribute not found in response" - } + } + + requireNotNull(attributeData) { "Windsupport attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1247,118 +1144,108 @@ suspend fun readWindSupportAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windsupport attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Windsupport attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWindSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readWindSettingAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windsetting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Windsetting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeWindSettingAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeWindSettingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1380,7 +1267,7 @@ suspend fun readWindSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWindSettingAttribute( @@ -1388,118 +1275,108 @@ suspend fun readWindSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Windsetting attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Windsetting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAirflowDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAirflowDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Airflowdirection attribute not found in response" - } + } + + requireNotNull(attributeData) { "Airflowdirection attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeAirflowDirectionAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeAirflowDirectionAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 11u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1521,7 +1398,7 @@ suspend fun readAirflowDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeAirflowDirectionAttribute( @@ -1529,96 +1406,92 @@ suspend fun readAirflowDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Airflowdirection attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Airflowdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1628,45 +1501,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1674,49 +1552,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1726,45 +1598,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1772,49 +1649,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1824,45 +1695,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1870,49 +1744,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1922,45 +1790,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1968,44 +1839,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2014,35 +1878,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2054,44 +1920,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2100,34 +1959,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2140,7 +2003,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt index cd6627c787c57a..5597bfd94af98a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FaultInjectionCluster.kt @@ -17,107 +17,80 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class FaultInjectionCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class FaultInjectionCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun failAtFault(type: UByte - ,id: UInt - ,numCallsToSkip: UInt - ,numCallsToFail: UInt - ,takeMutex: Boolean - ,timedInvokeTimeout: Duration? = null) { + suspend fun failAtFault( + type: UByte, + id: UInt, + numCallsToSkip: UInt, + numCallsToFail: UInt, + takeMutex: Boolean, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -136,7 +109,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_NUM_CALLS_TO_FAIL_REQ), numCallsToFail) val TAG_TAKE_MUTEX_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_TAKE_MUTEX_REQ), takeMutex) + tlvWriter.put(ContextSpecificTag(TAG_TAKE_MUTEX_REQ), takeMutex) tlvWriter.endStructure() val request: InvokeRequest = @@ -150,10 +123,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun failRandomlyAtFault(type: UByte - ,id: UInt - ,percentage: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun failRandomlyAtFault( + type: UByte, + id: UInt, + percentage: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -166,7 +141,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ID_REQ), id) val TAG_PERCENTAGE_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_PERCENTAGE_REQ), percentage) + tlvWriter.put(ContextSpecificTag(TAG_PERCENTAGE_REQ), percentage) tlvWriter.endStructure() val request: InvokeRequest = @@ -179,47 +154,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -229,45 +198,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -275,49 +249,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -327,45 +295,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -373,49 +346,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -425,45 +392,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -471,49 +441,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -523,45 +487,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -569,44 +536,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -615,35 +575,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -655,44 +617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -701,34 +656,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -741,7 +700,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt index f36bab66f10935..4fe3dd45c9ccd6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FixedLabelCluster.kt @@ -17,154 +17,109 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class FixedLabelCluster(private val controller: MatterController, private val endpointId: UShort) {class LabelListAttribute( - val value: List - ) +class FixedLabelCluster(private val controller: MatterController, private val endpointId: UShort) { + class LabelListAttribute(val value: List) sealed class LabelListAttributeSubscriptionState { - data class Success( - val value: List - ) : LabelListAttributeSubscriptionState() - + data class Success(val value: List) : + LabelListAttributeSubscriptionState() + data class Error(val exception: Exception) : LabelListAttributeSubscriptionState() - object SubscriptionEstablished : LabelListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LabelListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readLabelListAttribute(): LabelListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Labellist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Labellist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return LabelListAttribute(decodedValue) } @@ -174,45 +129,48 @@ suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LabelListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LabelListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Labellist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Labellist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(FixedLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(LabelListAttributeSubscriptionState.Success(decodedValue)) } @@ -220,49 +178,43 @@ suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt emit(LabelListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -272,45 +224,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -318,49 +275,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -370,45 +321,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -416,49 +372,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -468,45 +418,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -514,49 +467,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -566,45 +513,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -612,44 +562,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -658,35 +601,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -698,44 +643,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -744,34 +682,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -784,7 +726,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt index 4987d915eb1c39..35d293bd0a4ca9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FlowMeasurementCluster.kt @@ -17,179 +17,130 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class FlowMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: UShort? - ) +class FlowMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: UShort?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: UShort?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: UShort?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -199,96 +150,90 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -298,96 +243,92 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -397,95 +338,91 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -495,96 +432,90 @@ suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -594,45 +525,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -640,49 +576,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -692,45 +622,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -738,49 +673,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -790,45 +719,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -836,49 +768,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -888,45 +814,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -934,44 +863,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -980,35 +902,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1020,44 +944,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1066,34 +983,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1106,7 +1027,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt index 472a14b09e3fea..c60f4e6484a856 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/FormaldehydeConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class FormaldehydeConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class FormaldehydeConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,11 +1742,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(FormaldehydeConcentrationMeasurementCluster::class.java.name) + private val logger = + Logger.getLogger(FormaldehydeConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1067u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt index 6427becbb270e0..f16803780a0253 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralCommissioningCluster.kt @@ -17,132 +17,102 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralCommissioningCluster(private val controller: MatterController, private val endpointId: UShort) { - class ArmFailSafeResponse( - val errorCode: UByte, - val debugText: String - ) +class GeneralCommissioningCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ArmFailSafeResponse(val errorCode: UByte, val debugText: String) - class SetRegulatoryConfigResponse( - val errorCode: UByte, - val debugText: String - ) + class SetRegulatoryConfigResponse(val errorCode: UByte, val debugText: String) - class CommissioningCompleteResponse( - val errorCode: UByte, - val debugText: String - ) -class BasicCommissioningInfoAttribute( + class CommissioningCompleteResponse(val errorCode: UByte, val debugText: String) + + class BasicCommissioningInfoAttribute( val value: GeneralCommissioningClusterBasicCommissioningInfo ) sealed class BasicCommissioningInfoAttributeSubscriptionState { - data class Success( - val value: GeneralCommissioningClusterBasicCommissioningInfo - ) : BasicCommissioningInfoAttributeSubscriptionState() - + data class Success(val value: GeneralCommissioningClusterBasicCommissioningInfo) : + BasicCommissioningInfoAttributeSubscriptionState() + data class Error(val exception: Exception) : BasicCommissioningInfoAttributeSubscriptionState() - object SubscriptionEstablished : BasicCommissioningInfoAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : BasicCommissioningInfoAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun armFailSafe(expiryLengthSeconds: UShort - ,breadcrumb: ULong - ,timedInvokeTimeout: Duration? = null): ArmFailSafeResponse { + suspend fun armFailSafe( + expiryLengthSeconds: UShort, + breadcrumb: ULong, + timedInvokeTimeout: Duration? = null + ): ArmFailSafeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -152,7 +122,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_EXPIRY_LENGTH_SECONDS_REQ), expiryLengthSeconds) val TAG_BREADCRUMB_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) tlvWriter.endStructure() val request: InvokeRequest = @@ -169,49 +139,43 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ERROR_CODE: Int = 0 var errorCode_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ERROR_CODE)) {errorCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = tlvReader.getString(tag)} - + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { + errorCode_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (errorCode_decoded == null) { - throw IllegalStateException("errorCode not found in TLV") + throw IllegalStateException("errorCode not found in TLV") } - - + if (debugText_decoded == null) { - throw IllegalStateException("debugText not found in TLV") + throw IllegalStateException("debugText not found in TLV") } - tlvReader.exitContainer() - return ArmFailSafeResponse( - errorCode_decoded, - debugText_decoded - ) + return ArmFailSafeResponse(errorCode_decoded, debugText_decoded) } - suspend fun setRegulatoryConfig(newRegulatoryConfig: UByte - ,countryCode: String - ,breadcrumb: ULong - ,timedInvokeTimeout: Duration? = null): SetRegulatoryConfigResponse { + suspend fun setRegulatoryConfig( + newRegulatoryConfig: UByte, + countryCode: String, + breadcrumb: ULong, + timedInvokeTimeout: Duration? = null + ): SetRegulatoryConfigResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -224,7 +188,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_COUNTRY_CODE_REQ), countryCode) val TAG_BREADCRUMB_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) + tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) tlvWriter.endStructure() val request: InvokeRequest = @@ -241,50 +205,44 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ERROR_CODE: Int = 0 var errorCode_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ERROR_CODE)) {errorCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = tlvReader.getString(tag)} - + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { + errorCode_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (errorCode_decoded == null) { - throw IllegalStateException("errorCode not found in TLV") + throw IllegalStateException("errorCode not found in TLV") } - - + if (debugText_decoded == null) { - throw IllegalStateException("debugText not found in TLV") + throw IllegalStateException("debugText not found in TLV") } - tlvReader.exitContainer() - return SetRegulatoryConfigResponse( - errorCode_decoded, - debugText_decoded - ) + return SetRegulatoryConfigResponse(errorCode_decoded, debugText_decoded) } - suspend fun commissioningComplete(timedInvokeTimeout: Duration? = null): CommissioningCompleteResponse { + suspend fun commissioningComplete( + timedInvokeTimeout: Duration? = null + ): CommissioningCompleteResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -301,103 +259,84 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ERROR_CODE: Int = 0 var errorCode_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ERROR_CODE)) {errorCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = tlvReader.getString(tag)} - + if (tag == ContextSpecificTag(TAG_ERROR_CODE)) { + errorCode_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (errorCode_decoded == null) { - throw IllegalStateException("errorCode not found in TLV") + throw IllegalStateException("errorCode not found in TLV") } - - + if (debugText_decoded == null) { - throw IllegalStateException("debugText not found in TLV") + throw IllegalStateException("debugText not found in TLV") } - tlvReader.exitContainer() - return CommissioningCompleteResponse( - errorCode_decoded, - debugText_decoded - ) + return CommissioningCompleteResponse(errorCode_decoded, debugText_decoded) } -suspend fun readBreadcrumbAttribute(): ULong {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBreadcrumbAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Breadcrumb attribute not found in response" - } + } + + requireNotNull(attributeData) { "Breadcrumb attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeBreadcrumbAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeBreadcrumbAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -419,7 +358,7 @@ suspend fun readBreadcrumbAttribute(): ULong {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBreadcrumbAttribute( @@ -427,35 +366,37 @@ suspend fun readBreadcrumbAttribute(): ULong {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Breadcrumb attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Breadcrumb attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -467,43 +408,37 @@ suspend fun readBreadcrumbAttribute(): ULong {val ATTRIBUTE_ID: UInt = 0u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Basiccommissioninginfo attribute not found in response" - } + } + + requireNotNull(attributeData) { "Basiccommissioninginfo attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = + GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) return BasicCommissioningInfoAttribute(decodedValue) } @@ -513,39 +448,44 @@ suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BasicCommissioningInfoAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BasicCommissioningInfoAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Basiccommissioninginfo attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Basiccommissioninginfo attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) + val decodedValue: GeneralCommissioningClusterBasicCommissioningInfo = + GeneralCommissioningClusterBasicCommissioningInfo.fromTlv(AnonymousTag, tlvReader) emit(BasicCommissioningInfoAttributeSubscriptionState.Success(decodedValue)) } @@ -553,44 +493,37 @@ suspend fun readBasicCommissioningInfoAttribute(): BasicCommissioningInfoAttribu emit(BasicCommissioningInfoAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRegulatoryConfigAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRegulatoryConfigAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Regulatoryconfig attribute not found in response" - } + } + + requireNotNull(attributeData) { "Regulatoryconfig attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -599,34 +532,38 @@ suspend fun readRegulatoryConfigAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Regulatoryconfig attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Regulatoryconfig attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -639,44 +576,37 @@ suspend fun readRegulatoryConfigAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocationCapabilityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLocationCapabilityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Locationcapability attribute not found in response" - } + } + + requireNotNull(attributeData) { "Locationcapability attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -685,34 +615,38 @@ suspend fun readLocationCapabilityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Locationcapability attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Locationcapability attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -725,44 +659,37 @@ suspend fun readLocationCapabilityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportsConcurrentConnectionAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportsConcurrentConnectionAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportsconcurrentconnection attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportsconcurrentconnection attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -771,34 +698,38 @@ suspend fun readSupportsConcurrentConnectionAttribute(): Boolean {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportsconcurrentconnection attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportsconcurrentconnection attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -811,49 +742,43 @@ suspend fun readSupportsConcurrentConnectionAttribute(): Boolean {val ATTRIBUTE_ emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -863,45 +788,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -909,49 +839,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -961,45 +885,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1007,49 +936,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1059,45 +982,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1105,49 +1031,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1157,45 +1077,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1203,44 +1126,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1249,35 +1165,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1289,44 +1207,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1335,34 +1246,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1375,7 +1290,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt index f2e917cb082f20..cdc7a18ad10d15 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GeneralDiagnosticsCluster.kt @@ -17,161 +17,123 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) { - class TimeSnapshotResponse( - val systemTimeMs: ULong, - val posixTimeMs: ULong? - ) -class NetworkInterfacesAttribute( - val value: List - ) +class GeneralDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class TimeSnapshotResponse(val systemTimeMs: ULong, val posixTimeMs: ULong?) + + class NetworkInterfacesAttribute(val value: List) sealed class NetworkInterfacesAttributeSubscriptionState { - data class Success( - val value: List - ) : NetworkInterfacesAttributeSubscriptionState() - + data class Success(val value: List) : + NetworkInterfacesAttributeSubscriptionState() + data class Error(val exception: Exception) : NetworkInterfacesAttributeSubscriptionState() - object SubscriptionEstablished : NetworkInterfacesAttributeSubscriptionState() - } -class ActiveHardwareFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : NetworkInterfacesAttributeSubscriptionState() + } + + class ActiveHardwareFaultsAttribute(val value: List?) sealed class ActiveHardwareFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveHardwareFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveHardwareFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveHardwareFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveHardwareFaultsAttributeSubscriptionState() - } -class ActiveRadioFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : ActiveHardwareFaultsAttributeSubscriptionState() + } + + class ActiveRadioFaultsAttribute(val value: List?) sealed class ActiveRadioFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveRadioFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveRadioFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveRadioFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveRadioFaultsAttributeSubscriptionState() - } -class ActiveNetworkFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : ActiveRadioFaultsAttributeSubscriptionState() + } + + class ActiveNetworkFaultsAttribute(val value: List?) sealed class ActiveNetworkFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveNetworkFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveNetworkFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveNetworkFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveNetworkFaultsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ActiveNetworkFaultsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun testEventTrigger(enableKey: ByteArray - ,eventTrigger: ULong - ,timedInvokeTimeout: Duration? = null) { + suspend fun testEventTrigger( + enableKey: ByteArray, + eventTrigger: ULong, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -181,7 +143,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ENABLE_KEY_REQ), enableKey) val TAG_EVENT_TRIGGER_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_EVENT_TRIGGER_REQ), eventTrigger) + tlvWriter.put(ContextSpecificTag(TAG_EVENT_TRIGGER_REQ), eventTrigger) tlvWriter.endStructure() val request: InvokeRequest = @@ -199,7 +161,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -216,93 +178,78 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_SYSTEM_TIME_MS: Int = 0 var systemTimeMs_decoded: ULong? = null - + val TAG_POSIX_TIME_MS: Int = 1 var posixTimeMs_decoded: ULong? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_SYSTEM_TIME_MS)) {systemTimeMs_decoded = tlvReader.getULong(tag)} - - if (tag == ContextSpecificTag(TAG_POSIX_TIME_MS)) {posixTimeMs_decoded = + if (tag == ContextSpecificTag(TAG_SYSTEM_TIME_MS)) { + systemTimeMs_decoded = tlvReader.getULong(tag) + } + + if (tag == ContextSpecificTag(TAG_POSIX_TIME_MS)) { + posixTimeMs_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getULong(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + tlvReader.getULong(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (systemTimeMs_decoded == null) { - throw IllegalStateException("systemTimeMs not found in TLV") + throw IllegalStateException("systemTimeMs not found in TLV") } - - - tlvReader.exitContainer() - return TimeSnapshotResponse( - systemTimeMs_decoded, - posixTimeMs_decoded - ) + return TimeSnapshotResponse(systemTimeMs_decoded, posixTimeMs_decoded) } -suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networkinterfaces attribute not found in response" - } + } + + requireNotNull(attributeData) { "Networkinterfaces attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return NetworkInterfacesAttribute(decodedValue) } @@ -312,45 +259,50 @@ suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NetworkInterfacesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NetworkInterfacesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networkinterfaces attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Networkinterfaces attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GeneralDiagnosticsClusterNetworkInterface.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(NetworkInterfacesAttributeSubscriptionState.Success(decodedValue)) } @@ -358,44 +310,37 @@ suspend fun readNetworkInterfacesAttribute(): NetworkInterfacesAttribute {val AT emit(NetworkInterfacesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRebootCountAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRebootCountAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rebootcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rebootcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -404,35 +349,37 @@ suspend fun readRebootCountAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rebootcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rebootcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -444,47 +391,41 @@ suspend fun readRebootCountAttribute(): UShort {val ATTRIBUTE_ID: UInt = 1u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUpTimeAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUpTimeAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uptime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uptime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -494,94 +435,88 @@ suspend fun readUpTimeAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uptime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uptime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTotalOperationalHoursAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTotalOperationalHoursAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totaloperationalhours attribute not found in response" - } + } + + requireNotNull(attributeData) { "Totaloperationalhours attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -591,94 +526,90 @@ suspend fun readTotalOperationalHoursAttribute(): UInt? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Totaloperationalhours attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Totaloperationalhours attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBootReasonAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBootReasonAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bootreason attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bootreason attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -688,100 +619,94 @@ suspend fun readBootReasonAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bootreason attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bootreason attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveHardwareFaultsAttribute(): ActiveHardwareFaultsAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveHardwareFaultsAttribute(): ActiveHardwareFaultsAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activehardwarefaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activehardwarefaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveHardwareFaultsAttribute(decodedValue) } @@ -791,106 +716,102 @@ suspend fun readActiveHardwareFaultsAttribute(): ActiveHardwareFaultsAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveHardwareFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveHardwareFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activehardwarefaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activehardwarefaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveHardwareFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveHardwareFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveHardwareFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveRadioFaultsAttribute(): ActiveRadioFaultsAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveRadioFaultsAttribute(): ActiveRadioFaultsAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeradiofaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activeradiofaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveRadioFaultsAttribute(decodedValue) } @@ -900,106 +821,102 @@ suspend fun readActiveRadioFaultsAttribute(): ActiveRadioFaultsAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveRadioFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveRadioFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeradiofaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activeradiofaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveRadioFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveRadioFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveRadioFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveNetworkFaultsAttribute(): ActiveNetworkFaultsAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveNetworkFaultsAttribute(): ActiveNetworkFaultsAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activenetworkfaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activenetworkfaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveNetworkFaultsAttribute(decodedValue) } @@ -1009,97 +926,92 @@ suspend fun readActiveNetworkFaultsAttribute(): ActiveNetworkFaultsAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveNetworkFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveNetworkFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activenetworkfaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activenetworkfaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveNetworkFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveNetworkFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveNetworkFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTestEventTriggersEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTestEventTriggersEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Testeventtriggersenabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Testeventtriggersenabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -1108,34 +1020,38 @@ suspend fun readTestEventTriggersEnabledAttribute(): Boolean {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Testeventtriggersenabled attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Testeventtriggersenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1148,49 +1064,43 @@ suspend fun readTestEventTriggersEnabledAttribute(): Boolean {val ATTRIBUTE_ID: emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1200,45 +1110,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1246,49 +1161,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1298,45 +1207,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1344,49 +1258,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1396,45 +1304,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1442,49 +1353,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1494,45 +1399,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1540,44 +1448,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1586,35 +1487,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1626,44 +1529,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1672,34 +1568,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1712,7 +1612,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt index 975133eb203f79..7d6a660be3afb0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupKeyManagementCluster.kt @@ -17,144 +17,112 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GroupKeyManagementCluster(private val controller: MatterController, private val endpointId: UShort) { - class KeySetReadResponse( - val groupKeySet: GroupKeyManagementClusterGroupKeySetStruct - ) +class GroupKeyManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class KeySetReadResponse(val groupKeySet: GroupKeyManagementClusterGroupKeySetStruct) + + class KeySetReadAllIndicesResponse(val groupKeySetIDs: List) - class KeySetReadAllIndicesResponse( - val groupKeySetIDs: List - ) -class GroupKeyMapAttribute( - val value: List - ) + class GroupKeyMapAttribute(val value: List) sealed class GroupKeyMapAttributeSubscriptionState { - data class Success( - val value: List - ) : GroupKeyMapAttributeSubscriptionState() - + data class Success(val value: List) : + GroupKeyMapAttributeSubscriptionState() + data class Error(val exception: Exception) : GroupKeyMapAttributeSubscriptionState() - object SubscriptionEstablished : GroupKeyMapAttributeSubscriptionState() - } -class GroupTableAttribute( - val value: List - ) + object SubscriptionEstablished : GroupKeyMapAttributeSubscriptionState() + } + + class GroupTableAttribute(val value: List) sealed class GroupTableAttributeSubscriptionState { - data class Success( - val value: List - ) : GroupTableAttributeSubscriptionState() - + data class Success(val value: List) : + GroupTableAttributeSubscriptionState() + data class Error(val exception: Exception) : GroupTableAttributeSubscriptionState() - object SubscriptionEstablished : GroupTableAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GroupTableAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun keySetWrite(groupKeySet: GroupKeyManagementClusterGroupKeySetStruct - ,timedInvokeTimeout: Duration? = null) { + suspend fun keySetWrite( + groupKeySet: GroupKeyManagementClusterGroupKeySetStruct, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_KEY_SET_REQ: Int = 0 - groupKeySet.toTlv(ContextSpecificTag(TAG_GROUP_KEY_SET_REQ), tlvWriter) + groupKeySet.toTlv(ContextSpecificTag(TAG_GROUP_KEY_SET_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -168,15 +136,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun keySetRead(groupKeySetID: UShort - ,timedInvokeTimeout: Duration? = null): KeySetReadResponse { + suspend fun keySetRead( + groupKeySetID: UShort, + timedInvokeTimeout: Duration? = null + ): KeySetReadResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_KEY_SET_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) tlvWriter.endStructure() val request: InvokeRequest = @@ -193,43 +163,34 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_GROUP_KEY_SET: Int = 0 var groupKeySet_decoded: GroupKeyManagementClusterGroupKeySetStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET)) {groupKeySet_decoded = GroupKeyManagementClusterGroupKeySetStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET)) { + groupKeySet_decoded = GroupKeyManagementClusterGroupKeySetStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (groupKeySet_decoded == null) { - throw IllegalStateException("groupKeySet not found in TLV") + throw IllegalStateException("groupKeySet not found in TLV") } - tlvReader.exitContainer() - return KeySetReadResponse( - groupKeySet_decoded - ) + return KeySetReadResponse(groupKeySet_decoded) } - suspend fun keySetRemove(groupKeySetID: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun keySetRemove(groupKeySetID: UShort, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_KEY_SET_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D_REQ), groupKeySetID) tlvWriter.endStructure() val request: InvokeRequest = @@ -243,11 +204,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun keySetReadAllIndices(timedInvokeTimeout: Duration? = null): KeySetReadAllIndicesResponse { + suspend fun keySetReadAllIndices( + timedInvokeTimeout: Duration? = null + ): KeySetReadAllIndicesResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -264,108 +227,94 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_GROUP_KEY_SET_I_DS: Int = 0 var groupKeySetIDs_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET_I_DS)) {groupKeySetIDs_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - }} - - - else { + if (tag == ContextSpecificTag(TAG_GROUP_KEY_SET_I_DS)) { + groupKeySetIDs_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - if (groupKeySetIDs_decoded == null) { - throw IllegalStateException("groupKeySetIDs not found in TLV") + throw IllegalStateException("groupKeySetIDs not found in TLV") } - tlvReader.exitContainer() - return KeySetReadAllIndicesResponse( - groupKeySetIDs_decoded - ) + return KeySetReadAllIndicesResponse(groupKeySetIDs_decoded) } -suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Groupkeymap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Groupkeymap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GroupKeyMapAttribute(decodedValue) } suspend fun writeGroupKeyMapAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -387,7 +336,7 @@ suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeGroupKeyMapAttribute( @@ -395,45 +344,48 @@ suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GroupKeyMapAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GroupKeyMapAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Groupkeymap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Groupkeymap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupKeyMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(GroupKeyMapAttributeSubscriptionState.Success(decodedValue)) } @@ -441,49 +393,43 @@ suspend fun readGroupKeyMapAttribute(): GroupKeyMapAttribute {val ATTRIBUTE_ID: emit(GroupKeyMapAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGroupTableAttribute(): GroupTableAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGroupTableAttribute(): GroupTableAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Grouptable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Grouptable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GroupTableAttribute(decodedValue) } @@ -493,45 +439,48 @@ suspend fun readGroupTableAttribute(): GroupTableAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GroupTableAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GroupTableAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Grouptable attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Grouptable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(GroupKeyManagementClusterGroupInfoMapStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(GroupTableAttributeSubscriptionState.Success(decodedValue)) } @@ -539,44 +488,37 @@ suspend fun readGroupTableAttribute(): GroupTableAttribute {val ATTRIBUTE_ID: UI emit(GroupTableAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxGroupsPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxGroupsPerFabricAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxgroupsperfabric attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxgroupsperfabric attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -585,34 +527,38 @@ suspend fun readMaxGroupsPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxgroupsperfabric attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxgroupsperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -625,44 +571,37 @@ suspend fun readMaxGroupsPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxGroupKeysPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxGroupKeysPerFabricAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxgroupkeysperfabric attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxgroupkeysperfabric attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -671,34 +610,38 @@ suspend fun readMaxGroupKeysPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxgroupkeysperfabric attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxgroupkeysperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -711,49 +654,43 @@ suspend fun readMaxGroupKeysPerFabricAttribute(): UShort {val ATTRIBUTE_ID: UInt emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -763,45 +700,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -809,49 +751,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -861,45 +797,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -907,49 +848,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -959,45 +894,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1005,49 +943,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1057,45 +989,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1103,44 +1038,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1149,35 +1077,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1189,44 +1119,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1235,34 +1158,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1275,7 +1202,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt index 3236b70b54bf79..ca466afbdd0f61 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/GroupsCluster.kt @@ -17,125 +17,83 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class GroupsCluster(private val controller: MatterController, private val endpointId: UShort) { - class AddGroupResponse( - val status: UByte, - val groupID: UShort - ) - - class ViewGroupResponse( - val status: UByte, - val groupID: UShort, - val groupName: String - ) - - class GetGroupMembershipResponse( - val capacity: UByte?, - val groupList: List - ) - - class RemoveGroupResponse( - val status: UByte, - val groupID: UShort - ) -class GeneratedCommandListAttribute( - val value: List - ) + class AddGroupResponse(val status: UByte, val groupID: UShort) + + class ViewGroupResponse(val status: UByte, val groupID: UShort, val groupName: String) + + class GetGroupMembershipResponse(val capacity: UByte?, val groupList: List) + + class RemoveGroupResponse(val status: UByte, val groupID: UShort) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun addGroup(groupID: UShort - ,groupName: String - ,timedInvokeTimeout: Duration? = null): AddGroupResponse { + suspend fun addGroup( + groupID: UShort, + groupName: String, + timedInvokeTimeout: Duration? = null + ): AddGroupResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -145,7 +103,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_GROUP_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) tlvWriter.endStructure() val request: InvokeRequest = @@ -162,54 +120,45 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - tlvReader.exitContainer() - return AddGroupResponse( - status_decoded, - groupID_decoded - ) + return AddGroupResponse(status_decoded, groupID_decoded) } - suspend fun viewGroup(groupID: UShort - ,timedInvokeTimeout: Duration? = null): ViewGroupResponse { + suspend fun viewGroup(groupID: UShort, timedInvokeTimeout: Duration? = null): ViewGroupResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -226,58 +175,52 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_GROUP_NAME: Int = 2 var groupName_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_NAME)) {groupName_decoded = tlvReader.getString(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_NAME)) { + groupName_decoded = tlvReader.getString(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (groupName_decoded == null) { - throw IllegalStateException("groupName not found in TLV") + throw IllegalStateException("groupName not found in TLV") } - tlvReader.exitContainer() - return ViewGroupResponse( - status_decoded, - groupID_decoded, - groupName_decoded - ) + return ViewGroupResponse(status_decoded, groupID_decoded, groupName_decoded) } - suspend fun getGroupMembership(groupList: List - ,timedInvokeTimeout: Duration? = null): GetGroupMembershipResponse { + suspend fun getGroupMembership( + groupList: List, + timedInvokeTimeout: Duration? = null + ): GetGroupMembershipResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -285,10 +228,10 @@ class AttributeListAttribute( val TAG_GROUP_LIST_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_GROUP_LIST_REQ)) - for (item in groupList.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in groupList.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -305,68 +248,62 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_CAPACITY: Int = 0 var capacity_decoded: UByte? = null - + val TAG_GROUP_LIST: Int = 1 var groupList_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_CAPACITY)) {capacity_decoded = + if (tag == ContextSpecificTag(TAG_CAPACITY)) { + capacity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_GROUP_LIST)) {groupList_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } } - tlvReader.exitContainer() - }} - - else { + if (tag == ContextSpecificTag(TAG_GROUP_LIST)) { + groupList_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - - - if (groupList_decoded == null) { - throw IllegalStateException("groupList not found in TLV") + throw IllegalStateException("groupList not found in TLV") } - tlvReader.exitContainer() - return GetGroupMembershipResponse( - capacity_decoded, - groupList_decoded - ) + return GetGroupMembershipResponse(capacity_decoded, groupList_decoded) } - suspend fun removeGroup(groupID: UShort - ,timedInvokeTimeout: Duration? = null): RemoveGroupResponse { + suspend fun removeGroup( + groupID: UShort, + timedInvokeTimeout: Duration? = null + ): RemoveGroupResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -383,50 +320,42 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - tlvReader.exitContainer() - return RemoveGroupResponse( - status_decoded, - groupID_decoded - ) + return RemoveGroupResponse(status_decoded, groupID_decoded) } suspend fun removeAllGroups(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -440,9 +369,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addGroupIfIdentifying(groupID: UShort - ,groupName: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun addGroupIfIdentifying( + groupID: UShort, + groupName: String, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -452,7 +383,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_GROUP_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_NAME_REQ), groupName) tlvWriter.endStructure() val request: InvokeRequest = @@ -465,42 +396,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readNameSupportAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNameSupportAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Namesupport attribute not found in response" - } + } + + requireNotNull(attributeData) { "Namesupport attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -509,35 +433,37 @@ suspend fun readNameSupportAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Namesupport attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Namesupport attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -549,49 +475,43 @@ suspend fun readNameSupportAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -601,45 +521,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -647,49 +572,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -699,45 +618,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -745,49 +669,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -797,45 +715,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -843,49 +764,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -895,45 +810,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -941,44 +859,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -987,35 +898,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1027,44 +940,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1073,34 +979,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1113,7 +1023,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt index 8ca45695cd230c..4d7d42bebb7c47 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/HepaFilterMonitoringCluster.kt @@ -17,132 +17,104 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class HepaFilterMonitoringCluster(private val controller: MatterController, private val endpointId: UShort) {class LastChangedTimeAttribute( - val value: UInt? - ) +class HepaFilterMonitoringCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class LastChangedTimeAttribute(val value: UInt?) sealed class LastChangedTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LastChangedTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : LastChangedTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : LastChangedTimeAttributeSubscriptionState() - object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() - } -class ReplacementProductListAttribute( + object SubscriptionEstablished : LastChangedTimeAttributeSubscriptionState() + } + + class ReplacementProductListAttribute( val value: List? ) sealed class ReplacementProductListAttributeSubscriptionState { - data class Success( - val value: List? - ) : ReplacementProductListAttributeSubscriptionState() - + data class Success(val value: List?) : + ReplacementProductListAttributeSubscriptionState() + data class Error(val exception: Exception) : ReplacementProductListAttributeSubscriptionState() - object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ReplacementProductListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCondition(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -155,45 +127,39 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readConditionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readConditionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Condition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Condition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -203,94 +169,88 @@ suspend fun readConditionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Condition attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Condition attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDegradationDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDegradationDirectionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Degradationdirection attribute not found in response" - } + } + + requireNotNull(attributeData) { "Degradationdirection attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -300,91 +260,86 @@ suspend fun readDegradationDirectionAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Degradationdirection attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Degradationdirection attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readChangeIndicationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Changeindication attribute not found in response" - } + } + + requireNotNull(attributeData) { "Changeindication attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -393,34 +348,38 @@ suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Changeindication attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Changeindication attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -433,47 +392,41 @@ suspend fun readChangeIndicationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInPlaceIndicatorAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInPlaceIndicatorAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inplaceindicator attribute not found in response" - } + } + + requireNotNull(attributeData) { "Inplaceindicator attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -483,123 +436,115 @@ suspend fun readInPlaceIndicatorAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inplaceindicator attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Inplaceindicator attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastchangedtime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastchangedtime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastChangedTimeAttribute(decodedValue) } - suspend fun writeLastChangedTimeAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeLastChangedTimeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -621,7 +566,7 @@ suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLastChangedTimeAttribute( @@ -629,105 +574,103 @@ suspend fun readLastChangedTimeAttribute(): LastChangedTimeAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastChangedTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastChangedTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastchangedtime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lastchangedtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LastChangedTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LastChangedTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastChangedTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Replacementproductlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Replacementproductlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(HepaFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + HepaFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ReplacementProductListAttribute(decodedValue) } @@ -737,102 +680,103 @@ suspend fun readReplacementProductListAttribute(): ReplacementProductListAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ReplacementProductListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ReplacementProductListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Replacementproductlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Replacementproductlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(HepaFilterMonitoringClusterReplacementProductStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ReplacementProductListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + HepaFilterMonitoringClusterReplacementProductStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ReplacementProductListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ReplacementProductListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -842,45 +786,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -888,49 +837,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -940,45 +883,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -986,49 +934,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1038,45 +980,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1084,49 +1029,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1136,45 +1075,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1182,44 +1124,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1228,35 +1163,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1268,44 +1205,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1314,34 +1244,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1354,7 +1288,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt index fe2a372f2188bd..9421d92a1742f7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IcdManagementCluster.kt @@ -17,127 +17,98 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class IcdManagementCluster(private val controller: MatterController, private val endpointId: UShort) { - class RegisterClientResponse( - val ICDCounter: UInt - ) +class IcdManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class RegisterClientResponse(val ICDCounter: UInt) - class StayActiveResponse( - val promisedActiveDuration: UInt - ) -class RegisteredClientsAttribute( + class StayActiveResponse(val promisedActiveDuration: UInt) + + class RegisteredClientsAttribute( val value: List? ) sealed class RegisteredClientsAttributeSubscriptionState { - data class Success( - val value: List? - ) : RegisteredClientsAttributeSubscriptionState() - + data class Success(val value: List?) : + RegisteredClientsAttributeSubscriptionState() + data class Error(val exception: Exception) : RegisteredClientsAttributeSubscriptionState() - object SubscriptionEstablished : RegisteredClientsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : RegisteredClientsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun registerClient(checkInNodeID: ULong - ,monitoredSubject: ULong - ,key: ByteArray - ,verificationKey: ByteArray? - ,timedInvokeTimeout: Duration? = null): RegisterClientResponse { + suspend fun registerClient( + checkInNodeID: ULong, + monitoredSubject: ULong, + key: ByteArray, + verificationKey: ByteArray?, + timedInvokeTimeout: Duration? = null + ): RegisterClientResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -155,7 +126,7 @@ class AttributeListAttribute( val TAG_VERIFICATION_KEY_REQ: Int = 3 verificationKey?.let { tlvWriter.put(ContextSpecificTag(TAG_VERIFICATION_KEY_REQ), verificationKey) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -172,37 +143,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_I_C_D_COUNTER: Int = 0 var ICDCounter_decoded: UInt? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_I_C_D_COUNTER)) {ICDCounter_decoded = tlvReader.getUInt(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_I_C_D_COUNTER)) { + ICDCounter_decoded = tlvReader.getUInt(tag) + } else { tlvReader.skipElement() } } - - if (ICDCounter_decoded == null) { - throw IllegalStateException("ICDCounter not found in TLV") + throw IllegalStateException("ICDCounter not found in TLV") } - tlvReader.exitContainer() - return RegisterClientResponse( - ICDCounter_decoded - ) + return RegisterClientResponse(ICDCounter_decoded) } - suspend fun unregisterClient(checkInNodeID: ULong - ,verificationKey: ByteArray? - ,timedInvokeTimeout: Duration? = null) { + suspend fun unregisterClient( + checkInNodeID: ULong, + verificationKey: ByteArray?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -214,7 +179,7 @@ class AttributeListAttribute( val TAG_VERIFICATION_KEY_REQ: Int = 1 verificationKey?.let { tlvWriter.put(ContextSpecificTag(TAG_VERIFICATION_KEY_REQ), verificationKey) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -232,7 +197,7 @@ class AttributeListAttribute( val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -249,69 +214,54 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_PROMISED_ACTIVE_DURATION: Int = 0 var promisedActiveDuration_decoded: UInt? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_PROMISED_ACTIVE_DURATION)) {promisedActiveDuration_decoded = tlvReader.getUInt(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_PROMISED_ACTIVE_DURATION)) { + promisedActiveDuration_decoded = tlvReader.getUInt(tag) + } else { tlvReader.skipElement() } } - - if (promisedActiveDuration_decoded == null) { - throw IllegalStateException("promisedActiveDuration not found in TLV") + throw IllegalStateException("promisedActiveDuration not found in TLV") } - tlvReader.exitContainer() - return StayActiveResponse( - promisedActiveDuration_decoded - ) + return StayActiveResponse(promisedActiveDuration_decoded) } -suspend fun readIdleModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readIdleModeDurationAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Idlemodeduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Idlemodeduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -320,34 +270,38 @@ suspend fun readIdleModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Idlemodeduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Idlemodeduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -360,44 +314,37 @@ suspend fun readIdleModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveModeDurationAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activemodeduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activemodeduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -406,34 +353,38 @@ suspend fun readActiveModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activemodeduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activemodeduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -446,44 +397,37 @@ suspend fun readActiveModeDurationAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveModeThresholdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveModeThresholdAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activemodethreshold attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activemodethreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -492,34 +436,38 @@ suspend fun readActiveModeThresholdAttribute(): UShort {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activemodethreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activemodethreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -532,53 +480,47 @@ suspend fun readActiveModeThresholdAttribute(): UShort {val ATTRIBUTE_ID: UInt = emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRegisteredClientsAttribute(): RegisteredClientsAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRegisteredClientsAttribute(): RegisteredClientsAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Registeredclients attribute not found in response" - } + } + + requireNotNull(attributeData) { "Registeredclients attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(IcdManagementClusterMonitoringRegistrationStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(IcdManagementClusterMonitoringRegistrationStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return RegisteredClientsAttribute(decodedValue) } @@ -588,100 +530,101 @@ suspend fun readRegisteredClientsAttribute(): RegisteredClientsAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RegisteredClientsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RegisteredClientsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Registeredclients attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Registeredclients attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(IcdManagementClusterMonitoringRegistrationStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(RegisteredClientsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + IcdManagementClusterMonitoringRegistrationStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(RegisteredClientsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RegisteredClientsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readICDCounterAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readICDCounterAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Icdcounter attribute not found in response" - } + } + + requireNotNull(attributeData) { "Icdcounter attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -691,94 +634,88 @@ suspend fun readICDCounterAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Icdcounter attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Icdcounter attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClientsSupportedPerFabricAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClientsSupportedPerFabricAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clientssupportedperfabric attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clientssupportedperfabric attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -788,94 +725,90 @@ suspend fun readClientsSupportedPerFabricAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clientssupportedperfabric attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clientssupportedperfabric attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUserActiveModeTriggerHintAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUserActiveModeTriggerHintAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Useractivemodetriggerhint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Useractivemodetriggerhint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -885,94 +818,92 @@ suspend fun readUserActiveModeTriggerHintAttribute(): UInt? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Useractivemodetriggerhint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Useractivemodetriggerhint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUserActiveModeTriggerInstructionAttribute(): String? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUserActiveModeTriggerInstructionAttribute(): String? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Useractivemodetriggerinstruction attribute not found in response" + } + + requireNotNull(attributeData) { + "Useractivemodetriggerinstruction attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -982,94 +913,90 @@ suspend fun readUserActiveModeTriggerInstructionAttribute(): String? {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Useractivemodetriggerinstruction attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Useractivemodetriggerinstruction attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperatingModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperatingModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operatingmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operatingmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1079,96 +1006,90 @@ suspend fun readOperatingModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operatingmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Operatingmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1178,45 +1099,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1224,49 +1150,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1276,45 +1196,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1322,49 +1247,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1374,45 +1293,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1420,49 +1342,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1472,45 +1388,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1518,44 +1437,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1564,35 +1476,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1604,44 +1518,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1650,34 +1557,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1690,7 +1601,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt index cdf0dd8d361438..f7ed262f1a73ba 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IdentifyCluster.kt @@ -17,110 +17,81 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class IdentifyCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class IdentifyCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun identify(identifyTime: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun identify(identifyTime: UShort, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_IDENTIFY_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_IDENTIFY_TIME_REQ), identifyTime) + tlvWriter.put(ContextSpecificTag(TAG_IDENTIFY_TIME_REQ), identifyTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -134,9 +105,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun triggerEffect(effectIdentifier: UByte - ,effectVariant: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun triggerEffect( + effectIdentifier: UByte, + effectVariant: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -146,7 +119,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_EFFECT_IDENTIFIER_REQ), effectIdentifier) val TAG_EFFECT_VARIANT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) + tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) tlvWriter.endStructure() val request: InvokeRequest = @@ -159,65 +132,54 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readIdentifyTimeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readIdentifyTimeAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Identifytime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Identifytime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } - suspend fun writeIdentifyTimeAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeIdentifyTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -239,7 +201,7 @@ suspend fun readIdentifyTimeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeIdentifyTimeAttribute( @@ -247,35 +209,37 @@ suspend fun readIdentifyTimeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Identifytime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Identifytime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -287,44 +251,37 @@ suspend fun readIdentifyTimeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 0u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readIdentifyTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readIdentifyTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Identifytype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Identifytype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -333,35 +290,37 @@ suspend fun readIdentifyTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Identifytype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Identifytype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -373,49 +332,43 @@ suspend fun readIdentifyTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -425,45 +378,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -471,49 +429,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -523,45 +475,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -569,49 +526,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -621,45 +572,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -667,49 +621,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -719,45 +667,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -765,44 +716,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -811,35 +755,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -851,44 +797,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -897,34 +836,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -937,7 +880,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt index cbfb9f08ed8a40..3fbcfa85674aff 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/IlluminanceMeasurementCluster.kt @@ -17,192 +17,140 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class IlluminanceMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: UShort? - ) +class IlluminanceMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: UShort?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: UShort?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: UShort?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class LightSensorTypeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class LightSensorTypeAttribute(val value: UByte?) sealed class LightSensorTypeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : LightSensorTypeAttributeSubscriptionState() - + data class Success(val value: UByte?) : LightSensorTypeAttributeSubscriptionState() + data class Error(val exception: Exception) : LightSensorTypeAttributeSubscriptionState() - object SubscriptionEstablished : LightSensorTypeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LightSensorTypeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -212,96 +160,90 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -311,96 +253,92 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -410,95 +348,91 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -508,99 +442,93 @@ suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLightSensorTypeAttribute(): LightSensorTypeAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLightSensorTypeAttribute(): LightSensorTypeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lightsensortype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lightsensortype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LightSensorTypeAttribute(decodedValue) } @@ -610,101 +538,97 @@ suspend fun readLightSensorTypeAttribute(): LightSensorTypeAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LightSensorTypeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LightSensorTypeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lightsensortype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lightsensortype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LightSensorTypeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LightSensorTypeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LightSensorTypeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -714,45 +638,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -760,49 +689,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -812,45 +735,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -858,49 +786,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -910,45 +832,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -956,49 +881,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1008,45 +927,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1054,44 +976,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1100,35 +1015,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1140,44 +1057,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1186,34 +1096,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1226,7 +1140,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt index 168b0718b0ff16..8e65a58bb20e56 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/KeypadInputCluster.kt @@ -17,114 +17,79 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class KeypadInputCluster(private val controller: MatterController, private val endpointId: UShort) { - class SendKeyResponse( - val status: UByte - ) -class GeneratedCommandListAttribute( - val value: List - ) + class SendKeyResponse(val status: UByte) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun sendKey(keyCode: UByte - ,timedInvokeTimeout: Duration? = null): SendKeyResponse { + suspend fun sendKey(keyCode: UByte, timedInvokeTimeout: Duration? = null): SendKeyResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_KEY_CODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_KEY_CODE_REQ), keyCode) + tlvWriter.put(ContextSpecificTag(TAG_KEY_CODE_REQ), keyCode) tlvWriter.endStructure() val request: InvokeRequest = @@ -141,74 +106,60 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - tlvReader.exitContainer() - return SendKeyResponse( - status_decoded - ) + return SendKeyResponse(status_decoded) } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -218,45 +169,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -264,49 +220,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -316,45 +266,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -362,49 +317,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -414,45 +363,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -460,49 +412,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -512,45 +458,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -558,44 +507,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -604,35 +546,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -644,44 +588,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -690,34 +627,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -730,7 +671,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt index c4800abe53cffd..f782f3ec082767 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryDryerControlsCluster.kt @@ -17,167 +17,125 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryDryerControlsCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedDrynessLevelsAttribute( - val value: List - ) +class LaundryDryerControlsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedDrynessLevelsAttribute(val value: List) sealed class SupportedDrynessLevelsAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedDrynessLevelsAttributeSubscriptionState() - + data class Success(val value: List) : SupportedDrynessLevelsAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedDrynessLevelsAttributeSubscriptionState() - object SubscriptionEstablished : SupportedDrynessLevelsAttributeSubscriptionState() - } -class SelectedDrynessLevelAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedDrynessLevelsAttributeSubscriptionState() + } + + class SelectedDrynessLevelAttribute(val value: UByte?) sealed class SelectedDrynessLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : SelectedDrynessLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : SelectedDrynessLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : SelectedDrynessLevelAttributeSubscriptionState() - object SubscriptionEstablished : SelectedDrynessLevelAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SelectedDrynessLevelAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supporteddrynesslevels attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supporteddrynesslevels attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedDrynessLevelsAttribute(decodedValue) } @@ -187,45 +145,50 @@ suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedDrynessLevelsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedDrynessLevelsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supporteddrynesslevels attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supporteddrynesslevels attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(SupportedDrynessLevelsAttributeSubscriptionState.Success(decodedValue)) } @@ -233,72 +196,65 @@ suspend fun readSupportedDrynessLevelsAttribute(): SupportedDrynessLevelsAttribu emit(SupportedDrynessLevelsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selecteddrynesslevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Selecteddrynesslevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SelectedDrynessLevelAttribute(decodedValue) } suspend fun writeSelectedDrynessLevelAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -320,7 +276,7 @@ suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute { throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSelectedDrynessLevelAttribute( @@ -328,97 +284,93 @@ suspend fun readSelectedDrynessLevelAttribute(): SelectedDrynessLevelAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SelectedDrynessLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SelectedDrynessLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selecteddrynesslevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Selecteddrynesslevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SelectedDrynessLevelAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SelectedDrynessLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SelectedDrynessLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -428,45 +380,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -474,49 +431,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -526,45 +477,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -572,49 +528,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -624,45 +574,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -670,49 +623,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -722,45 +669,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -768,44 +718,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -814,35 +757,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -854,44 +799,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -900,34 +838,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -940,7 +882,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt index 2e547ec206a574..42b5ed96fc640a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherControlsCluster.kt @@ -17,184 +17,140 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherControlsCluster(private val controller: MatterController, private val endpointId: UShort) {class SpinSpeedsAttribute( - val value: List? - ) +class LaundryWasherControlsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SpinSpeedsAttribute(val value: List?) sealed class SpinSpeedsAttributeSubscriptionState { - data class Success( - val value: List? - ) : SpinSpeedsAttributeSubscriptionState() - + data class Success(val value: List?) : SpinSpeedsAttributeSubscriptionState() + data class Error(val exception: Exception) : SpinSpeedsAttributeSubscriptionState() - object SubscriptionEstablished : SpinSpeedsAttributeSubscriptionState() - } -class SpinSpeedCurrentAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SpinSpeedsAttributeSubscriptionState() + } + + class SpinSpeedCurrentAttribute(val value: UByte?) sealed class SpinSpeedCurrentAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : SpinSpeedCurrentAttributeSubscriptionState() - + data class Success(val value: UByte?) : SpinSpeedCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : SpinSpeedCurrentAttributeSubscriptionState() - object SubscriptionEstablished : SpinSpeedCurrentAttributeSubscriptionState() - } -class SupportedRinsesAttribute( - val value: List? - ) + object SubscriptionEstablished : SpinSpeedCurrentAttributeSubscriptionState() + } + + class SupportedRinsesAttribute(val value: List?) sealed class SupportedRinsesAttributeSubscriptionState { - data class Success( - val value: List? - ) : SupportedRinsesAttributeSubscriptionState() - + data class Success(val value: List?) : SupportedRinsesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedRinsesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedRinsesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedRinsesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readSpinSpeedsAttribute(): SpinSpeedsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readSpinSpeedsAttribute(): SpinSpeedsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Spinspeeds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Spinspeeds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SpinSpeedsAttribute(decodedValue) } @@ -204,129 +160,119 @@ suspend fun readSpinSpeedsAttribute(): SpinSpeedsAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SpinSpeedsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SpinSpeedsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Spinspeeds attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Spinspeeds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SpinSpeedsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SpinSpeedsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SpinSpeedsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Spinspeedcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Spinspeedcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SpinSpeedCurrentAttribute(decodedValue) } - suspend fun writeSpinSpeedCurrentAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeSpinSpeedCurrentAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -348,7 +294,7 @@ suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSpinSpeedCurrentAttribute( @@ -356,123 +302,115 @@ suspend fun readSpinSpeedCurrentAttribute(): SpinSpeedCurrentAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SpinSpeedCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SpinSpeedCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Spinspeedcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Spinspeedcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SpinSpeedCurrentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SpinSpeedCurrentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SpinSpeedCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfRinsesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNumberOfRinsesAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofrinses attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofrinses attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeNumberOfRinsesAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNumberOfRinsesAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -494,7 +432,7 @@ suspend fun readNumberOfRinsesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNumberOfRinsesAttribute( @@ -502,100 +440,96 @@ suspend fun readNumberOfRinsesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofrinses attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofrinses attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedRinsesAttribute(): SupportedRinsesAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedRinsesAttribute(): SupportedRinsesAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedrinses attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedrinses attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SupportedRinsesAttribute(decodedValue) } @@ -605,102 +539,98 @@ suspend fun readSupportedRinsesAttribute(): SupportedRinsesAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedRinsesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedRinsesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedrinses attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedrinses attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SupportedRinsesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SupportedRinsesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SupportedRinsesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -710,45 +640,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -756,49 +691,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -808,45 +737,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -854,49 +788,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -906,45 +834,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -952,49 +883,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1004,45 +929,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1050,44 +978,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1096,35 +1017,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1136,44 +1059,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1182,34 +1098,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1222,7 +1142,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt index 3094ee32e0a394..39984ca8d45b8c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LaundryWasherModeCluster.kt @@ -17,154 +17,120 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) +class LaundryWasherModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -181,92 +147,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -276,45 +227,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -322,44 +278,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -368,35 +317,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -408,76 +359,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +440,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -507,128 +448,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -650,7 +581,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -658,101 +589,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -762,45 +687,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -808,49 +738,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -860,45 +784,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -906,49 +835,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -958,45 +881,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1004,49 +930,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1056,45 +976,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,44 +1025,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1148,35 +1064,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1188,44 +1106,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1234,34 +1145,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1274,7 +1189,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt index 293ad3ccf28462..aa67210f9b5551 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LevelControlCluster.kt @@ -17,184 +17,143 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LevelControlCluster(private val controller: MatterController, private val endpointId: UShort) {class CurrentLevelAttribute( - val value: UByte? - ) +class LevelControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class CurrentLevelAttribute(val value: UByte?) sealed class CurrentLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentLevelAttributeSubscriptionState() - object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() - } -class OnLevelAttribute( - val value: UByte? - ) + object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() + } + + class OnLevelAttribute(val value: UByte?) sealed class OnLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : OnLevelAttributeSubscriptionState() - object SubscriptionEstablished : OnLevelAttributeSubscriptionState() - } -class OnTransitionTimeAttribute( - val value: UShort? - ) + object SubscriptionEstablished : OnLevelAttributeSubscriptionState() + } + + class OnTransitionTimeAttribute(val value: UShort?) sealed class OnTransitionTimeAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : OnTransitionTimeAttributeSubscriptionState() - + data class Success(val value: UShort?) : OnTransitionTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnTransitionTimeAttributeSubscriptionState() - object SubscriptionEstablished : OnTransitionTimeAttributeSubscriptionState() - } -class OffTransitionTimeAttribute( - val value: UShort? - ) + object SubscriptionEstablished : OnTransitionTimeAttributeSubscriptionState() + } + + class OffTransitionTimeAttribute(val value: UShort?) sealed class OffTransitionTimeAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : OffTransitionTimeAttributeSubscriptionState() - + data class Success(val value: UShort?) : OffTransitionTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : OffTransitionTimeAttributeSubscriptionState() - object SubscriptionEstablished : OffTransitionTimeAttributeSubscriptionState() - } -class DefaultMoveRateAttribute( - val value: UByte? - ) + object SubscriptionEstablished : OffTransitionTimeAttributeSubscriptionState() + } + + class DefaultMoveRateAttribute(val value: UByte?) sealed class DefaultMoveRateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : DefaultMoveRateAttributeSubscriptionState() - + data class Success(val value: UByte?) : DefaultMoveRateAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultMoveRateAttributeSubscriptionState() - object SubscriptionEstablished : DefaultMoveRateAttributeSubscriptionState() - } -class StartUpCurrentLevelAttribute( - val value: UByte? - ) + object SubscriptionEstablished : DefaultMoveRateAttributeSubscriptionState() + } + + class StartUpCurrentLevelAttribute(val value: UByte?) sealed class StartUpCurrentLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpCurrentLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpCurrentLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpCurrentLevelAttributeSubscriptionState() - object SubscriptionEstablished : StartUpCurrentLevelAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : StartUpCurrentLevelAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun moveToLevel(level: UByte - ,transitionTime: UShort? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToLevel( + level: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -212,7 +171,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -226,11 +185,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun move(moveMode: UByte - ,rate: UByte? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun move( + moveMode: UByte, + rate: UByte?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -240,15 +201,13 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) val TAG_RATE_REQ: Int = 1 - rate?.let { - tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) - } + rate?.let { tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) } val TAG_OPTIONS_MASK_REQ: Int = 2 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -262,12 +221,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun step(stepMode: UByte - ,stepSize: UByte - ,transitionTime: UShort? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun step( + stepMode: UByte, + stepSize: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -288,7 +249,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -302,9 +263,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stop(optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stop( + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -314,7 +277,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -328,11 +291,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToLevelWithOnOff(level: UByte - ,transitionTime: UShort? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToLevelWithOnOff( + level: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -350,7 +315,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -364,11 +329,13 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveWithOnOff(moveMode: UByte - ,rate: UByte? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveWithOnOff( + moveMode: UByte, + rate: UByte?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -378,15 +345,13 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_MOVE_MODE_REQ), moveMode) val TAG_RATE_REQ: Int = 1 - rate?.let { - tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) - } + rate?.let { tlvWriter.put(ContextSpecificTag(TAG_RATE_REQ), rate) } val TAG_OPTIONS_MASK_REQ: Int = 2 tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 3 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -400,12 +365,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stepWithOnOff(stepMode: UByte - ,stepSize: UByte - ,transitionTime: UShort? - ,optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stepWithOnOff( + stepMode: UByte, + stepSize: UByte, + transitionTime: UShort?, + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -426,7 +393,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -440,9 +407,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun stopWithOnOff(optionsMask: UByte - ,optionsOverride: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun stopWithOnOff( + optionsMask: UByte, + optionsOverride: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -452,7 +421,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_MASK_REQ), optionsMask) val TAG_OPTIONS_OVERRIDE_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) + tlvWriter.put(ContextSpecificTag(TAG_OPTIONS_OVERRIDE_REQ), optionsOverride) tlvWriter.endStructure() val request: InvokeRequest = @@ -466,15 +435,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun moveToClosestFrequency(frequency: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun moveToClosestFrequency(frequency: UShort, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_FREQUENCY_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_FREQUENCY_REQ), frequency) + tlvWriter.put(ContextSpecificTag(TAG_FREQUENCY_REQ), frequency) tlvWriter.endStructure() val request: InvokeRequest = @@ -487,46 +455,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentLevelAttribute(decodedValue) } @@ -536,95 +498,89 @@ suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(CurrentLevelAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(CurrentLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRemainingTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRemainingTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingtime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Remainingtime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -634,94 +590,88 @@ suspend fun readRemainingTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingtime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Remainingtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -731,94 +681,88 @@ suspend fun readMinLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -828,94 +772,88 @@ suspend fun readMaxLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentfrequency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentfrequency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -925,94 +863,90 @@ suspend fun readCurrentFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 4 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentfrequency attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minfrequency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minfrequency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1022,94 +956,88 @@ suspend fun readMinFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minfrequency attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxFrequencyAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxfrequency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxfrequency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1119,114 +1047,103 @@ suspend fun readMaxFrequencyAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxfrequency attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOptionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Options attribute not found in response" - } + } + + requireNotNull(attributeData) { "Options attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeOptionsAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOptionsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 15u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1248,7 +1165,7 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOptionsAttribute( @@ -1256,35 +1173,37 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Options attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Options attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1296,71 +1215,64 @@ suspend fun readOptionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 15u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnOffTransitionTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOnOffTransitionTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onofftransitiontime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onofftransitiontime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeOnOffTransitionTimeAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1382,7 +1294,7 @@ suspend fun readOnOffTransitionTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnOffTransitionTimeAttribute( @@ -1390,119 +1302,111 @@ suspend fun readOnOffTransitionTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onofftransitiontime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Onofftransitiontime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnLevelAttribute(): OnLevelAttribute {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOnLevelAttribute(): OnLevelAttribute { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnLevelAttribute(decodedValue) } - suspend fun writeOnLevelAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1524,7 +1428,7 @@ suspend fun readOnLevelAttribute(): OnLevelAttribute {val ATTRIBUTE_ID: UInt = 1 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnLevelAttribute( @@ -1532,124 +1436,114 @@ suspend fun readOnLevelAttribute(): OnLevelAttribute {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(OnLevelAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(OnLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ontransitiontime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ontransitiontime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnTransitionTimeAttribute(decodedValue) } - suspend fun writeOnTransitionTimeAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnTransitionTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1671,7 +1565,7 @@ suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnTransitionTimeAttribute( @@ -1679,128 +1573,120 @@ suspend fun readOnTransitionTimeAttribute(): OnTransitionTimeAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnTransitionTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnTransitionTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ontransitiontime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ontransitiontime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnTransitionTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnTransitionTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnTransitionTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Offtransitiontime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Offtransitiontime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OffTransitionTimeAttribute(decodedValue) } - suspend fun writeOffTransitionTimeAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeOffTransitionTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 19u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1822,7 +1708,7 @@ suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute {val AT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOffTransitionTimeAttribute( @@ -1830,128 +1716,120 @@ suspend fun readOffTransitionTimeAttribute(): OffTransitionTimeAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OffTransitionTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OffTransitionTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Offtransitiontime attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Offtransitiontime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OffTransitionTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OffTransitionTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OffTransitionTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultmoverate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultmoverate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DefaultMoveRateAttribute(decodedValue) } - suspend fun writeDefaultMoveRateAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultMoveRateAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1973,7 +1851,7 @@ suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultMoveRateAttribute( @@ -1981,128 +1859,120 @@ suspend fun readDefaultMoveRateAttribute(): DefaultMoveRateAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DefaultMoveRateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DefaultMoveRateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultmoverate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultmoverate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DefaultMoveRateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DefaultMoveRateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DefaultMoveRateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute {val ATTRIBUTE_ID: UInt = 16384u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupcurrentlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupcurrentlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpCurrentLevelAttribute(decodedValue) } - suspend fun writeStartUpCurrentLevelAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpCurrentLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16384u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2124,7 +1994,7 @@ suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpCurrentLevelAttribute( @@ -2132,101 +2002,97 @@ suspend fun readStartUpCurrentLevelAttribute(): StartUpCurrentLevelAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpCurrentLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpCurrentLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupcurrentlevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Startupcurrentlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpCurrentLevelAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpCurrentLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpCurrentLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2236,45 +2102,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2282,49 +2153,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2334,45 +2199,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2380,49 +2250,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2432,45 +2296,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2478,49 +2345,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2530,45 +2391,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2576,44 +2440,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2622,35 +2479,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2662,44 +2521,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2708,34 +2560,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2748,7 +2604,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt index d2c92eb1b5c1f9..3eb0f7f602ddea 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LocalizationConfigurationCluster.kt @@ -17,172 +17,129 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LocalizationConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedLocalesAttribute( - val value: List - ) +class LocalizationConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedLocalesAttribute(val value: List) sealed class SupportedLocalesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedLocalesAttributeSubscriptionState() - + data class Success(val value: List) : SupportedLocalesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedLocalesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedLocalesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedLocalesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readActiveLocaleAttribute(): String {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readActiveLocaleAttribute(): String { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activelocale attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activelocale attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } - suspend fun writeActiveLocaleAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeActiveLocaleAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -204,7 +161,7 @@ suspend fun readActiveLocaleAttribute(): String {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeActiveLocaleAttribute( @@ -212,35 +169,37 @@ suspend fun readActiveLocaleAttribute(): String {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activelocale attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Activelocale attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -252,49 +211,43 @@ suspend fun readActiveLocaleAttribute(): String {val ATTRIBUTE_ID: UInt = 0u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedlocales attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedlocales attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedLocalesAttribute(decodedValue) } @@ -304,45 +257,50 @@ suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedLocalesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedLocalesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedlocales attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedlocales attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(SupportedLocalesAttributeSubscriptionState.Success(decodedValue)) } @@ -350,49 +308,43 @@ suspend fun readSupportedLocalesAttribute(): SupportedLocalesAttribute {val ATTR emit(SupportedLocalesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -402,45 +354,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -448,49 +405,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -500,45 +451,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -546,49 +502,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -598,45 +548,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -644,49 +597,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -696,45 +643,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -742,44 +692,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -788,35 +731,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -828,44 +773,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -874,34 +812,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -914,7 +856,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt index 93f537837ccd34..b0ca32ffc850b8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/LowPowerCluster.kt @@ -17,106 +17,73 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LowPowerCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class LowPowerCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun sleep(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -129,47 +96,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -179,45 +140,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -225,49 +191,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -277,45 +237,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -323,49 +288,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -375,45 +334,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -421,49 +383,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -473,45 +429,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -519,44 +478,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -565,35 +517,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -605,44 +559,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -651,34 +598,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -691,7 +642,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt index d26de7c78f7c10..96e656cd0a7bc9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaInputCluster.kt @@ -17,123 +17,89 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaInputCluster(private val controller: MatterController, private val endpointId: UShort) {class InputListAttribute( - val value: List - ) +class MediaInputCluster(private val controller: MatterController, private val endpointId: UShort) { + class InputListAttribute(val value: List) sealed class InputListAttributeSubscriptionState { - data class Success( - val value: List - ) : InputListAttributeSubscriptionState() - + data class Success(val value: List) : + InputListAttributeSubscriptionState() + data class Error(val exception: Exception) : InputListAttributeSubscriptionState() - object SubscriptionEstablished : InputListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : InputListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun selectInput(index: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun selectInput(index: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) + tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) tlvWriter.endStructure() val request: InvokeRequest = @@ -151,7 +117,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -169,7 +135,7 @@ class AttributeListAttribute( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -183,9 +149,7 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun renameInput(index: UByte - ,name: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun renameInput(index: UByte, name: String, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -195,7 +159,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_INDEX_REQ), index) val TAG_NAME_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) + tlvWriter.put(ContextSpecificTag(TAG_NAME_REQ), name) tlvWriter.endStructure() val request: InvokeRequest = @@ -208,47 +172,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readInputListAttribute(): InputListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInputListAttribute(): InputListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inputlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Inputlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return InputListAttribute(decodedValue) } @@ -258,45 +216,48 @@ suspend fun readInputListAttribute(): InputListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(InputListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + InputListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Inputlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Inputlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaInputClusterInputInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(InputListAttributeSubscriptionState.Success(decodedValue)) } @@ -304,44 +265,37 @@ suspend fun readInputListAttribute(): InputListAttribute {val ATTRIBUTE_ID: UInt emit(InputListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentInputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentInputAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentinput attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentinput attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -350,35 +304,37 @@ suspend fun readCurrentInputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentinput attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentinput attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -390,49 +346,43 @@ suspend fun readCurrentInputAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -442,45 +392,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -488,49 +443,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -540,45 +489,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -586,49 +540,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -638,45 +586,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -684,49 +635,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -736,45 +681,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -782,44 +730,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -828,35 +769,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -868,44 +811,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -914,34 +850,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -954,7 +894,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt index 189d95aadc2ba5..12b2afd339765b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MediaPlaybackCluster.kt @@ -17,228 +17,176 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaPlaybackCluster(private val controller: MatterController, private val endpointId: UShort) { - class PlaybackResponse( - val status: UByte, - val data: String? - ) -class StartTimeAttribute( - val value: ULong? - ) +class MediaPlaybackCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class PlaybackResponse(val status: UByte, val data: String?) + + class StartTimeAttribute(val value: ULong?) sealed class StartTimeAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : StartTimeAttributeSubscriptionState() - + data class Success(val value: ULong?) : StartTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartTimeAttributeSubscriptionState() - object SubscriptionEstablished : StartTimeAttributeSubscriptionState() - } -class DurationAttribute( - val value: ULong? - ) + object SubscriptionEstablished : StartTimeAttributeSubscriptionState() + } + + class DurationAttribute(val value: ULong?) sealed class DurationAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : DurationAttributeSubscriptionState() - + data class Success(val value: ULong?) : DurationAttributeSubscriptionState() + data class Error(val exception: Exception) : DurationAttributeSubscriptionState() - object SubscriptionEstablished : DurationAttributeSubscriptionState() - } -class SampledPositionAttribute( - val value: MediaPlaybackClusterPlaybackPositionStruct? - ) + object SubscriptionEstablished : DurationAttributeSubscriptionState() + } + + class SampledPositionAttribute(val value: MediaPlaybackClusterPlaybackPositionStruct?) sealed class SampledPositionAttributeSubscriptionState { - data class Success( - val value: MediaPlaybackClusterPlaybackPositionStruct? - ) : SampledPositionAttributeSubscriptionState() - + data class Success(val value: MediaPlaybackClusterPlaybackPositionStruct?) : + SampledPositionAttributeSubscriptionState() + data class Error(val exception: Exception) : SampledPositionAttributeSubscriptionState() - object SubscriptionEstablished : SampledPositionAttributeSubscriptionState() - } -class SeekRangeEndAttribute( - val value: ULong? - ) + object SubscriptionEstablished : SampledPositionAttributeSubscriptionState() + } + + class SeekRangeEndAttribute(val value: ULong?) sealed class SeekRangeEndAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : SeekRangeEndAttributeSubscriptionState() - + data class Success(val value: ULong?) : SeekRangeEndAttributeSubscriptionState() + data class Error(val exception: Exception) : SeekRangeEndAttributeSubscriptionState() - object SubscriptionEstablished : SeekRangeEndAttributeSubscriptionState() - } -class SeekRangeStartAttribute( - val value: ULong? - ) + object SubscriptionEstablished : SeekRangeEndAttributeSubscriptionState() + } + + class SeekRangeStartAttribute(val value: ULong?) sealed class SeekRangeStartAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : SeekRangeStartAttributeSubscriptionState() - + data class Success(val value: ULong?) : SeekRangeStartAttributeSubscriptionState() + data class Error(val exception: Exception) : SeekRangeStartAttributeSubscriptionState() - object SubscriptionEstablished : SeekRangeStartAttributeSubscriptionState() - } -class ActiveAudioTrackAttribute( - val value: MediaPlaybackClusterTrackStruct? - ) + object SubscriptionEstablished : SeekRangeStartAttributeSubscriptionState() + } + + class ActiveAudioTrackAttribute(val value: MediaPlaybackClusterTrackStruct?) sealed class ActiveAudioTrackAttributeSubscriptionState { - data class Success( - val value: MediaPlaybackClusterTrackStruct? - ) : ActiveAudioTrackAttributeSubscriptionState() - + data class Success(val value: MediaPlaybackClusterTrackStruct?) : + ActiveAudioTrackAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveAudioTrackAttributeSubscriptionState() - object SubscriptionEstablished : ActiveAudioTrackAttributeSubscriptionState() - } -class AvailableAudioTracksAttribute( - val value: List? - ) + object SubscriptionEstablished : ActiveAudioTrackAttributeSubscriptionState() + } + + class AvailableAudioTracksAttribute(val value: List?) sealed class AvailableAudioTracksAttributeSubscriptionState { - data class Success( - val value: List? - ) : AvailableAudioTracksAttributeSubscriptionState() - + data class Success(val value: List?) : + AvailableAudioTracksAttributeSubscriptionState() + data class Error(val exception: Exception) : AvailableAudioTracksAttributeSubscriptionState() - object SubscriptionEstablished : AvailableAudioTracksAttributeSubscriptionState() - } -class ActiveTextTrackAttribute( - val value: MediaPlaybackClusterTrackStruct? - ) + object SubscriptionEstablished : AvailableAudioTracksAttributeSubscriptionState() + } + + class ActiveTextTrackAttribute(val value: MediaPlaybackClusterTrackStruct?) sealed class ActiveTextTrackAttributeSubscriptionState { - data class Success( - val value: MediaPlaybackClusterTrackStruct? - ) : ActiveTextTrackAttributeSubscriptionState() - + data class Success(val value: MediaPlaybackClusterTrackStruct?) : + ActiveTextTrackAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveTextTrackAttributeSubscriptionState() - object SubscriptionEstablished : ActiveTextTrackAttributeSubscriptionState() - } -class AvailableTextTracksAttribute( - val value: List? - ) + object SubscriptionEstablished : ActiveTextTrackAttributeSubscriptionState() + } + + class AvailableTextTracksAttribute(val value: List?) sealed class AvailableTextTracksAttributeSubscriptionState { - data class Success( - val value: List? - ) : AvailableTextTracksAttributeSubscriptionState() - + data class Success(val value: List?) : + AvailableTextTracksAttributeSubscriptionState() + data class Error(val exception: Exception) : AvailableTextTracksAttributeSubscriptionState() - object SubscriptionEstablished : AvailableTextTracksAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AvailableTextTracksAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun play(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -255,57 +203,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } suspend fun pause(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -322,57 +261,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } suspend fun stop(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -389,57 +319,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } suspend fun startOver(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -456,57 +377,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } suspend fun previous(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -523,57 +435,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } suspend fun next(timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -590,54 +493,47 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun rewind(audioAdvanceUnmuted: Boolean? - ,timedInvokeTimeout: Duration? = null): PlaybackResponse { + suspend fun rewind( + audioAdvanceUnmuted: Boolean?, + timedInvokeTimeout: Duration? = null + ): PlaybackResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -646,7 +542,7 @@ class AttributeListAttribute( val TAG_AUDIO_ADVANCE_UNMUTED_REQ: Int = 0 audioAdvanceUnmuted?.let { tlvWriter.put(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED_REQ), audioAdvanceUnmuted) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -663,54 +559,47 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun fastForward(audioAdvanceUnmuted: Boolean? - ,timedInvokeTimeout: Duration? = null): PlaybackResponse { + suspend fun fastForward( + audioAdvanceUnmuted: Boolean?, + timedInvokeTimeout: Duration? = null + ): PlaybackResponse { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -719,7 +608,7 @@ class AttributeListAttribute( val TAG_AUDIO_ADVANCE_UNMUTED_REQ: Int = 0 audioAdvanceUnmuted?.let { tlvWriter.put(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED_REQ), audioAdvanceUnmuted) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -736,61 +625,57 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun skipForward(deltaPositionMilliseconds: ULong - ,timedInvokeTimeout: Duration? = null): PlaybackResponse { + suspend fun skipForward( + deltaPositionMilliseconds: ULong, + timedInvokeTimeout: Duration? = null + ): PlaybackResponse { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DELTA_POSITION_MILLISECONDS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), deltaPositionMilliseconds) + tlvWriter.put( + ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), + deltaPositionMilliseconds + ) tlvWriter.endStructure() val request: InvokeRequest = @@ -807,61 +692,57 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun skipBackward(deltaPositionMilliseconds: ULong - ,timedInvokeTimeout: Duration? = null): PlaybackResponse { + suspend fun skipBackward( + deltaPositionMilliseconds: ULong, + timedInvokeTimeout: Duration? = null + ): PlaybackResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DELTA_POSITION_MILLISECONDS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), deltaPositionMilliseconds) + tlvWriter.put( + ContextSpecificTag(TAG_DELTA_POSITION_MILLISECONDS_REQ), + deltaPositionMilliseconds + ) tlvWriter.endStructure() val request: InvokeRequest = @@ -878,61 +759,51 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun seek(position: ULong - ,timedInvokeTimeout: Duration? = null): PlaybackResponse { + suspend fun seek(position: ULong, timedInvokeTimeout: Duration? = null): PlaybackResponse { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_POSITION_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_POSITION_REQ), position) + tlvWriter.put(ContextSpecificTag(TAG_POSITION_REQ), position) tlvWriter.endStructure() val request: InvokeRequest = @@ -949,55 +820,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return PlaybackResponse( - status_decoded, - data_decoded - ) + return PlaybackResponse(status_decoded, data_decoded) } - suspend fun activateAudioTrack(trackID: String - ,audioOutputIndex: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun activateAudioTrack( + trackID: String, + audioOutputIndex: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 12u val tlvWriter = TlvWriter() @@ -1007,7 +871,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_TRACK_I_D_REQ), trackID) val TAG_AUDIO_OUTPUT_INDEX_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX_REQ), audioOutputIndex) + tlvWriter.put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX_REQ), audioOutputIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -1021,15 +885,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun activateTextTrack(trackID: String - ,timedInvokeTimeout: Duration? = null) { + suspend fun activateTextTrack(trackID: String, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 13u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TRACK_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TRACK_I_D_REQ), trackID) + tlvWriter.put(ContextSpecificTag(TAG_TRACK_I_D_REQ), trackID) tlvWriter.endStructure() val request: InvokeRequest = @@ -1047,7 +910,7 @@ class AttributeListAttribute( val commandId: UInt = 14u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -1060,42 +923,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readCurrentStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1104,35 +960,37 @@ suspend fun readCurrentStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1144,52 +1002,46 @@ suspend fun readCurrentStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartTimeAttribute(): StartTimeAttribute {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStartTimeAttribute(): StartTimeAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Starttime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Starttime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartTimeAttribute(decodedValue) } @@ -1199,104 +1051,98 @@ suspend fun readStartTimeAttribute(): StartTimeAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Starttime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Starttime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDurationAttribute(): DurationAttribute {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDurationAttribute(): DurationAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Duration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Duration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DurationAttribute(decodedValue) } @@ -1306,104 +1152,98 @@ suspend fun readDurationAttribute(): DurationAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Duration attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Duration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DurationAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DurationAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSampledPositionAttribute(): SampledPositionAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSampledPositionAttribute(): SampledPositionAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sampledposition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sampledposition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SampledPositionAttribute(decodedValue) } @@ -1413,99 +1253,95 @@ suspend fun readSampledPositionAttribute(): SampledPositionAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SampledPositionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SampledPositionAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sampledposition attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Sampledposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SampledPositionAttributeSubscriptionState.Success(it)) - } - + val decodedValue: MediaPlaybackClusterPlaybackPositionStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterPlaybackPositionStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SampledPositionAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SampledPositionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPlaybackSpeedAttribute(): Float? {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPlaybackSpeedAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Playbackspeed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Playbackspeed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -1515,99 +1351,93 @@ suspend fun readPlaybackSpeedAttribute(): Float? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Playbackspeed attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Playbackspeed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSeekRangeEndAttribute(): SeekRangeEndAttribute {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSeekRangeEndAttribute(): SeekRangeEndAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Seekrangeend attribute not found in response" - } + } + + requireNotNull(attributeData) { "Seekrangeend attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SeekRangeEndAttribute(decodedValue) } @@ -1617,104 +1447,98 @@ suspend fun readSeekRangeEndAttribute(): SeekRangeEndAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SeekRangeEndAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SeekRangeEndAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Seekrangeend attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Seekrangeend attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SeekRangeEndAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SeekRangeEndAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SeekRangeEndAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSeekRangeStartAttribute(): SeekRangeStartAttribute {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSeekRangeStartAttribute(): SeekRangeStartAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Seekrangestart attribute not found in response" - } + } + + requireNotNull(attributeData) { "Seekrangestart attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SeekRangeStartAttribute(decodedValue) } @@ -1724,104 +1548,100 @@ suspend fun readSeekRangeStartAttribute(): SeekRangeStartAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SeekRangeStartAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SeekRangeStartAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Seekrangestart attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Seekrangestart attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SeekRangeStartAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SeekRangeStartAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SeekRangeStartAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveAudioTrackAttribute(): ActiveAudioTrackAttribute {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveAudioTrackAttribute(): ActiveAudioTrackAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeaudiotrack attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activeaudiotrack attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: MediaPlaybackClusterTrackStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActiveAudioTrackAttribute(decodedValue) } @@ -1831,110 +1651,106 @@ suspend fun readActiveAudioTrackAttribute(): ActiveAudioTrackAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveAudioTrackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveAudioTrackAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeaudiotrack attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activeaudiotrack attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActiveAudioTrackAttributeSubscriptionState.Success(it)) - } - + val decodedValue: MediaPlaybackClusterTrackStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActiveAudioTrackAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveAudioTrackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAvailableAudioTracksAttribute(): AvailableAudioTracksAttribute {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAvailableAudioTracksAttribute(): AvailableAudioTracksAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Availableaudiotracks attribute not found in response" - } + } + + requireNotNull(attributeData) { "Availableaudiotracks attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return AvailableAudioTracksAttribute(decodedValue) } @@ -1944,110 +1760,106 @@ suspend fun readAvailableAudioTracksAttribute(): AvailableAudioTracksAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AvailableAudioTracksAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AvailableAudioTracksAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Availableaudiotracks attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Availableaudiotracks attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AvailableAudioTracksAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AvailableAudioTracksAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AvailableAudioTracksAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveTextTrackAttribute(): ActiveTextTrackAttribute {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveTextTrackAttribute(): ActiveTextTrackAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetexttrack attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activetexttrack attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: MediaPlaybackClusterTrackStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActiveTextTrackAttribute(decodedValue) } @@ -2057,110 +1869,106 @@ suspend fun readActiveTextTrackAttribute(): ActiveTextTrackAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveTextTrackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveTextTrackAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetexttrack attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activetexttrack attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: MediaPlaybackClusterTrackStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActiveTextTrackAttributeSubscriptionState.Success(it)) - } - + val decodedValue: MediaPlaybackClusterTrackStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActiveTextTrackAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveTextTrackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAvailableTextTracksAttribute(): AvailableTextTracksAttribute {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAvailableTextTracksAttribute(): AvailableTextTracksAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Availabletexttracks attribute not found in response" - } + } + + requireNotNull(attributeData) { "Availabletexttracks attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return AvailableTextTracksAttribute(decodedValue) } @@ -2170,107 +1978,103 @@ suspend fun readAvailableTextTracksAttribute(): AvailableTextTracksAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AvailableTextTracksAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AvailableTextTracksAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Availabletexttracks attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Availabletexttracks attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AvailableTextTracksAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MediaPlaybackClusterTrackStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AvailableTextTracksAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AvailableTextTracksAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2280,45 +2084,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2326,49 +2135,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2378,45 +2181,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2424,49 +2232,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2476,45 +2278,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2522,49 +2327,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2574,45 +2373,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2620,44 +2422,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2666,35 +2461,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2706,44 +2503,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2752,34 +2542,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2792,7 +2586,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt index 08a1b816898255..2548f9fdc3e725 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenControlCluster.kt @@ -17,139 +17,104 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MicrowaveOvenControlCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedWattsAttribute( - val value: List? - ) +class MicrowaveOvenControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedWattsAttribute(val value: List?) sealed class SupportedWattsAttributeSubscriptionState { - data class Success( - val value: List? - ) : SupportedWattsAttributeSubscriptionState() - + data class Success(val value: List?) : SupportedWattsAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedWattsAttributeSubscriptionState() - object SubscriptionEstablished : SupportedWattsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedWattsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setCookingParameters(cookMode: UByte? - ,cookTime: UInt? - ,powerSetting: UByte? - ,wattSettingIndex: UByte? - ,startAfterSetting: Boolean? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setCookingParameters( + cookMode: UByte?, + cookTime: UInt?, + powerSetting: UByte?, + wattSettingIndex: UByte?, + startAfterSetting: Boolean?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_COOK_MODE_REQ: Int = 0 - cookMode?.let { - tlvWriter.put(ContextSpecificTag(TAG_COOK_MODE_REQ), cookMode) - } + cookMode?.let { tlvWriter.put(ContextSpecificTag(TAG_COOK_MODE_REQ), cookMode) } val TAG_COOK_TIME_REQ: Int = 1 - cookTime?.let { - tlvWriter.put(ContextSpecificTag(TAG_COOK_TIME_REQ), cookTime) - } + cookTime?.let { tlvWriter.put(ContextSpecificTag(TAG_COOK_TIME_REQ), cookTime) } val TAG_POWER_SETTING_REQ: Int = 2 - powerSetting?.let { - tlvWriter.put(ContextSpecificTag(TAG_POWER_SETTING_REQ), powerSetting) - } + powerSetting?.let { tlvWriter.put(ContextSpecificTag(TAG_POWER_SETTING_REQ), powerSetting) } val TAG_WATT_SETTING_INDEX_REQ: Int = 3 wattSettingIndex?.let { @@ -159,7 +124,7 @@ class AttributeListAttribute( val TAG_START_AFTER_SETTING_REQ: Int = 4 startAfterSetting?.let { tlvWriter.put(ContextSpecificTag(TAG_START_AFTER_SETTING_REQ), startAfterSetting) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -173,15 +138,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addMoreTime(timeToAdd: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun addMoreTime(timeToAdd: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TIME_TO_ADD_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TIME_TO_ADD_REQ), timeToAdd) + tlvWriter.put(ContextSpecificTag(TAG_TIME_TO_ADD_REQ), timeToAdd) tlvWriter.endStructure() val request: InvokeRequest = @@ -194,42 +158,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCookTimeAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cooktime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Cooktime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -238,35 +195,37 @@ suspend fun readCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Cooktime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Cooktime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -278,44 +237,37 @@ suspend fun readCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxCookTimeAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcooktime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxcooktime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -324,35 +276,37 @@ suspend fun readMaxCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcooktime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxcooktime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -364,47 +318,41 @@ suspend fun readMaxCookTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPowerSettingAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powersetting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powersetting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -414,94 +362,88 @@ suspend fun readPowerSettingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powersetting attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powersetting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinPowerAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinPowerAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -511,94 +453,88 @@ suspend fun readMinPowerAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxPowerAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxPowerAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpower attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxpower attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -608,94 +544,88 @@ suspend fun readMaxPowerAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpower attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxpower attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerStepAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPowerStepAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerstep attribute not found in response" - } + } + + requireNotNull(attributeData) { "Powerstep attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -705,100 +635,94 @@ suspend fun readPowerStepAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Powerstep attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Powerstep attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedWattsAttribute(): SupportedWattsAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedWattsAttribute(): SupportedWattsAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedwatts attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedwatts attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SupportedWattsAttribute(decodedValue) } @@ -808,100 +732,96 @@ suspend fun readSupportedWattsAttribute(): SupportedWattsAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedWattsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedWattsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedwatts attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedwatts attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SupportedWattsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SupportedWattsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SupportedWattsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSelectedWattIndexAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSelectedWattIndexAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selectedwattindex attribute not found in response" - } + } + + requireNotNull(attributeData) { "Selectedwattindex attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -911,94 +831,90 @@ suspend fun readSelectedWattIndexAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selectedwattindex attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Selectedwattindex attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWattRatingAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readWattRatingAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wattrating attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wattrating attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1008,96 +924,90 @@ suspend fun readWattRatingAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wattrating attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Wattrating attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1107,45 +1017,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1153,49 +1068,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1205,45 +1114,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1251,49 +1165,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1303,45 +1211,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1349,49 +1260,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1401,45 +1306,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1447,44 +1355,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1493,35 +1394,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1533,44 +1436,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1579,34 +1475,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1619,7 +1519,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt index 70c0c2f0b02c69..8362dcb4500717 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/MicrowaveOvenModeCluster.kt @@ -17,154 +17,113 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class MicrowaveOvenModeCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedModesAttribute( - val value: List - ) +class MicrowaveOvenModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -174,45 +133,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -220,44 +184,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -266,35 +223,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -306,49 +265,43 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -358,45 +311,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -404,49 +362,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -456,45 +408,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -502,49 +459,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -554,45 +505,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -600,49 +554,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -652,45 +600,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -698,44 +649,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -744,35 +688,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -784,44 +730,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -830,34 +769,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -870,7 +813,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt index e07ee80f76b046..0119244a4e3865 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ModeSelectCluster.kt @@ -17,162 +17,123 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ModeSelectCluster(private val controller: MatterController, private val endpointId: UShort) {class StandardNamespaceAttribute( - val value: UShort? - ) +class ModeSelectCluster(private val controller: MatterController, private val endpointId: UShort) { + class StandardNamespaceAttribute(val value: UShort?) sealed class StandardNamespaceAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : StandardNamespaceAttributeSubscriptionState() - + data class Success(val value: UShort?) : StandardNamespaceAttributeSubscriptionState() + data class Error(val exception: Exception) : StandardNamespaceAttributeSubscriptionState() - object SubscriptionEstablished : StandardNamespaceAttributeSubscriptionState() - } -class SupportedModesAttribute( - val value: List - ) + object SubscriptionEstablished : StandardNamespaceAttributeSubscriptionState() + } + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun changeToMode(newMode: UByte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -185,42 +146,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDescriptionAttribute(): String { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in response" - } + } + + requireNotNull(attributeData) { "Description attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -229,35 +183,37 @@ suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Description attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -269,48 +225,42 @@ suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 0u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStandardNamespaceAttribute(): StandardNamespaceAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStandardNamespaceAttribute(): StandardNamespaceAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Standardnamespace attribute not found in response" - } + } + + requireNotNull(attributeData) { "Standardnamespace attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return StandardNamespaceAttribute(decodedValue) } @@ -320,97 +270,93 @@ suspend fun readStandardNamespaceAttribute(): StandardNamespaceAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StandardNamespaceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StandardNamespaceAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Standardnamespace attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Standardnamespace attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StandardNamespaceAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StandardNamespaceAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StandardNamespaceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -420,45 +366,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -466,44 +417,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -512,35 +456,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -552,76 +498,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -643,7 +579,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -651,128 +587,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -794,7 +720,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 5u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -802,101 +728,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -906,45 +826,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -952,49 +877,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1004,45 +923,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1050,49 +974,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1102,45 +1020,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1148,49 +1069,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1200,45 +1115,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1246,44 +1164,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1292,35 +1203,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1332,44 +1245,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1378,34 +1284,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1418,7 +1328,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt index 87f6e08bbd6d68..c7568cff62a71f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/NetworkCommissioningCluster.kt @@ -17,209 +17,166 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class NetworkCommissioningCluster(private val controller: MatterController, private val endpointId: UShort) { +class NetworkCommissioningCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class ScanNetworksResponse( - val networkingStatus: UByte, - val debugText: String?, - val wiFiScanResults: List?, + val networkingStatus: UByte, + val debugText: String?, + val wiFiScanResults: List?, val threadScanResults: List? ) class NetworkConfigResponse( - val networkingStatus: UByte, - val debugText: String?, - val networkIndex: UByte?, - val clientIdentity: ByteArray?, + val networkingStatus: UByte, + val debugText: String?, + val networkIndex: UByte?, + val clientIdentity: ByteArray?, val possessionSignature: ByteArray? ) class ConnectNetworkResponse( - val networkingStatus: UByte, - val debugText: String?, + val networkingStatus: UByte, + val debugText: String?, val errorValue: Int? ) - class QueryIdentityResponse( - val identity: ByteArray, - val possessionSignature: ByteArray? - ) -class NetworksAttribute( - val value: List - ) + class QueryIdentityResponse(val identity: ByteArray, val possessionSignature: ByteArray?) + + class NetworksAttribute(val value: List) sealed class NetworksAttributeSubscriptionState { - data class Success( - val value: List - ) : NetworksAttributeSubscriptionState() - + data class Success(val value: List) : + NetworksAttributeSubscriptionState() + data class Error(val exception: Exception) : NetworksAttributeSubscriptionState() - object SubscriptionEstablished : NetworksAttributeSubscriptionState() - } -class LastNetworkingStatusAttribute( - val value: UByte? - ) + object SubscriptionEstablished : NetworksAttributeSubscriptionState() + } + + class LastNetworkingStatusAttribute(val value: UByte?) sealed class LastNetworkingStatusAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : LastNetworkingStatusAttributeSubscriptionState() - + data class Success(val value: UByte?) : LastNetworkingStatusAttributeSubscriptionState() + data class Error(val exception: Exception) : LastNetworkingStatusAttributeSubscriptionState() - object SubscriptionEstablished : LastNetworkingStatusAttributeSubscriptionState() - } -class LastNetworkIDAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : LastNetworkingStatusAttributeSubscriptionState() + } + + class LastNetworkIDAttribute(val value: ByteArray?) sealed class LastNetworkIDAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : LastNetworkIDAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : LastNetworkIDAttributeSubscriptionState() + data class Error(val exception: Exception) : LastNetworkIDAttributeSubscriptionState() - object SubscriptionEstablished : LastNetworkIDAttributeSubscriptionState() - } -class LastConnectErrorValueAttribute( - val value: Int? - ) + object SubscriptionEstablished : LastNetworkIDAttributeSubscriptionState() + } + + class LastConnectErrorValueAttribute(val value: Int?) sealed class LastConnectErrorValueAttributeSubscriptionState { - data class Success( - val value: Int? - ) : LastConnectErrorValueAttributeSubscriptionState() - + data class Success(val value: Int?) : LastConnectErrorValueAttributeSubscriptionState() + data class Error(val exception: Exception) : LastConnectErrorValueAttributeSubscriptionState() - object SubscriptionEstablished : LastConnectErrorValueAttributeSubscriptionState() - } -class SupportedWiFiBandsAttribute( - val value: List? - ) + object SubscriptionEstablished : LastConnectErrorValueAttributeSubscriptionState() + } + + class SupportedWiFiBandsAttribute(val value: List?) sealed class SupportedWiFiBandsAttributeSubscriptionState { - data class Success( - val value: List? - ) : SupportedWiFiBandsAttributeSubscriptionState() - + data class Success(val value: List?) : SupportedWiFiBandsAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedWiFiBandsAttributeSubscriptionState() - object SubscriptionEstablished : SupportedWiFiBandsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedWiFiBandsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun scanNetworks(ssid: ByteArray? - ,breadcrumb: ULong? - ,timedInvokeTimeout: Duration? = null): ScanNetworksResponse { + suspend fun scanNetworks( + ssid: ByteArray?, + breadcrumb: ULong?, + timedInvokeTimeout: Duration? = null + ): ScanNetworksResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SSID_REQ: Int = 0 - ssid?.let { - tlvWriter.put(ContextSpecificTag(TAG_SSID_REQ), ssid) - } + ssid?.let { tlvWriter.put(ContextSpecificTag(TAG_SSID_REQ), ssid) } val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } tlvWriter.endStructure() val request: InvokeRequest = @@ -236,89 +193,96 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_WI_FI_SCAN_RESULTS: Int = 2 - var wiFiScanResults_decoded: List? = null - + var wiFiScanResults_decoded: List? = + null + val TAG_THREAD_SCAN_RESULTS: Int = 3 - var threadScanResults_decoded: List? = null - + var threadScanResults_decoded: + List? = + null while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_WI_FI_SCAN_RESULTS)) {wiFiScanResults_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_WI_FI_SCAN_RESULTS)) { + wiFiScanResults_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(NetworkCommissioningClusterWiFiInterfaceScanResultStruct.fromTlv(AnonymousTag, tlvReader)) + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add( + NetworkCommissioningClusterWiFiInterfaceScanResultStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } } - tlvReader.exitContainer() - } - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_THREAD_SCAN_RESULTS)) {threadScanResults_decoded = + + if (tag == ContextSpecificTag(TAG_THREAD_SCAN_RESULTS)) { + threadScanResults_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(NetworkCommissioningClusterThreadInterfaceScanResultStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - - else { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add( + NetworkCommissioningClusterThreadInterfaceScanResultStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - - - tlvReader.exitContainer() @@ -330,13 +294,15 @@ class AttributeListAttribute( ) } - suspend fun addOrUpdateWiFiNetwork(ssid: ByteArray - ,credentials: ByteArray - ,breadcrumb: ULong? - ,networkIdentity: ByteArray? - ,clientIdentifier: ByteArray? - ,possessionNonce: ByteArray? - ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { + suspend fun addOrUpdateWiFiNetwork( + ssid: ByteArray, + credentials: ByteArray, + breadcrumb: ULong?, + networkIdentity: ByteArray?, + clientIdentifier: ByteArray?, + possessionNonce: ByteArray?, + timedInvokeTimeout: Duration? = null + ): NetworkConfigResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -349,9 +315,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_CREDENTIALS_REQ), credentials) val TAG_BREADCRUMB_REQ: Int = 2 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } val TAG_NETWORK_IDENTITY_REQ: Int = 3 networkIdentity?.let { @@ -366,7 +330,7 @@ class AttributeListAttribute( val TAG_POSSESSION_NONCE_REQ: Int = 5 possessionNonce?.let { tlvWriter.put(ContextSpecificTag(TAG_POSSESSION_NONCE_REQ), possessionNonce) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -383,94 +347,88 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - - - - - tlvReader.exitContainer() @@ -483,9 +441,11 @@ class AttributeListAttribute( ) } - suspend fun addOrUpdateThreadNetwork(operationalDataset: ByteArray - ,breadcrumb: ULong? - ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { + suspend fun addOrUpdateThreadNetwork( + operationalDataset: ByteArray, + breadcrumb: ULong?, + timedInvokeTimeout: Duration? = null + ): NetworkConfigResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() @@ -495,9 +455,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_OPERATIONAL_DATASET_REQ), operationalDataset) val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } tlvWriter.endStructure() val request: InvokeRequest = @@ -514,94 +472,88 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - - - - - tlvReader.exitContainer() @@ -614,9 +566,11 @@ class AttributeListAttribute( ) } - suspend fun removeNetwork(networkID: ByteArray - ,breadcrumb: ULong? - ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { + suspend fun removeNetwork( + networkID: ByteArray, + breadcrumb: ULong?, + timedInvokeTimeout: Duration? = null + ): NetworkConfigResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -626,9 +580,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_NETWORK_I_D_REQ), networkID) val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } tlvWriter.endStructure() val request: InvokeRequest = @@ -645,94 +597,88 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - - - - - tlvReader.exitContainer() @@ -745,9 +691,11 @@ class AttributeListAttribute( ) } - suspend fun connectNetwork(networkID: ByteArray - ,breadcrumb: ULong? - ,timedInvokeTimeout: Duration? = null): ConnectNetworkResponse { + suspend fun connectNetwork( + networkID: ByteArray, + breadcrumb: ULong?, + timedInvokeTimeout: Duration? = null + ): ConnectNetworkResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -757,9 +705,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_NETWORK_I_D_REQ), networkID) val TAG_BREADCRUMB_REQ: Int = 1 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } tlvWriter.endStructure() val request: InvokeRequest = @@ -776,75 +722,67 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_ERROR_VALUE: Int = 2 var errorValue_decoded: Int? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_ERROR_VALUE)) {errorValue_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_ERROR_VALUE)) { + errorValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getInt(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + tlvReader.getInt(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - tlvReader.exitContainer() - return ConnectNetworkResponse( - networkingStatus_decoded, - debugText_decoded, - errorValue_decoded - ) + return ConnectNetworkResponse(networkingStatus_decoded, debugText_decoded, errorValue_decoded) } - suspend fun reorderNetwork(networkID: ByteArray - ,networkIndex: UByte - ,breadcrumb: ULong? - ,timedInvokeTimeout: Duration? = null): NetworkConfigResponse { + suspend fun reorderNetwork( + networkID: ByteArray, + networkIndex: UByte, + breadcrumb: ULong?, + timedInvokeTimeout: Duration? = null + ): NetworkConfigResponse { val commandId: UInt = 8u val tlvWriter = TlvWriter() @@ -857,9 +795,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_NETWORK_INDEX_REQ), networkIndex) val TAG_BREADCRUMB_REQ: Int = 2 - breadcrumb?.let { - tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) - } + breadcrumb?.let { tlvWriter.put(ContextSpecificTag(TAG_BREADCRUMB_REQ), breadcrumb) } tlvWriter.endStructure() val request: InvokeRequest = @@ -876,94 +812,88 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NETWORKING_STATUS: Int = 0 var networkingStatus_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 1 var debugText_decoded: String? = null - + val TAG_NETWORK_INDEX: Int = 2 var networkIndex_decoded: UByte? = null - + val TAG_CLIENT_IDENTITY: Int = 3 var clientIdentity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 4 var possessionSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) {networkingStatus_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + if (tag == ContextSpecificTag(TAG_NETWORKING_STATUS)) { + networkingStatus_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) {networkIndex_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NETWORK_INDEX)) { + networkIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) {clientIdentity_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_CLIENT_IDENTITY)) { + clientIdentity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (networkingStatus_decoded == null) { - throw IllegalStateException("networkingStatus not found in TLV") + throw IllegalStateException("networkingStatus not found in TLV") } - - - - - - - - - tlvReader.exitContainer() @@ -976,9 +906,11 @@ class AttributeListAttribute( ) } - suspend fun queryIdentity(keyIdentifier: ByteArray - ,possessionNonce: ByteArray? - ,timedInvokeTimeout: Duration? = null): QueryIdentityResponse { + suspend fun queryIdentity( + keyIdentifier: ByteArray, + possessionNonce: ByteArray?, + timedInvokeTimeout: Duration? = null + ): QueryIdentityResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -990,7 +922,7 @@ class AttributeListAttribute( val TAG_POSSESSION_NONCE_REQ: Int = 1 possessionNonce?.let { tlvWriter.put(ContextSpecificTag(TAG_POSSESSION_NONCE_REQ), possessionNonce) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1007,87 +939,71 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_IDENTITY: Int = 0 var identity_decoded: ByteArray? = null - + val TAG_POSSESSION_SIGNATURE: Int = 1 var possessionSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_IDENTITY)) {identity_decoded = tlvReader.getByteArray(tag)} - - if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) {possessionSignature_decoded = + if (tag == ContextSpecificTag(TAG_IDENTITY)) { + identity_decoded = tlvReader.getByteArray(tag) + } + + if (tag == ContextSpecificTag(TAG_POSSESSION_SIGNATURE)) { + possessionSignature_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (identity_decoded == null) { - throw IllegalStateException("identity not found in TLV") + throw IllegalStateException("identity not found in TLV") } - - - tlvReader.exitContainer() - return QueryIdentityResponse( - identity_decoded, - possessionSignature_decoded - ) + return QueryIdentityResponse(identity_decoded, possessionSignature_decoded) } -suspend fun readMaxNetworksAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxNetworksAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxnetworks attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxnetworks attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1096,35 +1012,37 @@ suspend fun readMaxNetworksAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxnetworks attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxnetworks attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1136,49 +1054,43 @@ suspend fun readMaxNetworksAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNetworksAttribute(): NetworksAttribute {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNetworksAttribute(): NetworksAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networks attribute not found in response" - } + } + + requireNotNull(attributeData) { "Networks attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return NetworksAttribute(decodedValue) } @@ -1188,45 +1100,48 @@ suspend fun readNetworksAttribute(): NetworksAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NetworksAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NetworksAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networks attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Networks attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(NetworkCommissioningClusterNetworkInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(NetworksAttributeSubscriptionState.Success(decodedValue)) } @@ -1234,47 +1149,41 @@ suspend fun readNetworksAttribute(): NetworksAttribute {val ATTRIBUTE_ID: UInt = emit(NetworksAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScanMaxTimeSecondsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readScanMaxTimeSecondsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scanmaxtimeseconds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scanmaxtimeseconds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1284,94 +1193,90 @@ suspend fun readScanMaxTimeSecondsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scanmaxtimeseconds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scanmaxtimeseconds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readConnectMaxTimeSecondsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readConnectMaxTimeSecondsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Connectmaxtimeseconds attribute not found in response" - } + } + + requireNotNull(attributeData) { "Connectmaxtimeseconds attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1381,114 +1286,105 @@ suspend fun readConnectMaxTimeSecondsAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Connectmaxtimeseconds attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Connectmaxtimeseconds attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInterfaceEnabledAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interfaceenabled attribute not found in response" - } + } + + requireNotNull(attributeData) { "Interfaceenabled attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writeInterfaceEnabledAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeInterfaceEnabledAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1510,7 +1406,7 @@ suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInterfaceEnabledAttribute( @@ -1518,34 +1414,38 @@ suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interfaceenabled attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Interfaceenabled attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1558,48 +1458,42 @@ suspend fun readInterfaceEnabledAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 4 emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLastNetworkingStatusAttribute(): LastNetworkingStatusAttribute {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLastNetworkingStatusAttribute(): LastNetworkingStatusAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastnetworkingstatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastnetworkingstatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastNetworkingStatusAttribute(decodedValue) } @@ -1609,96 +1503,92 @@ suspend fun readLastNetworkingStatusAttribute(): LastNetworkingStatusAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastNetworkingStatusAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastNetworkingStatusAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastnetworkingstatus attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lastnetworkingstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LastNetworkingStatusAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LastNetworkingStatusAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastNetworkingStatusAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLastNetworkIDAttribute(): LastNetworkIDAttribute {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLastNetworkIDAttribute(): LastNetworkIDAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastnetworkid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastnetworkid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastNetworkIDAttribute(decodedValue) } @@ -1708,96 +1598,90 @@ suspend fun readLastNetworkIDAttribute(): LastNetworkIDAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastNetworkIDAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastNetworkIDAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastnetworkid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Lastnetworkid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LastNetworkIDAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LastNetworkIDAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastNetworkIDAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLastConnectErrorValueAttribute(): LastConnectErrorValueAttribute {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLastConnectErrorValueAttribute(): LastConnectErrorValueAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastconnecterrorvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastconnecterrorvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastConnectErrorValueAttribute(decodedValue) } @@ -1807,101 +1691,97 @@ suspend fun readLastConnectErrorValueAttribute(): LastConnectErrorValueAttribute maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastConnectErrorValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastConnectErrorValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastconnecterrorvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lastconnecterrorvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LastConnectErrorValueAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LastConnectErrorValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastConnectErrorValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedWiFiBandsAttribute(): SupportedWiFiBandsAttribute {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSupportedWiFiBandsAttribute(): SupportedWiFiBandsAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedwifibands attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedwifibands attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SupportedWiFiBandsAttribute(decodedValue) } @@ -1911,100 +1791,96 @@ suspend fun readSupportedWiFiBandsAttribute(): SupportedWiFiBandsAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedWiFiBandsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedWiFiBandsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedwifibands attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedwifibands attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SupportedWiFiBandsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SupportedWiFiBandsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SupportedWiFiBandsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedThreadFeaturesAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSupportedThreadFeaturesAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedthreadfeatures attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedthreadfeatures attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2014,94 +1890,90 @@ suspend fun readSupportedThreadFeaturesAttribute(): UShort? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedthreadfeatures attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedthreadfeatures attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readThreadVersionAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readThreadVersionAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Threadversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2111,96 +1983,90 @@ suspend fun readThreadVersionAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadversion attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Threadversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2210,45 +2076,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2256,49 +2127,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2308,45 +2173,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2354,49 +2224,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2406,45 +2270,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2452,49 +2319,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2504,45 +2365,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2550,44 +2414,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2596,35 +2453,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2636,44 +2495,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2682,34 +2534,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2722,7 +2578,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt index d34170fb14b72c..d44ee68b808e62 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/NitrogenDioxideConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class NitrogenDioxideConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class NitrogenDioxideConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,11 +1742,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(NitrogenDioxideConcentrationMeasurementCluster::class.java.name) + private val logger = + Logger.getLogger(NitrogenDioxideConcentrationMeasurementCluster::class.java.name) const val CLUSTER_ID: UInt = 1043u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt index f568e8f24179fb..8dd16f44cabe05 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OccupancySensingCluster.kt @@ -17,136 +17,100 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OccupancySensingCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class OccupancySensingCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readOccupancyAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readOccupancyAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupancy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -155,35 +119,37 @@ suspend fun readOccupancyAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancy attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Occupancy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -195,44 +161,37 @@ suspend fun readOccupancyAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupancySensorTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOccupancySensorTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancysensortype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupancysensortype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -241,34 +200,38 @@ suspend fun readOccupancySensorTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancysensortype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupancysensortype attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -281,44 +244,37 @@ suspend fun readOccupancySensorTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupancySensorTypeBitmapAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOccupancySensorTypeBitmapAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancysensortypebitmap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupancysensortypebitmap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -327,34 +283,38 @@ suspend fun readOccupancySensorTypeBitmapAttribute(): UByte {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancysensortypebitmap attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupancysensortypebitmap attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -367,71 +327,64 @@ suspend fun readOccupancySensorTypeBitmapAttribute(): UByte {val ATTRIBUTE_ID: U emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Piroccupiedtounoccupieddelay attribute not found in response" - } + } + + requireNotNull(attributeData) { "Piroccupiedtounoccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePIROccupiedToUnoccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -453,7 +406,7 @@ suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePIROccupiedToUnoccupiedDelayAttribute( @@ -461,118 +414,113 @@ suspend fun readPIROccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Piroccupiedtounoccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Piroccupiedtounoccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pirunoccupiedtooccupieddelay attribute not found in response" - } + } + + requireNotNull(attributeData) { "Pirunoccupiedtooccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePIRUnoccupiedToOccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -594,7 +542,7 @@ suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePIRUnoccupiedToOccupiedDelayAttribute( @@ -602,118 +550,115 @@ suspend fun readPIRUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pirunoccupiedtooccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Pirunoccupiedtooccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 18u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pirunoccupiedtooccupiedthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Pirunoccupiedtooccupiedthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePIRUnoccupiedToOccupiedThresholdAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -735,7 +680,7 @@ suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBU throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePIRUnoccupiedToOccupiedThresholdAttribute( @@ -743,118 +688,115 @@ suspend fun readPIRUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBU maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pirunoccupiedtooccupiedthreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Pirunoccupiedtooccupiedthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 32u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicoccupiedtounoccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Ultrasonicoccupiedtounoccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUltrasonicOccupiedToUnoccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 32u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -876,7 +818,7 @@ suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort? {val ATT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUltrasonicOccupiedToUnoccupiedDelayAttribute( @@ -884,118 +826,115 @@ suspend fun readUltrasonicOccupiedToUnoccupiedDelayAttribute(): UShort? {val ATT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicoccupiedtounoccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ultrasonicoccupiedtounoccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 33u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUltrasonicUnoccupiedToOccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1017,7 +956,7 @@ suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUltrasonicUnoccupiedToOccupiedDelayAttribute( @@ -1025,118 +964,115 @@ suspend fun readUltrasonicUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUltrasonicUnoccupiedToOccupiedThresholdAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 34u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1158,7 +1094,7 @@ suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte? {val throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUltrasonicUnoccupiedToOccupiedThresholdAttribute( @@ -1166,118 +1102,115 @@ suspend fun readUltrasonicUnoccupiedToOccupiedThresholdAttribute(): UByte? {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ultrasonicunoccupiedtooccupiedthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 48u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactoccupiedtounoccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Physicalcontactoccupiedtounoccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePhysicalContactOccupiedToUnoccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1299,7 +1232,7 @@ suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort? {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePhysicalContactOccupiedToUnoccupiedDelayAttribute( @@ -1307,118 +1240,115 @@ suspend fun readPhysicalContactOccupiedToUnoccupiedDelayAttribute(): UShort? {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactoccupiedtounoccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalcontactoccupiedtounoccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 49u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupieddelay attribute not found in response" + } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupieddelay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePhysicalContactUnoccupiedToOccupiedDelayAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1440,7 +1370,7 @@ suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort? {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePhysicalContactUnoccupiedToOccupiedDelayAttribute( @@ -1448,118 +1378,115 @@ suspend fun readPhysicalContactUnoccupiedToOccupiedDelayAttribute(): UShort? {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupieddelay attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupieddelay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 50u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in response" + } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writePhysicalContactUnoccupiedToOccupiedThresholdAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1581,7 +1508,7 @@ suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte? throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePhysicalContactUnoccupiedToOccupiedThresholdAttribute( @@ -1589,96 +1516,92 @@ suspend fun readPhysicalContactUnoccupiedToOccupiedThresholdAttribute(): UByte? maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalcontactunoccupiedtooccupiedthreshold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1688,45 +1611,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1734,49 +1662,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1786,45 +1708,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1832,49 +1759,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1884,45 +1805,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1930,49 +1854,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1982,45 +1900,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2028,44 +1949,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2074,35 +1988,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2114,44 +2030,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2160,34 +2069,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2200,7 +2113,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt index 8897b4bd04a433..b0801165c6d93c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffCluster.kt @@ -17,119 +17,88 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OnOffCluster(private val controller: MatterController, private val endpointId: UShort) {class StartUpOnOffAttribute( - val value: UByte? - ) +class OnOffCluster(private val controller: MatterController, private val endpointId: UShort) { + class StartUpOnOffAttribute(val value: UByte?) sealed class StartUpOnOffAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpOnOffAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpOnOffAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpOnOffAttributeSubscriptionState() - object SubscriptionEstablished : StartUpOnOffAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : StartUpOnOffAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun off(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -147,7 +116,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -165,7 +134,7 @@ class AttributeListAttribute( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -179,9 +148,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun offWithEffect(effectIdentifier: UByte - ,effectVariant: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun offWithEffect( + effectIdentifier: UByte, + effectVariant: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -191,7 +162,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_EFFECT_IDENTIFIER_REQ), effectIdentifier) val TAG_EFFECT_VARIANT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) + tlvWriter.put(ContextSpecificTag(TAG_EFFECT_VARIANT_REQ), effectVariant) tlvWriter.endStructure() val request: InvokeRequest = @@ -209,7 +180,7 @@ class AttributeListAttribute( val commandId: UInt = 65u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -223,10 +194,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun onWithTimedOff(onOffControl: UByte - ,onTime: UShort - ,offWaitTime: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun onWithTimedOff( + onOffControl: UByte, + onTime: UShort, + offWaitTime: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 66u val tlvWriter = TlvWriter() @@ -239,7 +212,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ON_TIME_REQ), onTime) val TAG_OFF_WAIT_TIME_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_OFF_WAIT_TIME_REQ), offWaitTime) + tlvWriter.put(ContextSpecificTag(TAG_OFF_WAIT_TIME_REQ), offWaitTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -252,42 +225,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readOnOffAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnOffAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onoff attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onoff attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -296,35 +262,37 @@ suspend fun readOnOffAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onoff attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onoff attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -336,47 +304,41 @@ suspend fun readOnOffAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGlobalSceneControlAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 16384u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGlobalSceneControlAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Globalscenecontrol attribute not found in response" - } + } + + requireNotNull(attributeData) { "Globalscenecontrol attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -386,118 +348,110 @@ suspend fun readGlobalSceneControlAttribute(): Boolean? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Globalscenecontrol attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Globalscenecontrol attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16385u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16385u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ontime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ontime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeOnTimeAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16385u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -519,7 +473,7 @@ suspend fun readOnTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16385u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnTimeAttribute( @@ -527,118 +481,108 @@ suspend fun readOnTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16385u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16385u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ontime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Ontime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOffWaitTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16386u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOffWaitTimeAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16386u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Offwaittime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Offwaittime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeOffWaitTimeAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeOffWaitTimeAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16386u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -660,7 +604,7 @@ suspend fun readOffWaitTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16386u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOffWaitTimeAttribute( @@ -668,123 +612,113 @@ suspend fun readOffWaitTimeAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16386u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16386u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Offwaittime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Offwaittime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute {val ATTRIBUTE_ID: UInt = 16387u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute { + val ATTRIBUTE_ID: UInt = 16387u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startuponoff attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startuponoff attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpOnOffAttribute(decodedValue) } - suspend fun writeStartUpOnOffAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpOnOffAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16387u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -806,7 +740,7 @@ suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute {val ATTRIBUTE_ID throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpOnOffAttribute( @@ -814,101 +748,95 @@ suspend fun readStartUpOnOffAttribute(): StartUpOnOffAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16387u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpOnOffAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpOnOffAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startuponoff attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startuponoff attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpOnOffAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpOnOffAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpOnOffAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -918,45 +846,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -964,49 +897,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1016,45 +943,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1062,49 +994,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1114,45 +1040,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1160,49 +1089,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1212,45 +1135,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1258,44 +1184,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1304,35 +1223,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1344,44 +1265,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1390,34 +1304,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1430,7 +1348,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt index d30268d4c2280c..7359a28163aae6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OnOffSwitchConfigurationCluster.kt @@ -17,136 +17,100 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OnOffSwitchConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class OnOffSwitchConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readSwitchTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readSwitchTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Switchtype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Switchtype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -155,35 +119,37 @@ suspend fun readSwitchTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Switchtype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Switchtype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -195,67 +161,56 @@ suspend fun readSwitchTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSwitchActionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSwitchActionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Switchactions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Switchactions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeSwitchActionsAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeSwitchActionsAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -277,7 +232,7 @@ suspend fun readSwitchActionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSwitchActionsAttribute( @@ -285,35 +240,37 @@ suspend fun readSwitchActionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Switchactions attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Switchactions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -325,49 +282,43 @@ suspend fun readSwitchActionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 16u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -377,45 +328,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -423,49 +379,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -475,45 +425,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -521,49 +476,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -573,45 +522,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -619,49 +571,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -671,45 +617,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -717,44 +666,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -763,35 +705,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -803,44 +747,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -849,34 +786,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -889,7 +830,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt index ee45ff6bc3af2a..cfc1103e4216f4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalCredentialsCluster.kt @@ -17,169 +17,129 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalCredentialsCluster(private val controller: MatterController, private val endpointId: UShort) { +class OperationalCredentialsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class AttestationResponse( - val attestationElements: ByteArray, + val attestationElements: ByteArray, val attestationSignature: ByteArray ) - class CertificateChainResponse( - val certificate: ByteArray - ) + class CertificateChainResponse(val certificate: ByteArray) - class CSRResponse( - val NOCSRElements: ByteArray, - val attestationSignature: ByteArray - ) + class CSRResponse(val NOCSRElements: ByteArray, val attestationSignature: ByteArray) - class NOCResponse( - val statusCode: UByte, - val fabricIndex: UByte?, - val debugText: String? - ) -class NOCsAttribute( - val value: List - ) + class NOCResponse(val statusCode: UByte, val fabricIndex: UByte?, val debugText: String?) + + class NOCsAttribute(val value: List) sealed class NOCsAttributeSubscriptionState { - data class Success( - val value: List - ) : NOCsAttributeSubscriptionState() - + data class Success(val value: List) : + NOCsAttributeSubscriptionState() + data class Error(val exception: Exception) : NOCsAttributeSubscriptionState() - object SubscriptionEstablished : NOCsAttributeSubscriptionState() - } -class FabricsAttribute( - val value: List - ) + object SubscriptionEstablished : NOCsAttributeSubscriptionState() + } + + class FabricsAttribute(val value: List) sealed class FabricsAttributeSubscriptionState { - data class Success( - val value: List - ) : FabricsAttributeSubscriptionState() - + data class Success(val value: List) : + FabricsAttributeSubscriptionState() + data class Error(val exception: Exception) : FabricsAttributeSubscriptionState() - object SubscriptionEstablished : FabricsAttributeSubscriptionState() - } -class TrustedRootCertificatesAttribute( - val value: List - ) + object SubscriptionEstablished : FabricsAttributeSubscriptionState() + } + + class TrustedRootCertificatesAttribute(val value: List) sealed class TrustedRootCertificatesAttributeSubscriptionState { - data class Success( - val value: List - ) : TrustedRootCertificatesAttributeSubscriptionState() - - data class Error(val exception: Exception) : TrustedRootCertificatesAttributeSubscriptionState() - - object SubscriptionEstablished : TrustedRootCertificatesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List) : + TrustedRootCertificatesAttributeSubscriptionState() + + data class Error(val exception: Exception) : + TrustedRootCertificatesAttributeSubscriptionState() + + object SubscriptionEstablished : TrustedRootCertificatesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun attestationRequest(attestationNonce: ByteArray - ,timedInvokeTimeout: Duration? = null): AttestationResponse { + suspend fun attestationRequest( + attestationNonce: ByteArray, + timedInvokeTimeout: Duration? = null + ): AttestationResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ATTESTATION_NONCE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ATTESTATION_NONCE_REQ), attestationNonce) + tlvWriter.put(ContextSpecificTag(TAG_ATTESTATION_NONCE_REQ), attestationNonce) tlvWriter.endStructure() val request: InvokeRequest = @@ -196,54 +156,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ATTESTATION_ELEMENTS: Int = 0 var attestationElements_decoded: ByteArray? = null - + val TAG_ATTESTATION_SIGNATURE: Int = 1 var attestationSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ATTESTATION_ELEMENTS)) {attestationElements_decoded = tlvReader.getByteArray(tag)} - - if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) {attestationSignature_decoded = tlvReader.getByteArray(tag)} - + if (tag == ContextSpecificTag(TAG_ATTESTATION_ELEMENTS)) { + attestationElements_decoded = tlvReader.getByteArray(tag) + } - else { + if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) { + attestationSignature_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (attestationElements_decoded == null) { - throw IllegalStateException("attestationElements not found in TLV") + throw IllegalStateException("attestationElements not found in TLV") } - - + if (attestationSignature_decoded == null) { - throw IllegalStateException("attestationSignature not found in TLV") + throw IllegalStateException("attestationSignature not found in TLV") } - tlvReader.exitContainer() - return AttestationResponse( - attestationElements_decoded, - attestationSignature_decoded - ) + return AttestationResponse(attestationElements_decoded, attestationSignature_decoded) } - suspend fun certificateChainRequest(certificateType: UByte - ,timedInvokeTimeout: Duration? = null): CertificateChainResponse { + suspend fun certificateChainRequest( + certificateType: UByte, + timedInvokeTimeout: Duration? = null + ): CertificateChainResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_CERTIFICATE_TYPE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_CERTIFICATE_TYPE_REQ), certificateType) + tlvWriter.put(ContextSpecificTag(TAG_CERTIFICATE_TYPE_REQ), certificateType) tlvWriter.endStructure() val request: InvokeRequest = @@ -260,37 +214,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_CERTIFICATE: Int = 0 var certificate_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_CERTIFICATE)) {certificate_decoded = tlvReader.getByteArray(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_CERTIFICATE)) { + certificate_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (certificate_decoded == null) { - throw IllegalStateException("certificate not found in TLV") + throw IllegalStateException("certificate not found in TLV") } - tlvReader.exitContainer() - return CertificateChainResponse( - certificate_decoded - ) + return CertificateChainResponse(certificate_decoded) } - suspend fun CSRRequest(CSRNonce: ByteArray - ,isForUpdateNOC: Boolean? - ,timedInvokeTimeout: Duration? = null): CSRResponse { + suspend fun CSRRequest( + CSRNonce: ByteArray, + isForUpdateNOC: Boolean?, + timedInvokeTimeout: Duration? = null + ): CSRResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -302,7 +250,7 @@ class AttributeListAttribute( val TAG_IS_FOR_UPDATE_N_O_C_REQ: Int = 1 isForUpdateNOC?.let { tlvWriter.put(ContextSpecificTag(TAG_IS_FOR_UPDATE_N_O_C_REQ), isForUpdateNOC) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -319,51 +267,45 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_N_O_C_S_R_ELEMENTS: Int = 0 var NOCSRElements_decoded: ByteArray? = null - + val TAG_ATTESTATION_SIGNATURE: Int = 1 var attestationSignature_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_N_O_C_S_R_ELEMENTS)) {NOCSRElements_decoded = tlvReader.getByteArray(tag)} - - if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) {attestationSignature_decoded = tlvReader.getByteArray(tag)} - + if (tag == ContextSpecificTag(TAG_N_O_C_S_R_ELEMENTS)) { + NOCSRElements_decoded = tlvReader.getByteArray(tag) + } - else { + if (tag == ContextSpecificTag(TAG_ATTESTATION_SIGNATURE)) { + attestationSignature_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (NOCSRElements_decoded == null) { - throw IllegalStateException("NOCSRElements not found in TLV") + throw IllegalStateException("NOCSRElements not found in TLV") } - - + if (attestationSignature_decoded == null) { - throw IllegalStateException("attestationSignature not found in TLV") + throw IllegalStateException("attestationSignature not found in TLV") } - tlvReader.exitContainer() - return CSRResponse( - NOCSRElements_decoded, - attestationSignature_decoded - ) + return CSRResponse(NOCSRElements_decoded, attestationSignature_decoded) } - suspend fun addNOC(NOCValue: ByteArray - ,ICACValue: ByteArray? - ,IPKValue: ByteArray - ,caseAdminSubject: ULong - ,adminVendorId: UShort - ,timedInvokeTimeout: Duration? = null): NOCResponse { + suspend fun addNOC( + NOCValue: ByteArray, + ICACValue: ByteArray?, + IPKValue: ByteArray, + caseAdminSubject: ULong, + adminVendorId: UShort, + timedInvokeTimeout: Duration? = null + ): NOCResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -373,9 +315,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_N_O_C_VALUE_REQ), NOCValue) val TAG_I_C_A_C_VALUE_REQ: Int = 1 - ICACValue?.let { - tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) - } + ICACValue?.let { tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) } val TAG_I_P_K_VALUE_REQ: Int = 2 tlvWriter.put(ContextSpecificTag(TAG_I_P_K_VALUE_REQ), IPKValue) @@ -384,7 +324,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_CASE_ADMIN_SUBJECT_REQ), caseAdminSubject) val TAG_ADMIN_VENDOR_ID_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_ADMIN_VENDOR_ID_REQ), adminVendorId) + tlvWriter.put(ContextSpecificTag(TAG_ADMIN_VENDOR_ID_REQ), adminVendorId) tlvWriter.endStructure() val request: InvokeRequest = @@ -401,73 +341,65 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } - - - - - tlvReader.exitContainer() - return NOCResponse( - statusCode_decoded, - fabricIndex_decoded, - debugText_decoded - ) + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) } - suspend fun updateNOC(NOCValue: ByteArray - ,ICACValue: ByteArray? - ,timedInvokeTimeout: Duration? = null): NOCResponse { + suspend fun updateNOC( + NOCValue: ByteArray, + ICACValue: ByteArray?, + timedInvokeTimeout: Duration? = null + ): NOCResponse { val commandId: UInt = 7u val tlvWriter = TlvWriter() @@ -477,9 +409,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_N_O_C_VALUE_REQ), NOCValue) val TAG_I_C_A_C_VALUE_REQ: Int = 1 - ICACValue?.let { - tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) - } + ICACValue?.let { tlvWriter.put(ContextSpecificTag(TAG_I_C_A_C_VALUE_REQ), ICACValue) } tlvWriter.endStructure() val request: InvokeRequest = @@ -496,79 +426,68 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } - - - - - tlvReader.exitContainer() - return NOCResponse( - statusCode_decoded, - fabricIndex_decoded, - debugText_decoded - ) + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) } - suspend fun updateFabricLabel(label: String - ,timedInvokeTimeout: Duration? = null): NOCResponse { + suspend fun updateFabricLabel(label: String, timedInvokeTimeout: Duration? = null): NOCResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LABEL_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LABEL_REQ), label) + tlvWriter.put(ContextSpecificTag(TAG_LABEL_REQ), label) tlvWriter.endStructure() val request: InvokeRequest = @@ -585,79 +504,68 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } - - - - - tlvReader.exitContainer() - return NOCResponse( - statusCode_decoded, - fabricIndex_decoded, - debugText_decoded - ) + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) } - suspend fun removeFabric(fabricIndex: UByte - ,timedInvokeTimeout: Duration? = null): NOCResponse { + suspend fun removeFabric(fabricIndex: UByte, timedInvokeTimeout: Duration? = null): NOCResponse { val commandId: UInt = 10u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_FABRIC_INDEX_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_FABRIC_INDEX_REQ), fabricIndex) + tlvWriter.put(ContextSpecificTag(TAG_FABRIC_INDEX_REQ), fabricIndex) tlvWriter.endStructure() val request: InvokeRequest = @@ -674,79 +582,71 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS_CODE: Int = 0 var statusCode_decoded: UByte? = null - + val TAG_FABRIC_INDEX: Int = 1 var fabricIndex_decoded: UByte? = null - + val TAG_DEBUG_TEXT: Int = 2 var debugText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS_CODE)) {statusCode_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) {fabricIndex_decoded = + if (tag == ContextSpecificTag(TAG_STATUS_CODE)) { + statusCode_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_FABRIC_INDEX)) { + fabricIndex_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) {debugText_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_DEBUG_TEXT)) { + debugText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (statusCode_decoded == null) { - throw IllegalStateException("statusCode not found in TLV") + throw IllegalStateException("statusCode not found in TLV") } - - - - - tlvReader.exitContainer() - return NOCResponse( - statusCode_decoded, - fabricIndex_decoded, - debugText_decoded - ) + return NOCResponse(statusCode_decoded, fabricIndex_decoded, debugText_decoded) } - suspend fun addTrustedRootCertificate(rootCACertificate: ByteArray - ,timedInvokeTimeout: Duration? = null) { + suspend fun addTrustedRootCertificate( + rootCACertificate: ByteArray, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ROOT_C_A_CERTIFICATE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ROOT_C_A_CERTIFICATE_REQ), rootCACertificate) + tlvWriter.put(ContextSpecificTag(TAG_ROOT_C_A_CERTIFICATE_REQ), rootCACertificate) tlvWriter.endStructure() val request: InvokeRequest = @@ -759,47 +659,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readNOCsAttribute(): NOCsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNOCsAttribute(): NOCsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nocs attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nocs attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return NOCsAttribute(decodedValue) } @@ -809,45 +703,48 @@ suspend fun readNOCsAttribute(): NOCsAttribute {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NOCsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NOCsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nocs attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nocs attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterNOCStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(NOCsAttributeSubscriptionState.Success(decodedValue)) } @@ -855,49 +752,43 @@ suspend fun readNOCsAttribute(): NOCsAttribute {val ATTRIBUTE_ID: UInt = 0u emit(NOCsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFabricsAttribute(): FabricsAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFabricsAttribute(): FabricsAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fabrics attribute not found in response" - } + } + + requireNotNull(attributeData) { "Fabrics attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalCredentialsClusterFabricDescriptorStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalCredentialsClusterFabricDescriptorStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return FabricsAttribute(decodedValue) } @@ -907,45 +798,53 @@ suspend fun readFabricsAttribute(): FabricsAttribute {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FabricsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FabricsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fabrics attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Fabrics attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalCredentialsClusterFabricDescriptorStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + OperationalCredentialsClusterFabricDescriptorStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(FabricsAttributeSubscriptionState.Success(decodedValue)) } @@ -953,44 +852,37 @@ suspend fun readFabricsAttribute(): FabricsAttribute {val ATTRIBUTE_ID: UInt = 1 emit(FabricsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedFabricsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedfabrics attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedfabrics attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -999,34 +891,38 @@ suspend fun readSupportedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedfabrics attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedfabrics attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1039,44 +935,37 @@ suspend fun readSupportedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCommissionedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCommissionedFabricsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Commissionedfabrics attribute not found in response" - } + } + + requireNotNull(attributeData) { "Commissionedfabrics attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1085,34 +974,38 @@ suspend fun readCommissionedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Commissionedfabrics attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Commissionedfabrics attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1125,49 +1018,43 @@ suspend fun readCommissionedFabricsAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Trustedrootcertificates attribute not found in response" - } + } + + requireNotNull(attributeData) { "Trustedrootcertificates attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return TrustedRootCertificatesAttribute(decodedValue) } @@ -1177,45 +1064,50 @@ suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TrustedRootCertificatesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TrustedRootCertificatesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Trustedrootcertificates attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Trustedrootcertificates attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(TrustedRootCertificatesAttributeSubscriptionState.Success(decodedValue)) } @@ -1223,44 +1115,37 @@ suspend fun readTrustedRootCertificatesAttribute(): TrustedRootCertificatesAttri emit(TrustedRootCertificatesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentFabricIndexAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentFabricIndexAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentfabricindex attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentfabricindex attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1269,34 +1154,38 @@ suspend fun readCurrentFabricIndexAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentfabricindex attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentfabricindex attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1309,49 +1198,43 @@ suspend fun readCurrentFabricIndexAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1361,45 +1244,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1407,49 +1295,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1459,45 +1341,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1505,49 +1392,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1557,45 +1438,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1603,49 +1487,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1655,45 +1533,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1701,44 +1582,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1747,35 +1621,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1787,44 +1663,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1833,34 +1702,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1873,7 +1746,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt index e9f4f326e1fdbe..68dd297ecea977 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OperationalStateCluster.kt @@ -17,175 +17,136 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OperationalStateCluster(private val controller: MatterController, private val endpointId: UShort) { +class OperationalStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class OperationalCommandResponse( val commandResponseState: OperationalStateClusterErrorStateStruct ) -class PhaseListAttribute( - val value: List? - ) + + class PhaseListAttribute(val value: List?) sealed class PhaseListAttributeSubscriptionState { - data class Success( - val value: List? - ) : PhaseListAttributeSubscriptionState() - + data class Success(val value: List?) : PhaseListAttributeSubscriptionState() + data class Error(val exception: Exception) : PhaseListAttributeSubscriptionState() - object SubscriptionEstablished : PhaseListAttributeSubscriptionState() - } -class CurrentPhaseAttribute( - val value: UByte? - ) + object SubscriptionEstablished : PhaseListAttributeSubscriptionState() + } + + class CurrentPhaseAttribute(val value: UByte?) sealed class CurrentPhaseAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentPhaseAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentPhaseAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPhaseAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() - } -class CountdownTimeAttribute( - val value: UInt? - ) + object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() + } + + class CountdownTimeAttribute(val value: UInt?) sealed class CountdownTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : CountdownTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : CountdownTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : CountdownTimeAttributeSubscriptionState() - object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() - } -class OperationalStateListAttribute( + object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() + } + + class OperationalStateListAttribute( val value: List ) sealed class OperationalStateListAttributeSubscriptionState { - data class Success( - val value: List - ) : OperationalStateListAttributeSubscriptionState() - + data class Success(val value: List) : + OperationalStateListAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalStateListAttributeSubscriptionState() - object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() - } -class OperationalErrorAttribute( - val value: OperationalStateClusterErrorStateStruct - ) + object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() + } + + class OperationalErrorAttribute(val value: OperationalStateClusterErrorStateStruct) sealed class OperationalErrorAttributeSubscriptionState { - data class Success( - val value: OperationalStateClusterErrorStateStruct - ) : OperationalErrorAttributeSubscriptionState() - + data class Success(val value: OperationalStateClusterErrorStateStruct) : + OperationalErrorAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalErrorAttributeSubscriptionState() - object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun pause(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -202,39 +163,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun stop(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -251,39 +205,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun start(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -300,39 +247,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun resume(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -349,79 +289,66 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } -suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhaseListAttribute(): PhaseListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Phaselist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return PhaseListAttribute(decodedValue) } @@ -431,102 +358,96 @@ suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PhaseListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PhaseListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Phaselist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PhaseListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PhaseListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PhaseListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentphase attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPhaseAttribute(decodedValue) } @@ -536,100 +457,94 @@ suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPhaseAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPhaseAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentphase attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentPhaseAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentPhaseAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPhaseAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Countdowntime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CountdownTimeAttribute(decodedValue) } @@ -639,101 +554,95 @@ suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CountdownTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CountdownTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Countdowntime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CountdownTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CountdownTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CountdownTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return OperationalStateListAttribute(decodedValue) } @@ -743,45 +652,50 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalStateListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalStateListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(OperationalStateListAttributeSubscriptionState.Success(decodedValue)) } @@ -789,44 +703,37 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { emit(OperationalStateListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -835,34 +742,38 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -875,43 +786,37 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalerror attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OperationalStateClusterErrorStateStruct = OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: OperationalStateClusterErrorStateStruct = + OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) return OperationalErrorAttribute(decodedValue) } @@ -921,39 +826,44 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalErrorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalErrorAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OperationalStateClusterErrorStateStruct = OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: OperationalStateClusterErrorStateStruct = + OperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) emit(OperationalErrorAttributeSubscriptionState.Success(decodedValue)) } @@ -961,49 +871,43 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR emit(OperationalErrorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1013,45 +917,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1059,49 +968,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1111,45 +1014,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1157,49 +1065,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1209,45 +1111,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1255,49 +1160,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1307,45 +1206,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1353,44 +1255,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1399,35 +1294,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1439,44 +1336,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1485,34 +1375,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1525,7 +1419,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt index ad0f41fcd07f31..5f109918016959 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateProviderCluster.kt @@ -17,126 +17,96 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OtaSoftwareUpdateProviderCluster(private val controller: MatterController, private val endpointId: UShort) { +class OtaSoftwareUpdateProviderCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class QueryImageResponse( - val status: UByte, - val delayedActionTime: UInt?, - val imageURI: String?, - val softwareVersion: UInt?, - val softwareVersionString: String?, - val updateToken: ByteArray?, - val userConsentNeeded: Boolean?, + val status: UByte, + val delayedActionTime: UInt?, + val imageURI: String?, + val softwareVersion: UInt?, + val softwareVersionString: String?, + val updateToken: ByteArray?, + val userConsentNeeded: Boolean?, val metadataForRequestor: ByteArray? ) - class ApplyUpdateResponse( - val action: UByte, - val delayedActionTime: UInt - ) -class GeneratedCommandListAttribute( - val value: List - ) + class ApplyUpdateResponse(val action: UByte, val delayedActionTime: UInt) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } - - suspend fun queryImage(vendorID: UShort - ,productID: UShort - ,softwareVersion: UInt - ,protocolsSupported: List - ,hardwareVersion: UShort? - ,location: String? - ,requestorCanConsent: Boolean? - ,metadataForProvider: ByteArray? - ,timedInvokeTimeout: Duration? = null): QueryImageResponse { + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun queryImage( + vendorID: UShort, + productID: UShort, + softwareVersion: UInt, + protocolsSupported: List, + hardwareVersion: UShort?, + location: String?, + requestorCanConsent: Boolean?, + metadataForProvider: ByteArray?, + timedInvokeTimeout: Duration? = null + ): QueryImageResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -153,10 +123,10 @@ class AttributeListAttribute( val TAG_PROTOCOLS_SUPPORTED_REQ: Int = 3 tlvWriter.startArray(ContextSpecificTag(TAG_PROTOCOLS_SUPPORTED_REQ)) - for (item in protocolsSupported.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in protocolsSupported.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val TAG_HARDWARE_VERSION_REQ: Int = 4 hardwareVersion?.let { @@ -164,9 +134,7 @@ class AttributeListAttribute( } val TAG_LOCATION_REQ: Int = 5 - location?.let { - tlvWriter.put(ContextSpecificTag(TAG_LOCATION_REQ), location) - } + location?.let { tlvWriter.put(ContextSpecificTag(TAG_LOCATION_REQ), location) } val TAG_REQUESTOR_CAN_CONSENT_REQ: Int = 6 requestorCanConsent?.let { @@ -176,7 +144,7 @@ class AttributeListAttribute( val TAG_METADATA_FOR_PROVIDER_REQ: Int = 7 metadataForProvider?.let { tlvWriter.put(ContextSpecificTag(TAG_METADATA_FOR_PROVIDER_REQ), metadataForProvider) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -193,145 +161,139 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DELAYED_ACTION_TIME: Int = 1 var delayedActionTime_decoded: UInt? = null - + val TAG_IMAGE_U_R_I: Int = 2 var imageURI_decoded: String? = null - + val TAG_SOFTWARE_VERSION: Int = 3 var softwareVersion_decoded: UInt? = null - + val TAG_SOFTWARE_VERSION_STRING: Int = 4 var softwareVersionString_decoded: String? = null - + val TAG_UPDATE_TOKEN: Int = 5 var updateToken_decoded: ByteArray? = null - + val TAG_USER_CONSENT_NEEDED: Int = 6 var userConsentNeeded_decoded: Boolean? = null - + val TAG_METADATA_FOR_REQUESTOR: Int = 7 var metadataForRequestor_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) {delayedActionTime_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) { + delayedActionTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_IMAGE_U_R_I)) {imageURI_decoded = + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_IMAGE_U_R_I)) { + imageURI_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION)) {softwareVersion_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION)) { + softwareVersion_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUInt(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION_STRING)) {softwareVersionString_decoded = + tlvReader.getUInt(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_SOFTWARE_VERSION_STRING)) { + softwareVersionString_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_UPDATE_TOKEN)) {updateToken_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_UPDATE_TOKEN)) { + updateToken_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_USER_CONSENT_NEEDED)) {userConsentNeeded_decoded = + tlvReader.getByteArray(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_USER_CONSENT_NEEDED)) { + userConsentNeeded_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_METADATA_FOR_REQUESTOR)) {metadataForRequestor_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_METADATA_FOR_REQUESTOR)) { + metadataForRequestor_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getByteArray(tag) - } else { - null - } - }} - - - else { + tlvReader.getByteArray(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - - - - - - - - - - - - tlvReader.exitContainer() @@ -347,9 +309,11 @@ class AttributeListAttribute( ) } - suspend fun applyUpdateRequest(updateToken: ByteArray - ,newVersion: UInt - ,timedInvokeTimeout: Duration? = null): ApplyUpdateResponse { + suspend fun applyUpdateRequest( + updateToken: ByteArray, + newVersion: UInt, + timedInvokeTimeout: Duration? = null + ): ApplyUpdateResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -359,7 +323,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_UPDATE_TOKEN_REQ), updateToken) val TAG_NEW_VERSION_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_NEW_VERSION_REQ), newVersion) + tlvWriter.put(ContextSpecificTag(TAG_NEW_VERSION_REQ), newVersion) tlvWriter.endStructure() val request: InvokeRequest = @@ -376,48 +340,42 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ACTION: Int = 0 var action_decoded: UByte? = null - + val TAG_DELAYED_ACTION_TIME: Int = 1 var delayedActionTime_decoded: UInt? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ACTION)) {action_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) {delayedActionTime_decoded = tlvReader.getUInt(tag)} - + if (tag == ContextSpecificTag(TAG_ACTION)) { + action_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_DELAYED_ACTION_TIME)) { + delayedActionTime_decoded = tlvReader.getUInt(tag) + } else { tlvReader.skipElement() } } - - if (action_decoded == null) { - throw IllegalStateException("action not found in TLV") + throw IllegalStateException("action not found in TLV") } - - + if (delayedActionTime_decoded == null) { - throw IllegalStateException("delayedActionTime not found in TLV") + throw IllegalStateException("delayedActionTime not found in TLV") } - tlvReader.exitContainer() - return ApplyUpdateResponse( - action_decoded, - delayedActionTime_decoded - ) + return ApplyUpdateResponse(action_decoded, delayedActionTime_decoded) } - suspend fun notifyUpdateApplied(updateToken: ByteArray - ,softwareVersion: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun notifyUpdateApplied( + updateToken: ByteArray, + softwareVersion: UInt, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -427,7 +385,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_UPDATE_TOKEN_REQ), updateToken) val TAG_SOFTWARE_VERSION_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SOFTWARE_VERSION_REQ), softwareVersion) + tlvWriter.put(ContextSpecificTag(TAG_SOFTWARE_VERSION_REQ), softwareVersion) tlvWriter.endStructure() val request: InvokeRequest = @@ -440,47 +398,41 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -490,45 +442,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -536,49 +493,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -588,45 +539,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -634,49 +590,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -686,45 +636,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -732,49 +685,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -784,45 +731,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -830,44 +780,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -876,35 +819,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -916,44 +861,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -962,34 +900,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1002,7 +944,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt index 1309276b36b0d1..35f2a59e30fac9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OtaSoftwareUpdateRequestorCluster.kt @@ -17,133 +17,108 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OtaSoftwareUpdateRequestorCluster(private val controller: MatterController, private val endpointId: UShort) {class DefaultOTAProvidersAttribute( +class OtaSoftwareUpdateRequestorCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class DefaultOTAProvidersAttribute( val value: List ) sealed class DefaultOTAProvidersAttributeSubscriptionState { - data class Success( - val value: List - ) : DefaultOTAProvidersAttributeSubscriptionState() - + data class Success(val value: List) : + DefaultOTAProvidersAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultOTAProvidersAttributeSubscriptionState() - object SubscriptionEstablished : DefaultOTAProvidersAttributeSubscriptionState() - } -class UpdateStateProgressAttribute( - val value: UByte? - ) + object SubscriptionEstablished : DefaultOTAProvidersAttributeSubscriptionState() + } + + class UpdateStateProgressAttribute(val value: UByte?) sealed class UpdateStateProgressAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : UpdateStateProgressAttributeSubscriptionState() - + data class Success(val value: UByte?) : UpdateStateProgressAttributeSubscriptionState() + data class Error(val exception: Exception) : UpdateStateProgressAttributeSubscriptionState() - object SubscriptionEstablished : UpdateStateProgressAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : UpdateStateProgressAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun announceOTAProvider(providerNodeID: ULong - ,vendorID: UShort - ,announcementReason: UByte - ,metadataForNode: ByteArray? - ,endpoint: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun announceOTAProvider( + providerNodeID: ULong, + vendorID: UShort, + announcementReason: UByte, + metadataForNode: ByteArray?, + endpoint: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -164,7 +139,7 @@ class AttributeListAttribute( } val TAG_ENDPOINT_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_ENDPOINT_REQ), endpoint) + tlvWriter.put(ContextSpecificTag(TAG_ENDPOINT_REQ), endpoint) tlvWriter.endStructure() val request: InvokeRequest = @@ -177,75 +152,68 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultotaproviders attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultotaproviders attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return DefaultOTAProvidersAttribute(decodedValue) } suspend fun writeDefaultOTAProvidersAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -267,7 +235,7 @@ suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultOTAProvidersAttribute( @@ -275,45 +243,52 @@ suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DefaultOTAProvidersAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DefaultOTAProvidersAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultotaproviders attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultotaproviders attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + OtaSoftwareUpdateRequestorClusterProviderLocation.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } emit(DefaultOTAProvidersAttributeSubscriptionState.Success(decodedValue)) } @@ -321,44 +296,37 @@ suspend fun readDefaultOTAProvidersAttribute(): DefaultOTAProvidersAttribute {va emit(DefaultOTAProvidersAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUpdatePossibleAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUpdatePossibleAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatepossible attribute not found in response" - } + } + + requireNotNull(attributeData) { "Updatepossible attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -367,34 +335,38 @@ suspend fun readUpdatePossibleAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatepossible attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Updatepossible attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -407,44 +379,37 @@ suspend fun readUpdatePossibleAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 1u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUpdateStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUpdateStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatestate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Updatestate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -453,35 +418,37 @@ suspend fun readUpdateStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatestate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Updatestate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -493,48 +460,42 @@ suspend fun readUpdateStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUpdateStateProgressAttribute(): UpdateStateProgressAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUpdateStateProgressAttribute(): UpdateStateProgressAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatestateprogress attribute not found in response" - } + } + + requireNotNull(attributeData) { "Updatestateprogress attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return UpdateStateProgressAttribute(decodedValue) } @@ -544,97 +505,93 @@ suspend fun readUpdateStateProgressAttribute(): UpdateStateProgressAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UpdateStateProgressAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UpdateStateProgressAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Updatestateprogress attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Updatestateprogress attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(UpdateStateProgressAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(UpdateStateProgressAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UpdateStateProgressAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -644,45 +601,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -690,49 +652,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -742,45 +698,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -788,49 +749,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -840,45 +795,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -886,49 +844,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -938,45 +890,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -984,44 +939,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1030,35 +978,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1070,44 +1020,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1116,34 +1059,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1156,7 +1103,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt index 4ca4bd4f9307c1..86aeb3500ceee6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenCavityOperationalStateCluster.kt @@ -17,175 +17,136 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenCavityOperationalStateCluster(private val controller: MatterController, private val endpointId: UShort) { +class OvenCavityOperationalStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class OperationalCommandResponse( val commandResponseState: OvenCavityOperationalStateClusterErrorStateStruct ) -class PhaseListAttribute( - val value: List? - ) + + class PhaseListAttribute(val value: List?) sealed class PhaseListAttributeSubscriptionState { - data class Success( - val value: List? - ) : PhaseListAttributeSubscriptionState() - + data class Success(val value: List?) : PhaseListAttributeSubscriptionState() + data class Error(val exception: Exception) : PhaseListAttributeSubscriptionState() - object SubscriptionEstablished : PhaseListAttributeSubscriptionState() - } -class CurrentPhaseAttribute( - val value: UByte? - ) + object SubscriptionEstablished : PhaseListAttributeSubscriptionState() + } + + class CurrentPhaseAttribute(val value: UByte?) sealed class CurrentPhaseAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentPhaseAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentPhaseAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPhaseAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() - } -class CountdownTimeAttribute( - val value: UInt? - ) + object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() + } + + class CountdownTimeAttribute(val value: UInt?) sealed class CountdownTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : CountdownTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : CountdownTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : CountdownTimeAttributeSubscriptionState() - object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() - } -class OperationalStateListAttribute( + object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() + } + + class OperationalStateListAttribute( val value: List ) sealed class OperationalStateListAttributeSubscriptionState { - data class Success( - val value: List - ) : OperationalStateListAttributeSubscriptionState() - + data class Success(val value: List) : + OperationalStateListAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalStateListAttributeSubscriptionState() - object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() - } -class OperationalErrorAttribute( - val value: OvenCavityOperationalStateClusterErrorStateStruct - ) + object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() + } + + class OperationalErrorAttribute(val value: OvenCavityOperationalStateClusterErrorStateStruct) sealed class OperationalErrorAttributeSubscriptionState { - data class Success( - val value: OvenCavityOperationalStateClusterErrorStateStruct - ) : OperationalErrorAttributeSubscriptionState() - + data class Success(val value: OvenCavityOperationalStateClusterErrorStateStruct) : + OperationalErrorAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalErrorAttributeSubscriptionState() - object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun pause(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -202,39 +163,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun stop(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -251,39 +205,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun start(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -300,39 +247,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun resume(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -349,79 +289,66 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: OvenCavityOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } -suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhaseListAttribute(): PhaseListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Phaselist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return PhaseListAttribute(decodedValue) } @@ -431,102 +358,96 @@ suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PhaseListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PhaseListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Phaselist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PhaseListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PhaseListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PhaseListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentphase attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPhaseAttribute(decodedValue) } @@ -536,100 +457,94 @@ suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPhaseAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPhaseAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentphase attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentPhaseAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentPhaseAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPhaseAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Countdowntime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CountdownTimeAttribute(decodedValue) } @@ -639,101 +554,97 @@ suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CountdownTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CountdownTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Countdowntime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CountdownTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CountdownTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CountdownTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return OperationalStateListAttribute(decodedValue) } @@ -743,45 +654,55 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalStateListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalStateListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + OvenCavityOperationalStateClusterOperationalStateStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(OperationalStateListAttributeSubscriptionState.Success(decodedValue)) } @@ -789,44 +710,37 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { emit(OperationalStateListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -835,34 +749,38 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -875,43 +793,37 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalerror attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) return OperationalErrorAttribute(decodedValue) } @@ -921,39 +833,44 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalErrorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalErrorAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: OvenCavityOperationalStateClusterErrorStateStruct = + OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) emit(OperationalErrorAttributeSubscriptionState.Success(decodedValue)) } @@ -961,49 +878,43 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR emit(OperationalErrorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1013,45 +924,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1059,49 +975,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1111,45 +1021,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1157,49 +1072,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1209,45 +1118,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1255,49 +1167,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1307,45 +1213,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1353,44 +1262,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1399,35 +1301,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1439,44 +1343,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1485,34 +1382,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1525,7 +1426,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt index 072808ed1b0f75..8dcff4690b2aa5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OvenModeCluster.kt @@ -17,154 +17,117 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class OvenModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -181,92 +144,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -276,45 +224,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -322,44 +275,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -368,35 +314,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -408,76 +356,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +437,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -507,128 +445,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -650,7 +578,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -658,101 +586,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -762,45 +684,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -808,49 +735,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -860,45 +781,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -906,49 +832,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -958,45 +878,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1004,49 +927,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1056,45 +973,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,44 +1022,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1148,35 +1061,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1188,44 +1103,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1234,34 +1142,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1274,7 +1186,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt index 427cf896b35373..c660d89a0f566c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/OzoneConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class OzoneConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class OzoneConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,7 +1742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt index 0105d1d2a3b075..d81ab6b7f6574d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm10ConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class Pm10ConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class Pm10ConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,7 +1742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt index 56a19df1bc928d..9f880bbbec52d7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm1ConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class Pm1ConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class Pm1ConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,7 +1742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt index 090d17ca0c1584..cfd4cda6106049 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/Pm25ConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class Pm25ConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class Pm25ConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,7 +1742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt index 835ea746f9a7d8..e5df8e8e29a31d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceCluster.kt @@ -17,292 +17,218 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class PowerSourceCluster(private val controller: MatterController, private val endpointId: UShort) {class WiredAssessedInputVoltageAttribute( - val value: UInt? - ) +class PowerSourceCluster(private val controller: MatterController, private val endpointId: UShort) { + class WiredAssessedInputVoltageAttribute(val value: UInt?) sealed class WiredAssessedInputVoltageAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : WiredAssessedInputVoltageAttributeSubscriptionState() - - data class Error(val exception: Exception) : WiredAssessedInputVoltageAttributeSubscriptionState() - - object SubscriptionEstablished : WiredAssessedInputVoltageAttributeSubscriptionState() - } -class WiredAssessedInputFrequencyAttribute( - val value: UShort? - ) + data class Success(val value: UInt?) : WiredAssessedInputVoltageAttributeSubscriptionState() + + data class Error(val exception: Exception) : + WiredAssessedInputVoltageAttributeSubscriptionState() + + object SubscriptionEstablished : WiredAssessedInputVoltageAttributeSubscriptionState() + } + + class WiredAssessedInputFrequencyAttribute(val value: UShort?) sealed class WiredAssessedInputFrequencyAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : WiredAssessedInputFrequencyAttributeSubscriptionState() - - data class Error(val exception: Exception) : WiredAssessedInputFrequencyAttributeSubscriptionState() - - object SubscriptionEstablished : WiredAssessedInputFrequencyAttributeSubscriptionState() - } -class WiredAssessedCurrentAttribute( - val value: UInt? - ) + data class Success(val value: UShort?) : + WiredAssessedInputFrequencyAttributeSubscriptionState() + + data class Error(val exception: Exception) : + WiredAssessedInputFrequencyAttributeSubscriptionState() + + object SubscriptionEstablished : WiredAssessedInputFrequencyAttributeSubscriptionState() + } + + class WiredAssessedCurrentAttribute(val value: UInt?) sealed class WiredAssessedCurrentAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : WiredAssessedCurrentAttributeSubscriptionState() - + data class Success(val value: UInt?) : WiredAssessedCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : WiredAssessedCurrentAttributeSubscriptionState() - object SubscriptionEstablished : WiredAssessedCurrentAttributeSubscriptionState() - } -class ActiveWiredFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : WiredAssessedCurrentAttributeSubscriptionState() + } + + class ActiveWiredFaultsAttribute(val value: List?) sealed class ActiveWiredFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveWiredFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveWiredFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveWiredFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveWiredFaultsAttributeSubscriptionState() - } -class BatVoltageAttribute( - val value: UInt? - ) + object SubscriptionEstablished : ActiveWiredFaultsAttributeSubscriptionState() + } + + class BatVoltageAttribute(val value: UInt?) sealed class BatVoltageAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BatVoltageAttributeSubscriptionState() - + data class Success(val value: UInt?) : BatVoltageAttributeSubscriptionState() + data class Error(val exception: Exception) : BatVoltageAttributeSubscriptionState() - object SubscriptionEstablished : BatVoltageAttributeSubscriptionState() - } -class BatPercentRemainingAttribute( - val value: UByte? - ) + object SubscriptionEstablished : BatVoltageAttributeSubscriptionState() + } + + class BatPercentRemainingAttribute(val value: UByte?) sealed class BatPercentRemainingAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : BatPercentRemainingAttributeSubscriptionState() - + data class Success(val value: UByte?) : BatPercentRemainingAttributeSubscriptionState() + data class Error(val exception: Exception) : BatPercentRemainingAttributeSubscriptionState() - object SubscriptionEstablished : BatPercentRemainingAttributeSubscriptionState() - } -class BatTimeRemainingAttribute( - val value: UInt? - ) + object SubscriptionEstablished : BatPercentRemainingAttributeSubscriptionState() + } + + class BatTimeRemainingAttribute(val value: UInt?) sealed class BatTimeRemainingAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BatTimeRemainingAttributeSubscriptionState() - + data class Success(val value: UInt?) : BatTimeRemainingAttributeSubscriptionState() + data class Error(val exception: Exception) : BatTimeRemainingAttributeSubscriptionState() - object SubscriptionEstablished : BatTimeRemainingAttributeSubscriptionState() - } -class ActiveBatFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : BatTimeRemainingAttributeSubscriptionState() + } + + class ActiveBatFaultsAttribute(val value: List?) sealed class ActiveBatFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveBatFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveBatFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveBatFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveBatFaultsAttributeSubscriptionState() - } -class BatTimeToFullChargeAttribute( - val value: UInt? - ) + object SubscriptionEstablished : ActiveBatFaultsAttributeSubscriptionState() + } + + class BatTimeToFullChargeAttribute(val value: UInt?) sealed class BatTimeToFullChargeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BatTimeToFullChargeAttributeSubscriptionState() - + data class Success(val value: UInt?) : BatTimeToFullChargeAttributeSubscriptionState() + data class Error(val exception: Exception) : BatTimeToFullChargeAttributeSubscriptionState() - object SubscriptionEstablished : BatTimeToFullChargeAttributeSubscriptionState() - } -class BatChargingCurrentAttribute( - val value: UInt? - ) + object SubscriptionEstablished : BatTimeToFullChargeAttributeSubscriptionState() + } + + class BatChargingCurrentAttribute(val value: UInt?) sealed class BatChargingCurrentAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BatChargingCurrentAttributeSubscriptionState() - + data class Success(val value: UInt?) : BatChargingCurrentAttributeSubscriptionState() + data class Error(val exception: Exception) : BatChargingCurrentAttributeSubscriptionState() - object SubscriptionEstablished : BatChargingCurrentAttributeSubscriptionState() - } -class ActiveBatChargeFaultsAttribute( - val value: List? - ) + object SubscriptionEstablished : BatChargingCurrentAttributeSubscriptionState() + } + + class ActiveBatChargeFaultsAttribute(val value: List?) sealed class ActiveBatChargeFaultsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ActiveBatChargeFaultsAttributeSubscriptionState() - + data class Success(val value: List?) : ActiveBatChargeFaultsAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveBatChargeFaultsAttributeSubscriptionState() - object SubscriptionEstablished : ActiveBatChargeFaultsAttributeSubscriptionState() - } -class EndpointListAttribute( - val value: List - ) + object SubscriptionEstablished : ActiveBatChargeFaultsAttributeSubscriptionState() + } + + class EndpointListAttribute(val value: List) sealed class EndpointListAttributeSubscriptionState { - data class Success( - val value: List - ) : EndpointListAttributeSubscriptionState() - + data class Success(val value: List) : EndpointListAttributeSubscriptionState() + data class Error(val exception: Exception) : EndpointListAttributeSubscriptionState() - object SubscriptionEstablished : EndpointListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : EndpointListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Status attribute not found in response" - } + } + + requireNotNull(attributeData) { "Status attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -311,35 +237,37 @@ suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Status attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Status attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -351,44 +279,37 @@ suspend fun readStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOrderAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOrderAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Order attribute not found in response" - } + } + + requireNotNull(attributeData) { "Order attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -397,35 +318,37 @@ suspend fun readOrderAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Order attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Order attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -437,44 +360,37 @@ suspend fun readOrderAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDescriptionAttribute(): String { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in response" - } + } + + requireNotNull(attributeData) { "Description attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } @@ -483,35 +399,37 @@ suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Description attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Description attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -523,52 +441,46 @@ suspend fun readDescriptionAttribute(): String {val ATTRIBUTE_ID: UInt = 2u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredAssessedInputVoltageAttribute(): WiredAssessedInputVoltageAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredAssessedInputVoltageAttribute(): WiredAssessedInputVoltageAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedinputvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredassessedinputvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return WiredAssessedInputVoltageAttribute(decodedValue) } @@ -578,104 +490,102 @@ suspend fun readWiredAssessedInputVoltageAttribute(): WiredAssessedInputVoltageA maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(WiredAssessedInputVoltageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + WiredAssessedInputVoltageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedinputvoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wiredassessedinputvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(WiredAssessedInputVoltageAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(WiredAssessedInputVoltageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredAssessedInputFrequencyAttribute(): WiredAssessedInputFrequencyAttribute {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredAssessedInputFrequencyAttribute(): WiredAssessedInputFrequencyAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedinputfrequency attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredassessedinputfrequency attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return WiredAssessedInputFrequencyAttribute(decodedValue) } @@ -685,99 +595,97 @@ suspend fun readWiredAssessedInputFrequencyAttribute(): WiredAssessedInputFreque maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(WiredAssessedInputFrequencyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + WiredAssessedInputFrequencyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedinputfrequency attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wiredassessedinputfrequency attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(WiredAssessedInputFrequencyAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(WiredAssessedInputFrequencyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredCurrentTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredCurrentTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredcurrenttype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredcurrenttype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -787,99 +695,95 @@ suspend fun readWiredCurrentTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredcurrenttype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wiredcurrenttype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredAssessedCurrentAttribute(): WiredAssessedCurrentAttribute {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredAssessedCurrentAttribute(): WiredAssessedCurrentAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredassessedcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return WiredAssessedCurrentAttribute(decodedValue) } @@ -889,99 +793,95 @@ suspend fun readWiredAssessedCurrentAttribute(): WiredAssessedCurrentAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(WiredAssessedCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + WiredAssessedCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredassessedcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wiredassessedcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(WiredAssessedCurrentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(WiredAssessedCurrentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(WiredAssessedCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredNominalVoltageAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredNominalVoltageAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wirednominalvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wirednominalvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -991,94 +891,90 @@ suspend fun readWiredNominalVoltageAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wirednominalvoltage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wirednominalvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredMaximumCurrentAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredMaximumCurrentAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredmaximumcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredmaximumcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -1088,94 +984,90 @@ suspend fun readWiredMaximumCurrentAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredmaximumcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Wiredmaximumcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiredPresentAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWiredPresentAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredpresent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wiredpresent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -1185,100 +1077,94 @@ suspend fun readWiredPresentAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wiredpresent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Wiredpresent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveWiredFaultsAttribute(): ActiveWiredFaultsAttribute {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveWiredFaultsAttribute(): ActiveWiredFaultsAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activewiredfaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activewiredfaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveWiredFaultsAttribute(decodedValue) } @@ -1288,105 +1174,101 @@ suspend fun readActiveWiredFaultsAttribute(): ActiveWiredFaultsAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveWiredFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveWiredFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activewiredfaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activewiredfaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveWiredFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveWiredFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveWiredFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatVoltageAttribute(): BatVoltageAttribute {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatVoltageAttribute(): BatVoltageAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batvoltage attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batvoltage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatVoltageAttribute(decodedValue) } @@ -1396,104 +1278,98 @@ suspend fun readBatVoltageAttribute(): BatVoltageAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatVoltageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatVoltageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batvoltage attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Batvoltage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatVoltageAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatVoltageAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatVoltageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatPercentRemainingAttribute(): BatPercentRemainingAttribute {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatPercentRemainingAttribute(): BatPercentRemainingAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batpercentremaining attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batpercentremaining attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatPercentRemainingAttribute(decodedValue) } @@ -1503,104 +1379,100 @@ suspend fun readBatPercentRemainingAttribute(): BatPercentRemainingAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatPercentRemainingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatPercentRemainingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batpercentremaining attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batpercentremaining attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatPercentRemainingAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatPercentRemainingAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatPercentRemainingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatTimeRemainingAttribute(): BatTimeRemainingAttribute {val ATTRIBUTE_ID: UInt = 13u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatTimeRemainingAttribute(): BatTimeRemainingAttribute { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Battimeremaining attribute not found in response" - } + } + + requireNotNull(attributeData) { "Battimeremaining attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatTimeRemainingAttribute(decodedValue) } @@ -1610,99 +1482,95 @@ suspend fun readBatTimeRemainingAttribute(): BatTimeRemainingAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatTimeRemainingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatTimeRemainingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Battimeremaining attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Battimeremaining attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatTimeRemainingAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatTimeRemainingAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatTimeRemainingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatChargeLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 14u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatChargeLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargelevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batchargelevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1712,94 +1580,90 @@ suspend fun readBatChargeLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 14u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargelevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batchargelevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatReplacementNeededAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatReplacementNeededAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplacementneeded attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batreplacementneeded attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -1809,94 +1673,90 @@ suspend fun readBatReplacementNeededAttribute(): Boolean? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplacementneeded attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batreplacementneeded attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatReplaceabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatReplaceabilityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplaceability attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batreplaceability attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1906,94 +1766,90 @@ suspend fun readBatReplaceabilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplaceability attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batreplaceability attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatPresentAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatPresentAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batpresent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batpresent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -2003,100 +1859,94 @@ suspend fun readBatPresentAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batpresent attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Batpresent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveBatFaultsAttribute(): ActiveBatFaultsAttribute {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveBatFaultsAttribute(): ActiveBatFaultsAttribute { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activebatfaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activebatfaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveBatFaultsAttribute(decodedValue) } @@ -2106,100 +1956,96 @@ suspend fun readActiveBatFaultsAttribute(): ActiveBatFaultsAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveBatFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveBatFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activebatfaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activebatfaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveBatFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveBatFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveBatFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatReplacementDescriptionAttribute(): String? {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatReplacementDescriptionAttribute(): String? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplacementdescription attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batreplacementdescription attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -2209,94 +2055,90 @@ suspend fun readBatReplacementDescriptionAttribute(): String? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batreplacementdescription attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batreplacementdescription attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatCommonDesignationAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatCommonDesignationAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batcommondesignation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batcommondesignation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2306,94 +2148,90 @@ suspend fun readBatCommonDesignationAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batcommondesignation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batcommondesignation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatANSIDesignationAttribute(): String? {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatANSIDesignationAttribute(): String? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batansidesignation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batansidesignation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -2403,94 +2241,90 @@ suspend fun readBatANSIDesignationAttribute(): String? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batansidesignation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batansidesignation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatIECDesignationAttribute(): String? {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatIECDesignationAttribute(): String? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batiecdesignation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batiecdesignation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -2500,94 +2334,90 @@ suspend fun readBatIECDesignationAttribute(): String? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batiecdesignation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batiecdesignation attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatApprovedChemistryAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatApprovedChemistryAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batapprovedchemistry attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batapprovedchemistry attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2597,94 +2427,90 @@ suspend fun readBatApprovedChemistryAttribute(): UShort? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batapprovedchemistry attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batapprovedchemistry attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatCapacityAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 24u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatCapacityAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batcapacity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batcapacity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2694,94 +2520,88 @@ suspend fun readBatCapacityAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 24u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batcapacity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Batcapacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatQuantityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatQuantityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batquantity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batquantity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -2791,94 +2611,88 @@ suspend fun readBatQuantityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 25u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batquantity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Batquantity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatChargeStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatChargeStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargestate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batchargestate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -2888,99 +2702,95 @@ suspend fun readBatChargeStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargestate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batchargestate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatTimeToFullChargeAttribute(): BatTimeToFullChargeAttribute {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatTimeToFullChargeAttribute(): BatTimeToFullChargeAttribute { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Battimetofullcharge attribute not found in response" - } + } + + requireNotNull(attributeData) { "Battimetofullcharge attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatTimeToFullChargeAttribute(decodedValue) } @@ -2990,99 +2800,95 @@ suspend fun readBatTimeToFullChargeAttribute(): BatTimeToFullChargeAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatTimeToFullChargeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatTimeToFullChargeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Battimetofullcharge attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Battimetofullcharge attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatTimeToFullChargeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatTimeToFullChargeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatTimeToFullChargeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatFunctionalWhileChargingAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 28u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatFunctionalWhileChargingAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batfunctionalwhilecharging attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batfunctionalwhilecharging attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -3092,99 +2898,95 @@ suspend fun readBatFunctionalWhileChargingAttribute(): Boolean? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batfunctionalwhilecharging attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batfunctionalwhilecharging attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatChargingCurrentAttribute(): BatChargingCurrentAttribute {val ATTRIBUTE_ID: UInt = 29u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBatChargingCurrentAttribute(): BatChargingCurrentAttribute { + val ATTRIBUTE_ID: UInt = 29u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargingcurrent attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batchargingcurrent attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BatChargingCurrentAttribute(decodedValue) } @@ -3194,105 +2996,101 @@ suspend fun readBatChargingCurrentAttribute(): BatChargingCurrentAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 29u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BatChargingCurrentAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BatChargingCurrentAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batchargingcurrent attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Batchargingcurrent attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BatChargingCurrentAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BatChargingCurrentAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BatChargingCurrentAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveBatChargeFaultsAttribute(): ActiveBatChargeFaultsAttribute {val ATTRIBUTE_ID: UInt = 30u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveBatChargeFaultsAttribute(): ActiveBatChargeFaultsAttribute { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activebatchargefaults attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activebatchargefaults attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ActiveBatChargeFaultsAttribute(decodedValue) } @@ -3302,102 +3100,98 @@ suspend fun readActiveBatChargeFaultsAttribute(): ActiveBatChargeFaultsAttribute maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveBatChargeFaultsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveBatChargeFaultsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activebatchargefaults attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activebatchargefaults attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ActiveBatChargeFaultsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ActiveBatChargeFaultsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveBatChargeFaultsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEndpointListAttribute(): EndpointListAttribute {val ATTRIBUTE_ID: UInt = 31u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEndpointListAttribute(): EndpointListAttribute { + val ATTRIBUTE_ID: UInt = 31u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endpointlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Endpointlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EndpointListAttribute(decodedValue) } @@ -3407,45 +3201,48 @@ suspend fun readEndpointListAttribute(): EndpointListAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 31u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EndpointListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EndpointListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endpointlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Endpointlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EndpointListAttributeSubscriptionState.Success(decodedValue)) } @@ -3453,49 +3250,43 @@ suspend fun readEndpointListAttribute(): EndpointListAttribute {val ATTRIBUTE_ID emit(EndpointListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -3505,45 +3296,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3551,49 +3347,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -3603,45 +3393,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3649,49 +3444,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -3701,45 +3490,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -3747,49 +3539,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -3799,45 +3585,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -3845,44 +3634,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -3891,35 +3673,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3931,44 +3715,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -3977,34 +3754,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -4017,7 +3798,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt index 59bfeff63ee455..eb3b505f117912 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PowerSourceConfigurationCluster.kt @@ -17,154 +17,111 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class PowerSourceConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class SourcesAttribute( - val value: List - ) +class PowerSourceConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SourcesAttribute(val value: List) sealed class SourcesAttributeSubscriptionState { - data class Success( - val value: List - ) : SourcesAttributeSubscriptionState() - + data class Success(val value: List) : SourcesAttributeSubscriptionState() + data class Error(val exception: Exception) : SourcesAttributeSubscriptionState() - object SubscriptionEstablished : SourcesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SourcesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readSourcesAttribute(): SourcesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readSourcesAttribute(): SourcesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sources attribute not found in response" - } + } + + requireNotNull(attributeData) { "Sources attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SourcesAttribute(decodedValue) } @@ -174,45 +131,48 @@ suspend fun readSourcesAttribute(): SourcesAttribute {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SourcesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SourcesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Sources attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Sources attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(SourcesAttributeSubscriptionState.Success(decodedValue)) } @@ -220,49 +180,43 @@ suspend fun readSourcesAttribute(): SourcesAttribute {val ATTRIBUTE_ID: UInt = 0 emit(SourcesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -272,45 +226,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -318,49 +277,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -370,45 +323,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -416,49 +374,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -468,45 +420,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -514,49 +469,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -566,45 +515,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -612,44 +564,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -658,35 +603,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -698,44 +645,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -744,34 +684,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -784,7 +728,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt index e8726e5f3a3cac..e374599a909987 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PressureMeasurementCluster.kt @@ -17,218 +17,161 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.ByteSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class PressureMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Short? - ) +class PressureMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Short?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Short?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Short?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class ScaledValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class ScaledValueAttribute(val value: Short?) sealed class ScaledValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : ScaledValueAttributeSubscriptionState() - + data class Success(val value: Short?) : ScaledValueAttributeSubscriptionState() + data class Error(val exception: Exception) : ScaledValueAttributeSubscriptionState() - object SubscriptionEstablished : ScaledValueAttributeSubscriptionState() - } -class MinScaledValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : ScaledValueAttributeSubscriptionState() + } + + class MinScaledValueAttribute(val value: Short?) sealed class MinScaledValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinScaledValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MinScaledValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinScaledValueAttributeSubscriptionState() - object SubscriptionEstablished : MinScaledValueAttributeSubscriptionState() - } -class MaxScaledValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinScaledValueAttributeSubscriptionState() + } + + class MaxScaledValueAttribute(val value: Short?) sealed class MaxScaledValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxScaledValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxScaledValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxScaledValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxScaledValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : MaxScaledValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -238,96 +181,90 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -337,96 +274,92 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -436,95 +369,91 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -534,99 +463,93 @@ suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScaledValueAttribute(): ScaledValueAttribute {val ATTRIBUTE_ID: UInt = 16u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScaledValueAttribute(): ScaledValueAttribute { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scaledvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scaledvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ScaledValueAttribute(decodedValue) } @@ -636,104 +559,98 @@ suspend fun readScaledValueAttribute(): ScaledValueAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ScaledValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ScaledValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scaledvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Scaledvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ScaledValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ScaledValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ScaledValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinScaledValueAttribute(): MinScaledValueAttribute {val ATTRIBUTE_ID: UInt = 17u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinScaledValueAttribute(): MinScaledValueAttribute { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minscaledvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minscaledvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinScaledValueAttribute(decodedValue) } @@ -743,104 +660,100 @@ suspend fun readMinScaledValueAttribute(): MinScaledValueAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinScaledValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinScaledValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minscaledvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minscaledvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinScaledValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinScaledValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinScaledValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxScaledValueAttribute(): MaxScaledValueAttribute {val ATTRIBUTE_ID: UInt = 18u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxScaledValueAttribute(): MaxScaledValueAttribute { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxscaledvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxscaledvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxScaledValueAttribute(decodedValue) } @@ -850,99 +763,95 @@ suspend fun readMaxScaledValueAttribute(): MaxScaledValueAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxScaledValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxScaledValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxscaledvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxscaledvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxScaledValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxScaledValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxScaledValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScaledToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScaledToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scaledtolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scaledtolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -952,94 +861,90 @@ suspend fun readScaledToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scaledtolerance attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scaledtolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScaleAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 20u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScaleAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scale attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scale attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1049,96 +954,90 @@ suspend fun readScaleAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 20u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scale attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Scale attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1148,45 +1047,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1194,49 +1098,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1246,45 +1144,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1292,49 +1195,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1344,45 +1241,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1390,49 +1290,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1442,45 +1336,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1488,44 +1385,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1534,35 +1424,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1574,44 +1466,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1620,34 +1505,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1660,7 +1549,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt index b08df6933b9fd1..5eb0f105ba47d1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyConfigurationCluster.kt @@ -17,141 +17,101 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class ProxyConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class ProxyConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -161,45 +121,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -207,49 +172,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -259,45 +218,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -305,49 +269,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -357,45 +315,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -403,49 +364,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -455,45 +410,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -501,44 +459,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -547,35 +498,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -587,44 +540,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -633,34 +579,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -673,7 +623,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt index 42d50e762f785c..46ad79a25cd0c2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyDiscoveryCluster.kt @@ -17,141 +17,101 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class ProxyDiscoveryCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class ProxyDiscoveryCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -161,45 +121,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -207,49 +172,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -259,45 +218,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -305,49 +269,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -357,45 +315,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -403,49 +364,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -455,45 +410,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -501,44 +459,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -547,35 +498,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -587,44 +540,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -633,34 +579,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -673,7 +623,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt index 79217bb65e2c72..96d846ad277cec 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ProxyValidCluster.kt @@ -17,141 +17,98 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class ProxyValidCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class ProxyValidCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -161,45 +118,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -207,49 +169,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -259,45 +215,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -305,49 +266,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -357,45 +312,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -403,49 +361,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -455,45 +407,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -501,44 +456,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -547,35 +495,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -587,44 +537,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -633,34 +576,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -673,7 +620,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt index 0ae147a5169862..0e2ffc820350d9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PulseWidthModulationCluster.kt @@ -17,141 +17,101 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class PulseWidthModulationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class PulseWidthModulationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -161,45 +121,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -207,49 +172,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -259,45 +218,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -305,49 +269,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -357,45 +315,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -403,49 +364,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -455,45 +410,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -501,44 +459,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -547,35 +498,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -587,44 +540,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -633,34 +579,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -673,7 +623,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt index 77f27057b0a555..6620523d5be3fa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/PumpConfigurationAndControlCluster.kt @@ -17,374 +17,285 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PumpConfigurationAndControlCluster(private val controller: MatterController, private val endpointId: UShort) {class MaxPressureAttribute( - val value: Short? - ) +class PumpConfigurationAndControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MaxPressureAttribute(val value: Short?) sealed class MaxPressureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxPressureAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxPressureAttributeSubscriptionState() - object SubscriptionEstablished : MaxPressureAttributeSubscriptionState() - } -class MaxSpeedAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MaxPressureAttributeSubscriptionState() + } + + class MaxSpeedAttribute(val value: UShort?) sealed class MaxSpeedAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxSpeedAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxSpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxSpeedAttributeSubscriptionState() - object SubscriptionEstablished : MaxSpeedAttributeSubscriptionState() - } -class MaxFlowAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MaxSpeedAttributeSubscriptionState() + } + + class MaxFlowAttribute(val value: UShort?) sealed class MaxFlowAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxFlowAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxFlowAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxFlowAttributeSubscriptionState() - object SubscriptionEstablished : MaxFlowAttributeSubscriptionState() - } -class MinConstPressureAttribute( - val value: Short? - ) + object SubscriptionEstablished : MaxFlowAttributeSubscriptionState() + } + + class MinConstPressureAttribute(val value: Short?) sealed class MinConstPressureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinConstPressureAttributeSubscriptionState() - + data class Success(val value: Short?) : MinConstPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstPressureAttributeSubscriptionState() - object SubscriptionEstablished : MinConstPressureAttributeSubscriptionState() - } -class MaxConstPressureAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinConstPressureAttributeSubscriptionState() + } + + class MaxConstPressureAttribute(val value: Short?) sealed class MaxConstPressureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxConstPressureAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxConstPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstPressureAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstPressureAttributeSubscriptionState() - } -class MinCompPressureAttribute( - val value: Short? - ) + object SubscriptionEstablished : MaxConstPressureAttributeSubscriptionState() + } + + class MinCompPressureAttribute(val value: Short?) sealed class MinCompPressureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinCompPressureAttributeSubscriptionState() - + data class Success(val value: Short?) : MinCompPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MinCompPressureAttributeSubscriptionState() - object SubscriptionEstablished : MinCompPressureAttributeSubscriptionState() - } -class MaxCompPressureAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinCompPressureAttributeSubscriptionState() + } + + class MaxCompPressureAttribute(val value: Short?) sealed class MaxCompPressureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxCompPressureAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxCompPressureAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxCompPressureAttributeSubscriptionState() - object SubscriptionEstablished : MaxCompPressureAttributeSubscriptionState() - } -class MinConstSpeedAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MaxCompPressureAttributeSubscriptionState() + } + + class MinConstSpeedAttribute(val value: UShort?) sealed class MinConstSpeedAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MinConstSpeedAttributeSubscriptionState() - + data class Success(val value: UShort?) : MinConstSpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstSpeedAttributeSubscriptionState() - object SubscriptionEstablished : MinConstSpeedAttributeSubscriptionState() - } -class MaxConstSpeedAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MinConstSpeedAttributeSubscriptionState() + } + + class MaxConstSpeedAttribute(val value: UShort?) sealed class MaxConstSpeedAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxConstSpeedAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxConstSpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstSpeedAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstSpeedAttributeSubscriptionState() - } -class MinConstFlowAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MaxConstSpeedAttributeSubscriptionState() + } + + class MinConstFlowAttribute(val value: UShort?) sealed class MinConstFlowAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MinConstFlowAttributeSubscriptionState() - + data class Success(val value: UShort?) : MinConstFlowAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstFlowAttributeSubscriptionState() - object SubscriptionEstablished : MinConstFlowAttributeSubscriptionState() - } -class MaxConstFlowAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MinConstFlowAttributeSubscriptionState() + } + + class MaxConstFlowAttribute(val value: UShort?) sealed class MaxConstFlowAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxConstFlowAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxConstFlowAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstFlowAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstFlowAttributeSubscriptionState() - } -class MinConstTempAttribute( - val value: Short? - ) + object SubscriptionEstablished : MaxConstFlowAttributeSubscriptionState() + } + + class MinConstTempAttribute(val value: Short?) sealed class MinConstTempAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinConstTempAttributeSubscriptionState() - + data class Success(val value: Short?) : MinConstTempAttributeSubscriptionState() + data class Error(val exception: Exception) : MinConstTempAttributeSubscriptionState() - object SubscriptionEstablished : MinConstTempAttributeSubscriptionState() - } -class MaxConstTempAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinConstTempAttributeSubscriptionState() + } + + class MaxConstTempAttribute(val value: Short?) sealed class MaxConstTempAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxConstTempAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxConstTempAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxConstTempAttributeSubscriptionState() - object SubscriptionEstablished : MaxConstTempAttributeSubscriptionState() - } -class CapacityAttribute( - val value: Short? - ) + object SubscriptionEstablished : MaxConstTempAttributeSubscriptionState() + } + + class CapacityAttribute(val value: Short?) sealed class CapacityAttributeSubscriptionState { - data class Success( - val value: Short? - ) : CapacityAttributeSubscriptionState() - + data class Success(val value: Short?) : CapacityAttributeSubscriptionState() + data class Error(val exception: Exception) : CapacityAttributeSubscriptionState() - object SubscriptionEstablished : CapacityAttributeSubscriptionState() - } -class SpeedAttribute( - val value: UShort? - ) + object SubscriptionEstablished : CapacityAttributeSubscriptionState() + } + + class SpeedAttribute(val value: UShort?) sealed class SpeedAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : SpeedAttributeSubscriptionState() - + data class Success(val value: UShort?) : SpeedAttributeSubscriptionState() + data class Error(val exception: Exception) : SpeedAttributeSubscriptionState() - object SubscriptionEstablished : SpeedAttributeSubscriptionState() - } -class LifetimeRunningHoursAttribute( - val value: UInt? - ) + object SubscriptionEstablished : SpeedAttributeSubscriptionState() + } + + class LifetimeRunningHoursAttribute(val value: UInt?) sealed class LifetimeRunningHoursAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LifetimeRunningHoursAttributeSubscriptionState() - + data class Success(val value: UInt?) : LifetimeRunningHoursAttributeSubscriptionState() + data class Error(val exception: Exception) : LifetimeRunningHoursAttributeSubscriptionState() - object SubscriptionEstablished : LifetimeRunningHoursAttributeSubscriptionState() - } -class PowerAttribute( - val value: UInt? - ) + object SubscriptionEstablished : LifetimeRunningHoursAttributeSubscriptionState() + } + + class PowerAttribute(val value: UInt?) sealed class PowerAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PowerAttributeSubscriptionState() - + data class Success(val value: UInt?) : PowerAttributeSubscriptionState() + data class Error(val exception: Exception) : PowerAttributeSubscriptionState() - object SubscriptionEstablished : PowerAttributeSubscriptionState() - } -class LifetimeEnergyConsumedAttribute( - val value: UInt? - ) + object SubscriptionEstablished : PowerAttributeSubscriptionState() + } + + class LifetimeEnergyConsumedAttribute(val value: UInt?) sealed class LifetimeEnergyConsumedAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : LifetimeEnergyConsumedAttributeSubscriptionState() - + data class Success(val value: UInt?) : LifetimeEnergyConsumedAttributeSubscriptionState() + data class Error(val exception: Exception) : LifetimeEnergyConsumedAttributeSubscriptionState() - object SubscriptionEstablished : LifetimeEnergyConsumedAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LifetimeEnergyConsumedAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMaxPressureAttribute(): MaxPressureAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMaxPressureAttribute(): MaxPressureAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpressure attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxpressure attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxPressureAttribute(decodedValue) } @@ -394,96 +305,90 @@ suspend fun readMaxPressureAttribute(): MaxPressureAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxPressureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxpressure attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxpressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(MaxPressureAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(MaxPressureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxSpeedAttribute(): MaxSpeedAttribute {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxSpeedAttribute(): MaxSpeedAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxspeed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxspeed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxSpeedAttribute(decodedValue) } @@ -493,96 +398,90 @@ suspend fun readMaxSpeedAttribute(): MaxSpeedAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxSpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxSpeedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxspeed attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxspeed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(MaxSpeedAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(MaxSpeedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxSpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxFlowAttribute(): MaxFlowAttribute {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxFlowAttribute(): MaxFlowAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxflow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxflow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxFlowAttribute(decodedValue) } @@ -592,100 +491,94 @@ suspend fun readMaxFlowAttribute(): MaxFlowAttribute {val ATTRIBUTE_ID: UInt = 2 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxFlowAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxFlowAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxflow attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxflow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(MaxFlowAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(MaxFlowAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxFlowAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinConstPressureAttribute(): MinConstPressureAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinConstPressureAttribute(): MinConstPressureAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstpressure attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minconstpressure attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinConstPressureAttribute(decodedValue) } @@ -695,104 +588,100 @@ suspend fun readMinConstPressureAttribute(): MinConstPressureAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinConstPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinConstPressureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstpressure attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minconstpressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinConstPressureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinConstPressureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinConstPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxConstPressureAttribute(): MaxConstPressureAttribute {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxConstPressureAttribute(): MaxConstPressureAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstpressure attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxconstpressure attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxConstPressureAttribute(decodedValue) } @@ -802,104 +691,100 @@ suspend fun readMaxConstPressureAttribute(): MaxConstPressureAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxConstPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxConstPressureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstpressure attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxconstpressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxConstPressureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxConstPressureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinCompPressureAttribute(): MinCompPressureAttribute {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinCompPressureAttribute(): MinCompPressureAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mincomppressure attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mincomppressure attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinCompPressureAttribute(decodedValue) } @@ -909,104 +794,100 @@ suspend fun readMinCompPressureAttribute(): MinCompPressureAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinCompPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinCompPressureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mincomppressure attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Mincomppressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinCompPressureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinCompPressureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinCompPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxCompPressureAttribute(): MaxCompPressureAttribute {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxCompPressureAttribute(): MaxCompPressureAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcomppressure attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxcomppressure attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxCompPressureAttribute(decodedValue) } @@ -1016,104 +897,100 @@ suspend fun readMaxCompPressureAttribute(): MaxCompPressureAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxCompPressureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxCompPressureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcomppressure attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxcomppressure attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxCompPressureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxCompPressureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxCompPressureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinConstSpeedAttribute(): MinConstSpeedAttribute {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinConstSpeedAttribute(): MinConstSpeedAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstspeed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minconstspeed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinConstSpeedAttribute(decodedValue) } @@ -1123,104 +1000,98 @@ suspend fun readMinConstSpeedAttribute(): MinConstSpeedAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinConstSpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinConstSpeedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstspeed attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minconstspeed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinConstSpeedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinConstSpeedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinConstSpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxConstSpeedAttribute(): MaxConstSpeedAttribute {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxConstSpeedAttribute(): MaxConstSpeedAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstspeed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxconstspeed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxConstSpeedAttribute(decodedValue) } @@ -1230,104 +1101,98 @@ suspend fun readMaxConstSpeedAttribute(): MaxConstSpeedAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxConstSpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxConstSpeedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstspeed attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxconstspeed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxConstSpeedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxConstSpeedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstSpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinConstFlowAttribute(): MinConstFlowAttribute {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinConstFlowAttribute(): MinConstFlowAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstflow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minconstflow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinConstFlowAttribute(decodedValue) } @@ -1337,104 +1202,98 @@ suspend fun readMinConstFlowAttribute(): MinConstFlowAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinConstFlowAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinConstFlowAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconstflow attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minconstflow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinConstFlowAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinConstFlowAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinConstFlowAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxConstFlowAttribute(): MaxConstFlowAttribute {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxConstFlowAttribute(): MaxConstFlowAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstflow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxconstflow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxConstFlowAttribute(decodedValue) } @@ -1444,104 +1303,98 @@ suspend fun readMaxConstFlowAttribute(): MaxConstFlowAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxConstFlowAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxConstFlowAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconstflow attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxconstflow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxConstFlowAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxConstFlowAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstFlowAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinConstTempAttribute(): MinConstTempAttribute {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinConstTempAttribute(): MinConstTempAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconsttemp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minconsttemp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinConstTempAttribute(decodedValue) } @@ -1551,104 +1404,98 @@ suspend fun readMinConstTempAttribute(): MinConstTempAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinConstTempAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinConstTempAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minconsttemp attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Minconsttemp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinConstTempAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinConstTempAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinConstTempAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxConstTempAttribute(): MaxConstTempAttribute {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxConstTempAttribute(): MaxConstTempAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconsttemp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxconsttemp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxConstTempAttribute(decodedValue) } @@ -1658,99 +1505,93 @@ suspend fun readMaxConstTempAttribute(): MaxConstTempAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxConstTempAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxConstTempAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxconsttemp attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Maxconsttemp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxConstTempAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxConstTempAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxConstTempAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPumpStatusAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPumpStatusAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pumpstatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Pumpstatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1760,91 +1601,84 @@ suspend fun readPumpStatusAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pumpstatus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Pumpstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEffectiveOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEffectiveOperationModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Effectiveoperationmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Effectiveoperationmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1853,34 +1687,38 @@ suspend fun readEffectiveOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Effectiveoperationmode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Effectiveoperationmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1893,44 +1731,37 @@ suspend fun readEffectiveOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEffectiveControlModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEffectiveControlModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Effectivecontrolmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Effectivecontrolmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1939,34 +1770,38 @@ suspend fun readEffectiveControlModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Effectivecontrolmode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Effectivecontrolmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1979,48 +1814,42 @@ suspend fun readEffectiveControlModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCapacityAttribute(): CapacityAttribute {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCapacityAttribute(): CapacityAttribute { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Capacity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Capacity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CapacityAttribute(decodedValue) } @@ -2030,100 +1859,94 @@ suspend fun readCapacityAttribute(): CapacityAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CapacityAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CapacityAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Capacity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Capacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(CapacityAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(CapacityAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CapacityAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSpeedAttribute(): SpeedAttribute {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSpeedAttribute(): SpeedAttribute { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Speed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SpeedAttribute(decodedValue) } @@ -2133,128 +1956,118 @@ suspend fun readSpeedAttribute(): SpeedAttribute {val ATTRIBUTE_ID: UInt = 20u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SpeedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SpeedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Speed attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Speed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SpeedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SpeedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SpeedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lifetimerunninghours attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lifetimerunninghours attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LifetimeRunningHoursAttribute(decodedValue) } - suspend fun writeLifetimeRunningHoursAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeLifetimeRunningHoursAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2276,7 +2089,7 @@ suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute { throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLifetimeRunningHoursAttribute( @@ -2284,104 +2097,100 @@ suspend fun readLifetimeRunningHoursAttribute(): LifetimeRunningHoursAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LifetimeRunningHoursAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LifetimeRunningHoursAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lifetimerunninghours attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lifetimerunninghours attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LifetimeRunningHoursAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LifetimeRunningHoursAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LifetimeRunningHoursAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPowerAttribute(): PowerAttribute {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPowerAttribute(): PowerAttribute { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Power attribute not found in response" - } + } + + requireNotNull(attributeData) { "Power attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PowerAttribute(decodedValue) } @@ -2391,128 +2200,121 @@ suspend fun readPowerAttribute(): PowerAttribute {val ATTRIBUTE_ID: UInt = 22u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PowerAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PowerAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Power attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Power attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PowerAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PowerAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PowerAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribute {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribute { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lifetimeenergyconsumed attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lifetimeenergyconsumed attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LifetimeEnergyConsumedAttribute(decodedValue) } suspend fun writeLifetimeEnergyConsumedAttribute( value: UInt, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2534,7 +2336,7 @@ suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribu throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLifetimeEnergyConsumedAttribute( @@ -2542,119 +2344,110 @@ suspend fun readLifetimeEnergyConsumedAttribute(): LifetimeEnergyConsumedAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LifetimeEnergyConsumedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LifetimeEnergyConsumedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lifetimeenergyconsumed attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lifetimeenergyconsumed attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LifetimeEnergyConsumedAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LifetimeEnergyConsumedAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LifetimeEnergyConsumedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOperationModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeOperationModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOperationModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 32u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2676,7 +2469,7 @@ suspend fun readOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOperationModeAttribute( @@ -2684,35 +2477,37 @@ suspend fun readOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Operationmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2724,71 +2519,61 @@ suspend fun readOperationModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 32u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readControlModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readControlModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Controlmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Controlmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeControlModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeControlModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2810,7 +2595,7 @@ suspend fun readControlModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 33u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeControlModeAttribute( @@ -2818,96 +2603,90 @@ suspend fun readControlModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 33u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Controlmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Controlmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2917,45 +2696,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2963,49 +2747,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -3015,45 +2793,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -3061,49 +2844,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -3113,45 +2890,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -3159,49 +2939,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -3211,45 +2985,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -3257,44 +3034,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -3303,35 +3073,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3343,44 +3115,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -3389,34 +3154,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3429,7 +3198,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt index 05e3ef50cbd96d..d2d71369780de0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RadonConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class RadonConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class RadonConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,7 +1742,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt index fc8ca10f3d18d2..70eb72e6db7ec9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAlarmCluster.kt @@ -17,136 +17,95 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class RefrigeratorAlarmCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class RefrigeratorAlarmCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMaskAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mask attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mask attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -155,35 +114,37 @@ suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mask attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Mask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -195,44 +156,37 @@ suspend fun readMaskAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStateAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in response" - } + } + + requireNotNull(attributeData) { "State attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -241,35 +195,37 @@ suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "State attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "State attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -281,44 +237,37 @@ suspend fun readStateAttribute(): UInt {val ATTRIBUTE_ID: UInt = 2u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -327,35 +276,37 @@ suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supported attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Supported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -367,49 +318,43 @@ suspend fun readSupportedAttribute(): UInt {val ATTRIBUTE_ID: UInt = 3u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -419,45 +364,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -465,49 +415,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -517,45 +461,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -563,49 +512,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -615,45 +558,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -661,49 +607,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -713,45 +653,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -759,44 +702,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -805,35 +741,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -845,44 +783,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -891,34 +822,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -931,7 +866,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt index ce6565c3397935..61898b4f3d849d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RefrigeratorAndTemperatureControlledCabinetModeCluster.kt @@ -17,154 +17,123 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RefrigeratorAndTemperatureControlledCabinetModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( +class RefrigeratorAndTemperatureControlledCabinetModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute( val value: List ) sealed class SupportedModesAttributeSubscriptionState { data class Success( - val value: List + val value: List ) : SupportedModesAttributeSubscriptionState() - + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class StartUpModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class StartUpModeAttribute(val value: UByte?) sealed class StartUpModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : StartUpModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : StartUpModeAttributeSubscriptionState() + data class Error(val exception: Exception) : StartUpModeAttributeSubscriptionState() - object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StartUpModeAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -181,92 +150,82 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -276,45 +235,56 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: + List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -322,44 +292,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -368,35 +331,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -408,76 +373,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStartUpModeAttribute(): StartUpModeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startupmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return StartUpModeAttribute(decodedValue) } - suspend fun writeStartUpModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeStartUpModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -499,7 +454,7 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStartUpModeAttribute( @@ -507,128 +462,118 @@ suspend fun readStartUpModeAttribute(): StartUpModeAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StartUpModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StartUpModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startupmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startupmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(StartUpModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(StartUpModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StartUpModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -650,7 +595,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -658,101 +603,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -762,45 +701,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -808,49 +752,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -860,45 +798,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -906,49 +849,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -958,45 +895,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1004,49 +944,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1056,45 +990,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1102,44 +1039,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1148,35 +1078,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1188,44 +1120,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1234,34 +1159,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1274,11 +1203,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(RefrigeratorAndTemperatureControlledCabinetModeCluster::class.java.name) + private val logger = + Logger.getLogger(RefrigeratorAndTemperatureControlledCabinetModeCluster::class.java.name) const val CLUSTER_ID: UInt = 82u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt index c7f6f1f5cc66a8..c8b35042a38183 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RelativeHumidityMeasurementCluster.kt @@ -17,179 +17,130 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class RelativeHumidityMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: UShort? - ) +class RelativeHumidityMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: UShort?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: UShort?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: UShort? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: UShort?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: UShort?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -199,96 +150,90 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -298,96 +243,92 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -397,95 +338,91 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -495,96 +432,90 @@ suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -594,45 +525,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -640,49 +576,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -692,45 +622,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -738,49 +673,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -790,45 +719,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -836,49 +768,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -888,45 +814,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -934,44 +863,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -980,35 +902,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1020,44 +944,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1066,34 +983,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1106,7 +1027,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt index 4b5c4234e782ef..fc06787142bc87 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcCleanModeCluster.kt @@ -17,141 +17,110 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcCleanModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) +class RvcCleanModeCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -168,92 +137,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -263,45 +217,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -309,44 +268,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -355,35 +307,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -395,76 +349,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -486,7 +430,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -494,101 +438,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -598,45 +536,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -644,49 +587,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -696,45 +633,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -742,49 +684,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -794,45 +730,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -840,49 +779,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -892,45 +825,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -938,44 +874,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -984,35 +913,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1024,44 +955,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1070,34 +994,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1110,7 +1038,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt index 15089a43d93b59..d2a53548665600 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcOperationalStateCluster.kt @@ -17,175 +17,136 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcOperationalStateCluster(private val controller: MatterController, private val endpointId: UShort) { +class RvcOperationalStateCluster( + private val controller: MatterController, + private val endpointId: UShort +) { class OperationalCommandResponse( val commandResponseState: RvcOperationalStateClusterErrorStateStruct ) -class PhaseListAttribute( - val value: List? - ) + + class PhaseListAttribute(val value: List?) sealed class PhaseListAttributeSubscriptionState { - data class Success( - val value: List? - ) : PhaseListAttributeSubscriptionState() - + data class Success(val value: List?) : PhaseListAttributeSubscriptionState() + data class Error(val exception: Exception) : PhaseListAttributeSubscriptionState() - object SubscriptionEstablished : PhaseListAttributeSubscriptionState() - } -class CurrentPhaseAttribute( - val value: UByte? - ) + object SubscriptionEstablished : PhaseListAttributeSubscriptionState() + } + + class CurrentPhaseAttribute(val value: UByte?) sealed class CurrentPhaseAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentPhaseAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentPhaseAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPhaseAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() - } -class CountdownTimeAttribute( - val value: UInt? - ) + object SubscriptionEstablished : CurrentPhaseAttributeSubscriptionState() + } + + class CountdownTimeAttribute(val value: UInt?) sealed class CountdownTimeAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : CountdownTimeAttributeSubscriptionState() - + data class Success(val value: UInt?) : CountdownTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : CountdownTimeAttributeSubscriptionState() - object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() - } -class OperationalStateListAttribute( + object SubscriptionEstablished : CountdownTimeAttributeSubscriptionState() + } + + class OperationalStateListAttribute( val value: List ) sealed class OperationalStateListAttributeSubscriptionState { - data class Success( - val value: List - ) : OperationalStateListAttributeSubscriptionState() - + data class Success(val value: List) : + OperationalStateListAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalStateListAttributeSubscriptionState() - object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() - } -class OperationalErrorAttribute( - val value: RvcOperationalStateClusterErrorStateStruct - ) + object SubscriptionEstablished : OperationalStateListAttributeSubscriptionState() + } + + class OperationalErrorAttribute(val value: RvcOperationalStateClusterErrorStateStruct) sealed class OperationalErrorAttributeSubscriptionState { - data class Success( - val value: RvcOperationalStateClusterErrorStateStruct - ) : OperationalErrorAttributeSubscriptionState() - + data class Success(val value: RvcOperationalStateClusterErrorStateStruct) : + OperationalErrorAttributeSubscriptionState() + data class Error(val exception: Exception) : OperationalErrorAttributeSubscriptionState() - object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OperationalErrorAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun pause(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -202,39 +163,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun stop(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -251,39 +205,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun start(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -300,39 +247,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun resume(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -349,39 +289,32 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } suspend fun goHome(timedInvokeTimeout: Duration? = null): OperationalCommandResponse { val commandId: UInt = 128u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -398,79 +331,66 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_COMMAND_RESPONSE_STATE: Int = 0 var commandResponseState_decoded: RvcOperationalStateClusterErrorStateStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) {commandResponseState_decoded = RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_COMMAND_RESPONSE_STATE)) { + commandResponseState_decoded = + RvcOperationalStateClusterErrorStateStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (commandResponseState_decoded == null) { - throw IllegalStateException("commandResponseState not found in TLV") + throw IllegalStateException("commandResponseState not found in TLV") } - tlvReader.exitContainer() - return OperationalCommandResponse( - commandResponseState_decoded - ) + return OperationalCommandResponse(commandResponseState_decoded) } -suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPhaseListAttribute(): PhaseListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Phaselist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - return PhaseListAttribute(decodedValue) } @@ -480,102 +400,96 @@ suspend fun readPhaseListAttribute(): PhaseListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PhaseListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PhaseListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Phaselist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Phaselist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PhaseListAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PhaseListAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PhaseListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentphase attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPhaseAttribute(decodedValue) } @@ -585,100 +499,94 @@ suspend fun readCurrentPhaseAttribute(): CurrentPhaseAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPhaseAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPhaseAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentphase attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentphase attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentPhaseAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentPhaseAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPhaseAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Countdowntime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CountdownTimeAttribute(decodedValue) } @@ -688,101 +596,95 @@ suspend fun readCountdownTimeAttribute(): CountdownTimeAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CountdownTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CountdownTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Countdowntime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Countdowntime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CountdownTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CountdownTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CountdownTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstatelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return OperationalStateListAttribute(decodedValue) } @@ -792,45 +694,52 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalStateListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalStateListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatelist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstatelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + RvcOperationalStateClusterOperationalStateStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } emit(OperationalStateListAttributeSubscriptionState.Success(decodedValue)) } @@ -838,44 +747,37 @@ suspend fun readOperationalStateListAttribute(): OperationalStateListAttribute { emit(OperationalStateListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -884,34 +786,38 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -924,43 +830,37 @@ suspend fun readOperationalStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalerror attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: RvcOperationalStateClusterErrorStateStruct = RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: RvcOperationalStateClusterErrorStateStruct = + RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) return OperationalErrorAttribute(decodedValue) } @@ -970,39 +870,44 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalErrorAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalErrorAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalerror attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalerror attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: RvcOperationalStateClusterErrorStateStruct = RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: RvcOperationalStateClusterErrorStateStruct = + RvcOperationalStateClusterErrorStateStruct.fromTlv(AnonymousTag, tlvReader) emit(OperationalErrorAttributeSubscriptionState.Success(decodedValue)) } @@ -1010,49 +915,43 @@ suspend fun readOperationalErrorAttribute(): OperationalErrorAttribute {val ATTR emit(OperationalErrorAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1062,45 +961,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1108,49 +1012,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1160,45 +1058,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1206,49 +1109,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1258,45 +1155,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1304,49 +1204,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1356,45 +1250,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1402,44 +1299,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1448,35 +1338,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1488,44 +1380,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1534,34 +1419,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1574,7 +1463,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt index a5a84c7128df14..2297e2fb439d4e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/RvcRunModeCluster.kt @@ -17,141 +17,107 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class RvcRunModeCluster(private val controller: MatterController, private val endpointId: UShort) { - class ChangeToModeResponse( - val status: UByte, - val statusText: String? - ) -class SupportedModesAttribute( - val value: List - ) + class ChangeToModeResponse(val status: UByte, val statusText: String?) + + class SupportedModesAttribute(val value: List) sealed class SupportedModesAttributeSubscriptionState { - data class Success( - val value: List - ) : SupportedModesAttributeSubscriptionState() - + data class Success(val value: List) : + SupportedModesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedModesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() - } -class OnModeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SupportedModesAttributeSubscriptionState() + } + + class OnModeAttribute(val value: UByte?) sealed class OnModeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OnModeAttributeSubscriptionState() - + data class Success(val value: UByte?) : OnModeAttributeSubscriptionState() + data class Error(val exception: Exception) : OnModeAttributeSubscriptionState() - object SubscriptionEstablished : OnModeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OnModeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun changeToMode(newMode: UByte - ,timedInvokeTimeout: Duration? = null): ChangeToModeResponse { + suspend fun changeToMode( + newMode: UByte, + timedInvokeTimeout: Duration? = null + ): ChangeToModeResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_MODE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) + tlvWriter.put(ContextSpecificTag(TAG_NEW_MODE_REQ), newMode) tlvWriter.endStructure() val request: InvokeRequest = @@ -168,92 +134,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_STATUS_TEXT: Int = 1 var statusText_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) {statusText_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_STATUS_TEXT)) { + statusText_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return ChangeToModeResponse( - status_decoded, - statusText_decoded - ) + return ChangeToModeResponse(status_decoded, statusText_decoded) } -suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedModesAttribute(): SupportedModesAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedmodes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return SupportedModesAttribute(decodedValue) } @@ -263,45 +214,50 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedModesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedModesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedmodes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedmodes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeOptionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(SupportedModesAttributeSubscriptionState.Success(decodedValue)) } @@ -309,44 +265,37 @@ suspend fun readSupportedModesAttribute(): SupportedModesAttribute {val ATTRIBUT emit(SupportedModesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -355,35 +304,37 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -395,76 +346,66 @@ suspend fun readCurrentModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOnModeAttribute(): OnModeAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Onmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OnModeAttribute(decodedValue) } - suspend fun writeOnModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOnModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -486,7 +427,7 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOnModeAttribute( @@ -494,101 +435,95 @@ suspend fun readOnModeAttribute(): OnModeAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OnModeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OnModeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Onmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Onmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OnModeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OnModeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OnModeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -598,45 +533,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -644,49 +584,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -696,45 +630,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -742,49 +681,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -794,45 +727,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -840,49 +776,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -892,45 +822,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -938,44 +871,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -984,35 +910,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1024,44 +952,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1070,34 +991,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1110,7 +1035,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt index 9d5b10e9a5a6ce..4514121f33fa31 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SampleMeiCluster.kt @@ -17,110 +17,80 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class SampleMeiCluster(private val controller: MatterController, private val endpointId: UShort) { - class AddArgumentsResponse( - val returnValue: UByte - ) -class GeneratedCommandListAttribute( - val value: List - ) + class AddArgumentsResponse(val returnValue: UByte) + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun ping(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -134,9 +104,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addArguments(arg1: UByte - ,arg2: UByte - ,timedInvokeTimeout: Duration? = null): AddArgumentsResponse { + suspend fun addArguments( + arg1: UByte, + arg2: UByte, + timedInvokeTimeout: Duration? = null + ): AddArgumentsResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -146,7 +118,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) val TAG_ARG2_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) tlvWriter.endStructure() val request: InvokeRequest = @@ -163,92 +135,73 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getUByte(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } - tlvReader.exitContainer() - return AddArgumentsResponse( - returnValue_decoded - ) + return AddArgumentsResponse(returnValue_decoded) } -suspend fun readFlipFlopAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFlipFlopAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Flipflop attribute not found in response" - } + } + + requireNotNull(attributeData) { "Flipflop attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writeFlipFlopAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeFlipFlopAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -270,7 +223,7 @@ suspend fun readFlipFlopAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFlipFlopAttribute( @@ -278,35 +231,37 @@ suspend fun readFlipFlopAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Flipflop attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Flipflop attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -318,49 +273,43 @@ suspend fun readFlipFlopAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -370,45 +319,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -416,49 +370,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -468,45 +416,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -514,49 +467,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -566,45 +513,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -612,49 +562,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -664,45 +608,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -710,44 +657,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -756,35 +696,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -796,44 +738,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -842,34 +777,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -882,7 +821,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt index b74311f864c1cc..a7c4b66d6ee5be 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ScenesManagementCluster.kt @@ -17,193 +17,144 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ScenesManagementCluster(private val controller: MatterController, private val endpointId: UShort) { - class AddSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte - ) +class ScenesManagementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class AddSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) class ViewSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte, - val transitionTime: UShort?, - val sceneName: String?, + val status: UByte, + val groupID: UShort, + val sceneID: UByte, + val transitionTime: UShort?, + val sceneName: String?, val extensionFieldSets: List? ) - class RemoveSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte - ) + class RemoveSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) - class RemoveAllScenesResponse( - val status: UByte, - val groupID: UShort - ) + class RemoveAllScenesResponse(val status: UByte, val groupID: UShort) - class StoreSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte - ) + class StoreSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) class GetSceneMembershipResponse( - val status: UByte, - val capacity: UByte?, - val groupID: UShort, + val status: UByte, + val capacity: UByte?, + val groupID: UShort, val sceneList: List? ) - class EnhancedAddSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte - ) + class EnhancedAddSceneResponse(val status: UByte, val groupID: UShort, val sceneID: UByte) class EnhancedViewSceneResponse( - val status: UByte, - val groupID: UShort, - val sceneID: UByte, - val transitionTime: UShort?, - val sceneName: String?, + val status: UByte, + val groupID: UShort, + val sceneID: UByte, + val transitionTime: UShort?, + val sceneName: String?, val extensionFieldSets: List? ) class CopySceneResponse( - val status: UByte, - val groupIdentifierFrom: UShort, + val status: UByte, + val groupIdentifierFrom: UShort, val sceneIdentifierFrom: UByte ) -class LastConfiguredByAttribute( - val value: ULong? - ) + + class LastConfiguredByAttribute(val value: ULong?) sealed class LastConfiguredByAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : LastConfiguredByAttributeSubscriptionState() - + data class Success(val value: ULong?) : LastConfiguredByAttributeSubscriptionState() + data class Error(val exception: Exception) : LastConfiguredByAttributeSubscriptionState() - object SubscriptionEstablished : LastConfiguredByAttributeSubscriptionState() - } -class FabricSceneInfoAttribute( - val value: List - ) + object SubscriptionEstablished : LastConfiguredByAttributeSubscriptionState() + } + + class FabricSceneInfoAttribute(val value: List) sealed class FabricSceneInfoAttributeSubscriptionState { - data class Success( - val value: List - ) : FabricSceneInfoAttributeSubscriptionState() - + data class Success(val value: List) : + FabricSceneInfoAttributeSubscriptionState() + data class Error(val exception: Exception) : FabricSceneInfoAttributeSubscriptionState() - object SubscriptionEstablished : FabricSceneInfoAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : FabricSceneInfoAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun addScene(groupID: UShort - ,sceneID: UByte - ,transitionTime: UShort - ,sceneName: String - ,extensionFieldSets: List - ,timedInvokeTimeout: Duration? = null): AddSceneResponse { + suspend fun addScene( + groupID: UShort, + sceneID: UByte, + transitionTime: UShort, + sceneName: String, + extensionFieldSets: List, + timedInvokeTimeout: Duration? = null + ): AddSceneResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -223,10 +174,10 @@ class AttributeListAttribute( val TAG_EXTENSION_FIELD_SETS_REQ: Int = 4 tlvWriter.startArray(ContextSpecificTag(TAG_EXTENSION_FIELD_SETS_REQ)) - for (item in extensionFieldSets.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in extensionFieldSets.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -243,59 +194,53 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } - tlvReader.exitContainer() - return AddSceneResponse( - status_decoded, - groupID_decoded, - sceneID_decoded - ) + return AddSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) } - suspend fun viewScene(groupID: UShort - ,sceneID: UByte - ,timedInvokeTimeout: Duration? = null): ViewSceneResponse { + suspend fun viewScene( + groupID: UShort, + sceneID: UByte, + timedInvokeTimeout: Duration? = null + ): ViewSceneResponse { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -305,7 +250,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_SCENE_I_D_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) tlvWriter.endStructure() val request: InvokeRequest = @@ -322,103 +267,99 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - + val TAG_TRANSITION_TIME: Int = 3 var transitionTime_decoded: UShort? = null - + val TAG_SCENE_NAME: Int = 4 var sceneName_decoded: String? = null - + val TAG_EXTENSION_FIELD_SETS: Int = 5 var extensionFieldSets_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) {transitionTime_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) { + transitionTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_SCENE_NAME)) {sceneName_decoded = + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_SCENE_NAME)) { + sceneName_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) {extensionFieldSets_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) { + extensionFieldSets_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - - else { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } - - - - - - - tlvReader.exitContainer() @@ -432,9 +373,11 @@ class AttributeListAttribute( ) } - suspend fun removeScene(groupID: UShort - ,sceneID: UByte - ,timedInvokeTimeout: Duration? = null): RemoveSceneResponse { + suspend fun removeScene( + groupID: UShort, + sceneID: UByte, + timedInvokeTimeout: Duration? = null + ): RemoveSceneResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -444,7 +387,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_SCENE_I_D_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) tlvWriter.endStructure() val request: InvokeRequest = @@ -461,65 +404,59 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } - tlvReader.exitContainer() - return RemoveSceneResponse( - status_decoded, - groupID_decoded, - sceneID_decoded - ) + return RemoveSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) } - suspend fun removeAllScenes(groupID: UShort - ,timedInvokeTimeout: Duration? = null): RemoveAllScenesResponse { + suspend fun removeAllScenes( + groupID: UShort, + timedInvokeTimeout: Duration? = null + ): RemoveAllScenesResponse { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -536,48 +473,42 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - tlvReader.exitContainer() - return RemoveAllScenesResponse( - status_decoded, - groupID_decoded - ) + return RemoveAllScenesResponse(status_decoded, groupID_decoded) } - suspend fun storeScene(groupID: UShort - ,sceneID: UByte - ,timedInvokeTimeout: Duration? = null): StoreSceneResponse { + suspend fun storeScene( + groupID: UShort, + sceneID: UByte, + timedInvokeTimeout: Duration? = null + ): StoreSceneResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -587,7 +518,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_SCENE_I_D_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) tlvWriter.endStructure() val request: InvokeRequest = @@ -604,60 +535,54 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } - else { + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } - tlvReader.exitContainer() - return StoreSceneResponse( - status_decoded, - groupID_decoded, - sceneID_decoded - ) + return StoreSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) } - suspend fun recallScene(groupID: UShort - ,sceneID: UByte - ,transitionTime: UShort? - ,timedInvokeTimeout: Duration? = null) { + suspend fun recallScene( + groupID: UShort, + sceneID: UByte, + transitionTime: UShort?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() @@ -672,7 +597,7 @@ class AttributeListAttribute( val TAG_TRANSITION_TIME_REQ: Int = 2 transitionTime?.let { tlvWriter.put(ContextSpecificTag(TAG_TRANSITION_TIME_REQ), transitionTime) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -686,15 +611,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getSceneMembership(groupID: UShort - ,timedInvokeTimeout: Duration? = null): GetSceneMembershipResponse { + suspend fun getSceneMembership( + groupID: UShort, + timedInvokeTimeout: Duration? = null + ): GetSceneMembershipResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_GROUP_I_D_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) + tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) tlvWriter.endStructure() val request: InvokeRequest = @@ -711,77 +638,72 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_CAPACITY: Int = 1 var capacity_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 2 var groupID_decoded: UShort? = null - + val TAG_SCENE_LIST: Int = 3 var sceneList_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_CAPACITY)) {capacity_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_CAPACITY)) { + capacity_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - tlvReader.getUByte(tag) - } else { - tlvReader.getNull(tag) - null - } - }} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_LIST)) {sceneList_decoded = + tlvReader.getUByte(tag) + } else { + tlvReader.getNull(tag) + null + } + } + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_LIST)) { + sceneList_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - - else { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - - tlvReader.exitContainer() @@ -793,12 +715,14 @@ class AttributeListAttribute( ) } - suspend fun enhancedAddScene(groupID: UShort - ,sceneID: UByte - ,transitionTime: UShort - ,sceneName: String - ,extensionFieldSets: List - ,timedInvokeTimeout: Duration? = null): EnhancedAddSceneResponse { + suspend fun enhancedAddScene( + groupID: UShort, + sceneID: UByte, + transitionTime: UShort, + sceneName: String, + extensionFieldSets: List, + timedInvokeTimeout: Duration? = null + ): EnhancedAddSceneResponse { val commandId: UInt = 64u val tlvWriter = TlvWriter() @@ -818,10 +742,10 @@ class AttributeListAttribute( val TAG_EXTENSION_FIELD_SETS_REQ: Int = 4 tlvWriter.startArray(ContextSpecificTag(TAG_EXTENSION_FIELD_SETS_REQ)) - for (item in extensionFieldSets.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in extensionFieldSets.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -838,59 +762,53 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } - else { + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } - tlvReader.exitContainer() - return EnhancedAddSceneResponse( - status_decoded, - groupID_decoded, - sceneID_decoded - ) + return EnhancedAddSceneResponse(status_decoded, groupID_decoded, sceneID_decoded) } - suspend fun enhancedViewScene(groupID: UShort - ,sceneID: UByte - ,timedInvokeTimeout: Duration? = null): EnhancedViewSceneResponse { + suspend fun enhancedViewScene( + groupID: UShort, + sceneID: UByte, + timedInvokeTimeout: Duration? = null + ): EnhancedViewSceneResponse { val commandId: UInt = 65u val tlvWriter = TlvWriter() @@ -900,7 +818,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_I_D_REQ), groupID) val TAG_SCENE_I_D_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_I_D_REQ), sceneID) tlvWriter.endStructure() val request: InvokeRequest = @@ -917,103 +835,99 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_I_D: Int = 1 var groupID_decoded: UShort? = null - + val TAG_SCENE_I_D: Int = 2 var sceneID_decoded: UByte? = null - + val TAG_TRANSITION_TIME: Int = 3 var transitionTime_decoded: UShort? = null - + val TAG_SCENE_NAME: Int = 4 var sceneName_decoded: String? = null - + val TAG_EXTENSION_FIELD_SETS: Int = 5 var extensionFieldSets_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_I_D)) {groupID_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_I_D)) {sceneID_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) {transitionTime_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_I_D)) { + groupID_decoded = tlvReader.getUShort(tag) + } + + if (tag == ContextSpecificTag(TAG_SCENE_I_D)) { + sceneID_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_TRANSITION_TIME)) { + transitionTime_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_SCENE_NAME)) {sceneName_decoded = + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_SCENE_NAME)) { + sceneName_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) {extensionFieldSets_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_EXTENSION_FIELD_SETS)) { + extensionFieldSets_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - - else { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterExtensionFieldSet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupID_decoded == null) { - throw IllegalStateException("groupID not found in TLV") + throw IllegalStateException("groupID not found in TLV") } - - + if (sceneID_decoded == null) { - throw IllegalStateException("sceneID not found in TLV") + throw IllegalStateException("sceneID not found in TLV") } - - - - - - - tlvReader.exitContainer() @@ -1027,12 +941,14 @@ class AttributeListAttribute( ) } - suspend fun copyScene(mode: UByte - ,groupIdentifierFrom: UShort - ,sceneIdentifierFrom: UByte - ,groupIdentifierTo: UShort - ,sceneIdentifierTo: UByte - ,timedInvokeTimeout: Duration? = null): CopySceneResponse { + suspend fun copyScene( + mode: UByte, + groupIdentifierFrom: UShort, + sceneIdentifierFrom: UByte, + groupIdentifierTo: UShort, + sceneIdentifierTo: UByte, + timedInvokeTimeout: Duration? = null + ): CopySceneResponse { val commandId: UInt = 66u val tlvWriter = TlvWriter() @@ -1051,7 +967,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GROUP_IDENTIFIER_TO_REQ), groupIdentifierTo) val TAG_SCENE_IDENTIFIER_TO_REQ: Int = 4 - tlvWriter.put(ContextSpecificTag(TAG_SCENE_IDENTIFIER_TO_REQ), sceneIdentifierTo) + tlvWriter.put(ContextSpecificTag(TAG_SCENE_IDENTIFIER_TO_REQ), sceneIdentifierTo) tlvWriter.endStructure() val request: InvokeRequest = @@ -1068,46 +984,42 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_GROUP_IDENTIFIER_FROM: Int = 1 var groupIdentifierFrom_decoded: UShort? = null - + val TAG_SCENE_IDENTIFIER_FROM: Int = 2 var sceneIdentifierFrom_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_GROUP_IDENTIFIER_FROM)) {groupIdentifierFrom_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_SCENE_IDENTIFIER_FROM)) {sceneIdentifierFrom_decoded = tlvReader.getUByte(tag)} - + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_GROUP_IDENTIFIER_FROM)) { + groupIdentifierFrom_decoded = tlvReader.getUShort(tag) + } - else { + if (tag == ContextSpecificTag(TAG_SCENE_IDENTIFIER_FROM)) { + sceneIdentifierFrom_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - + if (groupIdentifierFrom_decoded == null) { - throw IllegalStateException("groupIdentifierFrom not found in TLV") + throw IllegalStateException("groupIdentifierFrom not found in TLV") } - - + if (sceneIdentifierFrom_decoded == null) { - throw IllegalStateException("sceneIdentifierFrom not found in TLV") + throw IllegalStateException("sceneIdentifierFrom not found in TLV") } - tlvReader.exitContainer() @@ -1117,45 +1029,39 @@ class AttributeListAttribute( sceneIdentifierFrom_decoded ) } -suspend fun readSceneCountAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSceneCountAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scenecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scenecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1165,94 +1071,88 @@ suspend fun readSceneCountAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scenecount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Scenecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentSceneAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentSceneAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentscene attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentscene attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1262,94 +1162,88 @@ suspend fun readCurrentSceneAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentscene attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentscene attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentGroupAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentGroupAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentgroup attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentgroup attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1359,94 +1253,88 @@ suspend fun readCurrentGroupAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentgroup attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentgroup attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSceneValidAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSceneValidAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scenevalid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scenevalid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -1456,91 +1344,84 @@ suspend fun readSceneValidAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scenevalid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Scenevalid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNameSupportAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNameSupportAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Namesupport attribute not found in response" - } + } + + requireNotNull(attributeData) { "Namesupport attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1549,35 +1430,37 @@ suspend fun readNameSupportAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Namesupport attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Namesupport attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1589,52 +1472,46 @@ suspend fun readNameSupportAttribute(): UByte {val ATTRIBUTE_ID: UInt = 4u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLastConfiguredByAttribute(): LastConfiguredByAttribute {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLastConfiguredByAttribute(): LastConfiguredByAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastconfiguredby attribute not found in response" - } + } + + requireNotNull(attributeData) { "Lastconfiguredby attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LastConfiguredByAttribute(decodedValue) } @@ -1644,96 +1521,91 @@ suspend fun readLastConfiguredByAttribute(): LastConfiguredByAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LastConfiguredByAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LastConfiguredByAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Lastconfiguredby attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Lastconfiguredby attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LastConfiguredByAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LastConfiguredByAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LastConfiguredByAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSceneTableSizeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSceneTableSizeAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scenetablesize attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scenetablesize attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1742,34 +1614,38 @@ suspend fun readSceneTableSizeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scenetablesize attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scenetablesize attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1782,49 +1658,43 @@ suspend fun readSceneTableSizeAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fabricsceneinfo attribute not found in response" - } + } + + requireNotNull(attributeData) { "Fabricsceneinfo attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return FabricSceneInfoAttribute(decodedValue) } @@ -1834,45 +1704,50 @@ suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FabricSceneInfoAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FabricSceneInfoAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Fabricsceneinfo attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Fabricsceneinfo attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterSceneInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(FabricSceneInfoAttributeSubscriptionState.Success(decodedValue)) } @@ -1880,49 +1755,43 @@ suspend fun readFabricSceneInfoAttribute(): FabricSceneInfoAttribute {val ATTRIB emit(FabricSceneInfoAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1932,45 +1801,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1978,49 +1852,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2030,45 +1898,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2076,49 +1949,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2128,45 +1995,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2174,49 +2044,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2226,45 +2090,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2272,44 +2139,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2318,35 +2178,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2358,44 +2220,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2404,34 +2259,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2444,7 +2303,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt index ec9ca8d0e7e65a..12a337827e4c2c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SmokeCoAlarmCluster.kt @@ -17,106 +17,81 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class SmokeCoAlarmCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun selfTestRequest(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -129,42 +104,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readExpressedStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readExpressedStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expressedstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Expressedstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -173,34 +141,38 @@ suspend fun readExpressedStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expressedstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Expressedstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -213,47 +185,41 @@ suspend fun readExpressedStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSmokeStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSmokeStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Smokestate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Smokestate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -263,94 +229,88 @@ suspend fun readSmokeStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Smokestate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Smokestate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCOStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCOStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Costate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Costate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -360,91 +320,84 @@ suspend fun readCOStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Costate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Costate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBatteryAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBatteryAlertAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batteryalert attribute not found in response" - } + } + + requireNotNull(attributeData) { "Batteryalert attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -453,35 +406,37 @@ suspend fun readBatteryAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Batteryalert attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Batteryalert attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -493,47 +448,41 @@ suspend fun readBatteryAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 3u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDeviceMutedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDeviceMutedAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Devicemuted attribute not found in response" - } + } + + requireNotNull(attributeData) { "Devicemuted attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -543,91 +492,84 @@ suspend fun readDeviceMutedAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Devicemuted attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Devicemuted attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTestInProgressAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTestInProgressAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Testinprogress attribute not found in response" - } + } + + requireNotNull(attributeData) { "Testinprogress attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -636,34 +578,38 @@ suspend fun readTestInProgressAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Testinprogress attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Testinprogress attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -676,44 +622,37 @@ suspend fun readTestInProgressAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 5u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHardwareFaultAlertAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readHardwareFaultAlertAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwarefaultalert attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hardwarefaultalert attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } @@ -722,34 +661,38 @@ suspend fun readHardwareFaultAlertAttribute(): Boolean {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hardwarefaultalert attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hardwarefaultalert attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -762,44 +705,37 @@ suspend fun readHardwareFaultAlertAttribute(): Boolean {val ATTRIBUTE_ID: UInt = emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEndOfServiceAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEndOfServiceAlertAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endofservicealert attribute not found in response" - } + } + + requireNotNull(attributeData) { "Endofservicealert attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -808,34 +744,38 @@ suspend fun readEndOfServiceAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endofservicealert attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Endofservicealert attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -848,47 +788,41 @@ suspend fun readEndOfServiceAlertAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInterconnectSmokeAlarmAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInterconnectSmokeAlarmAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interconnectsmokealarm attribute not found in response" - } + } + + requireNotNull(attributeData) { "Interconnectsmokealarm attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -898,94 +832,90 @@ suspend fun readInterconnectSmokeAlarmAttribute(): UByte? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interconnectsmokealarm attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Interconnectsmokealarm attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInterconnectCOAlarmAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readInterconnectCOAlarmAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interconnectcoalarm attribute not found in response" - } + } + + requireNotNull(attributeData) { "Interconnectcoalarm attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -995,94 +925,90 @@ suspend fun readInterconnectCOAlarmAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Interconnectcoalarm attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Interconnectcoalarm attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readContaminationStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readContaminationStateAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Contaminationstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Contaminationstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1092,118 +1018,113 @@ suspend fun readContaminationStateAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Contaminationstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Contaminationstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSmokeSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSmokeSensitivityLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Smokesensitivitylevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Smokesensitivitylevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeSmokeSensitivityLevelAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 11u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1225,7 +1146,7 @@ suspend fun readSmokeSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSmokeSensitivityLevelAttribute( @@ -1233,94 +1154,90 @@ suspend fun readSmokeSensitivityLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Smokesensitivitylevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Smokesensitivitylevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readExpiryDateAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 12u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readExpiryDateAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expirydate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Expirydate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -1330,96 +1247,90 @@ suspend fun readExpiryDateAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 12u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Expirydate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Expirydate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1429,45 +1340,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1475,49 +1391,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1527,45 +1437,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1573,49 +1488,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1625,45 +1534,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1671,49 +1583,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1723,45 +1629,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1769,44 +1678,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1815,35 +1717,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1855,44 +1759,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1901,34 +1798,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1941,7 +1842,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt index 3e60be49a852ca..c3568e5825e8fe 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SoftwareDiagnosticsCluster.kt @@ -17,119 +17,88 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SoftwareDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class ThreadMetricsAttribute( - val value: List? - ) +class SoftwareDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ThreadMetricsAttribute(val value: List?) sealed class ThreadMetricsAttributeSubscriptionState { - data class Success( - val value: List? - ) : ThreadMetricsAttributeSubscriptionState() - + data class Success(val value: List?) : + ThreadMetricsAttributeSubscriptionState() + data class Error(val exception: Exception) : ThreadMetricsAttributeSubscriptionState() - object SubscriptionEstablished : ThreadMetricsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : ThreadMetricsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetWatermarks(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -142,51 +111,45 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readThreadMetricsAttribute(): ThreadMetricsAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readThreadMetricsAttribute(): ThreadMetricsAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadmetrics attribute not found in response" - } + } + + requireNotNull(attributeData) { "Threadmetrics attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ThreadMetricsAttribute(decodedValue) } @@ -196,100 +159,96 @@ suspend fun readThreadMetricsAttribute(): ThreadMetricsAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ThreadMetricsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ThreadMetricsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Threadmetrics attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Threadmetrics attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ThreadMetricsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + SoftwareDiagnosticsClusterThreadMetricsStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ThreadMetricsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ThreadMetricsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentHeapFreeAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentHeapFreeAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheapfree attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentheapfree attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -299,94 +258,90 @@ suspend fun readCurrentHeapFreeAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheapfree attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentheapfree attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentHeapUsedAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentHeapUsedAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheapused attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentheapused attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -396,94 +351,90 @@ suspend fun readCurrentHeapUsedAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheapused attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentheapused attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentHeapHighWatermarkAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentHeapHighWatermarkAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheaphighwatermark attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentheaphighwatermark attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -493,96 +444,92 @@ suspend fun readCurrentHeapHighWatermarkAttribute(): ULong? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentheaphighwatermark attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentheaphighwatermark attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -592,45 +539,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -638,49 +590,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -690,45 +636,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -736,49 +687,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -788,45 +733,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -834,49 +782,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -886,45 +828,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -932,44 +877,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -978,35 +916,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1018,44 +958,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1064,34 +997,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1104,7 +1041,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt index 0462ac9b0c886c..ec30f6aa7452e6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/SwitchCluster.kt @@ -17,136 +17,93 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class SwitchCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class SwitchCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readNumberOfPositionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readNumberOfPositionsAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpositions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofpositions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -155,34 +112,38 @@ suspend fun readNumberOfPositionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpositions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofpositions attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -195,44 +156,37 @@ suspend fun readNumberOfPositionsAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentPositionAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentposition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentposition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -241,34 +195,38 @@ suspend fun readCurrentPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentposition attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -281,47 +239,41 @@ suspend fun readCurrentPositionAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMultiPressMaxAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMultiPressMaxAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Multipressmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Multipressmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -331,96 +283,90 @@ suspend fun readMultiPressMaxAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Multipressmax attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Multipressmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -430,45 +376,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -476,49 +427,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -528,45 +473,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -574,49 +524,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -626,45 +570,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -672,49 +619,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -724,45 +665,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -770,44 +714,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -816,35 +753,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -856,44 +795,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -902,34 +834,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -942,7 +878,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt index c7aee150c59e6c..aa48d2e32d4736 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TargetNavigatorCluster.kt @@ -17,122 +17,91 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TargetNavigatorCluster(private val controller: MatterController, private val endpointId: UShort) { - class NavigateTargetResponse( - val status: UByte, - val data: String? - ) -class TargetListAttribute( - val value: List - ) +class TargetNavigatorCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class NavigateTargetResponse(val status: UByte, val data: String?) + + class TargetListAttribute(val value: List) sealed class TargetListAttributeSubscriptionState { - data class Success( - val value: List - ) : TargetListAttributeSubscriptionState() - + data class Success(val value: List) : + TargetListAttributeSubscriptionState() + data class Error(val exception: Exception) : TargetListAttributeSubscriptionState() - object SubscriptionEstablished : TargetListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : TargetListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun navigateTarget(target: UByte - ,data: String? - ,timedInvokeTimeout: Duration? = null): NavigateTargetResponse { + suspend fun navigateTarget( + target: UByte, + data: String?, + timedInvokeTimeout: Duration? = null + ): NavigateTargetResponse { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -142,9 +111,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_TARGET_REQ), target) val TAG_DATA_REQ: Int = 1 - data?.let { - tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) - } + data?.let { tlvWriter.put(ContextSpecificTag(TAG_DATA_REQ), data) } tlvWriter.endStructure() val request: InvokeRequest = @@ -161,92 +128,77 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_STATUS: Int = 0 var status_decoded: UByte? = null - + val TAG_DATA: Int = 1 var data_decoded: String? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_STATUS)) {status_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DATA)) {data_decoded = + if (tag == ContextSpecificTag(TAG_STATUS)) { + status_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DATA)) { + data_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - - else { + tlvReader.getString(tag) + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (status_decoded == null) { - throw IllegalStateException("status not found in TLV") + throw IllegalStateException("status not found in TLV") } - - - tlvReader.exitContainer() - return NavigateTargetResponse( - status_decoded, - data_decoded - ) + return NavigateTargetResponse(status_decoded, data_decoded) } -suspend fun readTargetListAttribute(): TargetListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTargetListAttribute(): TargetListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Targetlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return TargetListAttribute(decodedValue) } @@ -256,45 +208,48 @@ suspend fun readTargetListAttribute(): TargetListAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TargetListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TargetListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Targetlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(TargetListAttributeSubscriptionState.Success(decodedValue)) } @@ -302,47 +257,41 @@ suspend fun readTargetListAttribute(): TargetListAttribute {val ATTRIBUTE_ID: UI emit(TargetListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentTargetAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentTargetAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenttarget attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currenttarget attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -352,96 +301,90 @@ suspend fun readCurrentTargetAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currenttarget attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currenttarget attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -451,45 +394,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -497,49 +445,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -549,45 +491,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -595,49 +542,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -647,45 +588,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -693,49 +637,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -745,45 +683,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -791,44 +732,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -837,35 +771,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -877,44 +813,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -923,34 +852,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -963,7 +896,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt index 879479e9577967..ef8fa756028407 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureControlCluster.kt @@ -17,117 +17,91 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.ShortSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TemperatureControlCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedTemperatureLevelsAttribute( - val value: List? - ) +class TemperatureControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedTemperatureLevelsAttribute(val value: List?) sealed class SupportedTemperatureLevelsAttributeSubscriptionState { - data class Success( - val value: List? - ) : SupportedTemperatureLevelsAttributeSubscriptionState() - - data class Error(val exception: Exception) : SupportedTemperatureLevelsAttributeSubscriptionState() - - object SubscriptionEstablished : SupportedTemperatureLevelsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List?) : + SupportedTemperatureLevelsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + SupportedTemperatureLevelsAttributeSubscriptionState() + + object SubscriptionEstablished : SupportedTemperatureLevelsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setTemperature(targetTemperature: Short? - ,targetTemperatureLevel: UByte? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setTemperature( + targetTemperature: Short?, + targetTemperatureLevel: UByte?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -141,7 +115,7 @@ class AttributeListAttribute( val TAG_TARGET_TEMPERATURE_LEVEL_REQ: Int = 1 targetTemperatureLevel?.let { tlvWriter.put(ContextSpecificTag(TAG_TARGET_TEMPERATURE_LEVEL_REQ), targetTemperatureLevel) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -154,45 +128,39 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readTemperatureSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTemperatureSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Temperaturesetpoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -202,94 +170,90 @@ suspend fun readTemperatureSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperaturesetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinTemperatureAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinTemperatureAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mintemperature attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mintemperature attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -299,94 +263,90 @@ suspend fun readMinTemperatureAttribute(): Short? {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mintemperature attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Mintemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxTemperatureAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxTemperatureAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxtemperature attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxtemperature attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -396,94 +356,90 @@ suspend fun readMaxTemperatureAttribute(): Short? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxtemperature attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxtemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStepAttribute(): Short? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readStepAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Step attribute not found in response" - } + } + + requireNotNull(attributeData) { "Step attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -493,94 +449,88 @@ suspend fun readStepAttribute(): Short? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Step attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Step attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSelectedTemperatureLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSelectedTemperatureLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selectedtemperaturelevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Selectedtemperaturelevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -590,100 +540,96 @@ suspend fun readSelectedTemperatureLevelAttribute(): UByte? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Selectedtemperaturelevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Selectedtemperaturelevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedTemperatureLevelsAttribute(): SupportedTemperatureLevelsAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedTemperatureLevelsAttribute(): SupportedTemperatureLevelsAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedtemperaturelevels attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedtemperaturelevels attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SupportedTemperatureLevelsAttribute(decodedValue) } @@ -693,102 +639,100 @@ suspend fun readSupportedTemperatureLevelsAttribute(): SupportedTemperatureLevel maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedTemperatureLevelsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedTemperatureLevelsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedtemperaturelevels attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedtemperaturelevels attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } decodedValue?.let { emit(SupportedTemperatureLevelsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(SupportedTemperatureLevelsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -798,45 +742,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -844,49 +793,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -896,45 +839,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -942,49 +890,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -994,45 +936,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1040,49 +985,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1092,45 +1031,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1138,44 +1080,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1184,35 +1119,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1224,44 +1161,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1270,34 +1200,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1310,7 +1244,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt index ef6d1043bbbf5b..5cd6ac3392242f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TemperatureMeasurementCluster.kt @@ -17,179 +17,130 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class TemperatureMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Short? - ) +class TemperatureMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Short?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Short?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Short? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Short?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Short? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Short?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -199,96 +150,90 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -298,96 +243,92 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -397,95 +338,91 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readToleranceAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in response" - } + } + + requireNotNull(attributeData) { "Tolerance attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -495,96 +432,90 @@ suspend fun readToleranceAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Tolerance attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Tolerance attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -594,45 +525,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -640,49 +576,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -692,45 +622,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -738,49 +673,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -790,45 +719,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -836,49 +768,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -888,45 +814,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -934,44 +863,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -980,35 +902,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1020,44 +944,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1066,34 +983,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1106,7 +1027,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt index f64bc24d5bee34..2fa28950db06cd 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatCluster.kt @@ -17,371 +17,294 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.ShortSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class ThermostatCluster(private val controller: MatterController, private val endpointId: UShort) { class GetWeeklyScheduleResponse( - val numberOfTransitionsForSequence: UByte, - val dayOfWeekForSequence: UByte, - val modeForSequence: UByte, + val numberOfTransitionsForSequence: UByte, + val dayOfWeekForSequence: UByte, + val modeForSequence: UByte, val transitions: List ) -class LocalTemperatureAttribute( - val value: Short? - ) + + class LocalTemperatureAttribute(val value: Short?) sealed class LocalTemperatureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : LocalTemperatureAttributeSubscriptionState() - + data class Success(val value: Short?) : LocalTemperatureAttributeSubscriptionState() + data class Error(val exception: Exception) : LocalTemperatureAttributeSubscriptionState() - object SubscriptionEstablished : LocalTemperatureAttributeSubscriptionState() - } -class OutdoorTemperatureAttribute( - val value: Short? - ) + object SubscriptionEstablished : LocalTemperatureAttributeSubscriptionState() + } + + class OutdoorTemperatureAttribute(val value: Short?) sealed class OutdoorTemperatureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : OutdoorTemperatureAttributeSubscriptionState() - + data class Success(val value: Short?) : OutdoorTemperatureAttributeSubscriptionState() + data class Error(val exception: Exception) : OutdoorTemperatureAttributeSubscriptionState() - object SubscriptionEstablished : OutdoorTemperatureAttributeSubscriptionState() - } -class TemperatureSetpointHoldDurationAttribute( - val value: UShort? - ) + object SubscriptionEstablished : OutdoorTemperatureAttributeSubscriptionState() + } + + class TemperatureSetpointHoldDurationAttribute(val value: UShort?) sealed class TemperatureSetpointHoldDurationAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : TemperatureSetpointHoldDurationAttributeSubscriptionState() - - data class Error(val exception: Exception) : TemperatureSetpointHoldDurationAttributeSubscriptionState() - - object SubscriptionEstablished : TemperatureSetpointHoldDurationAttributeSubscriptionState() - } -class SetpointChangeAmountAttribute( - val value: Short? - ) + data class Success(val value: UShort?) : + TemperatureSetpointHoldDurationAttributeSubscriptionState() + + data class Error(val exception: Exception) : + TemperatureSetpointHoldDurationAttributeSubscriptionState() + + object SubscriptionEstablished : TemperatureSetpointHoldDurationAttributeSubscriptionState() + } + + class SetpointChangeAmountAttribute(val value: Short?) sealed class SetpointChangeAmountAttributeSubscriptionState { - data class Success( - val value: Short? - ) : SetpointChangeAmountAttributeSubscriptionState() - + data class Success(val value: Short?) : SetpointChangeAmountAttributeSubscriptionState() + data class Error(val exception: Exception) : SetpointChangeAmountAttributeSubscriptionState() - object SubscriptionEstablished : SetpointChangeAmountAttributeSubscriptionState() - } -class OccupiedSetbackAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SetpointChangeAmountAttributeSubscriptionState() + } + + class OccupiedSetbackAttribute(val value: UByte?) sealed class OccupiedSetbackAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OccupiedSetbackAttributeSubscriptionState() - + data class Success(val value: UByte?) : OccupiedSetbackAttributeSubscriptionState() + data class Error(val exception: Exception) : OccupiedSetbackAttributeSubscriptionState() - object SubscriptionEstablished : OccupiedSetbackAttributeSubscriptionState() - } -class OccupiedSetbackMinAttribute( - val value: UByte? - ) + object SubscriptionEstablished : OccupiedSetbackAttributeSubscriptionState() + } + + class OccupiedSetbackMinAttribute(val value: UByte?) sealed class OccupiedSetbackMinAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OccupiedSetbackMinAttributeSubscriptionState() - + data class Success(val value: UByte?) : OccupiedSetbackMinAttributeSubscriptionState() + data class Error(val exception: Exception) : OccupiedSetbackMinAttributeSubscriptionState() - object SubscriptionEstablished : OccupiedSetbackMinAttributeSubscriptionState() - } -class OccupiedSetbackMaxAttribute( - val value: UByte? - ) + object SubscriptionEstablished : OccupiedSetbackMinAttributeSubscriptionState() + } + + class OccupiedSetbackMaxAttribute(val value: UByte?) sealed class OccupiedSetbackMaxAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : OccupiedSetbackMaxAttributeSubscriptionState() - + data class Success(val value: UByte?) : OccupiedSetbackMaxAttributeSubscriptionState() + data class Error(val exception: Exception) : OccupiedSetbackMaxAttributeSubscriptionState() - object SubscriptionEstablished : OccupiedSetbackMaxAttributeSubscriptionState() - } -class UnoccupiedSetbackAttribute( - val value: UByte? - ) + object SubscriptionEstablished : OccupiedSetbackMaxAttributeSubscriptionState() + } + + class UnoccupiedSetbackAttribute(val value: UByte?) sealed class UnoccupiedSetbackAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : UnoccupiedSetbackAttributeSubscriptionState() - + data class Success(val value: UByte?) : UnoccupiedSetbackAttributeSubscriptionState() + data class Error(val exception: Exception) : UnoccupiedSetbackAttributeSubscriptionState() - object SubscriptionEstablished : UnoccupiedSetbackAttributeSubscriptionState() - } -class UnoccupiedSetbackMinAttribute( - val value: UByte? - ) + object SubscriptionEstablished : UnoccupiedSetbackAttributeSubscriptionState() + } + + class UnoccupiedSetbackMinAttribute(val value: UByte?) sealed class UnoccupiedSetbackMinAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : UnoccupiedSetbackMinAttributeSubscriptionState() - + data class Success(val value: UByte?) : UnoccupiedSetbackMinAttributeSubscriptionState() + data class Error(val exception: Exception) : UnoccupiedSetbackMinAttributeSubscriptionState() - object SubscriptionEstablished : UnoccupiedSetbackMinAttributeSubscriptionState() - } -class UnoccupiedSetbackMaxAttribute( - val value: UByte? - ) + object SubscriptionEstablished : UnoccupiedSetbackMinAttributeSubscriptionState() + } + + class UnoccupiedSetbackMaxAttribute(val value: UByte?) sealed class UnoccupiedSetbackMaxAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : UnoccupiedSetbackMaxAttributeSubscriptionState() - + data class Success(val value: UByte?) : UnoccupiedSetbackMaxAttributeSubscriptionState() + data class Error(val exception: Exception) : UnoccupiedSetbackMaxAttributeSubscriptionState() - object SubscriptionEstablished : UnoccupiedSetbackMaxAttributeSubscriptionState() - } -class ACCoilTemperatureAttribute( - val value: Short? - ) + object SubscriptionEstablished : UnoccupiedSetbackMaxAttributeSubscriptionState() + } + + class ACCoilTemperatureAttribute(val value: Short?) sealed class ACCoilTemperatureAttributeSubscriptionState { - data class Success( - val value: Short? - ) : ACCoilTemperatureAttributeSubscriptionState() - + data class Success(val value: Short?) : ACCoilTemperatureAttributeSubscriptionState() + data class Error(val exception: Exception) : ACCoilTemperatureAttributeSubscriptionState() - object SubscriptionEstablished : ACCoilTemperatureAttributeSubscriptionState() - } -class PresetTypesAttribute( - val value: List? - ) + object SubscriptionEstablished : ACCoilTemperatureAttributeSubscriptionState() + } + + class PresetTypesAttribute(val value: List?) sealed class PresetTypesAttributeSubscriptionState { - data class Success( - val value: List? - ) : PresetTypesAttributeSubscriptionState() - + data class Success(val value: List?) : + PresetTypesAttributeSubscriptionState() + data class Error(val exception: Exception) : PresetTypesAttributeSubscriptionState() - object SubscriptionEstablished : PresetTypesAttributeSubscriptionState() - } -class ScheduleTypesAttribute( - val value: List? - ) + object SubscriptionEstablished : PresetTypesAttributeSubscriptionState() + } + + class ScheduleTypesAttribute(val value: List?) sealed class ScheduleTypesAttributeSubscriptionState { - data class Success( - val value: List? - ) : ScheduleTypesAttributeSubscriptionState() - + data class Success(val value: List?) : + ScheduleTypesAttributeSubscriptionState() + data class Error(val exception: Exception) : ScheduleTypesAttributeSubscriptionState() - object SubscriptionEstablished : ScheduleTypesAttributeSubscriptionState() - } -class NumberOfScheduleTransitionPerDayAttribute( - val value: UByte? - ) + object SubscriptionEstablished : ScheduleTypesAttributeSubscriptionState() + } + + class NumberOfScheduleTransitionPerDayAttribute(val value: UByte?) sealed class NumberOfScheduleTransitionPerDayAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() - - data class Error(val exception: Exception) : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() - - object SubscriptionEstablished : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() - } -class ActivePresetHandleAttribute( - val value: ByteArray? - ) + data class Success(val value: UByte?) : + NumberOfScheduleTransitionPerDayAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NumberOfScheduleTransitionPerDayAttributeSubscriptionState() + + object SubscriptionEstablished : NumberOfScheduleTransitionPerDayAttributeSubscriptionState() + } + + class ActivePresetHandleAttribute(val value: ByteArray?) sealed class ActivePresetHandleAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : ActivePresetHandleAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : ActivePresetHandleAttributeSubscriptionState() + data class Error(val exception: Exception) : ActivePresetHandleAttributeSubscriptionState() - object SubscriptionEstablished : ActivePresetHandleAttributeSubscriptionState() - } -class ActiveScheduleHandleAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : ActivePresetHandleAttributeSubscriptionState() + } + + class ActiveScheduleHandleAttribute(val value: ByteArray?) sealed class ActiveScheduleHandleAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : ActiveScheduleHandleAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : ActiveScheduleHandleAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveScheduleHandleAttributeSubscriptionState() - object SubscriptionEstablished : ActiveScheduleHandleAttributeSubscriptionState() - } -class PresetsAttribute( - val value: List? - ) + object SubscriptionEstablished : ActiveScheduleHandleAttributeSubscriptionState() + } + + class PresetsAttribute(val value: List?) sealed class PresetsAttributeSubscriptionState { - data class Success( - val value: List? - ) : PresetsAttributeSubscriptionState() - + data class Success(val value: List?) : + PresetsAttributeSubscriptionState() + data class Error(val exception: Exception) : PresetsAttributeSubscriptionState() - object SubscriptionEstablished : PresetsAttributeSubscriptionState() - } -class SchedulesAttribute( - val value: List? - ) + object SubscriptionEstablished : PresetsAttributeSubscriptionState() + } + + class SchedulesAttribute(val value: List?) sealed class SchedulesAttributeSubscriptionState { - data class Success( - val value: List? - ) : SchedulesAttributeSubscriptionState() - + data class Success(val value: List?) : + SchedulesAttributeSubscriptionState() + data class Error(val exception: Exception) : SchedulesAttributeSubscriptionState() - object SubscriptionEstablished : SchedulesAttributeSubscriptionState() - } -class SetpointHoldExpiryTimestampAttribute( - val value: UInt? - ) + object SubscriptionEstablished : SchedulesAttributeSubscriptionState() + } + + class SetpointHoldExpiryTimestampAttribute(val value: UInt?) sealed class SetpointHoldExpiryTimestampAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : SetpointHoldExpiryTimestampAttributeSubscriptionState() - - data class Error(val exception: Exception) : SetpointHoldExpiryTimestampAttributeSubscriptionState() - - object SubscriptionEstablished : SetpointHoldExpiryTimestampAttributeSubscriptionState() - } -class QueuedPresetAttribute( - val value: ThermostatClusterQueuedPresetStruct? - ) + data class Success(val value: UInt?) : SetpointHoldExpiryTimestampAttributeSubscriptionState() + + data class Error(val exception: Exception) : + SetpointHoldExpiryTimestampAttributeSubscriptionState() + + object SubscriptionEstablished : SetpointHoldExpiryTimestampAttributeSubscriptionState() + } + + class QueuedPresetAttribute(val value: ThermostatClusterQueuedPresetStruct?) sealed class QueuedPresetAttributeSubscriptionState { - data class Success( - val value: ThermostatClusterQueuedPresetStruct? - ) : QueuedPresetAttributeSubscriptionState() - + data class Success(val value: ThermostatClusterQueuedPresetStruct?) : + QueuedPresetAttributeSubscriptionState() + data class Error(val exception: Exception) : QueuedPresetAttributeSubscriptionState() - object SubscriptionEstablished : QueuedPresetAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : QueuedPresetAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setpointRaiseLower(mode: UByte - ,amount: Byte - ,timedInvokeTimeout: Duration? = null) { + suspend fun setpointRaiseLower(mode: UByte, amount: Byte, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -391,7 +314,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_MODE_REQ), mode) val TAG_AMOUNT_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_AMOUNT_REQ), amount) + tlvWriter.put(ContextSpecificTag(TAG_AMOUNT_REQ), amount) tlvWriter.endStructure() val request: InvokeRequest = @@ -405,18 +328,23 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setWeeklySchedule(numberOfTransitionsForSequence: UByte - ,dayOfWeekForSequence: UByte - ,modeForSequence: UByte - ,transitions: List - ,timedInvokeTimeout: Duration? = null) { + suspend fun setWeeklySchedule( + numberOfTransitionsForSequence: UByte, + dayOfWeekForSequence: UByte, + modeForSequence: UByte, + transitions: List, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE_REQ), numberOfTransitionsForSequence) + tlvWriter.put( + ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE_REQ), + numberOfTransitionsForSequence + ) val TAG_DAY_OF_WEEK_FOR_SEQUENCE_REQ: Int = 1 tlvWriter.put(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE_REQ), dayOfWeekForSequence) @@ -426,10 +354,10 @@ class AttributeListAttribute( val TAG_TRANSITIONS_REQ: Int = 3 tlvWriter.startArray(ContextSpecificTag(TAG_TRANSITIONS_REQ)) - for (item in transitions.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in transitions.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -443,9 +371,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun getWeeklySchedule(daysToReturn: UByte - ,modeToReturn: UByte - ,timedInvokeTimeout: Duration? = null): GetWeeklyScheduleResponse { + suspend fun getWeeklySchedule( + daysToReturn: UByte, + modeToReturn: UByte, + timedInvokeTimeout: Duration? = null + ): GetWeeklyScheduleResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -455,7 +385,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_DAYS_TO_RETURN_REQ), daysToReturn) val TAG_MODE_TO_RETURN_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_MODE_TO_RETURN_REQ), modeToReturn) + tlvWriter.put(ContextSpecificTag(TAG_MODE_TO_RETURN_REQ), modeToReturn) tlvWriter.endStructure() val request: InvokeRequest = @@ -472,62 +402,60 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE: Int = 0 var numberOfTransitionsForSequence_decoded: UByte? = null - + val TAG_DAY_OF_WEEK_FOR_SEQUENCE: Int = 1 var dayOfWeekForSequence_decoded: UByte? = null - + val TAG_MODE_FOR_SEQUENCE: Int = 2 var modeForSequence_decoded: UByte? = null - + val TAG_TRANSITIONS: Int = 3 var transitions_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE)) {numberOfTransitionsForSequence_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) {dayOfWeekForSequence_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_MODE_FOR_SEQUENCE)) {modeForSequence_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_TRANSITIONS)) {transitions_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterWeeklyScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }} - - - else { + if (tag == ContextSpecificTag(TAG_NUMBER_OF_TRANSITIONS_FOR_SEQUENCE)) { + numberOfTransitionsForSequence_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) { + dayOfWeekForSequence_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_MODE_FOR_SEQUENCE)) { + modeForSequence_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_TRANSITIONS)) { + transitions_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterWeeklyScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - if (numberOfTransitionsForSequence_decoded == null) { - throw IllegalStateException("numberOfTransitionsForSequence not found in TLV") + throw IllegalStateException("numberOfTransitionsForSequence not found in TLV") } - - + if (dayOfWeekForSequence_decoded == null) { - throw IllegalStateException("dayOfWeekForSequence not found in TLV") + throw IllegalStateException("dayOfWeekForSequence not found in TLV") } - - + if (modeForSequence_decoded == null) { - throw IllegalStateException("modeForSequence not found in TLV") + throw IllegalStateException("modeForSequence not found in TLV") } - - + if (transitions_decoded == null) { - throw IllegalStateException("transitions not found in TLV") + throw IllegalStateException("transitions not found in TLV") } - tlvReader.exitContainer() @@ -543,7 +471,7 @@ class AttributeListAttribute( val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -557,15 +485,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setActiveScheduleRequest(scheduleHandle: ByteArray - ,timedInvokeTimeout: Duration? = null) { + suspend fun setActiveScheduleRequest( + scheduleHandle: ByteArray, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SCHEDULE_HANDLE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_SCHEDULE_HANDLE_REQ), scheduleHandle) + tlvWriter.put(ContextSpecificTag(TAG_SCHEDULE_HANDLE_REQ), scheduleHandle) tlvWriter.endStructure() val request: InvokeRequest = @@ -579,9 +509,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setActivePresetRequest(presetHandle: ByteArray - ,delayMinutes: UShort? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setActivePresetRequest( + presetHandle: ByteArray, + delayMinutes: UShort?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -591,9 +523,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_PRESET_HANDLE_REQ), presetHandle) val TAG_DELAY_MINUTES_REQ: Int = 1 - delayMinutes?.let { - tlvWriter.put(ContextSpecificTag(TAG_DELAY_MINUTES_REQ), delayMinutes) - } + delayMinutes?.let { tlvWriter.put(ContextSpecificTag(TAG_DELAY_MINUTES_REQ), delayMinutes) } tlvWriter.endStructure() val request: InvokeRequest = @@ -607,15 +537,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun startPresetsSchedulesEditRequest(timeoutSeconds: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun startPresetsSchedulesEditRequest( + timeoutSeconds: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 7u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TIMEOUT_SECONDS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TIMEOUT_SECONDS_REQ), timeoutSeconds) + tlvWriter.put(ContextSpecificTag(TAG_TIMEOUT_SECONDS_REQ), timeoutSeconds) tlvWriter.endStructure() val request: InvokeRequest = @@ -633,7 +565,7 @@ class AttributeListAttribute( val commandId: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -651,7 +583,7 @@ class AttributeListAttribute( val commandId: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -669,7 +601,7 @@ class AttributeListAttribute( val commandId: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -683,15 +615,20 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTemperatureSetpointHoldPolicy(temperatureSetpointHoldPolicy: UByte - ,timedInvokeTimeout: Duration? = null) { + suspend fun setTemperatureSetpointHoldPolicy( + temperatureSetpointHoldPolicy: UByte, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TEMPERATURE_SETPOINT_HOLD_POLICY_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TEMPERATURE_SETPOINT_HOLD_POLICY_REQ), temperatureSetpointHoldPolicy) + tlvWriter.put( + ContextSpecificTag(TAG_TEMPERATURE_SETPOINT_HOLD_POLICY_REQ), + temperatureSetpointHoldPolicy + ) tlvWriter.endStructure() val request: InvokeRequest = @@ -704,46 +641,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readLocalTemperatureAttribute(): LocalTemperatureAttribute {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLocalTemperatureAttribute(): LocalTemperatureAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtemperature attribute not found in response" - } + } + + requireNotNull(attributeData) { "Localtemperature attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LocalTemperatureAttribute(decodedValue) } @@ -753,100 +684,96 @@ suspend fun readLocalTemperatureAttribute(): LocalTemperatureAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LocalTemperatureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LocalTemperatureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtemperature attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Localtemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LocalTemperatureAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LocalTemperatureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LocalTemperatureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOutdoorTemperatureAttribute(): OutdoorTemperatureAttribute {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOutdoorTemperatureAttribute(): OutdoorTemperatureAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outdoortemperature attribute not found in response" - } + } + + requireNotNull(attributeData) { "Outdoortemperature attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OutdoorTemperatureAttribute(decodedValue) } @@ -856,99 +783,95 @@ suspend fun readOutdoorTemperatureAttribute(): OutdoorTemperatureAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OutdoorTemperatureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OutdoorTemperatureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Outdoortemperature attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Outdoortemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OutdoorTemperatureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OutdoorTemperatureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OutdoorTemperatureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupancyAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupancyAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupancy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -958,94 +881,88 @@ suspend fun readOccupancyAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupancy attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Occupancy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAbsMinHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absminheatsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absminheatsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1055,94 +972,90 @@ suspend fun readAbsMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absminheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Absminheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAbsMaxHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxheatsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absmaxheatsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1152,94 +1065,90 @@ suspend fun readAbsMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Absmaxheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAbsMinCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmincoolsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absmincoolsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1249,94 +1158,90 @@ suspend fun readAbsMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmincoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Absmincoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAbsMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAbsMaxCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxcoolsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Absmaxcoolsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1346,94 +1251,90 @@ suspend fun readAbsMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Absmaxcoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Absmaxcoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPICoolingDemandAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPICoolingDemandAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Picoolingdemand attribute not found in response" - } + } + + requireNotNull(attributeData) { "Picoolingdemand attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1443,94 +1344,90 @@ suspend fun readPICoolingDemandAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Picoolingdemand attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Picoolingdemand attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPIHeatingDemandAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPIHeatingDemandAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Piheatingdemand attribute not found in response" - } + } + + requireNotNull(attributeData) { "Piheatingdemand attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1540,118 +1437,113 @@ suspend fun readPIHeatingDemandAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Piheatingdemand attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Piheatingdemand attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readHVACSystemTypeConfigurationAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readHVACSystemTypeConfigurationAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hvacsystemtypeconfiguration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hvacsystemtypeconfiguration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeHVACSystemTypeConfigurationAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1673,7 +1565,7 @@ suspend fun readHVACSystemTypeConfigurationAttribute(): UByte? {val ATTRIBUTE_ID throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeHVACSystemTypeConfigurationAttribute( @@ -1681,118 +1573,113 @@ suspend fun readHVACSystemTypeConfigurationAttribute(): UByte? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hvacsystemtypeconfiguration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Hvacsystemtypeconfiguration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocalTemperatureCalibrationAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLocalTemperatureCalibrationAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtemperaturecalibration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Localtemperaturecalibration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeLocalTemperatureCalibrationAttribute( value: Byte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1814,7 +1701,7 @@ suspend fun readLocalTemperatureCalibrationAttribute(): Byte? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLocalTemperatureCalibrationAttribute( @@ -1822,118 +1709,113 @@ suspend fun readLocalTemperatureCalibrationAttribute(): Byte? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtemperaturecalibration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Localtemperaturecalibration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupiedCoolingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedcoolingsetpoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupiedcoolingsetpoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeOccupiedCoolingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1955,7 +1837,7 @@ suspend fun readOccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOccupiedCoolingSetpointAttribute( @@ -1963,118 +1845,113 @@ suspend fun readOccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedcoolingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupiedcoolingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupiedHeatingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedheatingsetpoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupiedheatingsetpoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeOccupiedHeatingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2096,7 +1973,7 @@ suspend fun readOccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOccupiedHeatingSetpointAttribute( @@ -2104,118 +1981,113 @@ suspend fun readOccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedheatingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupiedheatingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnoccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnoccupiedCoolingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedcoolingsetpoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unoccupiedcoolingsetpoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUnoccupiedCoolingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 19u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2237,7 +2109,7 @@ suspend fun readUnoccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnoccupiedCoolingSetpointAttribute( @@ -2245,118 +2117,113 @@ suspend fun readUnoccupiedCoolingSetpointAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedcoolingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Unoccupiedcoolingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnoccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnoccupiedHeatingSetpointAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedheatingsetpoint attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unoccupiedheatingsetpoint attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeUnoccupiedHeatingSetpointAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2378,7 +2245,7 @@ suspend fun readUnoccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnoccupiedHeatingSetpointAttribute( @@ -2386,118 +2253,113 @@ suspend fun readUnoccupiedHeatingSetpointAttribute(): Short? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedheatingsetpoint attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Unoccupiedheatingsetpoint attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minheatsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minheatsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeMinHeatSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2519,7 +2381,7 @@ suspend fun readMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinHeatSetpointLimitAttribute( @@ -2527,118 +2389,113 @@ suspend fun readMinHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxHeatSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxheatsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxheatsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeMaxHeatSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 22u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2660,7 +2517,7 @@ suspend fun readMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMaxHeatSetpointLimitAttribute( @@ -2668,118 +2525,113 @@ suspend fun readMaxHeatSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxheatsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxheatsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mincoolsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mincoolsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeMinCoolSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2801,7 +2653,7 @@ suspend fun readMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinCoolSetpointLimitAttribute( @@ -2809,118 +2661,113 @@ suspend fun readMinCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mincoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Mincoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt = 24u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMaxCoolSetpointLimitAttribute(): Short? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcoolsetpointlimit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxcoolsetpointlimit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeMaxCoolSetpointLimitAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 24u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2942,7 +2789,7 @@ suspend fun readMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMaxCoolSetpointLimitAttribute( @@ -2950,118 +2797,110 @@ suspend fun readMaxCoolSetpointLimitAttribute(): Short? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxcoolsetpointlimit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxcoolsetpointlimit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } + val decodedValue: Short? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinSetpointDeadBandAttribute(): Byte? {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMinSetpointDeadBandAttribute(): Byte? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minsetpointdeadband attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minsetpointdeadband attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } - + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeMinSetpointDeadBandAttribute( - value: Byte, - timedWriteTimeout: Duration? = null) { + suspend fun writeMinSetpointDeadBandAttribute(value: Byte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 25u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3083,7 +2922,7 @@ suspend fun readMinSetpointDeadBandAttribute(): Byte? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeMinSetpointDeadBandAttribute( @@ -3091,118 +2930,110 @@ suspend fun readMinSetpointDeadBandAttribute(): Byte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minsetpointdeadband attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minsetpointdeadband attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByte(AnonymousTag) - } else { - null - } + val decodedValue: Byte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRemoteSensingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRemoteSensingAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remotesensing attribute not found in response" - } + } + + requireNotNull(attributeData) { "Remotesensing attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeRemoteSensingAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeRemoteSensingAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 26u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3224,7 +3055,7 @@ suspend fun readRemoteSensingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRemoteSensingAttribute( @@ -3232,114 +3063,106 @@ suspend fun readRemoteSensingAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 26u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remotesensing attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Remotesensing attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readControlSequenceOfOperationAttribute(): UByte {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readControlSequenceOfOperationAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Controlsequenceofoperation attribute not found in response" - } + } + + requireNotNull(attributeData) { "Controlsequenceofoperation attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } suspend fun writeControlSequenceOfOperationAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 27u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3361,7 +3184,7 @@ suspend fun readControlSequenceOfOperationAttribute(): UByte {val ATTRIBUTE_ID: throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeControlSequenceOfOperationAttribute( @@ -3369,34 +3192,38 @@ suspend fun readControlSequenceOfOperationAttribute(): UByte {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Controlsequenceofoperation attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Controlsequenceofoperation attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3409,67 +3236,56 @@ suspend fun readControlSequenceOfOperationAttribute(): UByte {val ATTRIBUTE_ID: emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSystemModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 28u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSystemModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Systemmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Systemmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeSystemModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeSystemModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 28u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3491,7 +3307,7 @@ suspend fun readSystemModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 28u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSystemModeAttribute( @@ -3499,35 +3315,37 @@ suspend fun readSystemModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 28u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Systemmode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Systemmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3539,47 +3357,41 @@ suspend fun readSystemModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 28u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readThermostatRunningModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 30u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readThermostatRunningModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatrunningmode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Thermostatrunningmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3589,94 +3401,90 @@ suspend fun readThermostatRunningModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatrunningmode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Thermostatrunningmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStartOfWeekAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 32u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStartOfWeekAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startofweek attribute not found in response" - } + } + + requireNotNull(attributeData) { "Startofweek attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3686,94 +3494,88 @@ suspend fun readStartOfWeekAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Startofweek attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Startofweek attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfWeeklyTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfWeeklyTransitionsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofweeklytransitions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofweeklytransitions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3783,94 +3585,90 @@ suspend fun readNumberOfWeeklyTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofweeklytransitions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofweeklytransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfDailyTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 34u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfDailyTransitionsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofdailytransitions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofdailytransitions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -3880,118 +3678,113 @@ suspend fun readNumberOfDailyTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofdailytransitions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofdailytransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTemperatureSetpointHoldAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 35u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTemperatureSetpointHoldAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointhold attribute not found in response" - } + } + + requireNotNull(attributeData) { "Temperaturesetpointhold attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeTemperatureSetpointHoldAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 35u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4013,7 +3806,7 @@ suspend fun readTemperatureSetpointHoldAttribute(): UByte? {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureSetpointHoldAttribute( @@ -4021,123 +3814,121 @@ suspend fun readTemperatureSetpointHoldAttribute(): UByte? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointhold attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperaturesetpointhold attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTemperatureSetpointHoldDurationAttribute(): TemperatureSetpointHoldDurationAttribute {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTemperatureSetpointHoldDurationAttribute(): + TemperatureSetpointHoldDurationAttribute { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointholdduration attribute not found in response" + } + + requireNotNull(attributeData) { + "Temperaturesetpointholdduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return TemperatureSetpointHoldDurationAttribute(decodedValue) } suspend fun writeTemperatureSetpointHoldDurationAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 36u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4159,7 +3950,7 @@ suspend fun readTemperatureSetpointHoldDurationAttribute(): TemperatureSetpointH throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureSetpointHoldDurationAttribute( @@ -4167,123 +3958,122 @@ suspend fun readTemperatureSetpointHoldDurationAttribute(): TemperatureSetpointH maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TemperatureSetpointHoldDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TemperatureSetpointHoldDurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointholdduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperaturesetpointholdduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(TemperatureSetpointHoldDurationAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(TemperatureSetpointHoldDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readThermostatProgrammingOperationModeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readThermostatProgrammingOperationModeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatprogrammingoperationmode attribute not found in response" + } + + requireNotNull(attributeData) { + "Thermostatprogrammingoperationmode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeThermostatProgrammingOperationModeAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 37u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4305,7 +4095,7 @@ suspend fun readThermostatProgrammingOperationModeAttribute(): UByte? {val ATTRI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeThermostatProgrammingOperationModeAttribute( @@ -4313,94 +4103,90 @@ suspend fun readThermostatProgrammingOperationModeAttribute(): UByte? {val ATTRI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatprogrammingoperationmode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Thermostatprogrammingoperationmode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readThermostatRunningStateAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 41u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readThermostatRunningStateAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatrunningstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Thermostatrunningstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -4410,94 +4196,90 @@ suspend fun readThermostatRunningStateAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Thermostatrunningstate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Thermostatrunningstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSetpointChangeSourceAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSetpointChangeSourceAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangesource attribute not found in response" - } + } + + requireNotNull(attributeData) { "Setpointchangesource attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -4507,99 +4289,95 @@ suspend fun readSetpointChangeSourceAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangesource attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Setpointchangesource attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSetpointChangeAmountAttribute(): SetpointChangeAmountAttribute {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSetpointChangeAmountAttribute(): SetpointChangeAmountAttribute { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangeamount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Setpointchangeamount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SetpointChangeAmountAttribute(decodedValue) } @@ -4609,99 +4387,97 @@ suspend fun readSetpointChangeAmountAttribute(): SetpointChangeAmountAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SetpointChangeAmountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SetpointChangeAmountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangeamount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Setpointchangeamount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SetpointChangeAmountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SetpointChangeAmountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SetpointChangeAmountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSetpointChangeSourceTimestampAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSetpointChangeSourceTimestampAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangesourcetimestamp attribute not found in response" + } + + requireNotNull(attributeData) { + "Setpointchangesourcetimestamp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4711,123 +4487,115 @@ suspend fun readSetpointChangeSourceTimestampAttribute(): UInt? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointchangesourcetimestamp attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Setpointchangesourcetimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute {val ATTRIBUTE_ID: UInt = 52u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetback attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupiedsetback attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OccupiedSetbackAttribute(decodedValue) } - suspend fun writeOccupiedSetbackAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeOccupiedSetbackAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 52u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4849,7 +4617,7 @@ suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOccupiedSetbackAttribute( @@ -4857,104 +4625,100 @@ suspend fun readOccupiedSetbackAttribute(): OccupiedSetbackAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OccupiedSetbackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OccupiedSetbackAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetback attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupiedsetback attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OccupiedSetbackAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OccupiedSetbackAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OccupiedSetbackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupiedSetbackMinAttribute(): OccupiedSetbackMinAttribute {val ATTRIBUTE_ID: UInt = 53u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupiedSetbackMinAttribute(): OccupiedSetbackMinAttribute { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetbackmin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupiedsetbackmin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OccupiedSetbackMinAttribute(decodedValue) } @@ -4964,104 +4728,100 @@ suspend fun readOccupiedSetbackMinAttribute(): OccupiedSetbackMinAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OccupiedSetbackMinAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OccupiedSetbackMinAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetbackmin attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupiedsetbackmin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OccupiedSetbackMinAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OccupiedSetbackMinAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OccupiedSetbackMinAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOccupiedSetbackMaxAttribute(): OccupiedSetbackMaxAttribute {val ATTRIBUTE_ID: UInt = 54u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOccupiedSetbackMaxAttribute(): OccupiedSetbackMaxAttribute { + val ATTRIBUTE_ID: UInt = 54u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetbackmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Occupiedsetbackmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OccupiedSetbackMaxAttribute(decodedValue) } @@ -5071,128 +4831,120 @@ suspend fun readOccupiedSetbackMaxAttribute(): OccupiedSetbackMaxAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 54u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OccupiedSetbackMaxAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OccupiedSetbackMaxAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Occupiedsetbackmax attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Occupiedsetbackmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OccupiedSetbackMaxAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OccupiedSetbackMaxAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OccupiedSetbackMaxAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute {val ATTRIBUTE_ID: UInt = 55u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute { + val ATTRIBUTE_ID: UInt = 55u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetback attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unoccupiedsetback attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return UnoccupiedSetbackAttribute(decodedValue) } - suspend fun writeUnoccupiedSetbackAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeUnoccupiedSetbackAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 55u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5214,7 +4966,7 @@ suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute {val AT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnoccupiedSetbackAttribute( @@ -5222,104 +4974,100 @@ suspend fun readUnoccupiedSetbackAttribute(): UnoccupiedSetbackAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 55u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UnoccupiedSetbackAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UnoccupiedSetbackAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetback attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Unoccupiedsetback attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(UnoccupiedSetbackAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(UnoccupiedSetbackAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UnoccupiedSetbackAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnoccupiedSetbackMinAttribute(): UnoccupiedSetbackMinAttribute {val ATTRIBUTE_ID: UInt = 56u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnoccupiedSetbackMinAttribute(): UnoccupiedSetbackMinAttribute { + val ATTRIBUTE_ID: UInt = 56u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetbackmin attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unoccupiedsetbackmin attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return UnoccupiedSetbackMinAttribute(decodedValue) } @@ -5329,104 +5077,100 @@ suspend fun readUnoccupiedSetbackMinAttribute(): UnoccupiedSetbackMinAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 56u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UnoccupiedSetbackMinAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UnoccupiedSetbackMinAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetbackmin attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Unoccupiedsetbackmin attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(UnoccupiedSetbackMinAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(UnoccupiedSetbackMinAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UnoccupiedSetbackMinAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnoccupiedSetbackMaxAttribute(): UnoccupiedSetbackMaxAttribute {val ATTRIBUTE_ID: UInt = 57u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnoccupiedSetbackMaxAttribute(): UnoccupiedSetbackMaxAttribute { + val ATTRIBUTE_ID: UInt = 57u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetbackmax attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unoccupiedsetbackmax attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return UnoccupiedSetbackMaxAttribute(decodedValue) } @@ -5436,123 +5180,115 @@ suspend fun readUnoccupiedSetbackMaxAttribute(): UnoccupiedSetbackMaxAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 57u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UnoccupiedSetbackMaxAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UnoccupiedSetbackMaxAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unoccupiedsetbackmax attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Unoccupiedsetbackmax attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(UnoccupiedSetbackMaxAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(UnoccupiedSetbackMaxAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UnoccupiedSetbackMaxAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEmergencyHeatDeltaAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 58u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEmergencyHeatDeltaAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 58u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Emergencyheatdelta attribute not found in response" - } + } + + requireNotNull(attributeData) { "Emergencyheatdelta attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeEmergencyHeatDeltaAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeEmergencyHeatDeltaAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 58u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5574,7 +5310,7 @@ suspend fun readEmergencyHeatDeltaAttribute(): UByte? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEmergencyHeatDeltaAttribute( @@ -5582,118 +5318,110 @@ suspend fun readEmergencyHeatDeltaAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 58u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Emergencyheatdelta attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Emergencyheatdelta attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 64u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 64u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Actype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACTypeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeACTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 64u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5715,7 +5443,7 @@ suspend fun readACTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 64u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACTypeAttribute( @@ -5723,118 +5451,108 @@ suspend fun readACTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 64u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 64u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Actype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Actype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACCapacityAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 65u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACCapacityAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 65u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accapacity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accapacity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACCapacityAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeACCapacityAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 65u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5856,7 +5574,7 @@ suspend fun readACCapacityAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 65u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACCapacityAttribute( @@ -5864,118 +5582,108 @@ suspend fun readACCapacityAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 65u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accapacity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Accapacity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACRefrigerantTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 66u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACRefrigerantTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 66u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acrefrigeranttype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acrefrigeranttype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACRefrigerantTypeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeACRefrigerantTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 66u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5997,7 +5705,7 @@ suspend fun readACRefrigerantTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACRefrigerantTypeAttribute( @@ -6005,118 +5713,110 @@ suspend fun readACRefrigerantTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 6 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 66u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acrefrigeranttype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acrefrigeranttype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACCompressorTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 67u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACCompressorTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 67u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accompressortype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accompressortype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACCompressorTypeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeACCompressorTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 67u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6138,7 +5838,7 @@ suspend fun readACCompressorTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 67 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACCompressorTypeAttribute( @@ -6146,118 +5846,110 @@ suspend fun readACCompressorTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 67 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 67u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accompressortype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accompressortype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACErrorCodeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 68u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACErrorCodeAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 68u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acerrorcode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acerrorcode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACErrorCodeAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeACErrorCodeAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 68u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6279,7 +5971,7 @@ suspend fun readACErrorCodeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 68u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACErrorCodeAttribute( @@ -6287,118 +5979,108 @@ suspend fun readACErrorCodeAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 68u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 68u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acerrorcode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Acerrorcode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACLouverPositionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 69u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACLouverPositionAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 69u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aclouverposition attribute not found in response" - } + } + + requireNotNull(attributeData) { "Aclouverposition attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACLouverPositionAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeACLouverPositionAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 69u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6420,7 +6102,7 @@ suspend fun readACLouverPositionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 69 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACLouverPositionAttribute( @@ -6428,99 +6110,95 @@ suspend fun readACLouverPositionAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 69 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 69u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Aclouverposition attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Aclouverposition attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACCoilTemperatureAttribute(): ACCoilTemperatureAttribute {val ATTRIBUTE_ID: UInt = 70u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACCoilTemperatureAttribute(): ACCoilTemperatureAttribute { + val ATTRIBUTE_ID: UInt = 70u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accoiltemperature attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accoiltemperature attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ACCoilTemperatureAttribute(decodedValue) } @@ -6530,123 +6208,115 @@ suspend fun readACCoilTemperatureAttribute(): ACCoilTemperatureAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 70u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ACCoilTemperatureAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ACCoilTemperatureAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accoiltemperature attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accoiltemperature attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ACCoilTemperatureAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ACCoilTemperatureAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ACCoilTemperatureAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readACCapacityformatAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 71u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readACCapacityformatAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 71u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accapacityformat attribute not found in response" - } + } + + requireNotNull(attributeData) { "Accapacityformat attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeACCapacityformatAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeACCapacityformatAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 71u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6668,7 +6338,7 @@ suspend fun readACCapacityformatAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 71 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeACCapacityformatAttribute( @@ -6676,100 +6346,96 @@ suspend fun readACCapacityformatAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 71 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 71u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Accapacityformat attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Accapacityformat attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPresetTypesAttribute(): PresetTypesAttribute {val ATTRIBUTE_ID: UInt = 72u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPresetTypesAttribute(): PresetTypesAttribute { + val ATTRIBUTE_ID: UInt = 72u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presettypes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Presettypes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return PresetTypesAttribute(decodedValue) } @@ -6779,106 +6445,100 @@ suspend fun readPresetTypesAttribute(): PresetTypesAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 72u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PresetTypesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PresetTypesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presettypes attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Presettypes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(PresetTypesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(PresetTypesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PresetTypesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScheduleTypesAttribute(): ScheduleTypesAttribute {val ATTRIBUTE_ID: UInt = 73u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readScheduleTypesAttribute(): ScheduleTypesAttribute { + val ATTRIBUTE_ID: UInt = 73u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduletypes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Scheduletypes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return ScheduleTypesAttribute(decodedValue) } @@ -6888,100 +6548,94 @@ suspend fun readScheduleTypesAttribute(): ScheduleTypesAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 73u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ScheduleTypesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ScheduleTypesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduletypes attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Scheduletypes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(ScheduleTypesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTypeStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(ScheduleTypesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ScheduleTypesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfPresetsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 74u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfPresetsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 74u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpresets attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofpresets attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -6991,94 +6645,90 @@ suspend fun readNumberOfPresetsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 74u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 74u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofpresets attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofpresets attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfSchedulesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 75u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfSchedulesAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 75u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofschedules attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofschedules attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -7088,94 +6738,90 @@ suspend fun readNumberOfSchedulesAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 7 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 75u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofschedules attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofschedules attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfScheduleTransitionsAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 76u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfScheduleTransitionsAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 76u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofscheduletransitions attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofscheduletransitions attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -7185,99 +6831,98 @@ suspend fun readNumberOfScheduleTransitionsAttribute(): UByte? {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 76u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofscheduletransitions attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofscheduletransitions attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfScheduleTransitionPerDayAttribute(): NumberOfScheduleTransitionPerDayAttribute {val ATTRIBUTE_ID: UInt = 77u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfScheduleTransitionPerDayAttribute(): + NumberOfScheduleTransitionPerDayAttribute { + val ATTRIBUTE_ID: UInt = 77u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofscheduletransitionperday attribute not found in response" + } + + requireNotNull(attributeData) { + "Numberofscheduletransitionperday attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return NumberOfScheduleTransitionPerDayAttribute(decodedValue) } @@ -7287,104 +6932,102 @@ suspend fun readNumberOfScheduleTransitionPerDayAttribute(): NumberOfScheduleTra maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 77u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NumberOfScheduleTransitionPerDayAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NumberOfScheduleTransitionPerDayAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofscheduletransitionperday attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofscheduletransitionperday attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NumberOfScheduleTransitionPerDayAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(NumberOfScheduleTransitionPerDayAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActivePresetHandleAttribute(): ActivePresetHandleAttribute {val ATTRIBUTE_ID: UInt = 78u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActivePresetHandleAttribute(): ActivePresetHandleAttribute { + val ATTRIBUTE_ID: UInt = 78u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepresethandle attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activepresethandle attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActivePresetHandleAttribute(decodedValue) } @@ -7394,104 +7037,100 @@ suspend fun readActivePresetHandleAttribute(): ActivePresetHandleAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 78u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActivePresetHandleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActivePresetHandleAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activepresethandle attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activepresethandle attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActivePresetHandleAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActivePresetHandleAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActivePresetHandleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveScheduleHandleAttribute(): ActiveScheduleHandleAttribute {val ATTRIBUTE_ID: UInt = 79u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveScheduleHandleAttribute(): ActiveScheduleHandleAttribute { + val ATTRIBUTE_ID: UInt = 79u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeschedulehandle attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activeschedulehandle attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActiveScheduleHandleAttribute(decodedValue) } @@ -7501,133 +7140,128 @@ suspend fun readActiveScheduleHandleAttribute(): ActiveScheduleHandleAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 79u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveScheduleHandleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveScheduleHandleAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activeschedulehandle attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activeschedulehandle attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActiveScheduleHandleAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActiveScheduleHandleAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveScheduleHandleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPresetsAttribute(): PresetsAttribute {val ATTRIBUTE_ID: UInt = 80u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPresetsAttribute(): PresetsAttribute { + val ATTRIBUTE_ID: UInt = 80u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presets attribute not found in response" - } + } + + requireNotNull(attributeData) { "Presets attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return PresetsAttribute(decodedValue) } suspend fun writePresetsAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 80u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7649,7 +7283,7 @@ suspend fun readPresetsAttribute(): PresetsAttribute {val ATTRIBUTE_ID: UInt = 8 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribePresetsAttribute( @@ -7657,134 +7291,127 @@ suspend fun readPresetsAttribute(): PresetsAttribute {val ATTRIBUTE_ID: UInt = 8 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 80u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PresetsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PresetsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presets attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Presets attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(PresetsAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterPresetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(PresetsAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PresetsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSchedulesAttribute(): SchedulesAttribute {val ATTRIBUTE_ID: UInt = 81u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSchedulesAttribute(): SchedulesAttribute { + val ATTRIBUTE_ID: UInt = 81u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Schedules attribute not found in response" - } + } + + requireNotNull(attributeData) { "Schedules attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SchedulesAttribute(decodedValue) } suspend fun writeSchedulesAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 81u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7806,7 +7433,7 @@ suspend fun readSchedulesAttribute(): SchedulesAttribute {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeSchedulesAttribute( @@ -7814,100 +7441,94 @@ suspend fun readSchedulesAttribute(): SchedulesAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 81u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SchedulesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SchedulesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Schedules attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Schedules attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SchedulesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SchedulesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SchedulesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPresetsSchedulesEditableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 82u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPresetsSchedulesEditableAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 82u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presetsscheduleseditable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Presetsscheduleseditable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -7917,94 +7538,92 @@ suspend fun readPresetsSchedulesEditableAttribute(): Boolean? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 82u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Presetsscheduleseditable attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Presetsscheduleseditable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTemperatureSetpointHoldPolicyAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 83u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTemperatureSetpointHoldPolicyAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 83u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointholdpolicy attribute not found in response" + } + + requireNotNull(attributeData) { + "Temperaturesetpointholdpolicy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -8014,99 +7633,95 @@ suspend fun readTemperatureSetpointHoldPolicyAttribute(): UByte? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 83u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturesetpointholdpolicy attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperaturesetpointholdpolicy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSetpointHoldExpiryTimestampAttribute(): SetpointHoldExpiryTimestampAttribute {val ATTRIBUTE_ID: UInt = 84u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSetpointHoldExpiryTimestampAttribute(): SetpointHoldExpiryTimestampAttribute { + val ATTRIBUTE_ID: UInt = 84u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointholdexpirytimestamp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Setpointholdexpirytimestamp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return SetpointHoldExpiryTimestampAttribute(decodedValue) } @@ -8116,104 +7731,102 @@ suspend fun readSetpointHoldExpiryTimestampAttribute(): SetpointHoldExpiryTimest maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 84u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SetpointHoldExpiryTimestampAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SetpointHoldExpiryTimestampAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Setpointholdexpirytimestamp attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Setpointholdexpirytimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(SetpointHoldExpiryTimestampAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(SetpointHoldExpiryTimestampAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readQueuedPresetAttribute(): QueuedPresetAttribute {val ATTRIBUTE_ID: UInt = 85u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readQueuedPresetAttribute(): QueuedPresetAttribute { + val ATTRIBUTE_ID: UInt = 85u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Queuedpreset attribute not found in response" - } + } + + requireNotNull(attributeData) { "Queuedpreset attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThermostatClusterQueuedPresetStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ThermostatClusterQueuedPresetStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return QueuedPresetAttribute(decodedValue) } @@ -8223,101 +7836,95 @@ suspend fun readQueuedPresetAttribute(): QueuedPresetAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 85u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(QueuedPresetAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + QueuedPresetAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Queuedpreset attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Queuedpreset attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThermostatClusterQueuedPresetStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(QueuedPresetAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ThermostatClusterQueuedPresetStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + ThermostatClusterQueuedPresetStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(QueuedPresetAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(QueuedPresetAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -8327,45 +7934,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -8373,49 +7985,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -8425,45 +8031,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -8471,49 +8082,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -8523,45 +8128,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -8569,49 +8177,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -8621,45 +8223,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -8667,44 +8272,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -8713,35 +8311,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -8753,44 +8353,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -8799,34 +8392,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8839,7 +8436,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt index f766146a4a3b89..1f5a0777fcb41f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThermostatUserInterfaceConfigurationCluster.kt @@ -17,159 +17,122 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThermostatUserInterfaceConfigurationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class ThermostatUserInterfaceConfigurationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readTemperatureDisplayModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readTemperatureDisplayModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturedisplaymode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Temperaturedisplaymode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } suspend fun writeTemperatureDisplayModeAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -191,7 +154,7 @@ suspend fun readTemperatureDisplayModeAttribute(): UByte {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureDisplayModeAttribute( @@ -199,34 +162,38 @@ suspend fun readTemperatureDisplayModeAttribute(): UByte {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperaturedisplaymode attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperaturedisplaymode attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -239,67 +206,56 @@ suspend fun readTemperatureDisplayModeAttribute(): UByte {val ATTRIBUTE_ID: UInt emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readKeypadLockoutAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readKeypadLockoutAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Keypadlockout attribute not found in response" - } + } + + requireNotNull(attributeData) { "Keypadlockout attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeKeypadLockoutAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeKeypadLockoutAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -321,7 +277,7 @@ suspend fun readKeypadLockoutAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeKeypadLockoutAttribute( @@ -329,35 +285,37 @@ suspend fun readKeypadLockoutAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Keypadlockout attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Keypadlockout attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -369,71 +327,66 @@ suspend fun readKeypadLockoutAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readScheduleProgrammingVisibilityAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readScheduleProgrammingVisibilityAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduleprogrammingvisibility attribute not found in response" + } + + requireNotNull(attributeData) { + "Scheduleprogrammingvisibility attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } suspend fun writeScheduleProgrammingVisibilityAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -455,7 +408,7 @@ suspend fun readScheduleProgrammingVisibilityAttribute(): UByte? {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeScheduleProgrammingVisibilityAttribute( @@ -463,96 +416,92 @@ suspend fun readScheduleProgrammingVisibilityAttribute(): UByte? {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Scheduleprogrammingvisibility attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Scheduleprogrammingvisibility attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -562,45 +511,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -608,49 +562,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -660,45 +608,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -706,49 +659,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -758,45 +705,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -804,49 +754,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -856,45 +800,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -902,44 +849,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -948,35 +888,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -988,44 +930,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1034,34 +969,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1074,11 +1013,12 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(ThermostatUserInterfaceConfigurationCluster::class.java.name) + private val logger = + Logger.getLogger(ThermostatUserInterfaceConfigurationCluster::class.java.name) const val CLUSTER_ID: UInt = 516u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt index 865e7b62d0545d..d4949cb4df2bf6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ThreadNetworkDiagnosticsCluster.kt @@ -17,366 +17,286 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class ChannelAttribute( - val value: UShort? - ) +class ThreadNetworkDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class ChannelAttribute(val value: UShort?) sealed class ChannelAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : ChannelAttributeSubscriptionState() - + data class Success(val value: UShort?) : ChannelAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelAttributeSubscriptionState() - object SubscriptionEstablished : ChannelAttributeSubscriptionState() - } -class RoutingRoleAttribute( - val value: UByte? - ) + object SubscriptionEstablished : ChannelAttributeSubscriptionState() + } + + class RoutingRoleAttribute(val value: UByte?) sealed class RoutingRoleAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : RoutingRoleAttributeSubscriptionState() - + data class Success(val value: UByte?) : RoutingRoleAttributeSubscriptionState() + data class Error(val exception: Exception) : RoutingRoleAttributeSubscriptionState() - object SubscriptionEstablished : RoutingRoleAttributeSubscriptionState() - } -class NetworkNameAttribute( - val value: String? - ) + object SubscriptionEstablished : RoutingRoleAttributeSubscriptionState() + } + + class NetworkNameAttribute(val value: String?) sealed class NetworkNameAttributeSubscriptionState { - data class Success( - val value: String? - ) : NetworkNameAttributeSubscriptionState() - + data class Success(val value: String?) : NetworkNameAttributeSubscriptionState() + data class Error(val exception: Exception) : NetworkNameAttributeSubscriptionState() - object SubscriptionEstablished : NetworkNameAttributeSubscriptionState() - } -class PanIdAttribute( - val value: UShort? - ) + object SubscriptionEstablished : NetworkNameAttributeSubscriptionState() + } + + class PanIdAttribute(val value: UShort?) sealed class PanIdAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : PanIdAttributeSubscriptionState() - + data class Success(val value: UShort?) : PanIdAttributeSubscriptionState() + data class Error(val exception: Exception) : PanIdAttributeSubscriptionState() - object SubscriptionEstablished : PanIdAttributeSubscriptionState() - } -class ExtendedPanIdAttribute( - val value: ULong? - ) + object SubscriptionEstablished : PanIdAttributeSubscriptionState() + } + + class ExtendedPanIdAttribute(val value: ULong?) sealed class ExtendedPanIdAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : ExtendedPanIdAttributeSubscriptionState() - + data class Success(val value: ULong?) : ExtendedPanIdAttributeSubscriptionState() + data class Error(val exception: Exception) : ExtendedPanIdAttributeSubscriptionState() - object SubscriptionEstablished : ExtendedPanIdAttributeSubscriptionState() - } -class MeshLocalPrefixAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : ExtendedPanIdAttributeSubscriptionState() + } + + class MeshLocalPrefixAttribute(val value: ByteArray?) sealed class MeshLocalPrefixAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : MeshLocalPrefixAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : MeshLocalPrefixAttributeSubscriptionState() + data class Error(val exception: Exception) : MeshLocalPrefixAttributeSubscriptionState() - object SubscriptionEstablished : MeshLocalPrefixAttributeSubscriptionState() - } -class NeighborTableAttribute( - val value: List - ) + object SubscriptionEstablished : MeshLocalPrefixAttributeSubscriptionState() + } + + class NeighborTableAttribute(val value: List) sealed class NeighborTableAttributeSubscriptionState { - data class Success( - val value: List - ) : NeighborTableAttributeSubscriptionState() - + data class Success(val value: List) : + NeighborTableAttributeSubscriptionState() + data class Error(val exception: Exception) : NeighborTableAttributeSubscriptionState() - object SubscriptionEstablished : NeighborTableAttributeSubscriptionState() - } -class RouteTableAttribute( - val value: List - ) + object SubscriptionEstablished : NeighborTableAttributeSubscriptionState() + } + + class RouteTableAttribute(val value: List) sealed class RouteTableAttributeSubscriptionState { - data class Success( - val value: List - ) : RouteTableAttributeSubscriptionState() - + data class Success(val value: List) : + RouteTableAttributeSubscriptionState() + data class Error(val exception: Exception) : RouteTableAttributeSubscriptionState() - object SubscriptionEstablished : RouteTableAttributeSubscriptionState() - } -class PartitionIdAttribute( - val value: UInt? - ) + object SubscriptionEstablished : RouteTableAttributeSubscriptionState() + } + + class PartitionIdAttribute(val value: UInt?) sealed class PartitionIdAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PartitionIdAttributeSubscriptionState() - + data class Success(val value: UInt?) : PartitionIdAttributeSubscriptionState() + data class Error(val exception: Exception) : PartitionIdAttributeSubscriptionState() - object SubscriptionEstablished : PartitionIdAttributeSubscriptionState() - } -class WeightingAttribute( - val value: UShort? - ) + object SubscriptionEstablished : PartitionIdAttributeSubscriptionState() + } + + class WeightingAttribute(val value: UShort?) sealed class WeightingAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : WeightingAttributeSubscriptionState() - + data class Success(val value: UShort?) : WeightingAttributeSubscriptionState() + data class Error(val exception: Exception) : WeightingAttributeSubscriptionState() - object SubscriptionEstablished : WeightingAttributeSubscriptionState() - } -class DataVersionAttribute( - val value: UShort? - ) + object SubscriptionEstablished : WeightingAttributeSubscriptionState() + } + + class DataVersionAttribute(val value: UShort?) sealed class DataVersionAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : DataVersionAttributeSubscriptionState() - + data class Success(val value: UShort?) : DataVersionAttributeSubscriptionState() + data class Error(val exception: Exception) : DataVersionAttributeSubscriptionState() - object SubscriptionEstablished : DataVersionAttributeSubscriptionState() - } -class StableDataVersionAttribute( - val value: UShort? - ) + object SubscriptionEstablished : DataVersionAttributeSubscriptionState() + } + + class StableDataVersionAttribute(val value: UShort?) sealed class StableDataVersionAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : StableDataVersionAttributeSubscriptionState() - + data class Success(val value: UShort?) : StableDataVersionAttributeSubscriptionState() + data class Error(val exception: Exception) : StableDataVersionAttributeSubscriptionState() - object SubscriptionEstablished : StableDataVersionAttributeSubscriptionState() - } -class LeaderRouterIdAttribute( - val value: UByte? - ) + object SubscriptionEstablished : StableDataVersionAttributeSubscriptionState() + } + + class LeaderRouterIdAttribute(val value: UByte?) sealed class LeaderRouterIdAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : LeaderRouterIdAttributeSubscriptionState() - + data class Success(val value: UByte?) : LeaderRouterIdAttributeSubscriptionState() + data class Error(val exception: Exception) : LeaderRouterIdAttributeSubscriptionState() - object SubscriptionEstablished : LeaderRouterIdAttributeSubscriptionState() - } -class ActiveTimestampAttribute( - val value: ULong? - ) + object SubscriptionEstablished : LeaderRouterIdAttributeSubscriptionState() + } + + class ActiveTimestampAttribute(val value: ULong?) sealed class ActiveTimestampAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : ActiveTimestampAttributeSubscriptionState() - + data class Success(val value: ULong?) : ActiveTimestampAttributeSubscriptionState() + data class Error(val exception: Exception) : ActiveTimestampAttributeSubscriptionState() - object SubscriptionEstablished : ActiveTimestampAttributeSubscriptionState() - } -class PendingTimestampAttribute( - val value: ULong? - ) + object SubscriptionEstablished : ActiveTimestampAttributeSubscriptionState() + } + + class PendingTimestampAttribute(val value: ULong?) sealed class PendingTimestampAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : PendingTimestampAttributeSubscriptionState() - + data class Success(val value: ULong?) : PendingTimestampAttributeSubscriptionState() + data class Error(val exception: Exception) : PendingTimestampAttributeSubscriptionState() - object SubscriptionEstablished : PendingTimestampAttributeSubscriptionState() - } -class DelayAttribute( - val value: UInt? - ) + object SubscriptionEstablished : PendingTimestampAttributeSubscriptionState() + } + + class DelayAttribute(val value: UInt?) sealed class DelayAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : DelayAttributeSubscriptionState() - + data class Success(val value: UInt?) : DelayAttributeSubscriptionState() + data class Error(val exception: Exception) : DelayAttributeSubscriptionState() - object SubscriptionEstablished : DelayAttributeSubscriptionState() - } -class SecurityPolicyAttribute( - val value: ThreadNetworkDiagnosticsClusterSecurityPolicy? - ) + object SubscriptionEstablished : DelayAttributeSubscriptionState() + } + + class SecurityPolicyAttribute(val value: ThreadNetworkDiagnosticsClusterSecurityPolicy?) sealed class SecurityPolicyAttributeSubscriptionState { - data class Success( - val value: ThreadNetworkDiagnosticsClusterSecurityPolicy? - ) : SecurityPolicyAttributeSubscriptionState() - + data class Success(val value: ThreadNetworkDiagnosticsClusterSecurityPolicy?) : + SecurityPolicyAttributeSubscriptionState() + data class Error(val exception: Exception) : SecurityPolicyAttributeSubscriptionState() - object SubscriptionEstablished : SecurityPolicyAttributeSubscriptionState() - } -class ChannelPage0MaskAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : SecurityPolicyAttributeSubscriptionState() + } + + class ChannelPage0MaskAttribute(val value: ByteArray?) sealed class ChannelPage0MaskAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : ChannelPage0MaskAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : ChannelPage0MaskAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelPage0MaskAttributeSubscriptionState() - object SubscriptionEstablished : ChannelPage0MaskAttributeSubscriptionState() - } -class OperationalDatasetComponentsAttribute( + object SubscriptionEstablished : ChannelPage0MaskAttributeSubscriptionState() + } + + class OperationalDatasetComponentsAttribute( val value: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? ) sealed class OperationalDatasetComponentsAttributeSubscriptionState { - data class Success( - val value: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? - ) : OperationalDatasetComponentsAttributeSubscriptionState() - - data class Error(val exception: Exception) : OperationalDatasetComponentsAttributeSubscriptionState() - - object SubscriptionEstablished : OperationalDatasetComponentsAttributeSubscriptionState() - } -class ActiveNetworkFaultsListAttribute( - val value: List - ) + data class Success(val value: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents?) : + OperationalDatasetComponentsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + OperationalDatasetComponentsAttributeSubscriptionState() + + object SubscriptionEstablished : OperationalDatasetComponentsAttributeSubscriptionState() + } + + class ActiveNetworkFaultsListAttribute(val value: List) sealed class ActiveNetworkFaultsListAttributeSubscriptionState { - data class Success( - val value: List - ) : ActiveNetworkFaultsListAttributeSubscriptionState() - - data class Error(val exception: Exception) : ActiveNetworkFaultsListAttributeSubscriptionState() - - object SubscriptionEstablished : ActiveNetworkFaultsListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: List) : + ActiveNetworkFaultsListAttributeSubscriptionState() + + data class Error(val exception: Exception) : + ActiveNetworkFaultsListAttributeSubscriptionState() + + object SubscriptionEstablished : ActiveNetworkFaultsListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCounts(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -389,46 +309,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readChannelAttribute(): ChannelAttribute {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readChannelAttribute(): ChannelAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Channel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ChannelAttribute(decodedValue) } @@ -438,96 +352,90 @@ suspend fun readChannelAttribute(): ChannelAttribute {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ChannelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ChannelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Channel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(ChannelAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ChannelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ChannelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRoutingRoleAttribute(): RoutingRoleAttribute {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRoutingRoleAttribute(): RoutingRoleAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routingrole attribute not found in response" - } + } + + requireNotNull(attributeData) { "Routingrole attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return RoutingRoleAttribute(decodedValue) } @@ -537,96 +445,90 @@ suspend fun readRoutingRoleAttribute(): RoutingRoleAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RoutingRoleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RoutingRoleAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routingrole attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Routingrole attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(RoutingRoleAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(RoutingRoleAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RoutingRoleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNetworkNameAttribute(): NetworkNameAttribute {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNetworkNameAttribute(): NetworkNameAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networkname attribute not found in response" - } + } + + requireNotNull(attributeData) { "Networkname attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NetworkNameAttribute(decodedValue) } @@ -636,96 +538,90 @@ suspend fun readNetworkNameAttribute(): NetworkNameAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NetworkNameAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NetworkNameAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Networkname attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Networkname attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: String? = + if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NetworkNameAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NetworkNameAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NetworkNameAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPanIdAttribute(): PanIdAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPanIdAttribute(): PanIdAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Panid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Panid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return PanIdAttribute(decodedValue) } @@ -735,96 +631,90 @@ suspend fun readPanIdAttribute(): PanIdAttribute {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PanIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PanIdAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Panid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Panid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(PanIdAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(PanIdAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PanIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readExtendedPanIdAttribute(): ExtendedPanIdAttribute {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readExtendedPanIdAttribute(): ExtendedPanIdAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Extendedpanid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Extendedpanid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ExtendedPanIdAttribute(decodedValue) } @@ -834,96 +724,90 @@ suspend fun readExtendedPanIdAttribute(): ExtendedPanIdAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ExtendedPanIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ExtendedPanIdAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Extendedpanid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Extendedpanid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(ExtendedPanIdAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ExtendedPanIdAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ExtendedPanIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeshLocalPrefixAttribute(): MeshLocalPrefixAttribute {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readMeshLocalPrefixAttribute(): MeshLocalPrefixAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Meshlocalprefix attribute not found in response" - } + } + + requireNotNull(attributeData) { "Meshlocalprefix attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeshLocalPrefixAttribute(decodedValue) } @@ -933,95 +817,91 @@ suspend fun readMeshLocalPrefixAttribute(): MeshLocalPrefixAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeshLocalPrefixAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeshLocalPrefixAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Meshlocalprefix attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Meshlocalprefix attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(MeshLocalPrefixAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(MeshLocalPrefixAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeshLocalPrefixAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOverrunCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOverrunCountAttribute(): ULong? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Overruncount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } return decodedValue } @@ -1031,96 +911,90 @@ suspend fun readOverrunCountAttribute(): ULong? {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Overruncount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } + val decodedValue: ULong? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(ULongSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ULongSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNeighborTableAttribute(): NeighborTableAttribute {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNeighborTableAttribute(): NeighborTableAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Neighbortable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Neighbortable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return NeighborTableAttribute(decodedValue) } @@ -1130,45 +1004,53 @@ suspend fun readNeighborTableAttribute(): NeighborTableAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NeighborTableAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NeighborTableAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Neighbortable attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Neighbortable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ThreadNetworkDiagnosticsClusterNeighborTableStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } emit(NeighborTableAttributeSubscriptionState.Success(decodedValue)) } @@ -1176,49 +1058,43 @@ suspend fun readNeighborTableAttribute(): NeighborTableAttribute {val ATTRIBUTE_ emit(NeighborTableAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRouteTableAttribute(): RouteTableAttribute {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRouteTableAttribute(): RouteTableAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routetable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Routetable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return RouteTableAttribute(decodedValue) } @@ -1228,45 +1104,50 @@ suspend fun readRouteTableAttribute(): RouteTableAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RouteTableAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RouteTableAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routetable attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Routetable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add( + ThreadNetworkDiagnosticsClusterRouteTableStruct.fromTlv(AnonymousTag, tlvReader) + ) + } + tlvReader.exitContainer() + } emit(RouteTableAttributeSubscriptionState.Success(decodedValue)) } @@ -1274,48 +1155,42 @@ suspend fun readRouteTableAttribute(): RouteTableAttribute {val ATTRIBUTE_ID: UI emit(RouteTableAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPartitionIdAttribute(): PartitionIdAttribute {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPartitionIdAttribute(): PartitionIdAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partitionid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Partitionid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return PartitionIdAttribute(decodedValue) } @@ -1325,96 +1200,90 @@ suspend fun readPartitionIdAttribute(): PartitionIdAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PartitionIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PartitionIdAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partitionid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Partitionid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(PartitionIdAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(PartitionIdAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PartitionIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWeightingAttribute(): WeightingAttribute {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWeightingAttribute(): WeightingAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Weighting attribute not found in response" - } + } + + requireNotNull(attributeData) { "Weighting attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return WeightingAttribute(decodedValue) } @@ -1424,96 +1293,90 @@ suspend fun readWeightingAttribute(): WeightingAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(WeightingAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + WeightingAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Weighting attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Weighting attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(WeightingAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(WeightingAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(WeightingAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDataVersionAttribute(): DataVersionAttribute {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDataVersionAttribute(): DataVersionAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dataversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dataversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return DataVersionAttribute(decodedValue) } @@ -1523,96 +1386,90 @@ suspend fun readDataVersionAttribute(): DataVersionAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DataVersionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DataVersionAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dataversion attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dataversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(DataVersionAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(DataVersionAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DataVersionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStableDataVersionAttribute(): StableDataVersionAttribute {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStableDataVersionAttribute(): StableDataVersionAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Stabledataversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Stabledataversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return StableDataVersionAttribute(decodedValue) } @@ -1622,96 +1479,92 @@ suspend fun readStableDataVersionAttribute(): StableDataVersionAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StableDataVersionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StableDataVersionAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Stabledataversion attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Stabledataversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(StableDataVersionAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(StableDataVersionAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StableDataVersionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLeaderRouterIdAttribute(): LeaderRouterIdAttribute {val ATTRIBUTE_ID: UInt = 13u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLeaderRouterIdAttribute(): LeaderRouterIdAttribute { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Leaderrouterid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Leaderrouterid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return LeaderRouterIdAttribute(decodedValue) } @@ -1721,95 +1574,91 @@ suspend fun readLeaderRouterIdAttribute(): LeaderRouterIdAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LeaderRouterIdAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LeaderRouterIdAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Leaderrouterid attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Leaderrouterid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(LeaderRouterIdAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(LeaderRouterIdAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LeaderRouterIdAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDetachedRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 14u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDetachedRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Detachedrolecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Detachedrolecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1819,94 +1668,90 @@ suspend fun readDetachedRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Detachedrolecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Detachedrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChildRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readChildRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Childrolecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Childrolecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1916,94 +1761,90 @@ suspend fun readChildRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Childrolecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Childrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRouterRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRouterRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routerrolecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Routerrolecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2013,94 +1854,90 @@ suspend fun readRouterRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Routerrolecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Routerrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLeaderRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLeaderRoleCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Leaderrolecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Leaderrolecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2110,94 +1947,90 @@ suspend fun readLeaderRoleCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Leaderrolecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Leaderrolecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttachAttemptCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttachAttemptCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attachattemptcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attachattemptcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2207,94 +2040,90 @@ suspend fun readAttachAttemptCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attachattemptcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Attachattemptcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPartitionIdChangeCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPartitionIdChangeCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partitionidchangecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Partitionidchangecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2304,94 +2133,92 @@ suspend fun readPartitionIdChangeCountAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Partitionidchangecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Partitionidchangecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBetterPartitionAttachAttemptCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBetterPartitionAttachAttemptCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Betterpartitionattachattemptcount attribute not found in response" + } + + requireNotNull(attributeData) { + "Betterpartitionattachattemptcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2401,94 +2228,90 @@ suspend fun readBetterPartitionAttachAttemptCountAttribute(): UShort? {val ATTRI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Betterpartitionattachattemptcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Betterpartitionattachattemptcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readParentChangeCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readParentChangeCountAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Parentchangecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Parentchangecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2498,94 +2321,90 @@ suspend fun readParentChangeCountAttribute(): UShort? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Parentchangecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Parentchangecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxTotalCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxTotalCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txtotalcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txtotalcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2595,94 +2414,88 @@ suspend fun readTxTotalCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 22u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txtotalcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txtotalcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxUnicastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxUnicastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txunicastcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txunicastcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2692,94 +2505,90 @@ suspend fun readTxUnicastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 23u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txunicastcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txunicastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxBroadcastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 24u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxBroadcastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbroadcastcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txbroadcastcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2789,94 +2598,90 @@ suspend fun readTxBroadcastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 24u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbroadcastcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txbroadcastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxAckRequestedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxAckRequestedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txackrequestedcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txackrequestedcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2886,94 +2691,90 @@ suspend fun readTxAckRequestedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txackrequestedcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txackrequestedcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxAckedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxAckedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txackedcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txackedcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -2983,94 +2784,88 @@ suspend fun readTxAckedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 26u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txackedcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txackedcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxNoAckRequestedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxNoAckRequestedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txnoackrequestedcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txnoackrequestedcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3080,94 +2875,90 @@ suspend fun readTxNoAckRequestedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txnoackrequestedcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txnoackrequestedcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxDataCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 28u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxDataCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdatacount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txdatacount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3177,94 +2968,88 @@ suspend fun readTxDataCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 28u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdatacount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txdatacount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxDataPollCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 29u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxDataPollCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 29u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdatapollcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txdatapollcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3274,94 +3059,90 @@ suspend fun readTxDataPollCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 29u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 29u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdatapollcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txdatapollcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxBeaconCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 30u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxBeaconCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbeaconcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txbeaconcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3371,94 +3152,88 @@ suspend fun readTxBeaconCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 30u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbeaconcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txbeaconcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxBeaconRequestCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 31u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxBeaconRequestCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 31u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbeaconrequestcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txbeaconrequestcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3468,94 +3243,90 @@ suspend fun readTxBeaconRequestCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 31u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txbeaconrequestcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txbeaconrequestcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 32u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxOtherCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txothercount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txothercount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3565,94 +3336,88 @@ suspend fun readTxOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txothercount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txothercount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxRetryCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxRetryCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txretrycount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txretrycount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3662,94 +3427,88 @@ suspend fun readTxRetryCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 33u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txretrycount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txretrycount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxDirectMaxRetryExpiryCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 34u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxDirectMaxRetryExpiryCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdirectmaxretryexpirycount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txdirectmaxretryexpirycount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3759,94 +3518,92 @@ suspend fun readTxDirectMaxRetryExpiryCountAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txdirectmaxretryexpirycount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txdirectmaxretryexpirycount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxIndirectMaxRetryExpiryCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 35u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxIndirectMaxRetryExpiryCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txindirectmaxretryexpirycount attribute not found in response" + } + + requireNotNull(attributeData) { + "Txindirectmaxretryexpirycount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3856,94 +3613,90 @@ suspend fun readTxIndirectMaxRetryExpiryCountAttribute(): UInt? {val ATTRIBUTE_I maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txindirectmaxretryexpirycount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txindirectmaxretryexpirycount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxErrCcaCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxErrCcaCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrccacount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txerrccacount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -3953,94 +3706,88 @@ suspend fun readTxErrCcaCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 36u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrccacount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Txerrccacount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxErrAbortCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxErrAbortCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrabortcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txerrabortcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4050,94 +3797,90 @@ suspend fun readTxErrAbortCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 37u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrabortcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txerrabortcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTxErrBusyChannelCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 38u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTxErrBusyChannelCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrbusychannelcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Txerrbusychannelcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4147,94 +3890,90 @@ suspend fun readTxErrBusyChannelCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Txerrbusychannelcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Txerrbusychannelcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxTotalCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 39u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxTotalCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxtotalcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxtotalcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4244,94 +3983,88 @@ suspend fun readRxTotalCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 39u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxtotalcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxtotalcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxUnicastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 40u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxUnicastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxunicastcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxunicastcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4341,94 +4074,90 @@ suspend fun readRxUnicastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 40u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxunicastcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxunicastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxBroadcastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 41u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxBroadcastCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbroadcastcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxbroadcastcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4438,94 +4167,90 @@ suspend fun readRxBroadcastCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 41u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbroadcastcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxbroadcastcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxDataCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 42u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxDataCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdatacount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxdatacount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4535,94 +4260,88 @@ suspend fun readRxDataCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 42u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdatacount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxdatacount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxDataPollCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 43u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxDataPollCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 43u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdatapollcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxdatapollcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4632,94 +4351,90 @@ suspend fun readRxDataPollCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 43u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 43u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdatapollcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxdatapollcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxBeaconCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 44u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxBeaconCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 44u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbeaconcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxbeaconcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4729,94 +4444,88 @@ suspend fun readRxBeaconCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 44u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 44u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbeaconcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxbeaconcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxBeaconRequestCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 45u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxBeaconRequestCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 45u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbeaconrequestcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxbeaconrequestcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4826,94 +4535,90 @@ suspend fun readRxBeaconRequestCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 45u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxbeaconrequestcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxbeaconrequestcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 46u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxOtherCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 46u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxothercount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxothercount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -4923,94 +4628,88 @@ suspend fun readRxOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 46u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 46u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxothercount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxothercount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxAddressFilteredCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 47u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxAddressFilteredCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 47u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxaddressfilteredcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxaddressfilteredcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5020,94 +4719,90 @@ suspend fun readRxAddressFilteredCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 47u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxaddressfilteredcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxaddressfilteredcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxDestAddrFilteredCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxDestAddrFilteredCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdestaddrfilteredcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxdestaddrfilteredcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5117,94 +4812,90 @@ suspend fun readRxDestAddrFilteredCountAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxdestaddrfilteredcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxdestaddrfilteredcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxDuplicatedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxDuplicatedCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxduplicatedcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxduplicatedcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5214,94 +4905,90 @@ suspend fun readRxDuplicatedCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 49 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxduplicatedcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxduplicatedcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrNoFrameCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrNoFrameCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrnoframecount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrnoframecount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5311,94 +4998,90 @@ suspend fun readRxErrNoFrameCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 50 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrnoframecount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxerrnoframecount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrUnknownNeighborCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 51u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrUnknownNeighborCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 51u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrunknownneighborcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrunknownneighborcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5408,94 +5091,90 @@ suspend fun readRxErrUnknownNeighborCountAttribute(): UInt? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 51u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrunknownneighborcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxerrunknownneighborcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrInvalidSrcAddrCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 52u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrInvalidSrcAddrCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 52u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrinvalidsrcaddrcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrinvalidsrcaddrcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5505,94 +5184,90 @@ suspend fun readRxErrInvalidSrcAddrCountAttribute(): UInt? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 52u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrinvalidsrcaddrcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxerrinvalidsrcaddrcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrSecCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 53u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrSecCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 53u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrseccount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrseccount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5602,94 +5277,88 @@ suspend fun readRxErrSecCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 53u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 53u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrseccount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxerrseccount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrFcsCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 54u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrFcsCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 54u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrfcscount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrfcscount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5699,94 +5368,88 @@ suspend fun readRxErrFcsCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 54u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 54u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrfcscount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rxerrfcscount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRxErrOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 55u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRxErrOtherCountAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 55u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrothercount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rxerrothercount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -5796,99 +5459,95 @@ suspend fun readRxErrOtherCountAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 55u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 55u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rxerrothercount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rxerrothercount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveTimestampAttribute(): ActiveTimestampAttribute {val ATTRIBUTE_ID: UInt = 56u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveTimestampAttribute(): ActiveTimestampAttribute { + val ATTRIBUTE_ID: UInt = 56u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetimestamp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activetimestamp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return ActiveTimestampAttribute(decodedValue) } @@ -5898,104 +5557,100 @@ suspend fun readActiveTimestampAttribute(): ActiveTimestampAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 56u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveTimestampAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveTimestampAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activetimestamp attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activetimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ActiveTimestampAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ActiveTimestampAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ActiveTimestampAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPendingTimestampAttribute(): PendingTimestampAttribute {val ATTRIBUTE_ID: UInt = 57u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPendingTimestampAttribute(): PendingTimestampAttribute { + val ATTRIBUTE_ID: UInt = 57u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pendingtimestamp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Pendingtimestamp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PendingTimestampAttribute(decodedValue) } @@ -6005,104 +5660,100 @@ suspend fun readPendingTimestampAttribute(): PendingTimestampAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 57u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PendingTimestampAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PendingTimestampAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Pendingtimestamp attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Pendingtimestamp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PendingTimestampAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PendingTimestampAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PendingTimestampAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDelayAttribute(): DelayAttribute {val ATTRIBUTE_ID: UInt = 58u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readDelayAttribute(): DelayAttribute { + val ATTRIBUTE_ID: UInt = 58u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Delay attribute not found in response" - } + } + + requireNotNull(attributeData) { "Delay attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DelayAttribute(decodedValue) } @@ -6112,100 +5763,94 @@ suspend fun readDelayAttribute(): DelayAttribute {val ATTRIBUTE_ID: UInt = 58u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 58u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DelayAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DelayAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Delay attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Delay attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DelayAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DelayAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DelayAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSecurityPolicyAttribute(): SecurityPolicyAttribute {val ATTRIBUTE_ID: UInt = 59u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSecurityPolicyAttribute(): SecurityPolicyAttribute { + val ATTRIBUTE_ID: UInt = 59u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Securitypolicy attribute not found in response" - } + } + + requireNotNull(attributeData) { "Securitypolicy attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = + if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SecurityPolicyAttribute(decodedValue) } @@ -6215,96 +5860,92 @@ suspend fun readSecurityPolicyAttribute(): SecurityPolicyAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 59u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SecurityPolicyAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SecurityPolicyAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Securitypolicy attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Securitypolicy attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ThreadNetworkDiagnosticsClusterSecurityPolicy? = + if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterSecurityPolicy.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(SecurityPolicyAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(SecurityPolicyAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SecurityPolicyAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChannelPage0MaskAttribute(): ChannelPage0MaskAttribute {val ATTRIBUTE_ID: UInt = 60u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readChannelPage0MaskAttribute(): ChannelPage0MaskAttribute { + val ATTRIBUTE_ID: UInt = 60u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channelpage0mask attribute not found in response" - } + } + + requireNotNull(attributeData) { "Channelpage0mask attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ChannelPage0MaskAttribute(decodedValue) } @@ -6314,96 +5955,92 @@ suspend fun readChannelPage0MaskAttribute(): ChannelPage0MaskAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 60u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ChannelPage0MaskAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ChannelPage0MaskAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channelpage0mask attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Channelpage0mask attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(ChannelPage0MaskAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(ChannelPage0MaskAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ChannelPage0MaskAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalDatasetComponentsAttribute(): OperationalDatasetComponentsAttribute {val ATTRIBUTE_ID: UInt = 61u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOperationalDatasetComponentsAttribute(): OperationalDatasetComponentsAttribute { + val ATTRIBUTE_ID: UInt = 61u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationaldatasetcomponents attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationaldatasetcomponents attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = + if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } return OperationalDatasetComponentsAttribute(decodedValue) } @@ -6413,97 +6050,98 @@ suspend fun readOperationalDatasetComponentsAttribute(): OperationalDatasetCompo maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 61u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OperationalDatasetComponentsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OperationalDatasetComponentsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationaldatasetcomponents attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationaldatasetcomponents attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = if (!tlvReader.isNull()) { - ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ThreadNetworkDiagnosticsClusterOperationalDatasetComponents? = + if (!tlvReader.isNull()) { + ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.fromTlv( + AnonymousTag, + tlvReader + ) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(OperationalDatasetComponentsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(OperationalDatasetComponentsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttribute {val ATTRIBUTE_ID: UInt = 62u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttribute { + val ATTRIBUTE_ID: UInt = 62u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activenetworkfaultslist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activenetworkfaultslist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ActiveNetworkFaultsListAttribute(decodedValue) } @@ -6513,45 +6151,50 @@ suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttri maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 62u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ActiveNetworkFaultsListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ActiveNetworkFaultsListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activenetworkfaultslist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activenetworkfaultslist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ActiveNetworkFaultsListAttributeSubscriptionState.Success(decodedValue)) } @@ -6559,49 +6202,43 @@ suspend fun readActiveNetworkFaultsListAttribute(): ActiveNetworkFaultsListAttri emit(ActiveNetworkFaultsListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -6611,45 +6248,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6657,49 +6299,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -6709,45 +6345,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -6755,49 +6396,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -6807,45 +6442,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -6853,49 +6491,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -6905,45 +6537,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -6951,44 +6586,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -6997,35 +6625,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7037,44 +6667,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -7083,34 +6706,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7123,7 +6750,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt index 0a6b84266fe5f8..c16c37cdb0d766 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeFormatLocalizationCluster.kt @@ -17,172 +17,130 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeFormatLocalizationCluster(private val controller: MatterController, private val endpointId: UShort) {class SupportedCalendarTypesAttribute( - val value: List? - ) +class TimeFormatLocalizationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SupportedCalendarTypesAttribute(val value: List?) sealed class SupportedCalendarTypesAttributeSubscriptionState { - data class Success( - val value: List? - ) : SupportedCalendarTypesAttributeSubscriptionState() - + data class Success(val value: List?) : + SupportedCalendarTypesAttributeSubscriptionState() + data class Error(val exception: Exception) : SupportedCalendarTypesAttributeSubscriptionState() - object SubscriptionEstablished : SupportedCalendarTypesAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : SupportedCalendarTypesAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readHourFormatAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readHourFormatAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hourformat attribute not found in response" - } + } + + requireNotNull(attributeData) { "Hourformat attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeHourFormatAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeHourFormatAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -204,7 +162,7 @@ suspend fun readHourFormatAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeHourFormatAttribute( @@ -212,35 +170,37 @@ suspend fun readHourFormatAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Hourformat attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Hourformat attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -252,71 +212,61 @@ suspend fun readHourFormatAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readActiveCalendarTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readActiveCalendarTypeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecalendartype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Activecalendartype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeActiveCalendarTypeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeActiveCalendarTypeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -338,7 +288,7 @@ suspend fun readActiveCalendarTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeActiveCalendarTypeAttribute( @@ -346,100 +296,96 @@ suspend fun readActiveCalendarTypeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Activecalendartype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Activecalendartype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportedCalendarTypesAttribute(): SupportedCalendarTypesAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportedCalendarTypesAttribute(): SupportedCalendarTypesAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedcalendartypes attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportedcalendartypes attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return SupportedCalendarTypesAttribute(decodedValue) } @@ -449,102 +395,98 @@ suspend fun readSupportedCalendarTypesAttribute(): SupportedCalendarTypesAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SupportedCalendarTypesAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SupportedCalendarTypesAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportedcalendartypes attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportedcalendartypes attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(SupportedCalendarTypesAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(SupportedCalendarTypesAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SupportedCalendarTypesAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -554,45 +496,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -600,49 +547,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -652,45 +593,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -698,49 +644,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -750,45 +690,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -796,49 +739,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -848,45 +785,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -894,44 +834,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -940,35 +873,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -980,44 +915,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1026,34 +954,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1066,7 +998,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt index 6310128a0314e5..13edfff80a046d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimeSynchronizationCluster.kt @@ -17,187 +17,145 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationCluster(private val controller: MatterController, private val endpointId: UShort) { - class SetTimeZoneResponse( - val DSTOffsetRequired: Boolean - ) -class UTCTimeAttribute( - val value: ULong? - ) +class TimeSynchronizationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class SetTimeZoneResponse(val DSTOffsetRequired: Boolean) + + class UTCTimeAttribute(val value: ULong?) sealed class UTCTimeAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : UTCTimeAttributeSubscriptionState() - + data class Success(val value: ULong?) : UTCTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : UTCTimeAttributeSubscriptionState() - object SubscriptionEstablished : UTCTimeAttributeSubscriptionState() - } -class TrustedTimeSourceAttribute( - val value: TimeSynchronizationClusterTrustedTimeSourceStruct? - ) + object SubscriptionEstablished : UTCTimeAttributeSubscriptionState() + } + + class TrustedTimeSourceAttribute(val value: TimeSynchronizationClusterTrustedTimeSourceStruct?) sealed class TrustedTimeSourceAttributeSubscriptionState { - data class Success( - val value: TimeSynchronizationClusterTrustedTimeSourceStruct? - ) : TrustedTimeSourceAttributeSubscriptionState() - + data class Success(val value: TimeSynchronizationClusterTrustedTimeSourceStruct?) : + TrustedTimeSourceAttributeSubscriptionState() + data class Error(val exception: Exception) : TrustedTimeSourceAttributeSubscriptionState() - object SubscriptionEstablished : TrustedTimeSourceAttributeSubscriptionState() - } -class DefaultNTPAttribute( - val value: String? - ) + object SubscriptionEstablished : TrustedTimeSourceAttributeSubscriptionState() + } + + class DefaultNTPAttribute(val value: String?) sealed class DefaultNTPAttributeSubscriptionState { - data class Success( - val value: String? - ) : DefaultNTPAttributeSubscriptionState() - + data class Success(val value: String?) : DefaultNTPAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultNTPAttributeSubscriptionState() - object SubscriptionEstablished : DefaultNTPAttributeSubscriptionState() - } -class TimeZoneAttribute( - val value: List? - ) + object SubscriptionEstablished : DefaultNTPAttributeSubscriptionState() + } + + class TimeZoneAttribute(val value: List?) sealed class TimeZoneAttributeSubscriptionState { - data class Success( - val value: List? - ) : TimeZoneAttributeSubscriptionState() - + data class Success(val value: List?) : + TimeZoneAttributeSubscriptionState() + data class Error(val exception: Exception) : TimeZoneAttributeSubscriptionState() - object SubscriptionEstablished : TimeZoneAttributeSubscriptionState() - } -class DSTOffsetAttribute( - val value: List? - ) + object SubscriptionEstablished : TimeZoneAttributeSubscriptionState() + } + + class DSTOffsetAttribute(val value: List?) sealed class DSTOffsetAttributeSubscriptionState { - data class Success( - val value: List? - ) : DSTOffsetAttributeSubscriptionState() - + data class Success(val value: List?) : + DSTOffsetAttributeSubscriptionState() + data class Error(val exception: Exception) : DSTOffsetAttributeSubscriptionState() - object SubscriptionEstablished : DSTOffsetAttributeSubscriptionState() - } -class LocalTimeAttribute( - val value: ULong? - ) + object SubscriptionEstablished : DSTOffsetAttributeSubscriptionState() + } + + class LocalTimeAttribute(val value: ULong?) sealed class LocalTimeAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : LocalTimeAttributeSubscriptionState() - + data class Success(val value: ULong?) : LocalTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : LocalTimeAttributeSubscriptionState() - object SubscriptionEstablished : LocalTimeAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LocalTimeAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setUTCTime(UTCTime: ULong - ,granularity: UByte - ,timeSource: UByte? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setUTCTime( + UTCTime: ULong, + granularity: UByte, + timeSource: UByte?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 0u val tlvWriter = TlvWriter() @@ -210,9 +168,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_GRANULARITY_REQ), granularity) val TAG_TIME_SOURCE_REQ: Int = 2 - timeSource?.let { - tlvWriter.put(ContextSpecificTag(TAG_TIME_SOURCE_REQ), timeSource) - } + timeSource?.let { tlvWriter.put(ContextSpecificTag(TAG_TIME_SOURCE_REQ), timeSource) } tlvWriter.endStructure() val request: InvokeRequest = @@ -226,8 +182,10 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTrustedTimeSource(trustedTimeSource: TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setTrustedTimeSource( + trustedTimeSource: TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 1u val tlvWriter = TlvWriter() @@ -236,7 +194,7 @@ class AttributeListAttribute( val TAG_TRUSTED_TIME_SOURCE_REQ: Int = 0 trustedTimeSource?.let { trustedTimeSource.toTlv(ContextSpecificTag(TAG_TRUSTED_TIME_SOURCE_REQ), tlvWriter) - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -250,8 +208,10 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setTimeZone(timeZone: List - ,timedInvokeTimeout: Duration? = null): SetTimeZoneResponse { + suspend fun setTimeZone( + timeZone: List, + timedInvokeTimeout: Duration? = null + ): SetTimeZoneResponse { val commandId: UInt = 2u val tlvWriter = TlvWriter() @@ -259,10 +219,10 @@ class AttributeListAttribute( val TAG_TIME_ZONE_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_TIME_ZONE_REQ)) - for (item in timeZone.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in timeZone.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -279,36 +239,30 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_D_S_T_OFFSET_REQUIRED: Int = 0 var DSTOffsetRequired_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_D_S_T_OFFSET_REQUIRED)) {DSTOffsetRequired_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_D_S_T_OFFSET_REQUIRED)) { + DSTOffsetRequired_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (DSTOffsetRequired_decoded == null) { - throw IllegalStateException("DSTOffsetRequired not found in TLV") + throw IllegalStateException("DSTOffsetRequired not found in TLV") } - tlvReader.exitContainer() - return SetTimeZoneResponse( - DSTOffsetRequired_decoded - ) + return SetTimeZoneResponse(DSTOffsetRequired_decoded) } - suspend fun setDSTOffset(DSTOffset: List - ,timedInvokeTimeout: Duration? = null) { + suspend fun setDSTOffset( + DSTOffset: List, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -316,10 +270,10 @@ class AttributeListAttribute( val TAG_D_S_T_OFFSET_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_D_S_T_OFFSET_REQ)) - for (item in DSTOffset.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in DSTOffset.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -333,17 +287,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun setDefaultNTP(defaultNTP: String? - ,timedInvokeTimeout: Duration? = null) { + suspend fun setDefaultNTP(defaultNTP: String?, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_DEFAULT_N_T_P_REQ: Int = 0 - defaultNTP?.let { - tlvWriter.put(ContextSpecificTag(TAG_DEFAULT_N_T_P_REQ), defaultNTP) - } + defaultNTP?.let { tlvWriter.put(ContextSpecificTag(TAG_DEFAULT_N_T_P_REQ), defaultNTP) } tlvWriter.endStructure() val request: InvokeRequest = @@ -356,46 +307,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readUTCTimeAttribute(): UTCTimeAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUTCTimeAttribute(): UTCTimeAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Utctime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Utctime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return UTCTimeAttribute(decodedValue) } @@ -405,92 +350,85 @@ suspend fun readUTCTimeAttribute(): UTCTimeAttribute {val ATTRIBUTE_ID: UInt = 0 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UTCTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UTCTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Utctime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Utctime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(UTCTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(UTCTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UTCTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGranularityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGranularityAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Granularity attribute not found in response" - } + } + + requireNotNull(attributeData) { "Granularity attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -499,35 +437,37 @@ suspend fun readGranularityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Granularity attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Granularity attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -539,47 +479,41 @@ suspend fun readGranularityAttribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeSourceAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeSourceAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timesource attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timesource attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -589,99 +523,93 @@ suspend fun readTimeSourceAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timesource attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Timesource attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTrustedTimeSourceAttribute(): TrustedTimeSourceAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTrustedTimeSourceAttribute(): TrustedTimeSourceAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Trustedtimesource attribute not found in response" - } + } + + requireNotNull(attributeData) { "Trustedtimesource attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return TrustedTimeSourceAttribute(decodedValue) } @@ -691,104 +619,100 @@ suspend fun readTrustedTimeSourceAttribute(): TrustedTimeSourceAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TrustedTimeSourceAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TrustedTimeSourceAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Trustedtimesource attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Trustedtimesource attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(TrustedTimeSourceAttributeSubscriptionState.Success(it)) - } - + val decodedValue: TimeSynchronizationClusterTrustedTimeSourceStruct? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + TimeSynchronizationClusterTrustedTimeSourceStruct.fromTlv(AnonymousTag, tlvReader) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(TrustedTimeSourceAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(TrustedTimeSourceAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultNTPAttribute(): DefaultNTPAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultNTPAttribute(): DefaultNTPAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultntp attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultntp attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return DefaultNTPAttribute(decodedValue) } @@ -798,105 +722,99 @@ suspend fun readDefaultNTPAttribute(): DefaultNTPAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DefaultNTPAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DefaultNTPAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultntp attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Defaultntp attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DefaultNTPAttributeSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DefaultNTPAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DefaultNTPAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeZoneAttribute(): TimeZoneAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeZoneAttribute(): TimeZoneAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezone attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timezone attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return TimeZoneAttribute(decodedValue) } @@ -906,106 +824,100 @@ suspend fun readTimeZoneAttribute(): TimeZoneAttribute {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TimeZoneAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TimeZoneAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezone attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Timezone attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(TimeZoneAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterTimeZoneStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(TimeZoneAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(TimeZoneAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDSTOffsetAttribute(): DSTOffsetAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDSTOffsetAttribute(): DSTOffsetAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dstoffset attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dstoffset attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null } - tlvReader.exitContainer() - } - } else { - null - } - return DSTOffsetAttribute(decodedValue) } @@ -1015,105 +927,99 @@ suspend fun readDSTOffsetAttribute(): DSTOffsetAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DSTOffsetAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DSTOffsetAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dstoffset attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Dstoffset attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List? = if (tlvReader.isNextTag(AnonymousTag)) { - buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - null - } - - decodedValue?.let { - emit(DSTOffsetAttributeSubscriptionState.Success(it)) - } - + val decodedValue: List? = + if (tlvReader.isNextTag(AnonymousTag)) { + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(TimeSynchronizationClusterDSTOffsetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + null + } + + decodedValue?.let { emit(DSTOffsetAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DSTOffsetAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLocalTimeAttribute(): LocalTimeAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLocalTimeAttribute(): LocalTimeAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Localtime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return LocalTimeAttribute(decodedValue) } @@ -1123,99 +1029,93 @@ suspend fun readLocalTimeAttribute(): LocalTimeAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LocalTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LocalTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Localtime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Localtime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(LocalTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(LocalTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(LocalTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeZoneDatabaseAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeZoneDatabaseAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezonedatabase attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timezonedatabase attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1225,94 +1125,90 @@ suspend fun readTimeZoneDatabaseAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezonedatabase attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Timezonedatabase attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNTPServerAvailableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readNTPServerAvailableAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ntpserveravailable attribute not found in response" - } + } + + requireNotNull(attributeData) { "Ntpserveravailable attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -1322,94 +1218,90 @@ suspend fun readNTPServerAvailableAttribute(): Boolean? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Ntpserveravailable attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Ntpserveravailable attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeZoneListMaxSizeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeZoneListMaxSizeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezonelistmaxsize attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timezonelistmaxsize attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1419,94 +1311,90 @@ suspend fun readTimeZoneListMaxSizeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timezonelistmaxsize attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Timezonelistmaxsize attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDSTOffsetListMaxSizeAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 11u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDSTOffsetListMaxSizeAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dstoffsetlistmaxsize attribute not found in response" - } + } + + requireNotNull(attributeData) { "Dstoffsetlistmaxsize attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1516,94 +1404,90 @@ suspend fun readDSTOffsetListMaxSizeAttribute(): UByte? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Dstoffsetlistmaxsize attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Dstoffsetlistmaxsize attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSupportsDNSResolveAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 12u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSupportsDNSResolveAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportsdnsresolve attribute not found in response" - } + } + + requireNotNull(attributeData) { "Supportsdnsresolve attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } @@ -1613,96 +1497,92 @@ suspend fun readSupportsDNSResolveAttribute(): Boolean? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Supportsdnsresolve attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Supportsdnsresolve attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1712,45 +1592,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1758,49 +1643,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1810,45 +1689,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1856,49 +1740,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1908,45 +1786,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1954,49 +1835,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2006,45 +1881,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2052,44 +1930,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2098,35 +1969,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2138,44 +2011,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2184,34 +2050,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2224,7 +2094,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt index e974a2ed351918..c019d26a8a29bf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TimerCluster.kt @@ -17,110 +17,78 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimerCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class TimerCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun setTimer(newTime: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun setTimer(newTime: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NEW_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_NEW_TIME_REQ), newTime) + tlvWriter.put(ContextSpecificTag(TAG_NEW_TIME_REQ), newTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -138,7 +106,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -152,15 +120,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun addTime(additionalTime: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun addTime(additionalTime: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 2u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ADDITIONAL_TIME_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ADDITIONAL_TIME_REQ), additionalTime) + tlvWriter.put(ContextSpecificTag(TAG_ADDITIONAL_TIME_REQ), additionalTime) tlvWriter.endStructure() val request: InvokeRequest = @@ -174,15 +141,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun reduceTime(timeReduction: UInt - ,timedInvokeTimeout: Duration? = null) { + suspend fun reduceTime(timeReduction: UInt, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TIME_REDUCTION_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TIME_REDUCTION_REQ), timeReduction) + tlvWriter.put(ContextSpecificTag(TAG_TIME_REDUCTION_REQ), timeReduction) tlvWriter.endStructure() val request: InvokeRequest = @@ -195,42 +161,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readSetTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSetTimeAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Settime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Settime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -239,35 +198,37 @@ suspend fun readSetTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Settime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Settime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -279,44 +240,37 @@ suspend fun readSetTimeAttribute(): UInt {val ATTRIBUTE_ID: UInt = 0u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimeRemainingAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimeRemainingAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timeremaining attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timeremaining attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -325,35 +279,37 @@ suspend fun readTimeRemainingAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timeremaining attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Timeremaining attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -365,44 +321,37 @@ suspend fun readTimeRemainingAttribute(): UInt {val ATTRIBUTE_ID: UInt = 1u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimerStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTimerStateAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timerstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timerstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -411,35 +360,37 @@ suspend fun readTimerStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timerstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Timerstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -451,49 +402,43 @@ suspend fun readTimerStateAttribute(): UByte {val ATTRIBUTE_ID: UInt = 2u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -503,45 +448,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -549,49 +499,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -601,45 +545,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -647,49 +596,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -699,45 +642,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -745,49 +691,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -797,45 +737,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -843,44 +786,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -889,35 +825,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -929,44 +867,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -975,34 +906,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1015,7 +950,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt index acddad214ee5bc..5ff5251fad8295 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/TotalVolatileOrganicCompoundsConcentrationMeasurementCluster.kt @@ -17,209 +17,156 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.FloatSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster(private val controller: MatterController, private val endpointId: UShort) {class MeasuredValueAttribute( - val value: Float? - ) +class TotalVolatileOrganicCompoundsConcentrationMeasurementCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class MeasuredValueAttribute(val value: Float?) sealed class MeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() - } -class MinMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MeasuredValueAttributeSubscriptionState() + } + + class MinMeasuredValueAttribute(val value: Float?) sealed class MinMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MinMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MinMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MinMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() - } -class MaxMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MinMeasuredValueAttributeSubscriptionState() + } + + class MaxMeasuredValueAttribute(val value: Float?) sealed class MaxMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : MaxMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : MaxMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : MaxMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() - } -class PeakMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : MaxMeasuredValueAttributeSubscriptionState() + } + + class PeakMeasuredValueAttribute(val value: Float?) sealed class PeakMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : PeakMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : PeakMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : PeakMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() - } -class AverageMeasuredValueAttribute( - val value: Float? - ) + object SubscriptionEstablished : PeakMeasuredValueAttributeSubscriptionState() + } + + class AverageMeasuredValueAttribute(val value: Float?) sealed class AverageMeasuredValueAttributeSubscriptionState { - data class Success( - val value: Float? - ) : AverageMeasuredValueAttributeSubscriptionState() - + data class Success(val value: Float?) : AverageMeasuredValueAttributeSubscriptionState() + data class Error(val exception: Exception) : AverageMeasuredValueAttributeSubscriptionState() - object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : AverageMeasuredValueAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MeasuredValueAttribute(decodedValue) } @@ -229,104 +176,98 @@ suspend fun readMeasuredValueAttribute(): MeasuredValueAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measuredvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Measuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Minmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MinMeasuredValueAttribute(decodedValue) } @@ -336,104 +277,100 @@ suspend fun readMinMeasuredValueAttribute(): MinMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MinMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MinMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Minmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Minmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MinMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MinMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Maxmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return MaxMeasuredValueAttribute(decodedValue) } @@ -443,104 +380,100 @@ suspend fun readMaxMeasuredValueAttribute(): MaxMeasuredValueAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(MaxMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + MaxMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Maxmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Maxmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(MaxMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(MaxMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PeakMeasuredValueAttribute(decodedValue) } @@ -550,99 +483,95 @@ suspend fun readPeakMeasuredValueAttribute(): PeakMeasuredValueAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PeakMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PeakMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PeakMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PeakMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPeakMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Peakmeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -652,99 +581,95 @@ suspend fun readPeakMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UIn maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Peakmeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Peakmeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AverageMeasuredValueAttribute(decodedValue) } @@ -754,99 +679,95 @@ suspend fun readAverageMeasuredValueAttribute(): AverageMeasuredValueAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AverageMeasuredValueAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AverageMeasuredValueAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvalue attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AverageMeasuredValueAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AverageMeasuredValueAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAverageMeasuredValueWindowAttribute(): UInt? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in response" - } + } + + requireNotNull(attributeData) { "Averagemeasuredvaluewindow attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } return decodedValue } @@ -856,94 +777,90 @@ suspend fun readAverageMeasuredValueWindowAttribute(): UInt? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Averagemeasuredvaluewindow attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Averagemeasuredvaluewindow attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UIntSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UIntSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readUncertaintyAttribute(): Float? { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in response" - } + } + + requireNotNull(attributeData) { "Uncertainty attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } return decodedValue } @@ -953,94 +870,88 @@ suspend fun readUncertaintyAttribute(): Float? {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Uncertainty attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Uncertainty attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getFloat(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(FloatSubscriptionState.Success(it)) - } - + val decodedValue: Float? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getFloat(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(FloatSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1050,94 +961,90 @@ suspend fun readMeasurementUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readMeasurementMediumAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in response" - } + } + + requireNotNull(attributeData) { "Measurementmedium attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1147,94 +1054,90 @@ suspend fun readMeasurementMediumAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 9 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Measurementmedium attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Measurementmedium attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelValueAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelvalue attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1244,96 +1147,90 @@ suspend fun readLevelValueAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelvalue attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelvalue attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1343,45 +1240,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1389,49 +1291,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1441,45 +1337,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1487,49 +1388,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1539,45 +1434,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1585,49 +1483,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1637,45 +1529,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1683,44 +1578,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1729,35 +1617,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1769,44 +1659,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1815,34 +1698,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1855,11 +1742,14 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { - private val logger = Logger.getLogger(TotalVolatileOrganicCompoundsConcentrationMeasurementCluster::class.java.name) + private val logger = + Logger.getLogger( + TotalVolatileOrganicCompoundsConcentrationMeasurementCluster::class.java.name + ) const val CLUSTER_ID: UInt = 1070u } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt index 7d5cb6ca7abba9..36c750385a9bd6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitLocalizationCluster.kt @@ -17,163 +17,124 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitLocalizationCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class UnitLocalizationCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readTemperatureUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readTemperatureUnitAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperatureunit attribute not found in response" - } + } + + requireNotNull(attributeData) { "Temperatureunit attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeTemperatureUnitAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeTemperatureUnitAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -195,7 +156,7 @@ suspend fun readTemperatureUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTemperatureUnitAttribute( @@ -203,96 +164,92 @@ suspend fun readTemperatureUnitAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Temperatureunit attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Temperatureunit attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -302,45 +259,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -348,49 +310,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -400,45 +356,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -446,49 +407,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -498,45 +453,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -544,49 +502,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -596,45 +548,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -642,44 +597,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -688,35 +636,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -728,44 +678,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -774,34 +717,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -814,7 +761,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt index cfc1bf1fe749aa..468d4e4b310802 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UnitTestingCluster.kt @@ -17,714 +17,571 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.BooleanSubscriptionState +import matter.controller.ByteArraySubscriptionState +import matter.controller.ByteSubscriptionState +import matter.controller.DoubleSubscriptionState +import matter.controller.FloatSubscriptionState +import matter.controller.IntSubscriptionState +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse +import matter.controller.LongSubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.ShortSubscriptionState +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter class UnitTestingCluster(private val controller: MatterController, private val endpointId: UShort) { - class TestSpecificResponse( - val returnValue: UByte - ) + class TestSpecificResponse(val returnValue: UByte) - class TestAddArgumentsResponse( - val returnValue: UByte - ) + class TestAddArgumentsResponse(val returnValue: UByte) - class TestSimpleArgumentResponse( - val returnValue: Boolean - ) + class TestSimpleArgumentResponse(val returnValue: Boolean) class TestStructArrayArgumentResponse( - val arg1: List, - val arg2: List, - val arg3: List, - val arg4: List, - val arg5: UByte, + val arg1: List, + val arg2: List, + val arg3: List, + val arg4: List, + val arg5: UByte, val arg6: Boolean ) - class BooleanResponse( - val value: Boolean - ) + class BooleanResponse(val value: Boolean) - class TestListInt8UReverseResponse( - val arg1: List - ) + class TestListInt8UReverseResponse(val arg1: List) - class TestEnumsResponse( - val arg1: UShort, - val arg2: UByte - ) + class TestEnumsResponse(val arg1: UShort, val arg2: UByte) class TestNullableOptionalResponse( - val wasPresent: Boolean, - val wasNull: Boolean?, - val value: UByte?, + val wasPresent: Boolean, + val wasNull: Boolean?, + val value: UByte?, val originalValue: UByte? ) class TestComplexNullableOptionalResponse( - val nullableIntWasNull: Boolean, - val nullableIntValue: UShort?, - val optionalIntWasPresent: Boolean, - val optionalIntValue: UShort?, - val nullableOptionalIntWasPresent: Boolean, - val nullableOptionalIntWasNull: Boolean?, - val nullableOptionalIntValue: UShort?, - val nullableStringWasNull: Boolean, - val nullableStringValue: String?, - val optionalStringWasPresent: Boolean, - val optionalStringValue: String?, - val nullableOptionalStringWasPresent: Boolean, - val nullableOptionalStringWasNull: Boolean?, - val nullableOptionalStringValue: String?, - val nullableStructWasNull: Boolean, - val nullableStructValue: UnitTestingClusterSimpleStruct?, - val optionalStructWasPresent: Boolean, - val optionalStructValue: UnitTestingClusterSimpleStruct?, - val nullableOptionalStructWasPresent: Boolean, - val nullableOptionalStructWasNull: Boolean?, - val nullableOptionalStructValue: UnitTestingClusterSimpleStruct?, - val nullableListWasNull: Boolean, - val nullableListValue: List?, - val optionalListWasPresent: Boolean, - val optionalListValue: List?, - val nullableOptionalListWasPresent: Boolean, - val nullableOptionalListWasNull: Boolean?, + val nullableIntWasNull: Boolean, + val nullableIntValue: UShort?, + val optionalIntWasPresent: Boolean, + val optionalIntValue: UShort?, + val nullableOptionalIntWasPresent: Boolean, + val nullableOptionalIntWasNull: Boolean?, + val nullableOptionalIntValue: UShort?, + val nullableStringWasNull: Boolean, + val nullableStringValue: String?, + val optionalStringWasPresent: Boolean, + val optionalStringValue: String?, + val nullableOptionalStringWasPresent: Boolean, + val nullableOptionalStringWasNull: Boolean?, + val nullableOptionalStringValue: String?, + val nullableStructWasNull: Boolean, + val nullableStructValue: UnitTestingClusterSimpleStruct?, + val optionalStructWasPresent: Boolean, + val optionalStructValue: UnitTestingClusterSimpleStruct?, + val nullableOptionalStructWasPresent: Boolean, + val nullableOptionalStructWasNull: Boolean?, + val nullableOptionalStructValue: UnitTestingClusterSimpleStruct?, + val nullableListWasNull: Boolean, + val nullableListValue: List?, + val optionalListWasPresent: Boolean, + val optionalListValue: List?, + val nullableOptionalListWasPresent: Boolean, + val nullableOptionalListWasNull: Boolean?, val nullableOptionalListValue: List? ) - class SimpleStructResponse( - val arg1: UnitTestingClusterSimpleStruct - ) + class SimpleStructResponse(val arg1: UnitTestingClusterSimpleStruct) - class TestEmitTestEventResponse( - val value: ULong - ) + class TestEmitTestEventResponse(val value: ULong) - class TestEmitTestFabricScopedEventResponse( - val value: ULong - ) + class TestEmitTestFabricScopedEventResponse(val value: ULong) - class TestBatchHelperResponse( - val buffer: ByteArray - ) -class ListInt8uAttribute( - val value: List - ) + class TestBatchHelperResponse(val buffer: ByteArray) + + class ListInt8uAttribute(val value: List) sealed class ListInt8uAttributeSubscriptionState { - data class Success( - val value: List - ) : ListInt8uAttributeSubscriptionState() - + data class Success(val value: List) : ListInt8uAttributeSubscriptionState() + data class Error(val exception: Exception) : ListInt8uAttributeSubscriptionState() - object SubscriptionEstablished : ListInt8uAttributeSubscriptionState() - } -class ListOctetStringAttribute( - val value: List - ) + object SubscriptionEstablished : ListInt8uAttributeSubscriptionState() + } + + class ListOctetStringAttribute(val value: List) sealed class ListOctetStringAttributeSubscriptionState { - data class Success( - val value: List - ) : ListOctetStringAttributeSubscriptionState() - + data class Success(val value: List) : ListOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : ListOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : ListOctetStringAttributeSubscriptionState() - } -class ListStructOctetStringAttribute( - val value: List - ) + object SubscriptionEstablished : ListOctetStringAttributeSubscriptionState() + } + + class ListStructOctetStringAttribute(val value: List) sealed class ListStructOctetStringAttributeSubscriptionState { - data class Success( - val value: List - ) : ListStructOctetStringAttributeSubscriptionState() - + data class Success(val value: List) : + ListStructOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : ListStructOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : ListStructOctetStringAttributeSubscriptionState() - } -class ListNullablesAndOptionalsStructAttribute( + object SubscriptionEstablished : ListStructOctetStringAttributeSubscriptionState() + } + + class ListNullablesAndOptionalsStructAttribute( val value: List ) sealed class ListNullablesAndOptionalsStructAttributeSubscriptionState { - data class Success( - val value: List - ) : ListNullablesAndOptionalsStructAttributeSubscriptionState() - - data class Error(val exception: Exception) : ListNullablesAndOptionalsStructAttributeSubscriptionState() - - object SubscriptionEstablished : ListNullablesAndOptionalsStructAttributeSubscriptionState() - } -class StructAttrAttribute( - val value: UnitTestingClusterSimpleStruct - ) + data class Success(val value: List) : + ListNullablesAndOptionalsStructAttributeSubscriptionState() + + data class Error(val exception: Exception) : + ListNullablesAndOptionalsStructAttributeSubscriptionState() + + object SubscriptionEstablished : ListNullablesAndOptionalsStructAttributeSubscriptionState() + } + + class StructAttrAttribute(val value: UnitTestingClusterSimpleStruct) sealed class StructAttrAttributeSubscriptionState { - data class Success( - val value: UnitTestingClusterSimpleStruct - ) : StructAttrAttributeSubscriptionState() - + data class Success(val value: UnitTestingClusterSimpleStruct) : + StructAttrAttributeSubscriptionState() + data class Error(val exception: Exception) : StructAttrAttributeSubscriptionState() - object SubscriptionEstablished : StructAttrAttributeSubscriptionState() - } -class ListLongOctetStringAttribute( - val value: List - ) + object SubscriptionEstablished : StructAttrAttributeSubscriptionState() + } + + class ListLongOctetStringAttribute(val value: List) sealed class ListLongOctetStringAttributeSubscriptionState { - data class Success( - val value: List - ) : ListLongOctetStringAttributeSubscriptionState() - + data class Success(val value: List) : + ListLongOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : ListLongOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : ListLongOctetStringAttributeSubscriptionState() - } -class ListFabricScopedAttribute( - val value: List - ) + object SubscriptionEstablished : ListLongOctetStringAttributeSubscriptionState() + } + + class ListFabricScopedAttribute(val value: List) sealed class ListFabricScopedAttributeSubscriptionState { - data class Success( - val value: List - ) : ListFabricScopedAttributeSubscriptionState() - + data class Success(val value: List) : + ListFabricScopedAttributeSubscriptionState() + data class Error(val exception: Exception) : ListFabricScopedAttributeSubscriptionState() - object SubscriptionEstablished : ListFabricScopedAttributeSubscriptionState() - } -class NullableBooleanAttribute( - val value: Boolean? - ) + object SubscriptionEstablished : ListFabricScopedAttributeSubscriptionState() + } + + class NullableBooleanAttribute(val value: Boolean?) sealed class NullableBooleanAttributeSubscriptionState { - data class Success( - val value: Boolean? - ) : NullableBooleanAttributeSubscriptionState() - + data class Success(val value: Boolean?) : NullableBooleanAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBooleanAttributeSubscriptionState() - object SubscriptionEstablished : NullableBooleanAttributeSubscriptionState() - } -class NullableBitmap8Attribute( - val value: UByte? - ) + object SubscriptionEstablished : NullableBooleanAttributeSubscriptionState() + } + + class NullableBitmap8Attribute(val value: UByte?) sealed class NullableBitmap8AttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NullableBitmap8AttributeSubscriptionState() - + data class Success(val value: UByte?) : NullableBitmap8AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap8AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap8AttributeSubscriptionState() - } -class NullableBitmap16Attribute( - val value: UShort? - ) + object SubscriptionEstablished : NullableBitmap8AttributeSubscriptionState() + } + + class NullableBitmap16Attribute(val value: UShort?) sealed class NullableBitmap16AttributeSubscriptionState { - data class Success( - val value: UShort? - ) : NullableBitmap16AttributeSubscriptionState() - + data class Success(val value: UShort?) : NullableBitmap16AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap16AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap16AttributeSubscriptionState() - } -class NullableBitmap32Attribute( - val value: UInt? - ) + object SubscriptionEstablished : NullableBitmap16AttributeSubscriptionState() + } + + class NullableBitmap32Attribute(val value: UInt?) sealed class NullableBitmap32AttributeSubscriptionState { - data class Success( - val value: UInt? - ) : NullableBitmap32AttributeSubscriptionState() - + data class Success(val value: UInt?) : NullableBitmap32AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap32AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap32AttributeSubscriptionState() - } -class NullableBitmap64Attribute( - val value: ULong? - ) + object SubscriptionEstablished : NullableBitmap32AttributeSubscriptionState() + } + + class NullableBitmap64Attribute(val value: ULong?) sealed class NullableBitmap64AttributeSubscriptionState { - data class Success( - val value: ULong? - ) : NullableBitmap64AttributeSubscriptionState() - + data class Success(val value: ULong?) : NullableBitmap64AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableBitmap64AttributeSubscriptionState() - object SubscriptionEstablished : NullableBitmap64AttributeSubscriptionState() - } -class NullableInt8uAttribute( - val value: UByte? - ) + object SubscriptionEstablished : NullableBitmap64AttributeSubscriptionState() + } + + class NullableInt8uAttribute(val value: UByte?) sealed class NullableInt8uAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NullableInt8uAttributeSubscriptionState() - + data class Success(val value: UByte?) : NullableInt8uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt8uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt8uAttributeSubscriptionState() - } -class NullableInt16uAttribute( - val value: UShort? - ) + object SubscriptionEstablished : NullableInt8uAttributeSubscriptionState() + } + + class NullableInt16uAttribute(val value: UShort?) sealed class NullableInt16uAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : NullableInt16uAttributeSubscriptionState() - + data class Success(val value: UShort?) : NullableInt16uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt16uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt16uAttributeSubscriptionState() - } -class NullableInt24uAttribute( - val value: UInt? - ) + object SubscriptionEstablished : NullableInt16uAttributeSubscriptionState() + } + + class NullableInt24uAttribute(val value: UInt?) sealed class NullableInt24uAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : NullableInt24uAttributeSubscriptionState() - + data class Success(val value: UInt?) : NullableInt24uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt24uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt24uAttributeSubscriptionState() - } -class NullableInt32uAttribute( - val value: UInt? - ) + object SubscriptionEstablished : NullableInt24uAttributeSubscriptionState() + } + + class NullableInt32uAttribute(val value: UInt?) sealed class NullableInt32uAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : NullableInt32uAttributeSubscriptionState() - + data class Success(val value: UInt?) : NullableInt32uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt32uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt32uAttributeSubscriptionState() - } -class NullableInt40uAttribute( - val value: ULong? - ) + object SubscriptionEstablished : NullableInt32uAttributeSubscriptionState() + } + + class NullableInt40uAttribute(val value: ULong?) sealed class NullableInt40uAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : NullableInt40uAttributeSubscriptionState() - + data class Success(val value: ULong?) : NullableInt40uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt40uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt40uAttributeSubscriptionState() - } -class NullableInt48uAttribute( - val value: ULong? - ) + object SubscriptionEstablished : NullableInt40uAttributeSubscriptionState() + } + + class NullableInt48uAttribute(val value: ULong?) sealed class NullableInt48uAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : NullableInt48uAttributeSubscriptionState() - + data class Success(val value: ULong?) : NullableInt48uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt48uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt48uAttributeSubscriptionState() - } -class NullableInt56uAttribute( - val value: ULong? - ) + object SubscriptionEstablished : NullableInt48uAttributeSubscriptionState() + } + + class NullableInt56uAttribute(val value: ULong?) sealed class NullableInt56uAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : NullableInt56uAttributeSubscriptionState() - + data class Success(val value: ULong?) : NullableInt56uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt56uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt56uAttributeSubscriptionState() - } -class NullableInt64uAttribute( - val value: ULong? - ) + object SubscriptionEstablished : NullableInt56uAttributeSubscriptionState() + } + + class NullableInt64uAttribute(val value: ULong?) sealed class NullableInt64uAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : NullableInt64uAttributeSubscriptionState() - + data class Success(val value: ULong?) : NullableInt64uAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt64uAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt64uAttributeSubscriptionState() - } -class NullableInt8sAttribute( - val value: Byte? - ) + object SubscriptionEstablished : NullableInt64uAttributeSubscriptionState() + } + + class NullableInt8sAttribute(val value: Byte?) sealed class NullableInt8sAttributeSubscriptionState { - data class Success( - val value: Byte? - ) : NullableInt8sAttributeSubscriptionState() - + data class Success(val value: Byte?) : NullableInt8sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt8sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt8sAttributeSubscriptionState() - } -class NullableInt16sAttribute( - val value: Short? - ) + object SubscriptionEstablished : NullableInt8sAttributeSubscriptionState() + } + + class NullableInt16sAttribute(val value: Short?) sealed class NullableInt16sAttributeSubscriptionState { - data class Success( - val value: Short? - ) : NullableInt16sAttributeSubscriptionState() - + data class Success(val value: Short?) : NullableInt16sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt16sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt16sAttributeSubscriptionState() - } -class NullableInt24sAttribute( - val value: Int? - ) + object SubscriptionEstablished : NullableInt16sAttributeSubscriptionState() + } + + class NullableInt24sAttribute(val value: Int?) sealed class NullableInt24sAttributeSubscriptionState { - data class Success( - val value: Int? - ) : NullableInt24sAttributeSubscriptionState() - + data class Success(val value: Int?) : NullableInt24sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt24sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt24sAttributeSubscriptionState() - } -class NullableInt32sAttribute( - val value: Int? - ) + object SubscriptionEstablished : NullableInt24sAttributeSubscriptionState() + } + + class NullableInt32sAttribute(val value: Int?) sealed class NullableInt32sAttributeSubscriptionState { - data class Success( - val value: Int? - ) : NullableInt32sAttributeSubscriptionState() - + data class Success(val value: Int?) : NullableInt32sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt32sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt32sAttributeSubscriptionState() - } -class NullableInt40sAttribute( - val value: Long? - ) + object SubscriptionEstablished : NullableInt32sAttributeSubscriptionState() + } + + class NullableInt40sAttribute(val value: Long?) sealed class NullableInt40sAttributeSubscriptionState { - data class Success( - val value: Long? - ) : NullableInt40sAttributeSubscriptionState() - + data class Success(val value: Long?) : NullableInt40sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt40sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt40sAttributeSubscriptionState() - } -class NullableInt48sAttribute( - val value: Long? - ) + object SubscriptionEstablished : NullableInt40sAttributeSubscriptionState() + } + + class NullableInt48sAttribute(val value: Long?) sealed class NullableInt48sAttributeSubscriptionState { - data class Success( - val value: Long? - ) : NullableInt48sAttributeSubscriptionState() - + data class Success(val value: Long?) : NullableInt48sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt48sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt48sAttributeSubscriptionState() - } -class NullableInt56sAttribute( - val value: Long? - ) + object SubscriptionEstablished : NullableInt48sAttributeSubscriptionState() + } + + class NullableInt56sAttribute(val value: Long?) sealed class NullableInt56sAttributeSubscriptionState { - data class Success( - val value: Long? - ) : NullableInt56sAttributeSubscriptionState() - + data class Success(val value: Long?) : NullableInt56sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt56sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt56sAttributeSubscriptionState() - } -class NullableInt64sAttribute( - val value: Long? - ) + object SubscriptionEstablished : NullableInt56sAttributeSubscriptionState() + } + + class NullableInt64sAttribute(val value: Long?) sealed class NullableInt64sAttributeSubscriptionState { - data class Success( - val value: Long? - ) : NullableInt64sAttributeSubscriptionState() - + data class Success(val value: Long?) : NullableInt64sAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableInt64sAttributeSubscriptionState() - object SubscriptionEstablished : NullableInt64sAttributeSubscriptionState() - } -class NullableEnum8Attribute( - val value: UByte? - ) + object SubscriptionEstablished : NullableInt64sAttributeSubscriptionState() + } + + class NullableEnum8Attribute(val value: UByte?) sealed class NullableEnum8AttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NullableEnum8AttributeSubscriptionState() - + data class Success(val value: UByte?) : NullableEnum8AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableEnum8AttributeSubscriptionState() - object SubscriptionEstablished : NullableEnum8AttributeSubscriptionState() - } -class NullableEnum16Attribute( - val value: UShort? - ) + object SubscriptionEstablished : NullableEnum8AttributeSubscriptionState() + } + + class NullableEnum16Attribute(val value: UShort?) sealed class NullableEnum16AttributeSubscriptionState { - data class Success( - val value: UShort? - ) : NullableEnum16AttributeSubscriptionState() - + data class Success(val value: UShort?) : NullableEnum16AttributeSubscriptionState() + data class Error(val exception: Exception) : NullableEnum16AttributeSubscriptionState() - object SubscriptionEstablished : NullableEnum16AttributeSubscriptionState() - } -class NullableFloatSingleAttribute( - val value: Float? - ) + object SubscriptionEstablished : NullableEnum16AttributeSubscriptionState() + } + + class NullableFloatSingleAttribute(val value: Float?) sealed class NullableFloatSingleAttributeSubscriptionState { - data class Success( - val value: Float? - ) : NullableFloatSingleAttributeSubscriptionState() - + data class Success(val value: Float?) : NullableFloatSingleAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableFloatSingleAttributeSubscriptionState() - object SubscriptionEstablished : NullableFloatSingleAttributeSubscriptionState() - } -class NullableFloatDoubleAttribute( - val value: Double? - ) + object SubscriptionEstablished : NullableFloatSingleAttributeSubscriptionState() + } + + class NullableFloatDoubleAttribute(val value: Double?) sealed class NullableFloatDoubleAttributeSubscriptionState { - data class Success( - val value: Double? - ) : NullableFloatDoubleAttributeSubscriptionState() - + data class Success(val value: Double?) : NullableFloatDoubleAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableFloatDoubleAttributeSubscriptionState() - object SubscriptionEstablished : NullableFloatDoubleAttributeSubscriptionState() - } -class NullableOctetStringAttribute( - val value: ByteArray? - ) + object SubscriptionEstablished : NullableFloatDoubleAttributeSubscriptionState() + } + + class NullableOctetStringAttribute(val value: ByteArray?) sealed class NullableOctetStringAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : NullableOctetStringAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : NullableOctetStringAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableOctetStringAttributeSubscriptionState() - object SubscriptionEstablished : NullableOctetStringAttributeSubscriptionState() - } -class NullableCharStringAttribute( - val value: String? - ) + object SubscriptionEstablished : NullableOctetStringAttributeSubscriptionState() + } + + class NullableCharStringAttribute(val value: String?) sealed class NullableCharStringAttributeSubscriptionState { - data class Success( - val value: String? - ) : NullableCharStringAttributeSubscriptionState() - + data class Success(val value: String?) : NullableCharStringAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableCharStringAttributeSubscriptionState() - object SubscriptionEstablished : NullableCharStringAttributeSubscriptionState() - } -class NullableEnumAttrAttribute( - val value: UByte? - ) + object SubscriptionEstablished : NullableCharStringAttributeSubscriptionState() + } + + class NullableEnumAttrAttribute(val value: UByte?) sealed class NullableEnumAttrAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NullableEnumAttrAttributeSubscriptionState() - + data class Success(val value: UByte?) : NullableEnumAttrAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableEnumAttrAttributeSubscriptionState() - object SubscriptionEstablished : NullableEnumAttrAttributeSubscriptionState() - } -class NullableStructAttribute( - val value: UnitTestingClusterSimpleStruct? - ) + object SubscriptionEstablished : NullableEnumAttrAttributeSubscriptionState() + } + + class NullableStructAttribute(val value: UnitTestingClusterSimpleStruct?) sealed class NullableStructAttributeSubscriptionState { - data class Success( - val value: UnitTestingClusterSimpleStruct? - ) : NullableStructAttributeSubscriptionState() - + data class Success(val value: UnitTestingClusterSimpleStruct?) : + NullableStructAttributeSubscriptionState() + data class Error(val exception: Exception) : NullableStructAttributeSubscriptionState() - object SubscriptionEstablished : NullableStructAttributeSubscriptionState() - } -class NullableRangeRestrictedInt8uAttribute( - val value: UByte? - ) + object SubscriptionEstablished : NullableStructAttributeSubscriptionState() + } + + class NullableRangeRestrictedInt8uAttribute(val value: UByte?) sealed class NullableRangeRestrictedInt8uAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : NullableRangeRestrictedInt8uAttributeSubscriptionState() - - data class Error(val exception: Exception) : NullableRangeRestrictedInt8uAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt8uAttributeSubscriptionState() - } -class NullableRangeRestrictedInt8sAttribute( - val value: Byte? - ) + data class Success(val value: UByte?) : + NullableRangeRestrictedInt8uAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NullableRangeRestrictedInt8uAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt8uAttributeSubscriptionState() + } + + class NullableRangeRestrictedInt8sAttribute(val value: Byte?) sealed class NullableRangeRestrictedInt8sAttributeSubscriptionState { - data class Success( - val value: Byte? - ) : NullableRangeRestrictedInt8sAttributeSubscriptionState() - - data class Error(val exception: Exception) : NullableRangeRestrictedInt8sAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt8sAttributeSubscriptionState() - } -class NullableRangeRestrictedInt16uAttribute( - val value: UShort? - ) + data class Success(val value: Byte?) : NullableRangeRestrictedInt8sAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NullableRangeRestrictedInt8sAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt8sAttributeSubscriptionState() + } + + class NullableRangeRestrictedInt16uAttribute(val value: UShort?) sealed class NullableRangeRestrictedInt16uAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : NullableRangeRestrictedInt16uAttributeSubscriptionState() - - data class Error(val exception: Exception) : NullableRangeRestrictedInt16uAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt16uAttributeSubscriptionState() - } -class NullableRangeRestrictedInt16sAttribute( - val value: Short? - ) + data class Success(val value: UShort?) : + NullableRangeRestrictedInt16uAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NullableRangeRestrictedInt16uAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt16uAttributeSubscriptionState() + } + + class NullableRangeRestrictedInt16sAttribute(val value: Short?) sealed class NullableRangeRestrictedInt16sAttributeSubscriptionState { - data class Success( - val value: Short? - ) : NullableRangeRestrictedInt16sAttributeSubscriptionState() - - data class Error(val exception: Exception) : NullableRangeRestrictedInt16sAttributeSubscriptionState() - - object SubscriptionEstablished : NullableRangeRestrictedInt16sAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: Short?) : + NullableRangeRestrictedInt16sAttributeSubscriptionState() + + data class Error(val exception: Exception) : + NullableRangeRestrictedInt16sAttributeSubscriptionState() + + object SubscriptionEstablished : NullableRangeRestrictedInt16sAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun test(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -742,7 +599,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -760,7 +617,7 @@ class AttributeListAttribute( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -777,39 +634,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getUByte(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } - tlvReader.exitContainer() - return TestSpecificResponse( - returnValue_decoded - ) + return TestSpecificResponse(returnValue_decoded) } suspend fun testUnknownCommand(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -823,9 +672,11 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun testAddArguments(arg1: UByte - ,arg2: UByte - ,timedInvokeTimeout: Duration? = null): TestAddArgumentsResponse { + suspend fun testAddArguments( + arg1: UByte, + arg2: UByte, + timedInvokeTimeout: Duration? = null + ): TestAddArgumentsResponse { val commandId: UInt = 4u val tlvWriter = TlvWriter() @@ -835,7 +686,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) val TAG_ARG2_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) tlvWriter.endStructure() val request: InvokeRequest = @@ -852,43 +703,37 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getUByte(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } - tlvReader.exitContainer() - return TestAddArgumentsResponse( - returnValue_decoded - ) + return TestAddArgumentsResponse(returnValue_decoded) } - suspend fun testSimpleArgumentRequest(arg1: Boolean - ,timedInvokeTimeout: Duration? = null): TestSimpleArgumentResponse { + suspend fun testSimpleArgumentRequest( + arg1: Boolean, + timedInvokeTimeout: Duration? = null + ): TestSimpleArgumentResponse { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) tlvWriter.endStructure() val request: InvokeRequest = @@ -905,41 +750,35 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_RETURN_VALUE: Int = 0 var returnValue_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) {returnValue_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_RETURN_VALUE)) { + returnValue_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (returnValue_decoded == null) { - throw IllegalStateException("returnValue not found in TLV") + throw IllegalStateException("returnValue not found in TLV") } - tlvReader.exitContainer() - return TestSimpleArgumentResponse( - returnValue_decoded - ) + return TestSimpleArgumentResponse(returnValue_decoded) } - suspend fun testStructArrayArgumentRequest(arg1: List - ,arg2: List - ,arg3: List - ,arg4: List - ,arg5: UByte - ,arg6: Boolean - ,timedInvokeTimeout: Duration? = null): TestStructArrayArgumentResponse { + suspend fun testStructArrayArgumentRequest( + arg1: List, + arg2: List, + arg3: List, + arg4: List, + arg5: UByte, + arg6: Boolean, + timedInvokeTimeout: Duration? = null + ): TestStructArrayArgumentResponse { val commandId: UInt = 6u val tlvWriter = TlvWriter() @@ -947,37 +786,37 @@ class AttributeListAttribute( val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_ARG2_REQ: Int = 1 tlvWriter.startArray(ContextSpecificTag(TAG_ARG2_REQ)) - for (item in arg2.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg2.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val TAG_ARG3_REQ: Int = 2 tlvWriter.startArray(ContextSpecificTag(TAG_ARG3_REQ)) - for (item in arg3.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg3.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val TAG_ARG4_REQ: Int = 3 tlvWriter.startArray(ContextSpecificTag(TAG_ARG4_REQ)) - for (item in arg4.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg4.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val TAG_ARG5_REQ: Int = 4 tlvWriter.put(ContextSpecificTag(TAG_ARG5_REQ), arg5) val TAG_ARG6_REQ: Int = 5 - tlvWriter.put(ContextSpecificTag(TAG_ARG6_REQ), arg6) + tlvWriter.put(ContextSpecificTag(TAG_ARG6_REQ), arg6) tlvWriter.endStructure() val request: InvokeRequest = @@ -994,100 +833,103 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: List? = null - + val TAG_ARG2: Int = 1 var arg2_decoded: List? = null - + val TAG_ARG3: Int = 2 var arg3_decoded: List? = null - + val TAG_ARG4: Int = 3 var arg4_decoded: List? = null - + val TAG_ARG5: Int = 4 var arg5_decoded: UByte? = null - + val TAG_ARG6: Int = 5 var arg6_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }} - - if (tag == ContextSpecificTag(TAG_ARG2)) {arg2_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }} - - if (tag == ContextSpecificTag(TAG_ARG3)) {arg3_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - }} - - if (tag == ContextSpecificTag(TAG_ARG4)) {arg4_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getBoolean(AnonymousTag)) - } - tlvReader.exitContainer() - }} - - if (tag == ContextSpecificTag(TAG_ARG5)) {arg5_decoded = tlvReader.getUByte(tag)} - - if (tag == ContextSpecificTag(TAG_ARG6)) {arg6_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG2)) { + arg2_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG3)) { + arg3_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG4)) { + arg4_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getBoolean(AnonymousTag)) + } + tlvReader.exitContainer() + } + } + + if (tag == ContextSpecificTag(TAG_ARG5)) { + arg5_decoded = tlvReader.getUByte(tag) + } + + if (tag == ContextSpecificTag(TAG_ARG6)) { + arg6_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } - - + if (arg2_decoded == null) { - throw IllegalStateException("arg2 not found in TLV") + throw IllegalStateException("arg2 not found in TLV") } - - + if (arg3_decoded == null) { - throw IllegalStateException("arg3 not found in TLV") + throw IllegalStateException("arg3 not found in TLV") } - - + if (arg4_decoded == null) { - throw IllegalStateException("arg4 not found in TLV") + throw IllegalStateException("arg4 not found in TLV") } - - + if (arg5_decoded == null) { - throw IllegalStateException("arg5 not found in TLV") + throw IllegalStateException("arg5 not found in TLV") } - - + if (arg6_decoded == null) { - throw IllegalStateException("arg6 not found in TLV") + throw IllegalStateException("arg6 not found in TLV") } - tlvReader.exitContainer() @@ -1101,15 +943,17 @@ class AttributeListAttribute( ) } - suspend fun testStructArgumentRequest(arg1: UnitTestingClusterSimpleStruct - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testStructArgumentRequest( + arg1: UnitTestingClusterSimpleStruct, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 7u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -1126,43 +970,37 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testNestedStructArgumentRequest(arg1: UnitTestingClusterNestedStruct - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testNestedStructArgumentRequest( + arg1: UnitTestingClusterNestedStruct, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -1179,36 +1017,30 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testListStructArgumentRequest(arg1: List - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testListStructArgumentRequest( + arg1: List, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 9u val tlvWriter = TlvWriter() @@ -1216,10 +1048,10 @@ class AttributeListAttribute( val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1236,36 +1068,30 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testListInt8UArgumentRequest(arg1: List - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testListInt8UArgumentRequest( + arg1: List, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 10u val tlvWriter = TlvWriter() @@ -1273,10 +1099,10 @@ class AttributeListAttribute( val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1293,43 +1119,37 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testNestedStructListArgumentRequest(arg1: UnitTestingClusterNestedStructList - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testNestedStructListArgumentRequest( + arg1: UnitTestingClusterNestedStructList, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 11u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -1346,36 +1166,30 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testListNestedStructListArgumentRequest(arg1: List - ,timedInvokeTimeout: Duration? = null): BooleanResponse { + suspend fun testListNestedStructListArgumentRequest( + arg1: List, + timedInvokeTimeout: Duration? = null + ): BooleanResponse { val commandId: UInt = 12u val tlvWriter = TlvWriter() @@ -1383,10 +1197,10 @@ class AttributeListAttribute( val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1403,36 +1217,30 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: Boolean? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getBoolean(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getBoolean(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return BooleanResponse( - value_decoded - ) + return BooleanResponse(value_decoded) } - suspend fun testListInt8UReverseRequest(arg1: List - ,timedInvokeTimeout: Duration? = null): TestListInt8UReverseResponse { + suspend fun testListInt8UReverseRequest( + arg1: List, + timedInvokeTimeout: Duration? = null + ): TestListInt8UReverseResponse { val commandId: UInt = 13u val tlvWriter = TlvWriter() @@ -1440,10 +1248,10 @@ class AttributeListAttribute( val TAG_ARG1_REQ: Int = 0 tlvWriter.startArray(ContextSpecificTag(TAG_ARG1_REQ)) - for (item in arg1.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in arg1.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() tlvWriter.endStructure() val request: InvokeRequest = @@ -1460,43 +1268,38 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - }} - - - else { + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { tlvReader.skipElement() } } - - if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } - tlvReader.exitContainer() - return TestListInt8UReverseResponse( - arg1_decoded - ) + return TestListInt8UReverseResponse(arg1_decoded) } - suspend fun testEnumsRequest(arg1: UShort - ,arg2: UByte - ,timedInvokeTimeout: Duration? = null): TestEnumsResponse { + suspend fun testEnumsRequest( + arg1: UShort, + arg2: UByte, + timedInvokeTimeout: Duration? = null + ): TestEnumsResponse { val commandId: UInt = 14u val tlvWriter = TlvWriter() @@ -1506,7 +1309,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) val TAG_ARG2_REQ: Int = 1 - tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) + tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) tlvWriter.endStructure() val request: InvokeRequest = @@ -1523,56 +1326,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: UShort? = null - + val TAG_ARG2: Int = 1 var arg2_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = tlvReader.getUShort(tag)} - - if (tag == ContextSpecificTag(TAG_ARG2)) {arg2_decoded = tlvReader.getUByte(tag)} - + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = tlvReader.getUShort(tag) + } - else { + if (tag == ContextSpecificTag(TAG_ARG2)) { + arg2_decoded = tlvReader.getUByte(tag) + } else { tlvReader.skipElement() } } - - if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } - - + if (arg2_decoded == null) { - throw IllegalStateException("arg2 not found in TLV") + throw IllegalStateException("arg2 not found in TLV") } - tlvReader.exitContainer() - return TestEnumsResponse( - arg1_decoded, - arg2_decoded - ) + return TestEnumsResponse(arg1_decoded, arg2_decoded) } - suspend fun testNullableOptionalRequest(arg1: UByte? - ,timedInvokeTimeout: Duration? = null): TestNullableOptionalResponse { + suspend fun testNullableOptionalRequest( + arg1: UByte?, + timedInvokeTimeout: Duration? = null + ): TestNullableOptionalResponse { val commandId: UInt = 15u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1?.let { - tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) - } + arg1?.let { tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) } tlvWriter.endStructure() val request: InvokeRequest = @@ -1589,82 +1384,76 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_WAS_PRESENT: Int = 0 var wasPresent_decoded: Boolean? = null - + val TAG_WAS_NULL: Int = 1 var wasNull_decoded: Boolean? = null - + val TAG_VALUE: Int = 2 var value_decoded: UByte? = null - + val TAG_ORIGINAL_VALUE: Int = 3 var originalValue_decoded: UByte? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_WAS_PRESENT)) {wasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_WAS_NULL)) {wasNull_decoded = + if (tag == ContextSpecificTag(TAG_WAS_PRESENT)) { + wasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_WAS_NULL)) { + wasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_ORIGINAL_VALUE)) {originalValue_decoded = + tlvReader.getUByte(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_ORIGINAL_VALUE)) { + originalValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(tag)) { - tlvReader.getUByte(tag) - } else { - null - } - } else { - tlvReader.getNull(tag) - null - } - }} - - - else { + if (tlvReader.isNextTag(tag)) { + tlvReader.getUByte(tag) + } else { + null + } + } else { + tlvReader.getNull(tag) + null + } + } + } else { tlvReader.skipElement() } } - - if (wasPresent_decoded == null) { - throw IllegalStateException("wasPresent not found in TLV") + throw IllegalStateException("wasPresent not found in TLV") } - - - - - - - tlvReader.exitContainer() @@ -1676,33 +1465,31 @@ class AttributeListAttribute( ) } - suspend fun testComplexNullableOptionalRequest(nullableInt: UShort? - ,optionalInt: UShort? - ,nullableOptionalInt: UShort? - ,nullableString: String? - ,optionalString: String? - ,nullableOptionalString: String? - ,nullableStruct: UnitTestingClusterSimpleStruct? - ,optionalStruct: UnitTestingClusterSimpleStruct? - ,nullableOptionalStruct: UnitTestingClusterSimpleStruct? - ,nullableList: List? - ,optionalList: List? - ,nullableOptionalList: List? - ,timedInvokeTimeout: Duration? = null): TestComplexNullableOptionalResponse { + suspend fun testComplexNullableOptionalRequest( + nullableInt: UShort?, + optionalInt: UShort?, + nullableOptionalInt: UShort?, + nullableString: String?, + optionalString: String?, + nullableOptionalString: String?, + nullableStruct: UnitTestingClusterSimpleStruct?, + optionalStruct: UnitTestingClusterSimpleStruct?, + nullableOptionalStruct: UnitTestingClusterSimpleStruct?, + nullableList: List?, + optionalList: List?, + nullableOptionalList: List?, + timedInvokeTimeout: Duration? = null + ): TestComplexNullableOptionalResponse { val commandId: UInt = 16u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_NULLABLE_INT_REQ: Int = 0 - nullableInt?.let { - tlvWriter.put(ContextSpecificTag(TAG_NULLABLE_INT_REQ), nullableInt) - } + nullableInt?.let { tlvWriter.put(ContextSpecificTag(TAG_NULLABLE_INT_REQ), nullableInt) } val TAG_OPTIONAL_INT_REQ: Int = 1 - optionalInt?.let { - tlvWriter.put(ContextSpecificTag(TAG_OPTIONAL_INT_REQ), optionalInt) - } + optionalInt?.let { tlvWriter.put(ContextSpecificTag(TAG_OPTIONAL_INT_REQ), optionalInt) } val TAG_NULLABLE_OPTIONAL_INT_REQ: Int = 2 nullableOptionalInt?.let { @@ -1764,7 +1551,7 @@ class AttributeListAttribute( tlvWriter.put(AnonymousTag, item) } tlvWriter.endArray() - } + } tlvWriter.endStructure() val request: InvokeRequest = @@ -1781,426 +1568,431 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_NULLABLE_INT_WAS_NULL: Int = 0 var nullableIntWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_INT_VALUE: Int = 1 var nullableIntValue_decoded: UShort? = null - + val TAG_OPTIONAL_INT_WAS_PRESENT: Int = 2 var optionalIntWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_INT_VALUE: Int = 3 var optionalIntValue_decoded: UShort? = null - + val TAG_NULLABLE_OPTIONAL_INT_WAS_PRESENT: Int = 4 var nullableOptionalIntWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_INT_WAS_NULL: Int = 5 var nullableOptionalIntWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_INT_VALUE: Int = 6 var nullableOptionalIntValue_decoded: UShort? = null - + val TAG_NULLABLE_STRING_WAS_NULL: Int = 7 var nullableStringWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_STRING_VALUE: Int = 8 var nullableStringValue_decoded: String? = null - + val TAG_OPTIONAL_STRING_WAS_PRESENT: Int = 9 var optionalStringWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_STRING_VALUE: Int = 10 var optionalStringValue_decoded: String? = null - + val TAG_NULLABLE_OPTIONAL_STRING_WAS_PRESENT: Int = 11 var nullableOptionalStringWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRING_WAS_NULL: Int = 12 var nullableOptionalStringWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRING_VALUE: Int = 13 var nullableOptionalStringValue_decoded: String? = null - + val TAG_NULLABLE_STRUCT_WAS_NULL: Int = 14 var nullableStructWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_STRUCT_VALUE: Int = 15 var nullableStructValue_decoded: UnitTestingClusterSimpleStruct? = null - + val TAG_OPTIONAL_STRUCT_WAS_PRESENT: Int = 16 var optionalStructWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_STRUCT_VALUE: Int = 17 var optionalStructValue_decoded: UnitTestingClusterSimpleStruct? = null - + val TAG_NULLABLE_OPTIONAL_STRUCT_WAS_PRESENT: Int = 18 var nullableOptionalStructWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRUCT_WAS_NULL: Int = 19 var nullableOptionalStructWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_STRUCT_VALUE: Int = 20 var nullableOptionalStructValue_decoded: UnitTestingClusterSimpleStruct? = null - + val TAG_NULLABLE_LIST_WAS_NULL: Int = 21 var nullableListWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_LIST_VALUE: Int = 22 var nullableListValue_decoded: List? = null - + val TAG_OPTIONAL_LIST_WAS_PRESENT: Int = 23 var optionalListWasPresent_decoded: Boolean? = null - + val TAG_OPTIONAL_LIST_VALUE: Int = 24 var optionalListValue_decoded: List? = null - + val TAG_NULLABLE_OPTIONAL_LIST_WAS_PRESENT: Int = 25 var nullableOptionalListWasPresent_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_LIST_WAS_NULL: Int = 26 var nullableOptionalListWasNull_decoded: Boolean? = null - + val TAG_NULLABLE_OPTIONAL_LIST_VALUE: Int = 27 var nullableOptionalListValue_decoded: List? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_NULLABLE_INT_WAS_NULL)) {nullableIntWasNull_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_INT_VALUE)) {nullableIntValue_decoded = + if (tag == ContextSpecificTag(TAG_NULLABLE_INT_WAS_NULL)) { + nullableIntWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_INT_VALUE)) { + nullableIntValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_WAS_PRESENT)) {optionalIntWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_VALUE)) {optionalIntValue_decoded = + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_WAS_PRESENT)) { + optionalIntWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_INT_VALUE)) { + optionalIntValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_PRESENT)) {nullableOptionalIntWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_NULL)) {nullableOptionalIntWasNull_decoded = + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_PRESENT)) { + nullableOptionalIntWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_WAS_NULL)) { + nullableOptionalIntWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_VALUE)) {nullableOptionalIntValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT_VALUE)) { + nullableOptionalIntValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getUShort(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_WAS_NULL)) {nullableStringWasNull_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_VALUE)) {nullableStringValue_decoded = + tlvReader.getUShort(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_WAS_NULL)) { + nullableStringWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRING_VALUE)) { + nullableStringValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_WAS_PRESENT)) {optionalStringWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_VALUE)) {optionalStringValue_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_WAS_PRESENT)) { + optionalStringWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRING_VALUE)) { + optionalStringValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_PRESENT)) {nullableOptionalStringWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_NULL)) {nullableOptionalStringWasNull_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_PRESENT)) { + nullableOptionalStringWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_WAS_NULL)) { + nullableOptionalStringWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_VALUE)) {nullableOptionalStringValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING_VALUE)) { + nullableOptionalStringValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getString(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_WAS_NULL)) {nullableStructWasNull_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_VALUE)) {nullableStructValue_decoded = + tlvReader.getString(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_WAS_NULL)) { + nullableStructWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_STRUCT_VALUE)) { + nullableStructValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_WAS_PRESENT)) {optionalStructWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_VALUE)) {optionalStructValue_decoded = + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_WAS_PRESENT)) { + optionalStructWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_STRUCT_VALUE)) { + optionalStructValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_PRESENT)) {nullableOptionalStructWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_NULL)) {nullableOptionalStructWasNull_decoded = + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_PRESENT)) { + nullableOptionalStructWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_WAS_NULL)) { + nullableOptionalStructWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_VALUE)) {nullableOptionalStructValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT_VALUE)) { + nullableOptionalStructValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_WAS_NULL)) {nullableListWasNull_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_VALUE)) {nullableListValue_decoded = + UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_WAS_NULL)) { + nullableListWasNull_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_LIST_VALUE)) { + nullableListValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_WAS_PRESENT)) {optionalListWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_VALUE)) {optionalListValue_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_WAS_PRESENT)) { + optionalListWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_OPTIONAL_LIST_VALUE)) { + optionalListValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_PRESENT)) {nullableOptionalListWasPresent_decoded = tlvReader.getBoolean(tag)} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_NULL)) {nullableOptionalListWasNull_decoded = + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_PRESENT)) { + nullableOptionalListWasPresent_decoded = tlvReader.getBoolean(tag) + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_WAS_NULL)) { + nullableOptionalListWasNull_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - tlvReader.getBoolean(tag) - } else { - null - } - }} - - if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_VALUE)) {nullableOptionalListValue_decoded = + tlvReader.getBoolean(tag) + } else { + null + } + } + } + + if (tag == ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST_VALUE)) { + nullableOptionalListValue_decoded = if (tlvReader.isNull()) { tlvReader.getNull(tag) null } else { if (tlvReader.isNextTag(tag)) { - buildList { - tlvReader.enterArray(tag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - null - } - }} - - - else { + buildList { + tlvReader.enterArray(tag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + null + } + } + } else { tlvReader.skipElement() } } - - if (nullableIntWasNull_decoded == null) { - throw IllegalStateException("nullableIntWasNull not found in TLV") + throw IllegalStateException("nullableIntWasNull not found in TLV") } - - - - + if (optionalIntWasPresent_decoded == null) { - throw IllegalStateException("optionalIntWasPresent not found in TLV") + throw IllegalStateException("optionalIntWasPresent not found in TLV") } - - - - + if (nullableOptionalIntWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalIntWasPresent not found in TLV") - } - - - - - - + throw IllegalStateException("nullableOptionalIntWasPresent not found in TLV") + } + if (nullableStringWasNull_decoded == null) { - throw IllegalStateException("nullableStringWasNull not found in TLV") + throw IllegalStateException("nullableStringWasNull not found in TLV") } - - - - + if (optionalStringWasPresent_decoded == null) { - throw IllegalStateException("optionalStringWasPresent not found in TLV") + throw IllegalStateException("optionalStringWasPresent not found in TLV") } - - - - + if (nullableOptionalStringWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalStringWasPresent not found in TLV") - } - - - - - - + throw IllegalStateException("nullableOptionalStringWasPresent not found in TLV") + } + if (nullableStructWasNull_decoded == null) { - throw IllegalStateException("nullableStructWasNull not found in TLV") + throw IllegalStateException("nullableStructWasNull not found in TLV") } - - - - + if (optionalStructWasPresent_decoded == null) { - throw IllegalStateException("optionalStructWasPresent not found in TLV") + throw IllegalStateException("optionalStructWasPresent not found in TLV") } - - - - + if (nullableOptionalStructWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalStructWasPresent not found in TLV") - } - - - - - - + throw IllegalStateException("nullableOptionalStructWasPresent not found in TLV") + } + if (nullableListWasNull_decoded == null) { - throw IllegalStateException("nullableListWasNull not found in TLV") + throw IllegalStateException("nullableListWasNull not found in TLV") } - - - - + if (optionalListWasPresent_decoded == null) { - throw IllegalStateException("optionalListWasPresent not found in TLV") + throw IllegalStateException("optionalListWasPresent not found in TLV") } - - - - + if (nullableOptionalListWasPresent_decoded == null) { - throw IllegalStateException("nullableOptionalListWasPresent not found in TLV") + throw IllegalStateException("nullableOptionalListWasPresent not found in TLV") } - - - - - tlvReader.exitContainer() @@ -2236,15 +2028,17 @@ class AttributeListAttribute( ) } - suspend fun simpleStructEchoRequest(arg1: UnitTestingClusterSimpleStruct - ,timedInvokeTimeout: Duration? = null): SimpleStructResponse { + suspend fun simpleStructEchoRequest( + arg1: UnitTestingClusterSimpleStruct, + timedInvokeTimeout: Duration? = null + ): SimpleStructResponse { val commandId: UInt = 17u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) + arg1.toTlv(ContextSpecificTag(TAG_ARG1_REQ), tlvWriter) tlvWriter.endStructure() val request: InvokeRequest = @@ -2261,39 +2055,31 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_ARG1: Int = 0 var arg1_decoded: UnitTestingClusterSimpleStruct? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_ARG1)) {arg1_decoded = UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader)} - - - else { + if (tag == ContextSpecificTag(TAG_ARG1)) { + arg1_decoded = UnitTestingClusterSimpleStruct.fromTlv(tag, tlvReader) + } else { tlvReader.skipElement() } } - - if (arg1_decoded == null) { - throw IllegalStateException("arg1 not found in TLV") + throw IllegalStateException("arg1 not found in TLV") } - tlvReader.exitContainer() - return SimpleStructResponse( - arg1_decoded - ) + return SimpleStructResponse(arg1_decoded) } suspend fun timedInvokeRequest(timedInvokeTimeout: Duration) { val commandId: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -2307,17 +2093,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun testSimpleOptionalArgumentRequest(arg1: Boolean? - ,timedInvokeTimeout: Duration? = null) { + suspend fun testSimpleOptionalArgumentRequest( + arg1: Boolean?, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 19u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - arg1?.let { - tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) - } + arg1?.let { tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) } tlvWriter.endStructure() val request: InvokeRequest = @@ -2331,10 +2117,12 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun testEmitTestEventRequest(arg1: UByte - ,arg2: UByte - ,arg3: Boolean - ,timedInvokeTimeout: Duration? = null): TestEmitTestEventResponse { + suspend fun testEmitTestEventRequest( + arg1: UByte, + arg2: UByte, + arg3: Boolean, + timedInvokeTimeout: Duration? = null + ): TestEmitTestEventResponse { val commandId: UInt = 20u val tlvWriter = TlvWriter() @@ -2347,7 +2135,7 @@ class AttributeListAttribute( tlvWriter.put(ContextSpecificTag(TAG_ARG2_REQ), arg2) val TAG_ARG3_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_ARG3_REQ), arg3) + tlvWriter.put(ContextSpecificTag(TAG_ARG3_REQ), arg3) tlvWriter.endStructure() val request: InvokeRequest = @@ -2364,43 +2152,37 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: ULong? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getULong(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getULong(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return TestEmitTestEventResponse( - value_decoded - ) + return TestEmitTestEventResponse(value_decoded) } - suspend fun testEmitTestFabricScopedEventRequest(arg1: UByte - ,timedInvokeTimeout: Duration? = null): TestEmitTestFabricScopedEventResponse { + suspend fun testEmitTestFabricScopedEventRequest( + arg1: UByte, + timedInvokeTimeout: Duration? = null + ): TestEmitTestFabricScopedEventResponse { val commandId: UInt = 21u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_ARG1_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) + tlvWriter.put(ContextSpecificTag(TAG_ARG1_REQ), arg1) tlvWriter.endStructure() val request: InvokeRequest = @@ -2417,51 +2199,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_VALUE: Int = 0 var value_decoded: ULong? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_VALUE)) {value_decoded = tlvReader.getULong(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_VALUE)) { + value_decoded = tlvReader.getULong(tag) + } else { tlvReader.skipElement() } } - - if (value_decoded == null) { - throw IllegalStateException("value not found in TLV") + throw IllegalStateException("value not found in TLV") } - tlvReader.exitContainer() - return TestEmitTestFabricScopedEventResponse( - value_decoded - ) + return TestEmitTestFabricScopedEventResponse(value_decoded) } - suspend fun testBatchHelperRequest(sleepBeforeResponseTimeMs: UShort - ,sizeOfResponseBuffer: UShort - ,fillCharacter: UByte - ,timedInvokeTimeout: Duration? = null): TestBatchHelperResponse { + suspend fun testBatchHelperRequest( + sleepBeforeResponseTimeMs: UShort, + sizeOfResponseBuffer: UShort, + fillCharacter: UByte, + timedInvokeTimeout: Duration? = null + ): TestBatchHelperResponse { val commandId: UInt = 22u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), sleepBeforeResponseTimeMs) + tlvWriter.put( + ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), + sleepBeforeResponseTimeMs + ) val TAG_SIZE_OF_RESPONSE_BUFFER_REQ: Int = 1 tlvWriter.put(ContextSpecificTag(TAG_SIZE_OF_RESPONSE_BUFFER_REQ), sizeOfResponseBuffer) val TAG_FILL_CHARACTER_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) + tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) tlvWriter.endStructure() val request: InvokeRequest = @@ -2478,51 +2257,48 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_BUFFER: Int = 0 var buffer_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_BUFFER)) {buffer_decoded = tlvReader.getByteArray(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_BUFFER)) { + buffer_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (buffer_decoded == null) { - throw IllegalStateException("buffer not found in TLV") + throw IllegalStateException("buffer not found in TLV") } - tlvReader.exitContainer() - return TestBatchHelperResponse( - buffer_decoded - ) + return TestBatchHelperResponse(buffer_decoded) } - suspend fun testSecondBatchHelperRequest(sleepBeforeResponseTimeMs: UShort - ,sizeOfResponseBuffer: UShort - ,fillCharacter: UByte - ,timedInvokeTimeout: Duration? = null): TestBatchHelperResponse { + suspend fun testSecondBatchHelperRequest( + sleepBeforeResponseTimeMs: UShort, + sizeOfResponseBuffer: UShort, + fillCharacter: UByte, + timedInvokeTimeout: Duration? = null + ): TestBatchHelperResponse { val commandId: UInt = 23u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), sleepBeforeResponseTimeMs) + tlvWriter.put( + ContextSpecificTag(TAG_SLEEP_BEFORE_RESPONSE_TIME_MS_REQ), + sleepBeforeResponseTimeMs + ) val TAG_SIZE_OF_RESPONSE_BUFFER_REQ: Int = 1 tlvWriter.put(ContextSpecificTag(TAG_SIZE_OF_RESPONSE_BUFFER_REQ), sizeOfResponseBuffer) val TAG_FILL_CHARACTER_REQ: Int = 2 - tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) + tlvWriter.put(ContextSpecificTag(TAG_FILL_CHARACTER_REQ), fillCharacter) tlvWriter.endStructure() val request: InvokeRequest = @@ -2539,92 +2315,73 @@ class AttributeListAttribute( tlvReader.enterStructure(AnonymousTag) val TAG_BUFFER: Int = 0 var buffer_decoded: ByteArray? = null - while (!tlvReader.isEndOfContainer()) { val tag = tlvReader.peekElement().tag - - if (tag == ContextSpecificTag(TAG_BUFFER)) {buffer_decoded = tlvReader.getByteArray(tag)} - - - else { + if (tag == ContextSpecificTag(TAG_BUFFER)) { + buffer_decoded = tlvReader.getByteArray(tag) + } else { tlvReader.skipElement() } } - - if (buffer_decoded == null) { - throw IllegalStateException("buffer not found in TLV") + throw IllegalStateException("buffer not found in TLV") } - tlvReader.exitContainer() - return TestBatchHelperResponse( - buffer_decoded - ) + return TestBatchHelperResponse(buffer_decoded) } -suspend fun readBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Boolean attribute not found in response" - } + } + + requireNotNull(attributeData) { "Boolean attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writeBooleanAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeBooleanAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2646,7 +2403,7 @@ suspend fun readBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBooleanAttribute( @@ -2654,35 +2411,37 @@ suspend fun readBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Boolean attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Boolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2694,67 +2453,56 @@ suspend fun readBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 0u emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBitmap8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBitmap8Attribute(): UByte { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap8 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bitmap8 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeBitmap8Attribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2776,7 +2524,7 @@ suspend fun readBitmap8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 1u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap8Attribute( @@ -2784,35 +2532,37 @@ suspend fun readBitmap8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 1u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap8 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bitmap8 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2824,67 +2574,56 @@ suspend fun readBitmap8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 1u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBitmap16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBitmap16Attribute(): UShort { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap16 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bitmap16 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } - suspend fun writeBitmap16Attribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2906,7 +2645,7 @@ suspend fun readBitmap16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 2u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap16Attribute( @@ -2914,35 +2653,37 @@ suspend fun readBitmap16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 2u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap16 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bitmap16 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2954,67 +2695,56 @@ suspend fun readBitmap16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 2u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBitmap32Attribute(): UInt {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBitmap32Attribute(): UInt { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap32 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bitmap32 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } - suspend fun writeBitmap32Attribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap32Attribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 3u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3036,7 +2766,7 @@ suspend fun readBitmap32Attribute(): UInt {val ATTRIBUTE_ID: UInt = 3u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap32Attribute( @@ -3044,35 +2774,37 @@ suspend fun readBitmap32Attribute(): UInt {val ATTRIBUTE_ID: UInt = 3u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap32 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bitmap32 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3084,67 +2816,56 @@ suspend fun readBitmap32Attribute(): UInt {val ATTRIBUTE_ID: UInt = 3u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBitmap64Attribute(): ULong {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readBitmap64Attribute(): ULong { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap64 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bitmap64 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeBitmap64Attribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeBitmap64Attribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 4u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3166,7 +2887,7 @@ suspend fun readBitmap64Attribute(): ULong {val ATTRIBUTE_ID: UInt = 4u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeBitmap64Attribute( @@ -3174,35 +2895,37 @@ suspend fun readBitmap64Attribute(): ULong {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bitmap64 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bitmap64 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3214,67 +2937,56 @@ suspend fun readBitmap64Attribute(): ULong {val ATTRIBUTE_ID: UInt = 4u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt8uAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeInt8uAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt8uAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 5u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3296,7 +3008,7 @@ suspend fun readInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt8uAttribute( @@ -3304,35 +3016,37 @@ suspend fun readInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int8u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3344,67 +3058,56 @@ suspend fun readInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 5u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt16uAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int16u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int16u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } - suspend fun writeInt16uAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt16uAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 6u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3426,7 +3129,7 @@ suspend fun readInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt16uAttribute( @@ -3434,35 +3137,37 @@ suspend fun readInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int16u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int16u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3474,67 +3179,56 @@ suspend fun readInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 6u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt24uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt24uAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int24u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int24u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } - suspend fun writeInt24uAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt24uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 7u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3556,7 +3250,7 @@ suspend fun readInt24uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 7u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt24uAttribute( @@ -3564,35 +3258,37 @@ suspend fun readInt24uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int24u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int24u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3604,67 +3300,56 @@ suspend fun readInt24uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 7u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt32uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt32uAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int32u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int32u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } - suspend fun writeInt32uAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt32uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3686,7 +3371,7 @@ suspend fun readInt32uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 8u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt32uAttribute( @@ -3694,35 +3379,37 @@ suspend fun readInt32uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int32u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int32u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3734,67 +3421,56 @@ suspend fun readInt32uAttribute(): UInt {val ATTRIBUTE_ID: UInt = 8u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt40uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt40uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int40u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int40u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeInt40uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt40uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 9u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3816,7 +3492,7 @@ suspend fun readInt40uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 9u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt40uAttribute( @@ -3824,35 +3500,37 @@ suspend fun readInt40uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int40u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int40u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3864,67 +3542,56 @@ suspend fun readInt40uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 9u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt48uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt48uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int48u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int48u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeInt48uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt48uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 10u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -3946,7 +3613,7 @@ suspend fun readInt48uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 10u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt48uAttribute( @@ -3954,35 +3621,37 @@ suspend fun readInt48uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int48u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int48u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3994,67 +3663,56 @@ suspend fun readInt48uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 10u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt56uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt56uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int56u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int56u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeInt56uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt56uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 11u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4076,7 +3734,7 @@ suspend fun readInt56uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 11u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt56uAttribute( @@ -4084,35 +3742,37 @@ suspend fun readInt56uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 11u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int56u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int56u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4124,67 +3784,56 @@ suspend fun readInt56uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 11u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt64uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt64uAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int64u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int64u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeInt64uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt64uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 12u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4206,7 +3855,7 @@ suspend fun readInt64uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 12u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt64uAttribute( @@ -4214,35 +3863,37 @@ suspend fun readInt64uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 12u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int64u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int64u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4254,67 +3905,56 @@ suspend fun readInt64uAttribute(): ULong {val ATTRIBUTE_ID: UInt = 12u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 13u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt8sAttribute(): Byte { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int8s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int8s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Byte = tlvReader.getByte(AnonymousTag) - return decodedValue } - suspend fun writeInt8sAttribute( - value: Byte, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt8sAttribute(value: Byte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 13u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4336,7 +3976,7 @@ suspend fun readInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 13u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt8sAttribute( @@ -4344,35 +3984,37 @@ suspend fun readInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 13u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int8s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int8s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4384,67 +4026,56 @@ suspend fun readInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 13u emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 14u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt16sAttribute(): Short { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int16s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int16s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Short = tlvReader.getShort(AnonymousTag) - return decodedValue } - suspend fun writeInt16sAttribute( - value: Short, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt16sAttribute(value: Short, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 14u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4466,7 +4097,7 @@ suspend fun readInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 14u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt16sAttribute( @@ -4474,35 +4105,37 @@ suspend fun readInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 14u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int16s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int16s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4514,67 +4147,56 @@ suspend fun readInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 14u emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt24sAttribute(): Int {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt24sAttribute(): Int { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int24s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int24s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Int = tlvReader.getInt(AnonymousTag) - return decodedValue } - suspend fun writeInt24sAttribute( - value: Int, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt24sAttribute(value: Int, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 15u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4596,7 +4218,7 @@ suspend fun readInt24sAttribute(): Int {val ATTRIBUTE_ID: UInt = 15u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt24sAttribute( @@ -4604,35 +4226,37 @@ suspend fun readInt24sAttribute(): Int {val ATTRIBUTE_ID: UInt = 15u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + IntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int24s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int24s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4644,67 +4268,56 @@ suspend fun readInt24sAttribute(): Int {val ATTRIBUTE_ID: UInt = 15u emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt32sAttribute(): Int {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt32sAttribute(): Int { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int32s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int32s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Int = tlvReader.getInt(AnonymousTag) - return decodedValue } - suspend fun writeInt32sAttribute( - value: Int, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt32sAttribute(value: Int, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4726,7 +4339,7 @@ suspend fun readInt32sAttribute(): Int {val ATTRIBUTE_ID: UInt = 16u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt32sAttribute( @@ -4734,35 +4347,37 @@ suspend fun readInt32sAttribute(): Int {val ATTRIBUTE_ID: UInt = 16u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(IntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + IntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int32s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int32s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4774,67 +4389,56 @@ suspend fun readInt32sAttribute(): Int {val ATTRIBUTE_ID: UInt = 16u emit(IntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt40sAttribute(): Long {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt40sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int40s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int40s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } - suspend fun writeInt40sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt40sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 17u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4856,7 +4460,7 @@ suspend fun readInt40sAttribute(): Long {val ATTRIBUTE_ID: UInt = 17u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt40sAttribute( @@ -4864,35 +4468,37 @@ suspend fun readInt40sAttribute(): Long {val ATTRIBUTE_ID: UInt = 17u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int40s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int40s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -4904,67 +4510,56 @@ suspend fun readInt40sAttribute(): Long {val ATTRIBUTE_ID: UInt = 17u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt48sAttribute(): Long {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt48sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int48s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int48s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } - suspend fun writeInt48sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt48sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 18u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -4986,7 +4581,7 @@ suspend fun readInt48sAttribute(): Long {val ATTRIBUTE_ID: UInt = 18u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt48sAttribute( @@ -4994,35 +4589,37 @@ suspend fun readInt48sAttribute(): Long {val ATTRIBUTE_ID: UInt = 18u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int48s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int48s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5034,67 +4631,56 @@ suspend fun readInt48sAttribute(): Long {val ATTRIBUTE_ID: UInt = 18u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt56sAttribute(): Long {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt56sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int56s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int56s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } - suspend fun writeInt56sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt56sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 19u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5116,7 +4702,7 @@ suspend fun readInt56sAttribute(): Long {val ATTRIBUTE_ID: UInt = 19u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt56sAttribute( @@ -5124,35 +4710,37 @@ suspend fun readInt56sAttribute(): Long {val ATTRIBUTE_ID: UInt = 19u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int56s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int56s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5164,67 +4752,56 @@ suspend fun readInt56sAttribute(): Long {val ATTRIBUTE_ID: UInt = 19u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInt64sAttribute(): Long {val ATTRIBUTE_ID: UInt = 20u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInt64sAttribute(): Long { + val ATTRIBUTE_ID: UInt = 20u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int64s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Int64s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Long = tlvReader.getLong(AnonymousTag) - return decodedValue } - suspend fun writeInt64sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeInt64sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 20u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5246,7 +4823,7 @@ suspend fun readInt64sAttribute(): Long {val ATTRIBUTE_ID: UInt = 20u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeInt64sAttribute( @@ -5254,35 +4831,37 @@ suspend fun readInt64sAttribute(): Long {val ATTRIBUTE_ID: UInt = 20u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 20u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Int64s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Int64s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5294,67 +4873,56 @@ suspend fun readInt64sAttribute(): Long {val ATTRIBUTE_ID: UInt = 20u emit(LongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnum8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 21u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnum8Attribute(): UByte { + val ATTRIBUTE_ID: UInt = 21u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enum8 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enum8 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeEnum8Attribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeEnum8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 21u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5376,7 +4944,7 @@ suspend fun readEnum8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 21u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnum8Attribute( @@ -5384,35 +4952,37 @@ suspend fun readEnum8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 21u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 21u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enum8 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Enum8 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5424,67 +4994,56 @@ suspend fun readEnum8Attribute(): UByte {val ATTRIBUTE_ID: UInt = 21u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnum16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 22u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnum16Attribute(): UShort { + val ATTRIBUTE_ID: UInt = 22u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enum16 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enum16 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } - suspend fun writeEnum16Attribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeEnum16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 22u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5506,7 +5065,7 @@ suspend fun readEnum16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 22u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnum16Attribute( @@ -5514,35 +5073,37 @@ suspend fun readEnum16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 22u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 22u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enum16 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Enum16 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5554,67 +5115,56 @@ suspend fun readEnum16Attribute(): UShort {val ATTRIBUTE_ID: UInt = 22u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFloatSingleAttribute(): Float {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFloatSingleAttribute(): Float { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Floatsingle attribute not found in response" - } + } + + requireNotNull(attributeData) { "Floatsingle attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Float = tlvReader.getFloat(AnonymousTag) - return decodedValue } - suspend fun writeFloatSingleAttribute( - value: Float, - timedWriteTimeout: Duration? = null) { + suspend fun writeFloatSingleAttribute(value: Float, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5636,7 +5186,7 @@ suspend fun readFloatSingleAttribute(): Float {val ATTRIBUTE_ID: UInt = 23u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFloatSingleAttribute( @@ -5644,35 +5194,37 @@ suspend fun readFloatSingleAttribute(): Float {val ATTRIBUTE_ID: UInt = 23u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(FloatSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + FloatSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Floatsingle attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Floatsingle attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5684,67 +5236,56 @@ suspend fun readFloatSingleAttribute(): Float {val ATTRIBUTE_ID: UInt = 23u emit(FloatSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFloatDoubleAttribute(): Double {val ATTRIBUTE_ID: UInt = 24u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFloatDoubleAttribute(): Double { + val ATTRIBUTE_ID: UInt = 24u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Floatdouble attribute not found in response" - } + } + + requireNotNull(attributeData) { "Floatdouble attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Double = tlvReader.getDouble(AnonymousTag) - return decodedValue } - suspend fun writeFloatDoubleAttribute( - value: Double, - timedWriteTimeout: Duration? = null) { + suspend fun writeFloatDoubleAttribute(value: Double, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 24u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5766,7 +5307,7 @@ suspend fun readFloatDoubleAttribute(): Double {val ATTRIBUTE_ID: UInt = 24u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeFloatDoubleAttribute( @@ -5774,35 +5315,37 @@ suspend fun readFloatDoubleAttribute(): Double {val ATTRIBUTE_ID: UInt = 24u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 24u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DoubleSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DoubleSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Floatdouble attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Floatdouble attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5814,67 +5357,56 @@ suspend fun readFloatDoubleAttribute(): Double {val ATTRIBUTE_ID: UInt = 24u emit(DoubleSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 25u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOctetStringAttribute(): ByteArray { + val ATTRIBUTE_ID: UInt = 25u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Octetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Octetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ByteArray = tlvReader.getByteArray(AnonymousTag) - return decodedValue } - suspend fun writeOctetStringAttribute( - value: ByteArray, - timedWriteTimeout: Duration? = null) { + suspend fun writeOctetStringAttribute(value: ByteArray, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 25u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -5896,7 +5428,7 @@ suspend fun readOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 25u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeOctetStringAttribute( @@ -5904,35 +5436,37 @@ suspend fun readOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 25u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 25u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteArraySubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Octetstring attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Octetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -5944,77 +5478,67 @@ suspend fun readOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 25u emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListInt8uAttribute(): ListInt8uAttribute {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListInt8uAttribute(): ListInt8uAttribute { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listint8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Listint8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListInt8uAttribute(decodedValue) } - suspend fun writeListInt8uAttribute( - value: List, - timedWriteTimeout: Duration? = null) { + suspend fun writeListInt8uAttribute(value: List, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 26u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6036,7 +5560,7 @@ suspend fun readListInt8uAttribute(): ListInt8uAttribute {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListInt8uAttribute( @@ -6044,45 +5568,48 @@ suspend fun readListInt8uAttribute(): ListInt8uAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListInt8uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListInt8uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listint8u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Listint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ListInt8uAttributeSubscriptionState.Success(decodedValue)) } @@ -6090,77 +5617,70 @@ suspend fun readListInt8uAttribute(): ListInt8uAttribute {val ATTRIBUTE_ID: UInt emit(ListInt8uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListOctetStringAttribute(): ListOctetStringAttribute {val ATTRIBUTE_ID: UInt = 27u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListOctetStringAttribute(): ListOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 27u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listoctetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Listoctetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListOctetStringAttribute(decodedValue) } suspend fun writeListOctetStringAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 27u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6182,7 +5702,7 @@ suspend fun readListOctetStringAttribute(): ListOctetStringAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListOctetStringAttribute( @@ -6190,45 +5710,50 @@ suspend fun readListOctetStringAttribute(): ListOctetStringAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 27u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListOctetStringAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Listoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ListOctetStringAttributeSubscriptionState.Success(decodedValue)) } @@ -6236,77 +5761,70 @@ suspend fun readListOctetStringAttribute(): ListOctetStringAttribute {val ATTRIB emit(ListOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute {val ATTRIBUTE_ID: UInt = 28u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 28u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Liststructoctetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Liststructoctetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListStructOctetStringAttribute(decodedValue) } suspend fun writeListStructOctetStringAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 28u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6328,7 +5846,7 @@ suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListStructOctetStringAttribute( @@ -6336,45 +5854,50 @@ suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 28u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListStructOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListStructOctetStringAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Liststructoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Liststructoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestListStructOctet.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ListStructOctetStringAttributeSubscriptionState.Success(decodedValue)) } @@ -6382,67 +5905,56 @@ suspend fun readListStructOctetStringAttribute(): ListStructOctetStringAttribute emit(ListStructOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLongOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = 29u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLongOctetStringAttribute(): ByteArray { + val ATTRIBUTE_ID: UInt = 29u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Longoctetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Longoctetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ByteArray = tlvReader.getByteArray(AnonymousTag) - return decodedValue } - suspend fun writeLongOctetStringAttribute( - value: ByteArray, - timedWriteTimeout: Duration? = null) { + suspend fun writeLongOctetStringAttribute(value: ByteArray, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 29u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6464,7 +5976,7 @@ suspend fun readLongOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLongOctetStringAttribute( @@ -6472,34 +5984,38 @@ suspend fun readLongOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 29u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteArraySubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Longoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Longoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -6512,67 +6028,56 @@ suspend fun readLongOctetStringAttribute(): ByteArray {val ATTRIBUTE_ID: UInt = emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 30u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCharStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 30u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Charstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Charstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } - suspend fun writeCharStringAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeCharStringAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 30u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6594,7 +6099,7 @@ suspend fun readCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 30u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeCharStringAttribute( @@ -6602,35 +6107,37 @@ suspend fun readCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 30u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 30u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Charstring attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Charstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6642,67 +6149,56 @@ suspend fun readCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 30u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLongCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 31u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readLongCharStringAttribute(): String { + val ATTRIBUTE_ID: UInt = 31u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Longcharstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Longcharstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: String = tlvReader.getString(AnonymousTag) - return decodedValue } - suspend fun writeLongCharStringAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeLongCharStringAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 31u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6724,7 +6220,7 @@ suspend fun readLongCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 31u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLongCharStringAttribute( @@ -6732,34 +6228,38 @@ suspend fun readLongCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 31u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 31u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Longcharstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Longcharstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -6772,67 +6272,56 @@ suspend fun readLongCharStringAttribute(): String {val ATTRIBUTE_ID: UInt = 31u emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEpochUsAttribute(): ULong {val ATTRIBUTE_ID: UInt = 32u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEpochUsAttribute(): ULong { + val ATTRIBUTE_ID: UInt = 32u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Epochus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Epochus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: ULong = tlvReader.getULong(AnonymousTag) - return decodedValue } - suspend fun writeEpochUsAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeEpochUsAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 32u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6854,7 +6343,7 @@ suspend fun readEpochUsAttribute(): ULong {val ATTRIBUTE_ID: UInt = 32u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEpochUsAttribute( @@ -6862,35 +6351,37 @@ suspend fun readEpochUsAttribute(): ULong {val ATTRIBUTE_ID: UInt = 32u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 32u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ULongSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ULongSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Epochus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Epochus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -6902,67 +6393,56 @@ suspend fun readEpochUsAttribute(): ULong {val ATTRIBUTE_ID: UInt = 32u emit(ULongSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEpochSAttribute(): UInt {val ATTRIBUTE_ID: UInt = 33u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEpochSAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 33u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Epochs attribute not found in response" - } + } + + requireNotNull(attributeData) { "Epochs attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } - suspend fun writeEpochSAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeEpochSAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 33u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -6984,7 +6464,7 @@ suspend fun readEpochSAttribute(): UInt {val ATTRIBUTE_ID: UInt = 33u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEpochSAttribute( @@ -6992,35 +6472,37 @@ suspend fun readEpochSAttribute(): UInt {val ATTRIBUTE_ID: UInt = 33u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 33u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Epochs attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Epochs attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7032,67 +6514,56 @@ suspend fun readEpochSAttribute(): UInt {val ATTRIBUTE_ID: UInt = 33u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readVendorIdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 34u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readVendorIdAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 34u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Vendorid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } - suspend fun writeVendorIdAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeVendorIdAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 34u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7114,7 +6585,7 @@ suspend fun readVendorIdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 34u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeVendorIdAttribute( @@ -7122,35 +6593,37 @@ suspend fun readVendorIdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 34u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 34u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Vendorid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Vendorid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7162,77 +6635,73 @@ suspend fun readVendorIdAttribute(): UShort {val ATTRIBUTE_ID: UInt = 34u emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListNullablesAndOptionalsStructAttribute(): ListNullablesAndOptionalsStructAttribute {val ATTRIBUTE_ID: UInt = 35u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListNullablesAndOptionalsStructAttribute(): + ListNullablesAndOptionalsStructAttribute { + val ATTRIBUTE_ID: UInt = 35u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listnullablesandoptionalsstruct attribute not found in response" + } + + requireNotNull(attributeData) { + "Listnullablesandoptionalsstruct attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListNullablesAndOptionalsStructAttribute(decodedValue) } suspend fun writeListNullablesAndOptionalsStructAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 35u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7254,7 +6723,7 @@ suspend fun readListNullablesAndOptionalsStructAttribute(): ListNullablesAndOpti throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListNullablesAndOptionalsStructAttribute( @@ -7262,45 +6731,50 @@ suspend fun readListNullablesAndOptionalsStructAttribute(): ListNullablesAndOpti maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 35u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListNullablesAndOptionalsStructAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListNullablesAndOptionalsStructAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listnullablesandoptionalsstruct attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Listnullablesandoptionalsstruct attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNullablesAndOptionalsStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ListNullablesAndOptionalsStructAttributeSubscriptionState.Success(decodedValue)) } @@ -7308,67 +6782,56 @@ suspend fun readListNullablesAndOptionalsStructAttribute(): ListNullablesAndOpti emit(ListNullablesAndOptionalsStructAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEnumAttrAttribute(): UByte {val ATTRIBUTE_ID: UInt = 36u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEnumAttrAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 36u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enumattr attribute not found in response" - } + } + + requireNotNull(attributeData) { "Enumattr attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeEnumAttrAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeEnumAttrAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 36u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7390,7 +6853,7 @@ suspend fun readEnumAttrAttribute(): UByte {val ATTRIBUTE_ID: UInt = 36u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeEnumAttrAttribute( @@ -7398,35 +6861,37 @@ suspend fun readEnumAttrAttribute(): UByte {val ATTRIBUTE_ID: UInt = 36u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 36u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Enumattr attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Enumattr attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -7438,67 +6903,60 @@ suspend fun readEnumAttrAttribute(): UByte {val ATTRIBUTE_ID: UInt = 36u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readStructAttrAttribute(): StructAttrAttribute {val ATTRIBUTE_ID: UInt = 37u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readStructAttrAttribute(): StructAttrAttribute { + val ATTRIBUTE_ID: UInt = 37u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Structattr attribute not found in response" - } + } + + requireNotNull(attributeData) { "Structattr attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct = UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) - + val decodedValue: UnitTestingClusterSimpleStruct = + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) return StructAttrAttribute(decodedValue) } suspend fun writeStructAttrAttribute( value: UnitTestingClusterSimpleStruct, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 37u val tlvWriter = TlvWriter() - value.toTlv(AnonymousTag, tlvWriter) + value.toTlv(AnonymousTag, tlvWriter) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7520,7 +6978,7 @@ suspend fun readStructAttrAttribute(): StructAttrAttribute {val ATTRIBUTE_ID: UI throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeStructAttrAttribute( @@ -7528,39 +6986,42 @@ suspend fun readStructAttrAttribute(): StructAttrAttribute {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 37u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StructAttrAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StructAttrAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Structattr attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Structattr attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct = UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + val decodedValue: UnitTestingClusterSimpleStruct = + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) emit(StructAttrAttributeSubscriptionState.Success(decodedValue)) } @@ -7568,67 +7029,59 @@ suspend fun readStructAttrAttribute(): StructAttrAttribute {val ATTRIBUTE_ID: UI emit(StructAttrAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRangeRestrictedInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = 38u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRangeRestrictedInt8uAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 38u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rangerestrictedint8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } suspend fun writeRangeRestrictedInt8uAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 38u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7650,7 +7103,7 @@ suspend fun readRangeRestrictedInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt8uAttribute( @@ -7658,34 +7111,38 @@ suspend fun readRangeRestrictedInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 38u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint8u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rangerestrictedint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7698,67 +7155,56 @@ suspend fun readRangeRestrictedInt8uAttribute(): UByte {val ATTRIBUTE_ID: UInt = emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRangeRestrictedInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = 39u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRangeRestrictedInt8sAttribute(): Byte { + val ATTRIBUTE_ID: UInt = 39u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint8s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rangerestrictedint8s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Byte = tlvReader.getByte(AnonymousTag) - return decodedValue } - suspend fun writeRangeRestrictedInt8sAttribute( - value: Byte, - timedWriteTimeout: Duration? = null) { + suspend fun writeRangeRestrictedInt8sAttribute(value: Byte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 39u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7780,7 +7226,7 @@ suspend fun readRangeRestrictedInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt8sAttribute( @@ -7788,34 +7234,38 @@ suspend fun readRangeRestrictedInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 39u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint8s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rangerestrictedint8s attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7828,67 +7278,59 @@ suspend fun readRangeRestrictedInt8sAttribute(): Byte {val ATTRIBUTE_ID: UInt = emit(ByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRangeRestrictedInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt = 40u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRangeRestrictedInt16uAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 40u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint16u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rangerestrictedint16u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } suspend fun writeRangeRestrictedInt16uAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 40u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -7910,7 +7352,7 @@ suspend fun readRangeRestrictedInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt16uAttribute( @@ -7918,34 +7360,38 @@ suspend fun readRangeRestrictedInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 40u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint16u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rangerestrictedint16u attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -7958,67 +7404,59 @@ suspend fun readRangeRestrictedInt16uAttribute(): UShort {val ATTRIBUTE_ID: UInt emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRangeRestrictedInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt = 41u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readRangeRestrictedInt16sAttribute(): Short { + val ATTRIBUTE_ID: UInt = 41u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint16s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rangerestrictedint16s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Short = tlvReader.getShort(AnonymousTag) - return decodedValue } suspend fun writeRangeRestrictedInt16sAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 41u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8040,7 +7478,7 @@ suspend fun readRangeRestrictedInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeRangeRestrictedInt16sAttribute( @@ -8048,34 +7486,38 @@ suspend fun readRangeRestrictedInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 41u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rangerestrictedint16s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Rangerestrictedint16s attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8088,77 +7530,70 @@ suspend fun readRangeRestrictedInt16sAttribute(): Short {val ATTRIBUTE_ID: UInt emit(ShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute {val ATTRIBUTE_ID: UInt = 42u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 42u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listlongoctetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Listlongoctetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListLongOctetStringAttribute(decodedValue) } suspend fun writeListLongOctetStringAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 42u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - tlvWriter.put(AnonymousTag, item) - } - tlvWriter.endArray() + for (item in value.iterator()) { + tlvWriter.put(AnonymousTag, item) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8180,7 +7615,7 @@ suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListLongOctetStringAttribute( @@ -8188,45 +7623,50 @@ suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 42u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListLongOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListLongOctetStringAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listlongoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Listlongoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(ListLongOctetStringAttributeSubscriptionState.Success(decodedValue)) } @@ -8234,77 +7674,70 @@ suspend fun readListLongOctetStringAttribute(): ListLongOctetStringAttribute {va emit(ListLongOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute {val ATTRIBUTE_ID: UInt = 43u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute { + val ATTRIBUTE_ID: UInt = 43u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listfabricscoped attribute not found in response" - } + } + + requireNotNull(attributeData) { "Listfabricscoped attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return ListFabricScopedAttribute(decodedValue) } suspend fun writeListFabricScopedAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 43u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8326,7 +7759,7 @@ suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeListFabricScopedAttribute( @@ -8334,45 +7767,50 @@ suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 43u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ListFabricScopedAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ListFabricScopedAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Listfabricscoped attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Listfabricscoped attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterTestFabricScoped.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(ListFabricScopedAttributeSubscriptionState.Success(decodedValue)) } @@ -8380,67 +7818,56 @@ suspend fun readListFabricScopedAttribute(): ListFabricScopedAttribute {val ATTR emit(ListFabricScopedAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTimedWriteBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 48u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTimedWriteBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 48u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timedwriteboolean attribute not found in response" - } + } + + requireNotNull(attributeData) { "Timedwriteboolean attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } - suspend fun writeTimedWriteBooleanAttribute( - value: Boolean, - timedWriteTimeout: Duration) { + suspend fun writeTimedWriteBooleanAttribute(value: Boolean, timedWriteTimeout: Duration) { val ATTRIBUTE_ID: UInt = 48u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8462,7 +7889,7 @@ suspend fun readTimedWriteBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeTimedWriteBooleanAttribute( @@ -8470,34 +7897,38 @@ suspend fun readTimedWriteBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 48u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Timedwriteboolean attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Timedwriteboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8510,67 +7941,59 @@ suspend fun readTimedWriteBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneralErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 49u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneralErrorBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 49u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generalerrorboolean attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generalerrorboolean attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } suspend fun writeGeneralErrorBooleanAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 49u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8592,7 +8015,7 @@ suspend fun readGeneralErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeGeneralErrorBooleanAttribute( @@ -8600,34 +8023,38 @@ suspend fun readGeneralErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 49u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generalerrorboolean attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generalerrorboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8640,67 +8067,59 @@ suspend fun readGeneralErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt = 50u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterErrorBooleanAttribute(): Boolean { + val ATTRIBUTE_ID: UInt = 50u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clustererrorboolean attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clustererrorboolean attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: Boolean = tlvReader.getBoolean(AnonymousTag) - return decodedValue } suspend fun writeClusterErrorBooleanAttribute( value: Boolean, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 50u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8722,7 +8141,7 @@ suspend fun readClusterErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeClusterErrorBooleanAttribute( @@ -8730,34 +8149,38 @@ suspend fun readClusterErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 50u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clustererrorboolean attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clustererrorboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -8770,71 +8193,61 @@ suspend fun readClusterErrorBooleanAttribute(): Boolean {val ATTRIBUTE_ID: UInt emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readUnsupportedAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 255u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readUnsupportedAttribute(): Boolean? { + val ATTRIBUTE_ID: UInt = 255u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unsupported attribute not found in response" - } + } + + requireNotNull(attributeData) { "Unsupported attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } - + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeUnsupportedAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeUnsupportedAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 255u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8856,7 +8269,7 @@ suspend fun readUnsupportedAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 255u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeUnsupportedAttribute( @@ -8864,119 +8277,109 @@ suspend fun readUnsupportedAttribute(): Boolean? {val ATTRIBUTE_ID: UInt = 255u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 255u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BooleanSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BooleanSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Unsupported attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Unsupported attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getBoolean(AnonymousTag) - } else { - null - } + val decodedValue: Boolean? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getBoolean(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(BooleanSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(BooleanSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BooleanSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute {val ATTRIBUTE_ID: UInt = 16384u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute { + val ATTRIBUTE_ID: UInt = 16384u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableboolean attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableboolean attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - tlvReader.getBoolean(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableBooleanAttribute(decodedValue) } - suspend fun writeNullableBooleanAttribute( - value: Boolean, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBooleanAttribute(value: Boolean, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16384u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -8998,7 +8401,7 @@ suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBooleanAttribute( @@ -9006,120 +8409,112 @@ suspend fun readNullableBooleanAttribute(): NullableBooleanAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16384u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableBooleanAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableBooleanAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableboolean attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableboolean attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Boolean? = if (!tlvReader.isNull()) { - tlvReader.getBoolean(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Boolean? = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableBooleanAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableBooleanAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableBooleanAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute {val ATTRIBUTE_ID: UInt = 16385u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute { + val ATTRIBUTE_ID: UInt = 16385u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap8 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablebitmap8 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableBitmap8Attribute(decodedValue) } - suspend fun writeNullableBitmap8Attribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16385u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9141,7 +8536,7 @@ suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute {val ATTRIB throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap8Attribute( @@ -9149,120 +8544,112 @@ suspend fun readNullableBitmap8Attribute(): NullableBitmap8Attribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16385u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableBitmap8AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableBitmap8AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap8 attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablebitmap8 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableBitmap8AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableBitmap8AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap8AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute {val ATTRIBUTE_ID: UInt = 16386u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute { + val ATTRIBUTE_ID: UInt = 16386u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap16 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablebitmap16 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableBitmap16Attribute(decodedValue) } - suspend fun writeNullableBitmap16Attribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16386u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9284,7 +8671,7 @@ suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap16Attribute( @@ -9292,120 +8679,112 @@ suspend fun readNullableBitmap16Attribute(): NullableBitmap16Attribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16386u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableBitmap16AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableBitmap16AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap16 attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablebitmap16 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableBitmap16AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableBitmap16AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap16AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute {val ATTRIBUTE_ID: UInt = 16387u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute { + val ATTRIBUTE_ID: UInt = 16387u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap32 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablebitmap32 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableBitmap32Attribute(decodedValue) } - suspend fun writeNullableBitmap32Attribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap32Attribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16387u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9427,7 +8806,7 @@ suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap32Attribute( @@ -9435,120 +8814,112 @@ suspend fun readNullableBitmap32Attribute(): NullableBitmap32Attribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16387u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableBitmap32AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableBitmap32AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap32 attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablebitmap32 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableBitmap32AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableBitmap32AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap32AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute {val ATTRIBUTE_ID: UInt = 16388u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute { + val ATTRIBUTE_ID: UInt = 16388u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap64 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablebitmap64 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableBitmap64Attribute(decodedValue) } - suspend fun writeNullableBitmap64Attribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableBitmap64Attribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16388u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9570,7 +8941,7 @@ suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableBitmap64Attribute( @@ -9578,120 +8949,112 @@ suspend fun readNullableBitmap64Attribute(): NullableBitmap64Attribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16388u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableBitmap64AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableBitmap64AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablebitmap64 attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablebitmap64 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableBitmap64AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableBitmap64AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableBitmap64AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute {val ATTRIBUTE_ID: UInt = 16389u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute { + val ATTRIBUTE_ID: UInt = 16389u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt8uAttribute(decodedValue) } - suspend fun writeNullableInt8uAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt8uAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16389u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9713,7 +9076,7 @@ suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt8uAttribute( @@ -9721,120 +9084,110 @@ suspend fun readNullableInt8uAttribute(): NullableInt8uAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16389u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt8uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt8uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint8u attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nullableint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt8uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt8uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt8uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute {val ATTRIBUTE_ID: UInt = 16390u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute { + val ATTRIBUTE_ID: UInt = 16390u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint16u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint16u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt16uAttribute(decodedValue) } - suspend fun writeNullableInt16uAttribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt16uAttribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16390u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9856,7 +9209,7 @@ suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt16uAttribute( @@ -9864,120 +9217,112 @@ suspend fun readNullableInt16uAttribute(): NullableInt16uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16390u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt16uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt16uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint16u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint16u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt16uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt16uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt16uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute {val ATTRIBUTE_ID: UInt = 16391u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute { + val ATTRIBUTE_ID: UInt = 16391u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint24u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint24u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt24uAttribute(decodedValue) } - suspend fun writeNullableInt24uAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt24uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16391u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -9999,7 +9344,7 @@ suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt24uAttribute( @@ -10007,120 +9352,112 @@ suspend fun readNullableInt24uAttribute(): NullableInt24uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16391u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt24uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt24uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint24u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint24u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt24uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt24uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt24uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute {val ATTRIBUTE_ID: UInt = 16392u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute { + val ATTRIBUTE_ID: UInt = 16392u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint32u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint32u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt32uAttribute(decodedValue) } - suspend fun writeNullableInt32uAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt32uAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16392u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10142,7 +9479,7 @@ suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt32uAttribute( @@ -10150,120 +9487,112 @@ suspend fun readNullableInt32uAttribute(): NullableInt32uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16392u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt32uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt32uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint32u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint32u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt32uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt32uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt32uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute {val ATTRIBUTE_ID: UInt = 16393u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute { + val ATTRIBUTE_ID: UInt = 16393u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint40u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint40u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt40uAttribute(decodedValue) } - suspend fun writeNullableInt40uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt40uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16393u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10285,7 +9614,7 @@ suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt40uAttribute( @@ -10293,120 +9622,112 @@ suspend fun readNullableInt40uAttribute(): NullableInt40uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16393u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt40uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt40uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint40u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint40u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt40uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt40uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt40uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute {val ATTRIBUTE_ID: UInt = 16394u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute { + val ATTRIBUTE_ID: UInt = 16394u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint48u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint48u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt48uAttribute(decodedValue) } - suspend fun writeNullableInt48uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt48uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16394u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10428,7 +9749,7 @@ suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt48uAttribute( @@ -10436,120 +9757,112 @@ suspend fun readNullableInt48uAttribute(): NullableInt48uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16394u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt48uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt48uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint48u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint48u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt48uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt48uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt48uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute {val ATTRIBUTE_ID: UInt = 16395u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute { + val ATTRIBUTE_ID: UInt = 16395u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint56u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint56u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt56uAttribute(decodedValue) } - suspend fun writeNullableInt56uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt56uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16395u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10571,7 +9884,7 @@ suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt56uAttribute( @@ -10579,120 +9892,112 @@ suspend fun readNullableInt56uAttribute(): NullableInt56uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16395u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt56uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt56uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint56u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint56u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt56uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt56uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt56uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute {val ATTRIBUTE_ID: UInt = 16396u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute { + val ATTRIBUTE_ID: UInt = 16396u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint64u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint64u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt64uAttribute(decodedValue) } - suspend fun writeNullableInt64uAttribute( - value: ULong, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt64uAttribute(value: ULong, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16396u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10714,7 +10019,7 @@ suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt64uAttribute( @@ -10722,120 +10027,112 @@ suspend fun readNullableInt64uAttribute(): NullableInt64uAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16396u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt64uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt64uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint64u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint64u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - tlvReader.getULong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + tlvReader.getULong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt64uAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt64uAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt64uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute {val ATTRIBUTE_ID: UInt = 16397u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute { + val ATTRIBUTE_ID: UInt = 16397u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint8s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint8s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt8sAttribute(decodedValue) } - suspend fun writeNullableInt8sAttribute( - value: Byte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt8sAttribute(value: Byte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16397u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -10857,7 +10154,7 @@ suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt8sAttribute( @@ -10865,120 +10162,110 @@ suspend fun readNullableInt8sAttribute(): NullableInt8sAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16397u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt8sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt8sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint8s attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nullableint8s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt8sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt8sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt8sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute {val ATTRIBUTE_ID: UInt = 16398u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute { + val ATTRIBUTE_ID: UInt = 16398u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint16s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint16s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt16sAttribute(decodedValue) } - suspend fun writeNullableInt16sAttribute( - value: Short, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt16sAttribute(value: Short, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16398u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11000,7 +10287,7 @@ suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt16sAttribute( @@ -11008,120 +10295,112 @@ suspend fun readNullableInt16sAttribute(): NullableInt16sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16398u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt16sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt16sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint16s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint16s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt16sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt16sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt16sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute {val ATTRIBUTE_ID: UInt = 16399u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute { + val ATTRIBUTE_ID: UInt = 16399u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint24s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint24s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt24sAttribute(decodedValue) } - suspend fun writeNullableInt24sAttribute( - value: Int, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt24sAttribute(value: Int, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16399u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11143,7 +10422,7 @@ suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt24sAttribute( @@ -11151,120 +10430,112 @@ suspend fun readNullableInt24sAttribute(): NullableInt24sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16399u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt24sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt24sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint24s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint24s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt24sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt24sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt24sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute {val ATTRIBUTE_ID: UInt = 16400u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute { + val ATTRIBUTE_ID: UInt = 16400u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint32s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint32s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt32sAttribute(decodedValue) } - suspend fun writeNullableInt32sAttribute( - value: Int, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt32sAttribute(value: Int, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16400u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11286,7 +10557,7 @@ suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt32sAttribute( @@ -11294,120 +10565,112 @@ suspend fun readNullableInt32sAttribute(): NullableInt32sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16400u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt32sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt32sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint32s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint32s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Int? = if (!tlvReader.isNull()) { - tlvReader.getInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Int? = + if (!tlvReader.isNull()) { + tlvReader.getInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt32sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt32sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt32sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute {val ATTRIBUTE_ID: UInt = 16401u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute { + val ATTRIBUTE_ID: UInt = 16401u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint40s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint40s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt40sAttribute(decodedValue) } - suspend fun writeNullableInt40sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt40sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16401u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11429,7 +10692,7 @@ suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt40sAttribute( @@ -11437,120 +10700,112 @@ suspend fun readNullableInt40sAttribute(): NullableInt40sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16401u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt40sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt40sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint40s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint40s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt40sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt40sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt40sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute {val ATTRIBUTE_ID: UInt = 16402u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute { + val ATTRIBUTE_ID: UInt = 16402u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint48s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint48s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt48sAttribute(decodedValue) } - suspend fun writeNullableInt48sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt48sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16402u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11572,7 +10827,7 @@ suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt48sAttribute( @@ -11580,120 +10835,112 @@ suspend fun readNullableInt48sAttribute(): NullableInt48sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16402u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt48sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt48sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint48s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint48s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt48sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt48sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt48sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute {val ATTRIBUTE_ID: UInt = 16403u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute { + val ATTRIBUTE_ID: UInt = 16403u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint56s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint56s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt56sAttribute(decodedValue) } - suspend fun writeNullableInt56sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt56sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16403u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11715,7 +10962,7 @@ suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt56sAttribute( @@ -11723,120 +10970,112 @@ suspend fun readNullableInt56sAttribute(): NullableInt56sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16403u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt56sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt56sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint56s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint56s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt56sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt56sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt56sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute {val ATTRIBUTE_ID: UInt = 16404u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute { + val ATTRIBUTE_ID: UInt = 16404u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint64s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableint64s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableInt64sAttribute(decodedValue) } - suspend fun writeNullableInt64sAttribute( - value: Long, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableInt64sAttribute(value: Long, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16404u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -11858,7 +11097,7 @@ suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableInt64sAttribute( @@ -11866,120 +11105,112 @@ suspend fun readNullableInt64sAttribute(): NullableInt64sAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16404u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableInt64sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableInt64sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableint64s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableint64s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Long? = if (!tlvReader.isNull()) { - tlvReader.getLong(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Long? = + if (!tlvReader.isNull()) { + tlvReader.getLong(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableInt64sAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableInt64sAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableInt64sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute {val ATTRIBUTE_ID: UInt = 16405u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute { + val ATTRIBUTE_ID: UInt = 16405u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenum8 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableenum8 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableEnum8Attribute(decodedValue) } - suspend fun writeNullableEnum8Attribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableEnum8Attribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16405u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12001,7 +11232,7 @@ suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute {val ATTRIBUTE_ throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableEnum8Attribute( @@ -12009,120 +11240,110 @@ suspend fun readNullableEnum8Attribute(): NullableEnum8Attribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16405u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableEnum8AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableEnum8AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenum8 attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Nullableenum8 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableEnum8AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableEnum8AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableEnum8AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute {val ATTRIBUTE_ID: UInt = 16406u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute { + val ATTRIBUTE_ID: UInt = 16406u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenum16 attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableenum16 attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableEnum16Attribute(decodedValue) } - suspend fun writeNullableEnum16Attribute( - value: UShort, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableEnum16Attribute(value: UShort, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16406u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12144,7 +11365,7 @@ suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableEnum16Attribute( @@ -12152,120 +11373,112 @@ suspend fun readNullableEnum16Attribute(): NullableEnum16Attribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16406u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableEnum16AttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableEnum16AttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenum16 attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableenum16 attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableEnum16AttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableEnum16AttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableEnum16AttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute {val ATTRIBUTE_ID: UInt = 16407u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute { + val ATTRIBUTE_ID: UInt = 16407u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablefloatsingle attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablefloatsingle attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - tlvReader.getFloat(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Float? = + if (!tlvReader.isNull()) { + tlvReader.getFloat(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableFloatSingleAttribute(decodedValue) } - suspend fun writeNullableFloatSingleAttribute( - value: Float, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableFloatSingleAttribute(value: Float, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16407u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12287,7 +11500,7 @@ suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableFloatSingleAttribute( @@ -12295,120 +11508,115 @@ suspend fun readNullableFloatSingleAttribute(): NullableFloatSingleAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16407u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableFloatSingleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableFloatSingleAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablefloatsingle attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablefloatsingle attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Float? = if (!tlvReader.isNull()) { - tlvReader.getFloat(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Float? = + if (!tlvReader.isNull()) { + tlvReader.getFloat(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableFloatSingleAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableFloatSingleAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableFloatSingleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute {val ATTRIBUTE_ID: UInt = 16408u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute { + val ATTRIBUTE_ID: UInt = 16408u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablefloatdouble attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablefloatdouble attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Double? = if (!tlvReader.isNull()) { - tlvReader.getDouble(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Double? = + if (!tlvReader.isNull()) { + tlvReader.getDouble(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableFloatDoubleAttribute(decodedValue) } suspend fun writeNullableFloatDoubleAttribute( value: Double, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16408u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12430,7 +11638,7 @@ suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableFloatDoubleAttribute( @@ -12438,120 +11646,115 @@ suspend fun readNullableFloatDoubleAttribute(): NullableFloatDoubleAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16408u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableFloatDoubleAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableFloatDoubleAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablefloatdouble attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablefloatdouble attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Double? = if (!tlvReader.isNull()) { - tlvReader.getDouble(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Double? = + if (!tlvReader.isNull()) { + tlvReader.getDouble(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableFloatDoubleAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableFloatDoubleAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableFloatDoubleAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute {val ATTRIBUTE_ID: UInt = 16409u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute { + val ATTRIBUTE_ID: UInt = 16409u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableoctetstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableoctetstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableOctetStringAttribute(decodedValue) } suspend fun writeNullableOctetStringAttribute( value: ByteArray, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16409u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12573,7 +11776,7 @@ suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableOctetStringAttribute( @@ -12581,120 +11784,112 @@ suspend fun readNullableOctetStringAttribute(): NullableOctetStringAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16409u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableOctetStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableOctetStringAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableoctetstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableoctetstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableOctetStringAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableOctetStringAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableOctetStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute {val ATTRIBUTE_ID: UInt = 16414u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute { + val ATTRIBUTE_ID: UInt = 16414u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablecharstring attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablecharstring attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: String? = + if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableCharStringAttribute(decodedValue) } - suspend fun writeNullableCharStringAttribute( - value: String, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableCharStringAttribute(value: String, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16414u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12716,7 +11911,7 @@ suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute {val throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableCharStringAttribute( @@ -12724,120 +11919,112 @@ suspend fun readNullableCharStringAttribute(): NullableCharStringAttribute {val maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16414u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableCharStringAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableCharStringAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablecharstring attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablecharstring attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (!tlvReader.isNull()) { - tlvReader.getString(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: String? = + if (!tlvReader.isNull()) { + tlvReader.getString(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableCharStringAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableCharStringAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableCharStringAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute {val ATTRIBUTE_ID: UInt = 16420u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute { + val ATTRIBUTE_ID: UInt = 16420u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenumattr attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullableenumattr attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableEnumAttrAttribute(decodedValue) } - suspend fun writeNullableEnumAttrAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeNullableEnumAttrAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16420u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -12859,7 +12046,7 @@ suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute {val ATTR throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableEnumAttrAttribute( @@ -12867,120 +12054,115 @@ suspend fun readNullableEnumAttrAttribute(): NullableEnumAttrAttribute {val ATTR maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16420u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableEnumAttrAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableEnumAttrAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullableenumattr attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullableenumattr attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableEnumAttrAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableEnumAttrAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableEnumAttrAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableStructAttribute(): NullableStructAttribute {val ATTRIBUTE_ID: UInt = 16421u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableStructAttribute(): NullableStructAttribute { + val ATTRIBUTE_ID: UInt = 16421u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablestruct attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablestruct attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct? = if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UnitTestingClusterSimpleStruct? = + if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableStructAttribute(decodedValue) } suspend fun writeNullableStructAttribute( value: UnitTestingClusterSimpleStruct, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16421u val tlvWriter = TlvWriter() - value.toTlv(AnonymousTag, tlvWriter) + value.toTlv(AnonymousTag, tlvWriter) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13002,7 +12184,7 @@ suspend fun readNullableStructAttribute(): NullableStructAttribute {val ATTRIBUT throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableStructAttribute( @@ -13010,120 +12192,115 @@ suspend fun readNullableStructAttribute(): NullableStructAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16421u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableStructAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableStructAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablestruct attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablestruct attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UnitTestingClusterSimpleStruct? = if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UnitTestingClusterSimpleStruct? = + if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader) + } else { + tlvReader.getNull(AnonymousTag) + null + } - decodedValue?.let { - emit(NullableStructAttributeSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(NullableStructAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(NullableStructAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestrictedInt8uAttribute {val ATTRIBUTE_ID: UInt = 16422u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestrictedInt8uAttribute { + val ATTRIBUTE_ID: UInt = 16422u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablerangerestrictedint8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableRangeRestrictedInt8uAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt8uAttribute( value: UByte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16422u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13145,7 +12322,7 @@ suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestricted throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt8uAttribute( @@ -13153,120 +12330,117 @@ suspend fun readNullableRangeRestrictedInt8uAttribute(): NullableRangeRestricted maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16422u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableRangeRestrictedInt8uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableRangeRestrictedInt8uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint8u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt8uAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt8uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestrictedInt8sAttribute {val ATTRIBUTE_ID: UInt = 16423u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestrictedInt8sAttribute { + val ATTRIBUTE_ID: UInt = 16423u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint8s attribute not found in response" - } + } + + requireNotNull(attributeData) { "Nullablerangerestrictedint8s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableRangeRestrictedInt8sAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt8sAttribute( value: Byte, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16423u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13288,7 +12462,7 @@ suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestricted throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt8sAttribute( @@ -13296,120 +12470,119 @@ suspend fun readNullableRangeRestrictedInt8sAttribute(): NullableRangeRestricted maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16423u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableRangeRestrictedInt8sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableRangeRestrictedInt8sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint8s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint8s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt8sAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt8sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestrictedInt16uAttribute {val ATTRIBUTE_ID: UInt = 16424u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestrictedInt16uAttribute { + val ATTRIBUTE_ID: UInt = 16424u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16u attribute not found in response" + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableRangeRestrictedInt16uAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt16uAttribute( value: UShort, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16424u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13431,7 +12604,7 @@ suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestricte throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt16uAttribute( @@ -13439,120 +12612,119 @@ suspend fun readNullableRangeRestrictedInt16uAttribute(): NullableRangeRestricte maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16424u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableRangeRestrictedInt16uAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableRangeRestrictedInt16uAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt16uAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt16uAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestrictedInt16sAttribute {val ATTRIBUTE_ID: UInt = 16425u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestrictedInt16sAttribute { + val ATTRIBUTE_ID: UInt = 16425u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16s attribute not found in response" + } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16s attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return NullableRangeRestrictedInt16sAttribute(decodedValue) } suspend fun writeNullableRangeRestrictedInt16sAttribute( value: Short, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 16425u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13574,7 +12746,7 @@ suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestricte throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeNullableRangeRestrictedInt16sAttribute( @@ -13582,119 +12754,113 @@ suspend fun readNullableRangeRestrictedInt16sAttribute(): NullableRangeRestricte maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16425u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(NullableRangeRestrictedInt16sAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + NullableRangeRestrictedInt16sAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Nullablerangerestrictedint16s attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Nullablerangerestrictedint16s attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Short? = if (!tlvReader.isNull()) { - tlvReader.getShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: Short? = + if (!tlvReader.isNull()) { + tlvReader.getShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(NullableRangeRestrictedInt16sAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(NullableRangeRestrictedInt16sAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWriteOnlyInt8uAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 16426u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readWriteOnlyInt8uAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 16426u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Writeonlyint8u attribute not found in response" - } + } + + requireNotNull(attributeData) { "Writeonlyint8u attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeWriteOnlyInt8uAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeWriteOnlyInt8uAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 16426u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -13716,7 +12882,7 @@ suspend fun readWriteOnlyInt8uAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1642 throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeWriteOnlyInt8uAttribute( @@ -13724,96 +12890,92 @@ suspend fun readWriteOnlyInt8uAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 1642 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16426u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Writeonlyint8u attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Writeonlyint8u attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -13823,45 +12985,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -13869,49 +13036,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -13921,45 +13082,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -13967,49 +13133,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -14019,45 +13179,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -14065,49 +13228,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -14117,45 +13274,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -14163,44 +13323,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -14209,35 +13362,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -14249,44 +13404,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -14295,34 +13443,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -14335,7 +13487,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt index b7fb44b39973dc..df0867a6902b61 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/UserLabelCluster.kt @@ -17,182 +17,140 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UserLabelCluster(private val controller: MatterController, private val endpointId: UShort) {class LabelListAttribute( - val value: List - ) +class UserLabelCluster(private val controller: MatterController, private val endpointId: UShort) { + class LabelListAttribute(val value: List) sealed class LabelListAttributeSubscriptionState { - data class Success( - val value: List - ) : LabelListAttributeSubscriptionState() - + data class Success(val value: List) : + LabelListAttributeSubscriptionState() + data class Error(val exception: Exception) : LabelListAttributeSubscriptionState() - object SubscriptionEstablished : LabelListAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : LabelListAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readLabelListAttribute(): LabelListAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Labellist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Labellist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return LabelListAttribute(decodedValue) } suspend fun writeLabelListAttribute( value: List, - timedWriteTimeout: Duration? = null) { + timedWriteTimeout: Duration? = null + ) { val ATTRIBUTE_ID: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startArray(AnonymousTag) - for (item in value.iterator()) { - item.toTlv(AnonymousTag, tlvWriter) - } - tlvWriter.endArray() + for (item in value.iterator()) { + item.toTlv(AnonymousTag, tlvWriter) + } + tlvWriter.endArray() val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -214,7 +172,7 @@ suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeLabelListAttribute( @@ -222,45 +180,48 @@ suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(LabelListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + LabelListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Labellist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Labellist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(UserLabelClusterLabelStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } emit(LabelListAttributeSubscriptionState.Success(decodedValue)) } @@ -268,49 +229,43 @@ suspend fun readLabelListAttribute(): LabelListAttribute {val ATTRIBUTE_ID: UInt emit(LabelListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -320,45 +275,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -366,49 +326,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -418,45 +372,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -464,49 +423,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -516,45 +469,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -562,49 +518,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -614,45 +564,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -660,44 +613,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -706,35 +652,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -746,44 +694,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -792,34 +733,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -832,7 +777,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt index b4b18cde045376..6160dd924179e6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/ValveConfigurationAndControlCluster.kt @@ -17,222 +17,167 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ValveConfigurationAndControlCluster(private val controller: MatterController, private val endpointId: UShort) {class OpenDurationAttribute( - val value: UInt? - ) +class ValveConfigurationAndControlCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class OpenDurationAttribute(val value: UInt?) sealed class OpenDurationAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : OpenDurationAttributeSubscriptionState() - + data class Success(val value: UInt?) : OpenDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : OpenDurationAttributeSubscriptionState() - object SubscriptionEstablished : OpenDurationAttributeSubscriptionState() - } -class DefaultOpenDurationAttribute( - val value: UInt? - ) + object SubscriptionEstablished : OpenDurationAttributeSubscriptionState() + } + + class DefaultOpenDurationAttribute(val value: UInt?) sealed class DefaultOpenDurationAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : DefaultOpenDurationAttributeSubscriptionState() - + data class Success(val value: UInt?) : DefaultOpenDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : DefaultOpenDurationAttributeSubscriptionState() - object SubscriptionEstablished : DefaultOpenDurationAttributeSubscriptionState() - } -class AutoCloseTimeAttribute( - val value: ULong? - ) + object SubscriptionEstablished : DefaultOpenDurationAttributeSubscriptionState() + } + + class AutoCloseTimeAttribute(val value: ULong?) sealed class AutoCloseTimeAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : AutoCloseTimeAttributeSubscriptionState() - + data class Success(val value: ULong?) : AutoCloseTimeAttributeSubscriptionState() + data class Error(val exception: Exception) : AutoCloseTimeAttributeSubscriptionState() - object SubscriptionEstablished : AutoCloseTimeAttributeSubscriptionState() - } -class RemainingDurationAttribute( - val value: UInt? - ) + object SubscriptionEstablished : AutoCloseTimeAttributeSubscriptionState() + } + + class RemainingDurationAttribute(val value: UInt?) sealed class RemainingDurationAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : RemainingDurationAttributeSubscriptionState() - + data class Success(val value: UInt?) : RemainingDurationAttributeSubscriptionState() + data class Error(val exception: Exception) : RemainingDurationAttributeSubscriptionState() - object SubscriptionEstablished : RemainingDurationAttributeSubscriptionState() - } -class CurrentStateAttribute( - val value: UByte? - ) + object SubscriptionEstablished : RemainingDurationAttributeSubscriptionState() + } + + class CurrentStateAttribute(val value: UByte?) sealed class CurrentStateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentStateAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentStateAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentStateAttributeSubscriptionState() - object SubscriptionEstablished : CurrentStateAttributeSubscriptionState() - } -class TargetStateAttribute( - val value: UByte? - ) + object SubscriptionEstablished : CurrentStateAttributeSubscriptionState() + } + + class TargetStateAttribute(val value: UByte?) sealed class TargetStateAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : TargetStateAttributeSubscriptionState() - + data class Success(val value: UByte?) : TargetStateAttributeSubscriptionState() + data class Error(val exception: Exception) : TargetStateAttributeSubscriptionState() - object SubscriptionEstablished : TargetStateAttributeSubscriptionState() - } -class CurrentLevelAttribute( - val value: UByte? - ) + object SubscriptionEstablished : TargetStateAttributeSubscriptionState() + } + + class CurrentLevelAttribute(val value: UByte?) sealed class CurrentLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : CurrentLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentLevelAttributeSubscriptionState() - object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() - } -class TargetLevelAttribute( - val value: UByte? - ) + object SubscriptionEstablished : CurrentLevelAttributeSubscriptionState() + } + + class TargetLevelAttribute(val value: UByte?) sealed class TargetLevelAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : TargetLevelAttributeSubscriptionState() - + data class Success(val value: UByte?) : TargetLevelAttributeSubscriptionState() + data class Error(val exception: Exception) : TargetLevelAttributeSubscriptionState() - object SubscriptionEstablished : TargetLevelAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : TargetLevelAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } - suspend fun open(openDuration: UInt? - ,targetLevel: UByte? - ,timedInvokeTimeout: Duration? = null) { + suspend fun open(openDuration: UInt?, targetLevel: UByte?, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_OPEN_DURATION_REQ: Int = 0 - openDuration?.let { - tlvWriter.put(ContextSpecificTag(TAG_OPEN_DURATION_REQ), openDuration) - } + openDuration?.let { tlvWriter.put(ContextSpecificTag(TAG_OPEN_DURATION_REQ), openDuration) } val TAG_TARGET_LEVEL_REQ: Int = 1 - targetLevel?.let { - tlvWriter.put(ContextSpecificTag(TAG_TARGET_LEVEL_REQ), targetLevel) - } + targetLevel?.let { tlvWriter.put(ContextSpecificTag(TAG_TARGET_LEVEL_REQ), targetLevel) } tlvWriter.endStructure() val request: InvokeRequest = @@ -250,7 +195,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -263,46 +208,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readOpenDurationAttribute(): OpenDurationAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOpenDurationAttribute(): OpenDurationAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Openduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Openduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return OpenDurationAttribute(decodedValue) } @@ -312,120 +251,110 @@ suspend fun readOpenDurationAttribute(): OpenDurationAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OpenDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OpenDurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Openduration attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Openduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OpenDurationAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OpenDurationAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OpenDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultOpenDurationAttribute(): DefaultOpenDurationAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultOpenDurationAttribute(): DefaultOpenDurationAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultopenduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultopenduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return DefaultOpenDurationAttribute(decodedValue) } - suspend fun writeDefaultOpenDurationAttribute( - value: UInt, - timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultOpenDurationAttribute(value: UInt, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -447,7 +376,7 @@ suspend fun readDefaultOpenDurationAttribute(): DefaultOpenDurationAttribute {va throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultOpenDurationAttribute( @@ -455,100 +384,96 @@ suspend fun readDefaultOpenDurationAttribute(): DefaultOpenDurationAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(DefaultOpenDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + DefaultOpenDurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultopenduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultopenduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(DefaultOpenDurationAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(DefaultOpenDurationAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(DefaultOpenDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAutoCloseTimeAttribute(): AutoCloseTimeAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAutoCloseTimeAttribute(): AutoCloseTimeAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Autoclosetime attribute not found in response" - } + } + + requireNotNull(attributeData) { "Autoclosetime attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return AutoCloseTimeAttribute(decodedValue) } @@ -558,100 +483,94 @@ suspend fun readAutoCloseTimeAttribute(): AutoCloseTimeAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AutoCloseTimeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AutoCloseTimeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Autoclosetime attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Autoclosetime attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(AutoCloseTimeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(AutoCloseTimeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(AutoCloseTimeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRemainingDurationAttribute(): RemainingDurationAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRemainingDurationAttribute(): RemainingDurationAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingduration attribute not found in response" - } + } + + requireNotNull(attributeData) { "Remainingduration attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return RemainingDurationAttribute(decodedValue) } @@ -661,96 +580,92 @@ suspend fun readRemainingDurationAttribute(): RemainingDurationAttribute {val AT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RemainingDurationAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RemainingDurationAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Remainingduration attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Remainingduration attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - tlvReader.getUInt(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(RemainingDurationAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + tlvReader.getUInt(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(RemainingDurationAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RemainingDurationAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentStateAttribute(): CurrentStateAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentStateAttribute(): CurrentStateAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentStateAttribute(decodedValue) } @@ -760,96 +675,90 @@ suspend fun readCurrentStateAttribute(): CurrentStateAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentStateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentStateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentStateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTargetStateAttribute(): TargetStateAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTargetStateAttribute(): TargetStateAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetstate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Targetstate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return TargetStateAttribute(decodedValue) } @@ -859,100 +768,94 @@ suspend fun readTargetStateAttribute(): TargetStateAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TargetStateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TargetStateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetstate attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Targetstate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(TargetStateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(TargetStateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(TargetStateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentLevelAttribute(decodedValue) } @@ -962,104 +865,98 @@ suspend fun readCurrentLevelAttribute(): CurrentLevelAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Currentlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentLevelAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTargetLevelAttribute(): TargetLevelAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readTargetLevelAttribute(): TargetLevelAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Targetlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return TargetLevelAttribute(decodedValue) } @@ -1069,123 +966,113 @@ suspend fun readTargetLevelAttribute(): TargetLevelAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TargetLevelAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TargetLevelAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetlevel attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Targetlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(TargetLevelAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(TargetLevelAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(TargetLevelAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readDefaultOpenLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readDefaultOpenLevelAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultopenlevel attribute not found in response" - } + } + + requireNotNull(attributeData) { "Defaultopenlevel attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } - suspend fun writeDefaultOpenLevelAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeDefaultOpenLevelAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 8u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -1207,7 +1094,7 @@ suspend fun readDefaultOpenLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeDefaultOpenLevelAttribute( @@ -1215,94 +1102,90 @@ suspend fun readDefaultOpenLevelAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 8u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Defaultopenlevel attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Defaultopenlevel attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readValveFaultAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readValveFaultAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Valvefault attribute not found in response" - } + } + + requireNotNull(attributeData) { "Valvefault attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1312,94 +1195,88 @@ suspend fun readValveFaultAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 9u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Valvefault attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Valvefault attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLevelStepAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLevelStepAttribute(): UByte? { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelstep attribute not found in response" - } + } + + requireNotNull(attributeData) { "Levelstep attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } return decodedValue } @@ -1409,96 +1286,90 @@ suspend fun readLevelStepAttribute(): UByte? {val ATTRIBUTE_ID: UInt = 10u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Levelstep attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Levelstep attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(UByteSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(UByteSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1508,45 +1379,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1554,49 +1430,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1606,45 +1476,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1652,49 +1527,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1704,45 +1573,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1750,49 +1622,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1802,45 +1668,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -1848,44 +1717,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -1894,35 +1756,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1934,44 +1798,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -1980,34 +1837,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2020,7 +1881,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt index 18d648654b3557..b29d8ae7c59bd6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WakeOnLanCluster.kt @@ -17,139 +17,98 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.ByteArraySubscriptionState import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest +import matter.controller.StringSubscriptionState import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse -import matter.controller.model.AttributePath -import matter.controller.model.CommandPath +import matter.controller.UShortSubscriptionState import matter.controller.cluster.structs.* +import matter.controller.model.AttributePath import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader -import matter.tlv.TlvWriter -class WakeOnLanCluster(private val controller: MatterController, private val endpointId: UShort) {class GeneratedCommandListAttribute( - val value: List - ) +class WakeOnLanCluster(private val controller: MatterController, private val endpointId: UShort) { + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } -suspend fun readMACAddressAttribute(): String? {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } + + suspend fun readMACAddressAttribute(): String? { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Macaddress attribute not found in response" - } + } + + requireNotNull(attributeData) { "Macaddress attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } return decodedValue } @@ -159,94 +118,88 @@ suspend fun readMACAddressAttribute(): String? {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(StringSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + StringSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Macaddress attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Macaddress attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: String? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getString(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(StringSubscriptionState.Success(it)) - } - + val decodedValue: String? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getString(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(StringSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(StringSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readLinkLocalAddressAttribute(): ByteArray? {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readLinkLocalAddressAttribute(): ByteArray? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linklocaladdress attribute not found in response" - } + } + + requireNotNull(attributeData) { "Linklocaladdress attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - + val decodedValue: ByteArray? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } return decodedValue } @@ -256,96 +209,92 @@ suspend fun readLinkLocalAddressAttribute(): ByteArray? {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ByteArraySubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ByteArraySubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Linklocaladdress attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Linklocaladdress attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getByteArray(AnonymousTag) - } else { - null - } - - decodedValue?.let { - emit(ByteArraySubscriptionState.Success(it)) - } - + val decodedValue: ByteArray? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getByteArray(AnonymousTag) + } else { + null + } + + decodedValue?.let { emit(ByteArraySubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ByteArraySubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -355,45 +304,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -401,49 +355,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -453,45 +401,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -499,49 +452,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -551,45 +498,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -597,49 +547,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -649,45 +593,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -695,44 +642,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -741,35 +681,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -781,44 +723,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -827,34 +762,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -867,7 +806,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt index a863a7bdcbe2f5..a5a3c4300e4829 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WiFiNetworkDiagnosticsCluster.kt @@ -17,275 +17,206 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState -import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState -import matter.controller.WriteRequest -import matter.controller.WriteRequests -import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.UShortSubscriptionState +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag -import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsCluster(private val controller: MatterController, private val endpointId: UShort) {class BssidAttribute( - val value: ByteArray? - ) +class WiFiNetworkDiagnosticsCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class BssidAttribute(val value: ByteArray?) sealed class BssidAttributeSubscriptionState { - data class Success( - val value: ByteArray? - ) : BssidAttributeSubscriptionState() - + data class Success(val value: ByteArray?) : BssidAttributeSubscriptionState() + data class Error(val exception: Exception) : BssidAttributeSubscriptionState() - object SubscriptionEstablished : BssidAttributeSubscriptionState() - } -class SecurityTypeAttribute( - val value: UByte? - ) + object SubscriptionEstablished : BssidAttributeSubscriptionState() + } + + class SecurityTypeAttribute(val value: UByte?) sealed class SecurityTypeAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : SecurityTypeAttributeSubscriptionState() - + data class Success(val value: UByte?) : SecurityTypeAttributeSubscriptionState() + data class Error(val exception: Exception) : SecurityTypeAttributeSubscriptionState() - object SubscriptionEstablished : SecurityTypeAttributeSubscriptionState() - } -class WiFiVersionAttribute( - val value: UByte? - ) + object SubscriptionEstablished : SecurityTypeAttributeSubscriptionState() + } + + class WiFiVersionAttribute(val value: UByte?) sealed class WiFiVersionAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : WiFiVersionAttributeSubscriptionState() - + data class Success(val value: UByte?) : WiFiVersionAttributeSubscriptionState() + data class Error(val exception: Exception) : WiFiVersionAttributeSubscriptionState() - object SubscriptionEstablished : WiFiVersionAttributeSubscriptionState() - } -class ChannelNumberAttribute( - val value: UShort? - ) + object SubscriptionEstablished : WiFiVersionAttributeSubscriptionState() + } + + class ChannelNumberAttribute(val value: UShort?) sealed class ChannelNumberAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : ChannelNumberAttributeSubscriptionState() - + data class Success(val value: UShort?) : ChannelNumberAttributeSubscriptionState() + data class Error(val exception: Exception) : ChannelNumberAttributeSubscriptionState() - object SubscriptionEstablished : ChannelNumberAttributeSubscriptionState() - } -class RssiAttribute( - val value: Byte? - ) + object SubscriptionEstablished : ChannelNumberAttributeSubscriptionState() + } + + class RssiAttribute(val value: Byte?) sealed class RssiAttributeSubscriptionState { - data class Success( - val value: Byte? - ) : RssiAttributeSubscriptionState() - + data class Success(val value: Byte?) : RssiAttributeSubscriptionState() + data class Error(val exception: Exception) : RssiAttributeSubscriptionState() - object SubscriptionEstablished : RssiAttributeSubscriptionState() - } -class BeaconLostCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : RssiAttributeSubscriptionState() + } + + class BeaconLostCountAttribute(val value: UInt?) sealed class BeaconLostCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BeaconLostCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : BeaconLostCountAttributeSubscriptionState() + data class Error(val exception: Exception) : BeaconLostCountAttributeSubscriptionState() - object SubscriptionEstablished : BeaconLostCountAttributeSubscriptionState() - } -class BeaconRxCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : BeaconLostCountAttributeSubscriptionState() + } + + class BeaconRxCountAttribute(val value: UInt?) sealed class BeaconRxCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : BeaconRxCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : BeaconRxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : BeaconRxCountAttributeSubscriptionState() - object SubscriptionEstablished : BeaconRxCountAttributeSubscriptionState() - } -class PacketMulticastRxCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : BeaconRxCountAttributeSubscriptionState() + } + + class PacketMulticastRxCountAttribute(val value: UInt?) sealed class PacketMulticastRxCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PacketMulticastRxCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : PacketMulticastRxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketMulticastRxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketMulticastRxCountAttributeSubscriptionState() - } -class PacketMulticastTxCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : PacketMulticastRxCountAttributeSubscriptionState() + } + + class PacketMulticastTxCountAttribute(val value: UInt?) sealed class PacketMulticastTxCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PacketMulticastTxCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : PacketMulticastTxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketMulticastTxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketMulticastTxCountAttributeSubscriptionState() - } -class PacketUnicastRxCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : PacketMulticastTxCountAttributeSubscriptionState() + } + + class PacketUnicastRxCountAttribute(val value: UInt?) sealed class PacketUnicastRxCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PacketUnicastRxCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : PacketUnicastRxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketUnicastRxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketUnicastRxCountAttributeSubscriptionState() - } -class PacketUnicastTxCountAttribute( - val value: UInt? - ) + object SubscriptionEstablished : PacketUnicastRxCountAttributeSubscriptionState() + } + + class PacketUnicastTxCountAttribute(val value: UInt?) sealed class PacketUnicastTxCountAttributeSubscriptionState { - data class Success( - val value: UInt? - ) : PacketUnicastTxCountAttributeSubscriptionState() - + data class Success(val value: UInt?) : PacketUnicastTxCountAttributeSubscriptionState() + data class Error(val exception: Exception) : PacketUnicastTxCountAttributeSubscriptionState() - object SubscriptionEstablished : PacketUnicastTxCountAttributeSubscriptionState() - } -class CurrentMaxRateAttribute( - val value: ULong? - ) + object SubscriptionEstablished : PacketUnicastTxCountAttributeSubscriptionState() + } + + class CurrentMaxRateAttribute(val value: ULong?) sealed class CurrentMaxRateAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : CurrentMaxRateAttributeSubscriptionState() - + data class Success(val value: ULong?) : CurrentMaxRateAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentMaxRateAttributeSubscriptionState() - object SubscriptionEstablished : CurrentMaxRateAttributeSubscriptionState() - } -class OverrunCountAttribute( - val value: ULong? - ) + object SubscriptionEstablished : CurrentMaxRateAttributeSubscriptionState() + } + + class OverrunCountAttribute(val value: ULong?) sealed class OverrunCountAttributeSubscriptionState { - data class Success( - val value: ULong? - ) : OverrunCountAttributeSubscriptionState() - + data class Success(val value: ULong?) : OverrunCountAttributeSubscriptionState() + data class Error(val exception: Exception) : OverrunCountAttributeSubscriptionState() - object SubscriptionEstablished : OverrunCountAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : OverrunCountAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun resetCounts(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -298,46 +229,40 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readBssidAttribute(): BssidAttribute {val ATTRIBUTE_ID: UInt = 0u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBssidAttribute(): BssidAttribute { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bssid attribute not found in response" - } + } + + requireNotNull(attributeData) { "Bssid attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return BssidAttribute(decodedValue) } @@ -347,96 +272,90 @@ suspend fun readBssidAttribute(): BssidAttribute {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BssidAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BssidAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Bssid attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Bssid attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ByteArray? = if (!tlvReader.isNull()) { - tlvReader.getByteArray(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BssidAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ByteArray? = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BssidAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BssidAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSecurityTypeAttribute(): SecurityTypeAttribute {val ATTRIBUTE_ID: UInt = 1u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readSecurityTypeAttribute(): SecurityTypeAttribute { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Securitytype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Securitytype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return SecurityTypeAttribute(decodedValue) } @@ -446,96 +365,90 @@ suspend fun readSecurityTypeAttribute(): SecurityTypeAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(SecurityTypeAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + SecurityTypeAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Securitytype attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Securitytype attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(SecurityTypeAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(SecurityTypeAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(SecurityTypeAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readWiFiVersionAttribute(): WiFiVersionAttribute {val ATTRIBUTE_ID: UInt = 2u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readWiFiVersionAttribute(): WiFiVersionAttribute { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wifiversion attribute not found in response" - } + } + + requireNotNull(attributeData) { "Wifiversion attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return WiFiVersionAttribute(decodedValue) } @@ -545,96 +458,90 @@ suspend fun readWiFiVersionAttribute(): WiFiVersionAttribute {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(WiFiVersionAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + WiFiVersionAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Wifiversion attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Wifiversion attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - tlvReader.getUByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(WiFiVersionAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + tlvReader.getUByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(WiFiVersionAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(WiFiVersionAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readChannelNumberAttribute(): ChannelNumberAttribute {val ATTRIBUTE_ID: UInt = 3u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readChannelNumberAttribute(): ChannelNumberAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channelnumber attribute not found in response" - } + } + + requireNotNull(attributeData) { "Channelnumber attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return ChannelNumberAttribute(decodedValue) } @@ -644,96 +551,90 @@ suspend fun readChannelNumberAttribute(): ChannelNumberAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(ChannelNumberAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + ChannelNumberAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Channelnumber attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Channelnumber attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - tlvReader.getUShort(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(ChannelNumberAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + tlvReader.getUShort(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(ChannelNumberAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(ChannelNumberAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readRssiAttribute(): RssiAttribute {val ATTRIBUTE_ID: UInt = 4u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readRssiAttribute(): RssiAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rssi attribute not found in response" - } + } + + requireNotNull(attributeData) { "Rssi attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } return RssiAttribute(decodedValue) } @@ -743,100 +644,94 @@ suspend fun readRssiAttribute(): RssiAttribute {val ATTRIBUTE_ID: UInt = 4u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(RssiAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + RssiAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Rssi attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Rssi attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: Byte? = if (!tlvReader.isNull()) { - tlvReader.getByte(AnonymousTag) - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(RssiAttributeSubscriptionState.Success(it)) - } - + val decodedValue: Byte? = + if (!tlvReader.isNull()) { + tlvReader.getByte(AnonymousTag) + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(RssiAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(RssiAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBeaconLostCountAttribute(): BeaconLostCountAttribute {val ATTRIBUTE_ID: UInt = 5u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBeaconLostCountAttribute(): BeaconLostCountAttribute { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Beaconlostcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Beaconlostcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BeaconLostCountAttribute(decodedValue) } @@ -846,104 +741,100 @@ suspend fun readBeaconLostCountAttribute(): BeaconLostCountAttribute {val ATTRIB maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BeaconLostCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BeaconLostCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Beaconlostcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Beaconlostcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BeaconLostCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BeaconLostCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BeaconLostCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readBeaconRxCountAttribute(): BeaconRxCountAttribute {val ATTRIBUTE_ID: UInt = 6u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readBeaconRxCountAttribute(): BeaconRxCountAttribute { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Beaconrxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Beaconrxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return BeaconRxCountAttribute(decodedValue) } @@ -953,104 +844,98 @@ suspend fun readBeaconRxCountAttribute(): BeaconRxCountAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(BeaconRxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + BeaconRxCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Beaconrxcount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Beaconrxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(BeaconRxCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(BeaconRxCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(BeaconRxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketMulticastRxCountAttribute(): PacketMulticastRxCountAttribute {val ATTRIBUTE_ID: UInt = 7u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketMulticastRxCountAttribute(): PacketMulticastRxCountAttribute { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetmulticastrxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packetmulticastrxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PacketMulticastRxCountAttribute(decodedValue) } @@ -1060,104 +945,100 @@ suspend fun readPacketMulticastRxCountAttribute(): PacketMulticastRxCountAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PacketMulticastRxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PacketMulticastRxCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetmulticastrxcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Packetmulticastrxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PacketMulticastRxCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PacketMulticastRxCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PacketMulticastRxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketMulticastTxCountAttribute(): PacketMulticastTxCountAttribute {val ATTRIBUTE_ID: UInt = 8u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketMulticastTxCountAttribute(): PacketMulticastTxCountAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetmulticasttxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packetmulticasttxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PacketMulticastTxCountAttribute(decodedValue) } @@ -1167,104 +1048,100 @@ suspend fun readPacketMulticastTxCountAttribute(): PacketMulticastTxCountAttribu maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PacketMulticastTxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PacketMulticastTxCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetmulticasttxcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Packetmulticasttxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PacketMulticastTxCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PacketMulticastTxCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PacketMulticastTxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketUnicastRxCountAttribute(): PacketUnicastRxCountAttribute {val ATTRIBUTE_ID: UInt = 9u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketUnicastRxCountAttribute(): PacketUnicastRxCountAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetunicastrxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packetunicastrxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PacketUnicastRxCountAttribute(decodedValue) } @@ -1274,104 +1151,100 @@ suspend fun readPacketUnicastRxCountAttribute(): PacketUnicastRxCountAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PacketUnicastRxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PacketUnicastRxCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetunicastrxcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Packetunicastrxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PacketUnicastRxCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PacketUnicastRxCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PacketUnicastRxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPacketUnicastTxCountAttribute(): PacketUnicastTxCountAttribute {val ATTRIBUTE_ID: UInt = 10u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readPacketUnicastTxCountAttribute(): PacketUnicastTxCountAttribute { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetunicasttxcount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Packetunicasttxcount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return PacketUnicastTxCountAttribute(decodedValue) } @@ -1381,104 +1254,100 @@ suspend fun readPacketUnicastTxCountAttribute(): PacketUnicastTxCountAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(PacketUnicastTxCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + PacketUnicastTxCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Packetunicasttxcount attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Packetunicasttxcount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UInt? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUInt(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(PacketUnicastTxCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UInt? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUInt(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(PacketUnicastTxCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(PacketUnicastTxCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentMaxRateAttribute(): CurrentMaxRateAttribute {val ATTRIBUTE_ID: UInt = 11u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readCurrentMaxRateAttribute(): CurrentMaxRateAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmaxrate attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentmaxrate attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentMaxRateAttribute(decodedValue) } @@ -1488,104 +1357,100 @@ suspend fun readCurrentMaxRateAttribute(): CurrentMaxRateAttribute {val ATTRIBUT maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentMaxRateAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentMaxRateAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentmaxrate attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentmaxrate attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentMaxRateAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentMaxRateAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentMaxRateAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOverrunCountAttribute(): OverrunCountAttribute {val ATTRIBUTE_ID: UInt = 12u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readOverrunCountAttribute(): OverrunCountAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in response" - } + } + + requireNotNull(attributeData) { "Overruncount attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return OverrunCountAttribute(decodedValue) } @@ -1595,101 +1460,95 @@ suspend fun readOverrunCountAttribute(): OverrunCountAttribute {val ATTRIBUTE_ID maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(OverrunCountAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + OverrunCountAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Overruncount attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Overruncount attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: ULong? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getULong(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(OverrunCountAttributeSubscriptionState.Success(it)) - } - + val decodedValue: ULong? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getULong(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(OverrunCountAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(OverrunCountAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -1699,45 +1558,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1745,49 +1609,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -1797,45 +1655,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -1843,49 +1706,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -1895,45 +1752,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -1941,49 +1801,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -1993,45 +1847,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2039,44 +1896,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2085,35 +1935,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2125,44 +1977,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) - - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - + + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) + val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -2171,34 +2016,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -2211,7 +2060,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt b/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt index d47645e5b75dca..7fb2facd9cc45b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/clusters/WindowCoveringCluster.kt @@ -17,210 +17,173 @@ package matter.controller.cluster.clusters +import java.time.Duration import java.util.logging.Level import java.util.logging.Logger -import java.time.Duration import kotlinx.coroutines.flow.Flow import kotlinx.coroutines.flow.transform +import matter.controller.InvokeRequest +import matter.controller.InvokeResponse import matter.controller.MatterController -import matter.controller.ReadRequest import matter.controller.ReadData -import matter.controller.ReadFailure -import matter.controller.ReadResponse +import matter.controller.ReadRequest import matter.controller.SubscribeRequest import matter.controller.SubscriptionState -import matter.controller.ByteSubscriptionState -import matter.controller.ShortSubscriptionState -import matter.controller.IntSubscriptionState -import matter.controller.LongSubscriptionState -import matter.controller.FloatSubscriptionState -import matter.controller.DoubleSubscriptionState -import matter.controller.CharSubscriptionState -import matter.controller.BooleanSubscriptionState import matter.controller.UByteSubscriptionState -import matter.controller.UShortSubscriptionState import matter.controller.UIntSubscriptionState -import matter.controller.ULongSubscriptionState -import matter.controller.StringSubscriptionState -import matter.controller.ByteArraySubscriptionState +import matter.controller.UShortSubscriptionState import matter.controller.WriteRequest import matter.controller.WriteRequests import matter.controller.WriteResponse -import matter.controller.AttributeWriteError -import matter.controller.InvokeRequest -import matter.controller.InvokeResponse +import matter.controller.cluster.structs.* import matter.controller.model.AttributePath import matter.controller.model.CommandPath -import matter.controller.cluster.structs.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag -import matter.tlv.Tag -import matter.tlv.TlvParsingException import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WindowCoveringCluster(private val controller: MatterController, private val endpointId: UShort) {class CurrentPositionLiftAttribute( - val value: UShort? - ) +class WindowCoveringCluster( + private val controller: MatterController, + private val endpointId: UShort +) { + class CurrentPositionLiftAttribute(val value: UShort?) sealed class CurrentPositionLiftAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : CurrentPositionLiftAttributeSubscriptionState() - + data class Success(val value: UShort?) : CurrentPositionLiftAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPositionLiftAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPositionLiftAttributeSubscriptionState() - } -class CurrentPositionTiltAttribute( - val value: UShort? - ) + object SubscriptionEstablished : CurrentPositionLiftAttributeSubscriptionState() + } + + class CurrentPositionTiltAttribute(val value: UShort?) sealed class CurrentPositionTiltAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : CurrentPositionTiltAttributeSubscriptionState() - + data class Success(val value: UShort?) : CurrentPositionTiltAttributeSubscriptionState() + data class Error(val exception: Exception) : CurrentPositionTiltAttributeSubscriptionState() - object SubscriptionEstablished : CurrentPositionTiltAttributeSubscriptionState() - } -class CurrentPositionLiftPercentageAttribute( - val value: UByte? - ) + object SubscriptionEstablished : CurrentPositionTiltAttributeSubscriptionState() + } + + class CurrentPositionLiftPercentageAttribute(val value: UByte?) sealed class CurrentPositionLiftPercentageAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentPositionLiftPercentageAttributeSubscriptionState() - - data class Error(val exception: Exception) : CurrentPositionLiftPercentageAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionLiftPercentageAttributeSubscriptionState() - } -class CurrentPositionTiltPercentageAttribute( - val value: UByte? - ) + data class Success(val value: UByte?) : + CurrentPositionLiftPercentageAttributeSubscriptionState() + + data class Error(val exception: Exception) : + CurrentPositionLiftPercentageAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionLiftPercentageAttributeSubscriptionState() + } + + class CurrentPositionTiltPercentageAttribute(val value: UByte?) sealed class CurrentPositionTiltPercentageAttributeSubscriptionState { - data class Success( - val value: UByte? - ) : CurrentPositionTiltPercentageAttributeSubscriptionState() - - data class Error(val exception: Exception) : CurrentPositionTiltPercentageAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionTiltPercentageAttributeSubscriptionState() - } -class TargetPositionLiftPercent100thsAttribute( - val value: UShort? - ) + data class Success(val value: UByte?) : + CurrentPositionTiltPercentageAttributeSubscriptionState() + + data class Error(val exception: Exception) : + CurrentPositionTiltPercentageAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionTiltPercentageAttributeSubscriptionState() + } + + class TargetPositionLiftPercent100thsAttribute(val value: UShort?) sealed class TargetPositionLiftPercent100thsAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : TargetPositionLiftPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : TargetPositionLiftPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : TargetPositionLiftPercent100thsAttributeSubscriptionState() - } -class TargetPositionTiltPercent100thsAttribute( - val value: UShort? - ) + data class Success(val value: UShort?) : + TargetPositionLiftPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + TargetPositionLiftPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : TargetPositionLiftPercent100thsAttributeSubscriptionState() + } + + class TargetPositionTiltPercent100thsAttribute(val value: UShort?) sealed class TargetPositionTiltPercent100thsAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : TargetPositionTiltPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : TargetPositionTiltPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : TargetPositionTiltPercent100thsAttributeSubscriptionState() - } -class CurrentPositionLiftPercent100thsAttribute( - val value: UShort? - ) + data class Success(val value: UShort?) : + TargetPositionTiltPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + TargetPositionTiltPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : TargetPositionTiltPercent100thsAttributeSubscriptionState() + } + + class CurrentPositionLiftPercent100thsAttribute(val value: UShort?) sealed class CurrentPositionLiftPercent100thsAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : CurrentPositionLiftPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : CurrentPositionLiftPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionLiftPercent100thsAttributeSubscriptionState() - } -class CurrentPositionTiltPercent100thsAttribute( - val value: UShort? - ) + data class Success(val value: UShort?) : + CurrentPositionLiftPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + CurrentPositionLiftPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionLiftPercent100thsAttributeSubscriptionState() + } + + class CurrentPositionTiltPercent100thsAttribute(val value: UShort?) sealed class CurrentPositionTiltPercent100thsAttributeSubscriptionState { - data class Success( - val value: UShort? - ) : CurrentPositionTiltPercent100thsAttributeSubscriptionState() - - data class Error(val exception: Exception) : CurrentPositionTiltPercent100thsAttributeSubscriptionState() - - object SubscriptionEstablished : CurrentPositionTiltPercent100thsAttributeSubscriptionState() - } -class GeneratedCommandListAttribute( - val value: List - ) + data class Success(val value: UShort?) : + CurrentPositionTiltPercent100thsAttributeSubscriptionState() + + data class Error(val exception: Exception) : + CurrentPositionTiltPercent100thsAttributeSubscriptionState() + + object SubscriptionEstablished : CurrentPositionTiltPercent100thsAttributeSubscriptionState() + } + + class GeneratedCommandListAttribute(val value: List) sealed class GeneratedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : GeneratedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : GeneratedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : GeneratedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() - } -class AcceptedCommandListAttribute( - val value: List - ) + object SubscriptionEstablished : GeneratedCommandListAttributeSubscriptionState() + } + + class AcceptedCommandListAttribute(val value: List) sealed class AcceptedCommandListAttributeSubscriptionState { - data class Success( - val value: List - ) : AcceptedCommandListAttributeSubscriptionState() - + data class Success(val value: List) : AcceptedCommandListAttributeSubscriptionState() + data class Error(val exception: Exception) : AcceptedCommandListAttributeSubscriptionState() - object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() - } -class EventListAttribute( - val value: List - ) + object SubscriptionEstablished : AcceptedCommandListAttributeSubscriptionState() + } + + class EventListAttribute(val value: List) sealed class EventListAttributeSubscriptionState { - data class Success( - val value: List - ) : EventListAttributeSubscriptionState() - + data class Success(val value: List) : EventListAttributeSubscriptionState() + data class Error(val exception: Exception) : EventListAttributeSubscriptionState() - object SubscriptionEstablished : EventListAttributeSubscriptionState() - } -class AttributeListAttribute( - val value: List - ) + object SubscriptionEstablished : EventListAttributeSubscriptionState() + } + + class AttributeListAttribute(val value: List) sealed class AttributeListAttributeSubscriptionState { - data class Success( - val value: List - ) : AttributeListAttributeSubscriptionState() - + data class Success(val value: List) : AttributeListAttributeSubscriptionState() + data class Error(val exception: Exception) : AttributeListAttributeSubscriptionState() - object SubscriptionEstablished : AttributeListAttributeSubscriptionState() - } + object SubscriptionEstablished : AttributeListAttributeSubscriptionState() + } suspend fun upOrOpen(timedInvokeTimeout: Duration? = null) { val commandId: UInt = 0u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -238,7 +201,7 @@ class AttributeListAttribute( val commandId: UInt = 1u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -256,7 +219,7 @@ class AttributeListAttribute( val commandId: UInt = 2u val tlvWriter = TlvWriter() - tlvWriter.startStructure(AnonymousTag) + tlvWriter.startStructure(AnonymousTag) tlvWriter.endStructure() val request: InvokeRequest = @@ -270,15 +233,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToLiftValue(liftValue: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun goToLiftValue(liftValue: UShort, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 4u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LIFT_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LIFT_VALUE_REQ), liftValue) + tlvWriter.put(ContextSpecificTag(TAG_LIFT_VALUE_REQ), liftValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -292,15 +254,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToLiftPercentage(liftPercent100thsValue: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun goToLiftPercentage( + liftPercent100thsValue: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 5u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_LIFT_PERCENT100THS_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_LIFT_PERCENT100THS_VALUE_REQ), liftPercent100thsValue) + tlvWriter.put(ContextSpecificTag(TAG_LIFT_PERCENT100THS_VALUE_REQ), liftPercent100thsValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -314,15 +278,14 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToTiltValue(tiltValue: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun goToTiltValue(tiltValue: UShort, timedInvokeTimeout: Duration? = null) { val commandId: UInt = 7u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TILT_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TILT_VALUE_REQ), tiltValue) + tlvWriter.put(ContextSpecificTag(TAG_TILT_VALUE_REQ), tiltValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -336,15 +299,17 @@ class AttributeListAttribute( logger.log(Level.FINE, "Invoke command succeeded: ${response}") } - suspend fun goToTiltPercentage(tiltPercent100thsValue: UShort - ,timedInvokeTimeout: Duration? = null) { + suspend fun goToTiltPercentage( + tiltPercent100thsValue: UShort, + timedInvokeTimeout: Duration? = null + ) { val commandId: UInt = 8u val tlvWriter = TlvWriter() tlvWriter.startStructure(AnonymousTag) val TAG_TILT_PERCENT100THS_VALUE_REQ: Int = 0 - tlvWriter.put(ContextSpecificTag(TAG_TILT_PERCENT100THS_VALUE_REQ), tiltPercent100thsValue) + tlvWriter.put(ContextSpecificTag(TAG_TILT_PERCENT100THS_VALUE_REQ), tiltPercent100thsValue) tlvWriter.endStructure() val request: InvokeRequest = @@ -357,42 +322,35 @@ class AttributeListAttribute( val response: InvokeResponse = controller.invoke(request) logger.log(Level.FINE, "Invoke command succeeded: ${response}") } -suspend fun readTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 0u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Type attribute not found in response" - } + } + + requireNotNull(attributeData) { "Type attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -401,35 +359,37 @@ suspend fun readTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 0u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Type attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Type attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -441,47 +401,41 @@ suspend fun readTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 0u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalClosedLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 1u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPhysicalClosedLimitLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 1u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalclosedlimitlift attribute not found in response" - } + } + + requireNotNull(attributeData) { "Physicalclosedlimitlift attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -491,94 +445,90 @@ suspend fun readPhysicalClosedLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 1u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalclosedlimitlift attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalclosedlimitlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readPhysicalClosedLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 2u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readPhysicalClosedLimitTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 2u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalclosedlimittilt attribute not found in response" - } + } + + requireNotNull(attributeData) { "Physicalclosedlimittilt attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -588,99 +538,95 @@ suspend fun readPhysicalClosedLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: U maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 2u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Physicalclosedlimittilt attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Physicalclosedlimittilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionLiftAttribute(): CurrentPositionLiftAttribute {val ATTRIBUTE_ID: UInt = 3u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionLiftAttribute(): CurrentPositionLiftAttribute { + val ATTRIBUTE_ID: UInt = 3u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionlift attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentpositionlift attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionLiftAttribute(decodedValue) } @@ -690,104 +636,100 @@ suspend fun readCurrentPositionLiftAttribute(): CurrentPositionLiftAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 3u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionLiftAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionLiftAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionlift attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositionlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentPositionLiftAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentPositionLiftAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionLiftAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionTiltAttribute(): CurrentPositionTiltAttribute {val ATTRIBUTE_ID: UInt = 4u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionTiltAttribute(): CurrentPositionTiltAttribute { + val ATTRIBUTE_ID: UInt = 4u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontilt attribute not found in response" - } + } + + requireNotNull(attributeData) { "Currentpositiontilt attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionTiltAttribute(decodedValue) } @@ -797,99 +739,95 @@ suspend fun readCurrentPositionTiltAttribute(): CurrentPositionTiltAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 4u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionTiltAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionTiltAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontilt attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositiontilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - - decodedValue?.let { - emit(CurrentPositionTiltAttributeSubscriptionState.Success(it)) - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } + + decodedValue?.let { emit(CurrentPositionTiltAttributeSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionTiltAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfActuationsLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 5u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfActuationsLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 5u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofactuationslift attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofactuationslift attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -899,94 +837,90 @@ suspend fun readNumberOfActuationsLiftAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 5u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofactuationslift attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofactuationslift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readNumberOfActuationsTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 6u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readNumberOfActuationsTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 6u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofactuationstilt attribute not found in response" - } + } + + requireNotNull(attributeData) { "Numberofactuationstilt attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -996,91 +930,86 @@ suspend fun readNumberOfActuationsTiltAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 6u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Numberofactuationstilt attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Numberofactuationstilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readConfigStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readConfigStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 7u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Configstatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Configstatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1089,35 +1018,37 @@ suspend fun readConfigStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 7u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Configstatus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Configstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -1129,52 +1060,48 @@ suspend fun readConfigStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 7u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionLiftPercentageAttribute(): CurrentPositionLiftPercentageAttribute {val ATTRIBUTE_ID: UInt = 8u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionLiftPercentageAttribute(): CurrentPositionLiftPercentageAttribute { + val ATTRIBUTE_ID: UInt = 8u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionliftpercentage attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositionliftpercentage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionLiftPercentageAttribute(decodedValue) } @@ -1184,104 +1111,104 @@ suspend fun readCurrentPositionLiftPercentageAttribute(): CurrentPositionLiftPer maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 8u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionLiftPercentageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionLiftPercentageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionliftpercentage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositionliftpercentage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionLiftPercentageAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionLiftPercentageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionTiltPercentageAttribute(): CurrentPositionTiltPercentageAttribute {val ATTRIBUTE_ID: UInt = 9u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionTiltPercentageAttribute(): CurrentPositionTiltPercentageAttribute { + val ATTRIBUTE_ID: UInt = 9u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontiltpercentage attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositiontiltpercentage attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionTiltPercentageAttribute(decodedValue) } @@ -1291,96 +1218,93 @@ suspend fun readCurrentPositionTiltPercentageAttribute(): CurrentPositionTiltPer maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 9u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionTiltPercentageAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionTiltPercentageAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontiltpercentage attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositiontiltpercentage attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UByte? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUByte(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UByte? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUByte(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionTiltPercentageAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionTiltPercentageAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readOperationalStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readOperationalStatusAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 10u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Operationalstatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1389,34 +1313,38 @@ suspend fun readOperationalStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 10u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Operationalstatus attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Operationalstatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1429,52 +1357,49 @@ suspend fun readOperationalStatusAttribute(): UByte {val ATTRIBUTE_ID: UInt = 10 emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTargetPositionLiftPercent100thsAttribute(): TargetPositionLiftPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 11u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTargetPositionLiftPercent100thsAttribute(): + TargetPositionLiftPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 11u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetpositionliftpercent100ths attribute not found in response" + } + + requireNotNull(attributeData) { + "Targetpositionliftpercent100ths attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return TargetPositionLiftPercent100thsAttribute(decodedValue) } @@ -1484,104 +1409,105 @@ suspend fun readTargetPositionLiftPercent100thsAttribute(): TargetPositionLiftPe maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 11u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TargetPositionLiftPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TargetPositionLiftPercent100thsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetpositionliftpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Targetpositionliftpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(TargetPositionLiftPercent100thsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(TargetPositionLiftPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readTargetPositionTiltPercent100thsAttribute(): TargetPositionTiltPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 12u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readTargetPositionTiltPercent100thsAttribute(): + TargetPositionTiltPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 12u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetpositiontiltpercent100ths attribute not found in response" - } - - // Decode the TLV data into the appropriate type - val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null + } + + requireNotNull(attributeData) { + "Targetpositiontiltpercent100ths attribute not found in response" } + // Decode the TLV data into the appropriate type + val tlvReader = TlvReader(attributeData.data) + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return TargetPositionTiltPercent100thsAttribute(decodedValue) } @@ -1591,96 +1517,93 @@ suspend fun readTargetPositionTiltPercent100thsAttribute(): TargetPositionTiltPe maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 12u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(TargetPositionTiltPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + TargetPositionTiltPercent100thsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Targetpositiontiltpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Targetpositiontiltpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(TargetPositionTiltPercent100thsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(TargetPositionTiltPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEndProductTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 13u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEndProductTypeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 13u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endproducttype attribute not found in response" - } + } + + requireNotNull(attributeData) { "Endproducttype attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } @@ -1689,34 +1612,38 @@ suspend fun readEndProductTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 13u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 13u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Endproducttype attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Endproducttype attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -1729,52 +1656,49 @@ suspend fun readEndProductTypeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 13u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionLiftPercent100thsAttribute(): CurrentPositionLiftPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 14u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionLiftPercent100thsAttribute(): + CurrentPositionLiftPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 14u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionliftpercent100ths attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositionliftpercent100ths attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionLiftPercent100thsAttribute(decodedValue) } @@ -1784,104 +1708,105 @@ suspend fun readCurrentPositionLiftPercent100thsAttribute(): CurrentPositionLift maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 14u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionLiftPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionLiftPercent100thsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositionliftpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositionliftpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionLiftPercent100thsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionLiftPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readCurrentPositionTiltPercent100thsAttribute(): CurrentPositionTiltPercent100thsAttribute {val ATTRIBUTE_ID: UInt = 15u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readCurrentPositionTiltPercent100thsAttribute(): + CurrentPositionTiltPercent100thsAttribute { + val ATTRIBUTE_ID: UInt = 15u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontiltpercent100ths attribute not found in response" + } + + requireNotNull(attributeData) { + "Currentpositiontiltpercent100ths attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } - + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } return CurrentPositionTiltPercent100thsAttribute(decodedValue) } @@ -1891,99 +1816,97 @@ suspend fun readCurrentPositionTiltPercent100thsAttribute(): CurrentPositionTilt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 15u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(CurrentPositionTiltPercent100thsAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + CurrentPositionTiltPercent100thsAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Currentpositiontiltpercent100ths attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Currentpositiontiltpercent100ths attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - } else { - tlvReader.getNull(AnonymousTag) - null - } + val decodedValue: UShort? = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } + } else { + tlvReader.getNull(AnonymousTag) + null + } decodedValue?.let { emit(CurrentPositionTiltPercent100thsAttributeSubscriptionState.Success(it)) } - } SubscriptionState.SubscriptionEstablished -> { emit(CurrentPositionTiltPercent100thsAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstalledOpenLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 16u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstalledOpenLimitLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 16u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedopenlimitlift attribute not found in response" - } + } + + requireNotNull(attributeData) { "Installedopenlimitlift attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -1993,94 +1916,90 @@ suspend fun readInstalledOpenLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 16u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedopenlimitlift attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Installedopenlimitlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstalledClosedLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 17u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstalledClosedLimitLiftAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 17u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedclosedlimitlift attribute not found in response" - } + } + + requireNotNull(attributeData) { "Installedclosedlimitlift attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2090,94 +2009,90 @@ suspend fun readInstalledClosedLimitLiftAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 17u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedclosedlimitlift attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Installedclosedlimitlift attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstalledOpenLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 18u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstalledOpenLimitTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 18u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedopenlimittilt attribute not found in response" - } + } + + requireNotNull(attributeData) { "Installedopenlimittilt attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2187,94 +2102,90 @@ suspend fun readInstalledOpenLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: UI maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 18u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedopenlimittilt attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Installedopenlimittilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readInstalledClosedLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 19u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readInstalledClosedLimitTiltAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 19u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedclosedlimittilt attribute not found in response" - } + } + + requireNotNull(attributeData) { "Installedclosedlimittilt attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2284,114 +2195,105 @@ suspend fun readInstalledClosedLimitTiltAttribute(): UShort? {val ATTRIBUTE_ID: maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 19u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Installedclosedlimittilt attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Installedclosedlimittilt attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 23u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readModeAttribute(): UByte { + val ATTRIBUTE_ID: UInt = 23u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mode attribute not found in response" - } + } + + requireNotNull(attributeData) { "Mode attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UByte = tlvReader.getUByte(AnonymousTag) - return decodedValue } - suspend fun writeModeAttribute( - value: UByte, - timedWriteTimeout: Duration? = null) { + suspend fun writeModeAttribute(value: UByte, timedWriteTimeout: Duration? = null) { val ATTRIBUTE_ID: UInt = 23u val tlvWriter = TlvWriter() - tlvWriter.put(AnonymousTag, value) + tlvWriter.put(AnonymousTag, value) val writeRequests: WriteRequests = WriteRequests( - requests = listOf( - WriteRequest( - attributePath = AttributePath( - endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ), - tlvPayload = tlvWriter.getEncoded() - ) - ), + requests = + listOf( + WriteRequest( + attributePath = + AttributePath(endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID), + tlvPayload = tlvWriter.getEncoded() + ) + ), timedRequest = timedWriteTimeout ) @@ -2413,7 +2315,7 @@ suspend fun readModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 23u throw IllegalStateException("Write command failed with errors: \n$aggregatedErrorMessage") } - } + } } suspend fun subscribeModeAttribute( @@ -2421,35 +2323,37 @@ suspend fun readModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 23u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 23u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UByteSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UByteSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Mode attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Mode attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -2461,47 +2365,41 @@ suspend fun readModeAttribute(): UByte {val ATTRIBUTE_ID: UInt = 23u emit(UByteSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readSafetyStatusAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 26u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readSafetyStatusAttribute(): UShort? { + val ATTRIBUTE_ID: UInt = 26u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Safetystatus attribute not found in response" - } + } + + requireNotNull(attributeData) { "Safetystatus attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } - + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } return decodedValue } @@ -2511,96 +2409,90 @@ suspend fun readSafetyStatusAttribute(): UShort? {val ATTRIBUTE_ID: UInt = 26u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 26u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Safetystatus attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Safetystatus attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: UShort? = if (tlvReader.isNextTag(AnonymousTag)) { - tlvReader.getUShort(AnonymousTag) - } else { - null - } + val decodedValue: UShort? = + if (tlvReader.isNextTag(AnonymousTag)) { + tlvReader.getUShort(AnonymousTag) + } else { + null + } - decodedValue?.let { - emit(UShortSubscriptionState.Success(it)) - } - + decodedValue?.let { emit(UShortSubscriptionState.Success(it)) } } SubscriptionState.SubscriptionEstablished -> { emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65528u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65528u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Generatedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return GeneratedCommandListAttribute(decodedValue) } @@ -2610,45 +2502,50 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65528u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(GeneratedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + GeneratedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Generatedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Generatedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(GeneratedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2656,49 +2553,43 @@ suspend fun readGeneratedCommandListAttribute(): GeneratedCommandListAttribute { emit(GeneratedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {val ATTRIBUTE_ID: UInt = 65529u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute { + val ATTRIBUTE_ID: UInt = 65529u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Acceptedcommandlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AcceptedCommandListAttribute(decodedValue) } @@ -2708,45 +2599,50 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65529u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AcceptedCommandListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AcceptedCommandListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Acceptedcommandlist attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Acceptedcommandlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AcceptedCommandListAttributeSubscriptionState.Success(decodedValue)) } @@ -2754,49 +2650,43 @@ suspend fun readAcceptedCommandListAttribute(): AcceptedCommandListAttribute {va emit(AcceptedCommandListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt = 65530u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readEventListAttribute(): EventListAttribute { + val ATTRIBUTE_ID: UInt = 65530u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Eventlist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return EventListAttribute(decodedValue) } @@ -2806,45 +2696,48 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65530u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(EventListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + EventListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Eventlist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Eventlist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(EventListAttributeSubscriptionState.Success(decodedValue)) } @@ -2852,49 +2745,43 @@ suspend fun readEventListAttribute(): EventListAttribute {val ATTRIBUTE_ID: UInt emit(EventListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ID: UInt = 65531u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readAttributeListAttribute(): AttributeListAttribute { + val ATTRIBUTE_ID: UInt = 65531u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in response" - } + } + + requireNotNull(attributeData) { "Attributelist attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - return AttributeListAttribute(decodedValue) } @@ -2904,45 +2791,48 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65531u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(AttributeListAttributeSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + AttributeListAttributeSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Attributelist attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Attributelist attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) - val decodedValue: List = buildList { - tlvReader.enterArray(AnonymousTag) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } + val decodedValue: List = + buildList { + tlvReader.enterArray(AnonymousTag) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } emit(AttributeListAttributeSubscriptionState.Success(decodedValue)) } @@ -2950,44 +2840,37 @@ suspend fun readAttributeListAttribute(): AttributeListAttribute {val ATTRIBUTE_ emit(AttributeListAttributeSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readFeatureMapAttribute(): UInt { + val ATTRIBUTE_ID: UInt = 65532u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in response" - } + } + + requireNotNull(attributeData) { "Featuremap attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UInt = tlvReader.getUInt(AnonymousTag) - return decodedValue } @@ -2996,35 +2879,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65532u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UIntSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UIntSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Featuremap attribute not found in Node State update" - } + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { "Featuremap attribute not found in Node State update" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) @@ -3036,44 +2921,37 @@ suspend fun readFeatureMapAttribute(): UInt {val ATTRIBUTE_ID: UInt = 65532u emit(UIntSubscriptionState.SubscriptionEstablished) } } - } + } } -suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 65533u - val attributePath = AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID - ) + suspend fun readClusterRevisionAttribute(): UShort { + val ATTRIBUTE_ID: UInt = 65533u + + val attributePath = + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) + + val readRequest = ReadRequest(eventPaths = emptyList(), attributePaths = listOf(attributePath)) - val readRequest = ReadRequest( - eventPaths = emptyList(), - attributePaths = listOf(attributePath) - ) - val response = controller.read(readRequest) if (response.successes.isEmpty()) { logger.log(Level.WARNING, "Read command failed") - throw IllegalStateException("Read command failed with failures: ${response.failures}") - } + throw IllegalStateException("Read command failed with failures: ${response.failures}") + } logger.log(Level.FINE, "Read command succeeded") val attributeData = response.successes.filterIsInstance().firstOrNull { it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in response" - } + } + + requireNotNull(attributeData) { "Clusterrevision attribute not found in response" } // Decode the TLV data into the appropriate type val tlvReader = TlvReader(attributeData.data) val decodedValue: UShort = tlvReader.getUShort(AnonymousTag) - return decodedValue } @@ -3082,34 +2960,38 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 maxInterval: Int ): Flow { val ATTRIBUTE_ID: UInt = 65533u - val attributePaths = listOf( - AttributePath( - endpointId = endpointId, - clusterId = CLUSTER_ID, - attributeId = ATTRIBUTE_ID + val attributePaths = + listOf( + AttributePath(endpointId = endpointId, clusterId = CLUSTER_ID, attributeId = ATTRIBUTE_ID) ) - ) - val subscribeRequest: SubscribeRequest = SubscribeRequest( - eventPaths = emptyList(), - attributePaths = attributePaths, - minInterval = Duration.ofSeconds(minInterval.toLong()), - maxInterval = Duration.ofSeconds(maxInterval.toLong()) - ) + val subscribeRequest: SubscribeRequest = + SubscribeRequest( + eventPaths = emptyList(), + attributePaths = attributePaths, + minInterval = Duration.ofSeconds(minInterval.toLong()), + maxInterval = Duration.ofSeconds(maxInterval.toLong()) + ) return controller.subscribe(subscribeRequest).transform { subscriptionState -> when (subscriptionState) { is SubscriptionState.SubscriptionErrorNotification -> { - emit(UShortSubscriptionState.Error(Exception("Subscription terminated with error code: ${subscriptionState.terminationCause}"))) + emit( + UShortSubscriptionState.Error( + Exception( + "Subscription terminated with error code: ${subscriptionState.terminationCause}" + ) + ) + ) } is SubscriptionState.NodeStateUpdate -> { val attributeData = - subscriptionState.updateState.successes.filterIsInstance().firstOrNull { - it.path.attributeId == ATTRIBUTE_ID - } - - requireNotNull(attributeData) { - "Clusterrevision attribute not found in Node State update" + subscriptionState.updateState.successes + .filterIsInstance() + .firstOrNull { it.path.attributeId == ATTRIBUTE_ID } + + requireNotNull(attributeData) { + "Clusterrevision attribute not found in Node State update" } // Decode the TLV data into the appropriate type @@ -3122,7 +3004,7 @@ suspend fun readClusterRevisionAttribute(): UShort {val ATTRIBUTE_ID: UInt = 655 emit(UShortSubscriptionState.SubscriptionEstablished) } } - } + } } companion object { diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt index 391c1c223d35b1..bd0e6187f24cb5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlEntryChangedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,32 +70,47 @@ class AccessControlClusterAccessControlEntryChangedEvent( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlEntryChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlEntryChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUByte(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = if (!tlvReader.isNull()) { - matter.controller.cluster.structs.AccessControlClusterAccessControlEntryStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = + if (!tlvReader.isNull()) { + matter.controller.cluster.structs.AccessControlClusterAccessControlEntryStruct.fromTlv( + ContextSpecificTag(TAG_LATEST_VALUE), + tlvReader + ) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) + return AccessControlClusterAccessControlEntryChangedEvent( + adminNodeID, + adminPasscodeID, + changeType, + latestValue, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt index dafa1269b8e4c2..aa38ea414d325f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccessControlClusterAccessControlExtensionChangedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -28,7 +26,8 @@ class AccessControlClusterAccessControlExtensionChangedEvent( val adminNodeID: ULong?, val adminPasscodeID: UShort?, val changeType: UByte, - val latestValue: matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, + val latestValue: + matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct?, val fabricIndex: UByte ) { override fun toString(): String = buildString { @@ -72,32 +71,45 @@ class AccessControlClusterAccessControlExtensionChangedEvent( private const val TAG_LATEST_VALUE = 4 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccessControlClusterAccessControlExtensionChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlExtensionChangedEvent { tlvReader.enterStructure(tlvTag) - val adminNodeID = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) - null - } - val adminPasscodeID = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) - null - } + val adminNodeID = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_NODE_I_D)) + null + } + val adminPasscodeID = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ADMIN_PASSCODE_I_D)) + null + } val changeType = tlvReader.getUByte(ContextSpecificTag(TAG_CHANGE_TYPE)) - val latestValue = if (!tlvReader.isNull()) { - matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct.fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) - null - } + val latestValue = + if (!tlvReader.isNull()) { + matter.controller.cluster.structs.AccessControlClusterAccessControlExtensionStruct + .fromTlv(ContextSpecificTag(TAG_LATEST_VALUE), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LATEST_VALUE)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlExtensionChangedEvent(adminNodeID, adminPasscodeID, changeType, latestValue, fabricIndex) + return AccessControlClusterAccessControlExtensionChangedEvent( + adminNodeID, + adminPasscodeID, + changeType, + latestValue, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt index 4adc0b113c8e01..81e55baf4fe4f7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/AccountLoginClusterLoggedOutEvent.kt @@ -18,15 +18,12 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class AccountLoginClusterLoggedOutEvent( - val node: Optional -) { +class AccountLoginClusterLoggedOutEvent(val node: Optional) { override fun toString(): String = buildString { append("AccountLoginClusterLoggedOutEvent {\n") append("\tnode : $node\n") @@ -47,14 +44,15 @@ class AccountLoginClusterLoggedOutEvent( companion object { private const val TAG_NODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : AccountLoginClusterLoggedOutEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccountLoginClusterLoggedOutEvent { tlvReader.enterStructure(tlvTag) - val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - + val node = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return AccountLoginClusterLoggedOutEvent(node) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt index 90612b49fdd1d2..c1c26f5dc71c4a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterActionFailedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -56,13 +54,13 @@ class ActionsClusterActionFailedEvent( private const val TAG_NEW_STATE = 2 private const val TAG_ERROR = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterActionFailedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterActionFailedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUShort(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getUInt(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) val error = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR)) - + tlvReader.exitContainer() return ActionsClusterActionFailedEvent(actionID, invokeID, newState, error) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt index 2cf57936d0421c..25fdc842bf0af1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ActionsClusterStateChangedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,12 +50,12 @@ class ActionsClusterStateChangedEvent( private const val TAG_INVOKE_I_D = 1 private const val TAG_NEW_STATE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ActionsClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActionsClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val actionID = tlvReader.getUShort(ContextSpecificTag(TAG_ACTION_I_D)) val invokeID = tlvReader.getUInt(ContextSpecificTag(TAG_INVOKE_I_D)) val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) - + tlvReader.exitContainer() return ActionsClusterStateChangedEvent(actionID, invokeID, newState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt index 2b909a62b20b6f..ea0e7e1e1004c4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterLeaveEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterLeaveEvent( - val fabricIndex: UByte -) { +class BasicInformationClusterLeaveEvent(val fabricIndex: UByte) { override fun toString(): String = buildString { append("BasicInformationClusterLeaveEvent {\n") append("\tfabricIndex : $fabricIndex\n") @@ -44,10 +40,10 @@ class BasicInformationClusterLeaveEvent( companion object { private const val TAG_FABRIC_INDEX = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterLeaveEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterLeaveEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BasicInformationClusterLeaveEvent(fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt index 4bacfa94d86ef9..a6924b859aa024 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterReachableChangedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterReachableChangedEvent( - val reachableNewValue: Boolean -) { +class BasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { override fun toString(): String = buildString { append("BasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") @@ -44,10 +40,10 @@ class BasicInformationClusterReachableChangedEvent( companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterReachableChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt index 949ae5f92688a0..fff1d76a1fa86e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BasicInformationClusterStartUpEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterStartUpEvent( - val softwareVersion: UInt -) { +class BasicInformationClusterStartUpEvent(val softwareVersion: UInt) { override fun toString(): String = buildString { append("BasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") @@ -44,10 +40,10 @@ class BasicInformationClusterStartUpEvent( companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BasicInformationClusterStartUpEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt index 50b4494eebdc0d..82db9ecdb2a8f4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateClusterStateChangeEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateClusterStateChangeEvent( - val stateValue: Boolean -) { +class BooleanStateClusterStateChangeEvent(val stateValue: Boolean) { override fun toString(): String = buildString { append("BooleanStateClusterStateChangeEvent {\n") append("\tstateValue : $stateValue\n") @@ -44,10 +40,10 @@ class BooleanStateClusterStateChangeEvent( companion object { private const val TAG_STATE_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateClusterStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BooleanStateClusterStateChangeEvent { tlvReader.enterStructure(tlvTag) val stateValue = tlvReader.getBoolean(ContextSpecificTag(TAG_STATE_VALUE)) - + tlvReader.exitContainer() return BooleanStateClusterStateChangeEvent(stateValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt index 14d64045516493..f6777c819c9a57 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterAlarmsStateChangedEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,15 +50,19 @@ class BooleanStateConfigurationClusterAlarmsStateChangedEvent( private const val TAG_ALARMS_ACTIVE = 0 private const val TAG_ALARMS_SUPPRESSED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterAlarmsStateChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BooleanStateConfigurationClusterAlarmsStateChangedEvent { tlvReader.enterStructure(tlvTag) val alarmsActive = tlvReader.getUByte(ContextSpecificTag(TAG_ALARMS_ACTIVE)) - val alarmsSuppressed = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) - } else { - Optional.empty() - } - + val alarmsSuppressed = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ALARMS_SUPPRESSED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return BooleanStateConfigurationClusterAlarmsStateChangedEvent(alarmsActive, alarmsSuppressed) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt index 750d449968ba98..d29696d04cc3bf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BooleanStateConfigurationClusterSensorFaultEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BooleanStateConfigurationClusterSensorFaultEvent( - val sensorFault: UShort -) { +class BooleanStateConfigurationClusterSensorFaultEvent(val sensorFault: UShort) { override fun toString(): String = buildString { append("BooleanStateConfigurationClusterSensorFaultEvent {\n") append("\tsensorFault : $sensorFault\n") @@ -44,10 +40,13 @@ class BooleanStateConfigurationClusterSensorFaultEvent( companion object { private const val TAG_SENSOR_FAULT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BooleanStateConfigurationClusterSensorFaultEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BooleanStateConfigurationClusterSensorFaultEvent { tlvReader.enterStructure(tlvTag) val sensorFault = tlvReader.getUShort(ContextSpecificTag(TAG_SENSOR_FAULT)) - + tlvReader.exitContainer() return BooleanStateConfigurationClusterSensorFaultEvent(sensorFault) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt index 5bd65929e12bdc..2bdca2fbfb016e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterReachableChangedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationClusterReachableChangedEvent( - val reachableNewValue: Boolean -) { +class BridgedDeviceBasicInformationClusterReachableChangedEvent(val reachableNewValue: Boolean) { override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterReachableChangedEvent {\n") append("\treachableNewValue : $reachableNewValue\n") @@ -44,10 +40,13 @@ class BridgedDeviceBasicInformationClusterReachableChangedEvent( companion object { private const val TAG_REACHABLE_NEW_VALUE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterReachableChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterReachableChangedEvent { tlvReader.enterStructure(tlvTag) val reachableNewValue = tlvReader.getBoolean(ContextSpecificTag(TAG_REACHABLE_NEW_VALUE)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterReachableChangedEvent(reachableNewValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt index 67aa89e3788154..e812711dad48f2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/BridgedDeviceBasicInformationClusterStartUpEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BridgedDeviceBasicInformationClusterStartUpEvent( - val softwareVersion: UInt -) { +class BridgedDeviceBasicInformationClusterStartUpEvent(val softwareVersion: UInt) { override fun toString(): String = buildString { append("BridgedDeviceBasicInformationClusterStartUpEvent {\n") append("\tsoftwareVersion : $softwareVersion\n") @@ -44,10 +40,13 @@ class BridgedDeviceBasicInformationClusterStartUpEvent( companion object { private const val TAG_SOFTWARE_VERSION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : BridgedDeviceBasicInformationClusterStartUpEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterStartUpEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) - + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterStartUpEvent(softwareVersion) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt index fe72fb0963a739..21b147d7ffb931 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -30,11 +29,26 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( val status: UByte, val criticality: UByte, val control: UShort, - val temperatureControl: Optional?, - val averageLoadControl: Optional?, - val dutyCycleControl: Optional?, - val powerSavingsControl: Optional?, - val heatingSourceControl: Optional? + val temperatureControl: + Optional< + matter.controller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct + >?, + val averageLoadControl: + Optional< + matter.controller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct + >?, + val dutyCycleControl: + Optional< + matter.controller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct + >?, + val powerSavingsControl: + Optional< + matter.controller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct + >?, + val heatingSourceControl: + Optional< + matter.controller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct + >? ) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent {\n") @@ -65,41 +79,41 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( put(ContextSpecificTag(TAG_CONTROL), control) if (temperatureControl != null) { if (temperatureControl.isPresent) { - val opttemperatureControl = temperatureControl.get() - opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) - } + val opttemperatureControl = temperatureControl.get() + opttemperatureControl.toTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) } if (averageLoadControl != null) { if (averageLoadControl.isPresent) { - val optaverageLoadControl = averageLoadControl.get() - optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) - } + val optaverageLoadControl = averageLoadControl.get() + optaverageLoadControl.toTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) } if (dutyCycleControl != null) { if (dutyCycleControl.isPresent) { - val optdutyCycleControl = dutyCycleControl.get() - optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) - } + val optdutyCycleControl = dutyCycleControl.get() + optdutyCycleControl.toTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) } if (powerSavingsControl != null) { if (powerSavingsControl.isPresent) { - val optpowerSavingsControl = powerSavingsControl.get() - optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) - } + val optpowerSavingsControl = powerSavingsControl.get() + optpowerSavingsControl.toTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) } if (heatingSourceControl != null) { if (heatingSourceControl.isPresent) { - val optheatingSourceControl = heatingSourceControl.get() - optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) - } + val optheatingSourceControl = heatingSourceControl.get() + optheatingSourceControl.toTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), this) + } } else { putNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) } @@ -119,72 +133,112 @@ class DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( private const val TAG_POWER_SAVINGS_CONTROL = 8 private const val TAG_HEATING_SOURCE_CONTROL = 9 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val transitionIndex = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_TRANSITION_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) - null - } + val transitionIndex = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_TRANSITION_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_INDEX)) + null + } val status = tlvReader.getUByte(ContextSpecificTag(TAG_STATUS)) val criticality = tlvReader.getUByte(ContextSpecificTag(TAG_CRITICALITY)) val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) - null - } - val averageLoadControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) - null - } - val dutyCycleControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) - null - } - val powerSavingsControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) - null - } - val heatingSourceControl = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of(matter.controller.cluster.structs.DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) - null - } - + val temperatureControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of( + matter.controller.cluster.structs + .DemandResponseLoadControlClusterTemperatureControlStruct + .fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TEMPERATURE_CONTROL)) + null + } + val averageLoadControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of( + matter.controller.cluster.structs + .DemandResponseLoadControlClusterAverageLoadControlStruct + .fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL)) + null + } + val dutyCycleControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of( + matter.controller.cluster.structs + .DemandResponseLoadControlClusterDutyCycleControlStruct + .fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL)) + null + } + val powerSavingsControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of( + matter.controller.cluster.structs + .DemandResponseLoadControlClusterPowerSavingsControlStruct + .fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL)) + null + } + val heatingSourceControl = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of( + matter.controller.cluster.structs + .DemandResponseLoadControlClusterHeatingSourceControlStruct + .fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent(eventID, transitionIndex, status, criticality, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) + return DemandResponseLoadControlClusterLoadControlEventStatusChangeEvent( + eventID, + transitionIndex, + status, + criticality, + control, + temperatureControl, + averageLoadControl, + dutyCycleControl, + powerSavingsControl, + heatingSourceControl + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt index e05ca8e86ba704..10bda0f46af030 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterPowerAdjustEndEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,12 +50,15 @@ class DeviceEnergyManagementClusterPowerAdjustEndEvent( private const val TAG_DURATION = 1 private const val TAG_ENERGY_USE = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterPowerAdjustEndEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterPowerAdjustEndEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUByte(ContextSpecificTag(TAG_CAUSE)) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) val energyUse = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_USE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterPowerAdjustEndEvent(cause, duration, energyUse) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt index 8d103f74e33de4..db5219f72dba0e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DeviceEnergyManagementClusterResumedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DeviceEnergyManagementClusterResumedEvent( - val cause: UByte -) { +class DeviceEnergyManagementClusterResumedEvent(val cause: UByte) { override fun toString(): String = buildString { append("DeviceEnergyManagementClusterResumedEvent {\n") append("\tcause : $cause\n") @@ -44,10 +40,10 @@ class DeviceEnergyManagementClusterResumedEvent( companion object { private const val TAG_CAUSE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DeviceEnergyManagementClusterResumedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterResumedEvent { tlvReader.enterStructure(tlvTag) val cause = tlvReader.getUByte(ContextSpecificTag(TAG_CAUSE)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterResumedEvent(cause) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt index e17f43ed147ae0..d6a5d9227ec845 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DishwasherAlarmClusterNotifyEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -56,13 +54,13 @@ class DishwasherAlarmClusterNotifyEvent( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DishwasherAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getUInt(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getUInt(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return DishwasherAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt index a04df8246a437e..233130a2371a2e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorLockAlarmEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterDoorLockAlarmEvent( - val alarmCode: UByte -) { +class DoorLockClusterDoorLockAlarmEvent(val alarmCode: UByte) { override fun toString(): String = buildString { append("DoorLockClusterDoorLockAlarmEvent {\n") append("\talarmCode : $alarmCode\n") @@ -44,10 +40,10 @@ class DoorLockClusterDoorLockAlarmEvent( companion object { private const val TAG_ALARM_CODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorLockAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorLockAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmCode = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_CODE)) - + tlvReader.exitContainer() return DoorLockClusterDoorLockAlarmEvent(alarmCode) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt index c0dd0441ac3010..92d04f6662dffe 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterDoorStateChangeEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterDoorStateChangeEvent( - val doorState: UByte -) { +class DoorLockClusterDoorStateChangeEvent(val doorState: UByte) { override fun toString(): String = buildString { append("DoorLockClusterDoorStateChangeEvent {\n") append("\tdoorState : $doorState\n") @@ -44,10 +40,10 @@ class DoorLockClusterDoorStateChangeEvent( companion object { private const val TAG_DOOR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterDoorStateChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterDoorStateChangeEvent { tlvReader.enterStructure(tlvTag) val doorState = tlvReader.getUByte(ContextSpecificTag(TAG_DOOR_STATE)) - + tlvReader.exitContainer() return DoorLockClusterDoorStateChangeEvent(doorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt index af031bad313f8f..0834fde8914a0d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationErrorEvent.kt @@ -31,7 +31,8 @@ class DoorLockClusterLockOperationErrorEvent( val userIndex: UShort?, val fabricIndex: UByte?, val sourceNode: ULong?, - val credentials: Optional>? + val credentials: + Optional>? ) { override fun toString(): String = buildString { append("DoorLockClusterLockOperationErrorEvent {\n") @@ -68,13 +69,13 @@ class DoorLockClusterLockOperationErrorEvent( } if (credentials != null) { if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() - } + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } } else { putNull(ContextSpecificTag(TAG_CREDENTIALS)) } @@ -91,49 +92,68 @@ class DoorLockClusterLockOperationErrorEvent( private const val TAG_SOURCE_NODE = 5 private const val TAG_CREDENTIALS = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationErrorEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) val operationError = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_ERROR)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while(!tlvReader.isEndOfContainer()) { - this.add(matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null - } - + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while (!tlvReader.isEndOfContainer()) { + this.add( + matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationErrorEvent(lockOperationType, operationSource, operationError, userIndex, fabricIndex, sourceNode, credentials) + return DoorLockClusterLockOperationErrorEvent( + lockOperationType, + operationSource, + operationError, + userIndex, + fabricIndex, + sourceNode, + credentials + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt index d47734e612adc8..c063f08d6d1e64 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockOperationEvent.kt @@ -30,7 +30,8 @@ class DoorLockClusterLockOperationEvent( val userIndex: UShort?, val fabricIndex: UByte?, val sourceNode: ULong?, - val credentials: Optional>? + val credentials: + Optional>? ) { override fun toString(): String = buildString { append("DoorLockClusterLockOperationEvent {\n") @@ -65,13 +66,13 @@ class DoorLockClusterLockOperationEvent( } if (credentials != null) { if (credentials.isPresent) { - val optcredentials = credentials.get() - startArray(ContextSpecificTag(TAG_CREDENTIALS)) - for (item in optcredentials.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() - } + val optcredentials = credentials.get() + startArray(ContextSpecificTag(TAG_CREDENTIALS)) + for (item in optcredentials.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() + } } else { putNull(ContextSpecificTag(TAG_CREDENTIALS)) } @@ -87,48 +88,66 @@ class DoorLockClusterLockOperationEvent( private const val TAG_SOURCE_NODE = 4 private const val TAG_CREDENTIALS = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockOperationEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockOperationEvent { tlvReader.enterStructure(tlvTag) val lockOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_OPERATION_TYPE)) val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val credentials = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) - while(!tlvReader.isEndOfContainer()) { - this.add(matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv(AnonymousTag, tlvReader)) + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) - null - } - + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val credentials = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CREDENTIALS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CREDENTIALS)) + while (!tlvReader.isEndOfContainer()) { + this.add( + matter.controller.cluster.structs.DoorLockClusterCredentialStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CREDENTIALS)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockOperationEvent(lockOperationType, operationSource, userIndex, fabricIndex, sourceNode, credentials) + return DoorLockClusterLockOperationEvent( + lockOperationType, + operationSource, + userIndex, + fabricIndex, + sourceNode, + credentials + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt index bb39257e80cd71..3d3cd635977b85 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/DoorLockClusterLockUserChangeEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -84,39 +82,51 @@ class DoorLockClusterLockUserChangeEvent( private const val TAG_SOURCE_NODE = 5 private const val TAG_DATA_INDEX = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : DoorLockClusterLockUserChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DoorLockClusterLockUserChangeEvent { tlvReader.enterStructure(tlvTag) val lockDataType = tlvReader.getUByte(ContextSpecificTag(TAG_LOCK_DATA_TYPE)) val dataOperationType = tlvReader.getUByte(ContextSpecificTag(TAG_DATA_OPERATION_TYPE)) val operationSource = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATION_SOURCE)) - val userIndex = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) - null - } - val fabricIndex = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) - null - } - val sourceNode = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) - null - } - val dataIndex = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_DATA_INDEX)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) - null - } - + val userIndex = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_USER_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_USER_INDEX)) + null + } + val fabricIndex = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_FABRIC_INDEX)) + null + } + val sourceNode = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_SOURCE_NODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SOURCE_NODE)) + null + } + val dataIndex = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_DATA_INDEX)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DATA_INDEX)) + null + } + tlvReader.exitContainer() - return DoorLockClusterLockUserChangeEvent(lockDataType, dataOperationType, operationSource, userIndex, fabricIndex, sourceNode, dataIndex) + return DoorLockClusterLockUserChangeEvent( + lockDataType, + dataOperationType, + operationSource, + userIndex, + fabricIndex, + sourceNode, + dataIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt index 8fecbdd04a6da1..2533881132950b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent.kt @@ -18,15 +18,20 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( - val energyImported: Optional, - val energyExported: Optional + val energyImported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > ) { override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent {\n") @@ -54,22 +59,38 @@ class ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) - } else { - Optional.empty() - } - val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) - } else { - Optional.empty() - } - + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent(energyImported, energyExported) + return ElectricalEnergyMeasurementClusterCumulativeEnergyMeasuredEvent( + energyImported, + energyExported + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt index 65f3e9e1dc1ba1..17194fbe3f7d84 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent.kt @@ -18,15 +18,20 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( - val energyImported: Optional, - val energyExported: Optional + val energyImported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + >, + val energyExported: + Optional< + matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + > ) { override fun toString(): String = buildString { append("ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent {\n") @@ -54,22 +59,38 @@ class ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( private const val TAG_ENERGY_IMPORTED = 0 private const val TAG_ENERGY_EXPORTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent { tlvReader.enterStructure(tlvTag) - val energyImported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { - Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader)) - } else { - Optional.empty() - } - val energyExported = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { - Optional.of(matter.controller.cluster.structs.ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader)) - } else { - Optional.empty() - } - + val energyImported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_IMPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_IMPORTED), tlvReader) + ) + } else { + Optional.empty() + } + val energyExported = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENERGY_EXPORTED))) { + Optional.of( + matter.controller.cluster.structs + .ElectricalEnergyMeasurementClusterEnergyMeasurementStruct + .fromTlv(ContextSpecificTag(TAG_ENERGY_EXPORTED), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent(energyImported, energyExported) + return ElectricalEnergyMeasurementClusterPeriodicEnergyMeasuredEvent( + energyImported, + energyExported + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt index 6cc387e2e019e1..a0770e7e82af07 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVConnectedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterEVConnectedEvent( - val sessionID: UInt -) { +class EnergyEvseClusterEVConnectedEvent(val sessionID: UInt) { override fun toString(): String = buildString { append("EnergyEvseClusterEVConnectedEvent {\n") append("\tsessionID : $sessionID\n") @@ -44,10 +40,10 @@ class EnergyEvseClusterEVConnectedEvent( companion object { private const val TAG_SESSION_I_D = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVConnectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVConnectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) - + tlvReader.exitContainer() return EnergyEvseClusterEVConnectedEvent(sessionID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt index ac7c61d1a78738..673441a49f6265 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEVNotDetectedEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -63,21 +62,28 @@ class EnergyEvseClusterEVNotDetectedEvent( private const val TAG_SESSION_ENERGY_CHARGED = 3 private const val TAG_SESSION_ENERGY_DISCHARGED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEVNotDetectedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEVNotDetectedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val sessionDuration = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_DURATION)) val sessionEnergyCharged = tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_CHARGED)) - val sessionEnergyDischarged = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) - } else { - Optional.empty() - } - + val sessionEnergyDischarged = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_SESSION_ENERGY_DISCHARGED))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterEVNotDetectedEvent(sessionID, state, sessionDuration, sessionEnergyCharged, sessionEnergyDischarged) + return EnergyEvseClusterEVNotDetectedEvent( + sessionID, + state, + sessionDuration, + sessionEnergyCharged, + sessionEnergyDischarged + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt index 5a121c64f1fb70..0cd20e3e47ade3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStartedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,12 +50,12 @@ class EnergyEvseClusterEnergyTransferStartedEvent( private const val TAG_STATE = 1 private const val TAG_MAXIMUM_CURRENT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStartedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStartedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val maximumCurrent = tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_CURRENT)) - + tlvReader.exitContainer() return EnergyEvseClusterEnergyTransferStartedEvent(sessionID, state, maximumCurrent) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt index 01b19535348c67..093f687fb16662 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterEnergyTransferStoppedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -56,16 +54,21 @@ class EnergyEvseClusterEnergyTransferStoppedEvent( private const val TAG_REASON = 2 private const val TAG_ENERGY_TRANSFERRED = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterEnergyTransferStoppedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterEnergyTransferStoppedEvent { tlvReader.enterStructure(tlvTag) val sessionID = tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) val reason = tlvReader.getUByte(ContextSpecificTag(TAG_REASON)) val energyTransferred = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY_TRANSFERRED)) - + tlvReader.exitContainer() - return EnergyEvseClusterEnergyTransferStoppedEvent(sessionID, state, reason, energyTransferred) + return EnergyEvseClusterEnergyTransferStoppedEvent( + sessionID, + state, + reason, + energyTransferred + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt index e49931cd4b55b8..2167c1fca408eb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterFaultEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,21 +58,29 @@ class EnergyEvseClusterFaultEvent( private const val TAG_FAULT_STATE_PREVIOUS_STATE = 2 private const val TAG_FAULT_STATE_CURRENT_STATE = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterFaultEvent { tlvReader.enterStructure(tlvTag) - val sessionID = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) - null - } + val sessionID = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_SESSION_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SESSION_I_D)) + null + } val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) - val faultStatePreviousState = tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) - val faultStateCurrentState = tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) - + val faultStatePreviousState = + tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_PREVIOUS_STATE)) + val faultStateCurrentState = + tlvReader.getUByte(ContextSpecificTag(TAG_FAULT_STATE_CURRENT_STATE)) + tlvReader.exitContainer() - return EnergyEvseClusterFaultEvent(sessionID, state, faultStatePreviousState, faultStateCurrentState) + return EnergyEvseClusterFaultEvent( + sessionID, + state, + faultStatePreviousState, + faultStateCurrentState + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt index 6db4c1a10ed59f..cf0fe503e13bd8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/EnergyEvseClusterRFIDEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyEvseClusterRFIDEvent( - val uid: ByteArray -) { +class EnergyEvseClusterRFIDEvent(val uid: ByteArray) { override fun toString(): String = buildString { append("EnergyEvseClusterRFIDEvent {\n") append("\tuid : $uid\n") @@ -44,10 +40,10 @@ class EnergyEvseClusterRFIDEvent( companion object { private const val TAG_UID = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : EnergyEvseClusterRFIDEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterRFIDEvent { tlvReader.enterStructure(tlvTag) val uid = tlvReader.getByteArray(ContextSpecificTag(TAG_UID)) - + tlvReader.exitContainer() return EnergyEvseClusterRFIDEvent(uid) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt index 5d6ee591cdf22d..8d13675dece145 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterBootReasonEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class GeneralDiagnosticsClusterBootReasonEvent( - val bootReason: UByte -) { +class GeneralDiagnosticsClusterBootReasonEvent(val bootReason: UByte) { override fun toString(): String = buildString { append("GeneralDiagnosticsClusterBootReasonEvent {\n") append("\tbootReason : $bootReason\n") @@ -44,10 +40,10 @@ class GeneralDiagnosticsClusterBootReasonEvent( companion object { private const val TAG_BOOT_REASON = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterBootReasonEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterBootReasonEvent { tlvReader.enterStructure(tlvTag) val bootReason = tlvReader.getUByte(ContextSpecificTag(TAG_BOOT_REASON)) - + tlvReader.exitContainer() return GeneralDiagnosticsClusterBootReasonEvent(bootReason) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt index 415b83a66b74ba..5b7e6cd0f947aa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterHardwareFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,23 +55,28 @@ class GeneralDiagnosticsClusterHardwareFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterHardwareFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralDiagnosticsClusterHardwareFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return GeneralDiagnosticsClusterHardwareFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt index e5ae628b6edfc1..f256dddde339d2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,23 +55,28 @@ class GeneralDiagnosticsClusterNetworkFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return GeneralDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt index 9ebbfae718bb68..027949831806c8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/GeneralDiagnosticsClusterRadioFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,23 +55,25 @@ class GeneralDiagnosticsClusterRadioFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : GeneralDiagnosticsClusterRadioFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralDiagnosticsClusterRadioFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return GeneralDiagnosticsClusterRadioFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt index d7b7eb6f0d01d5..3326660b5e35d0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/MediaPlaybackClusterStateChangedEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -79,25 +78,40 @@ class MediaPlaybackClusterStateChangedEvent( private const val TAG_DATA = 7 private const val TAG_AUDIO_ADVANCE_UNMUTED = 8 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : MediaPlaybackClusterStateChangedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterStateChangedEvent { tlvReader.enterStructure(tlvTag) val currentState = tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_STATE)) val startTime = tlvReader.getULong(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getULong(ContextSpecificTag(TAG_DURATION)) - val sampledPosition = matter.controller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv(ContextSpecificTag(TAG_SAMPLED_POSITION), tlvReader) + val sampledPosition = + matter.controller.cluster.structs.MediaPlaybackClusterPlaybackPositionStruct.fromTlv( + ContextSpecificTag(TAG_SAMPLED_POSITION), + tlvReader + ) val playbackSpeed = tlvReader.getFloat(ContextSpecificTag(TAG_PLAYBACK_SPEED)) val seekRangeEnd = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_END)) val seekRangeStart = tlvReader.getULong(ContextSpecificTag(TAG_SEEK_RANGE_START)) - val data = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) - } else { - Optional.empty() - } + val data = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DATA))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_DATA))) + } else { + Optional.empty() + } val audioAdvanceUnmuted = tlvReader.getBoolean(ContextSpecificTag(TAG_AUDIO_ADVANCE_UNMUTED)) - + tlvReader.exitContainer() - return MediaPlaybackClusterStateChangedEvent(currentState, startTime, duration, sampledPosition, playbackSpeed, seekRangeEnd, seekRangeStart, data, audioAdvanceUnmuted) + return MediaPlaybackClusterStateChangedEvent( + currentState, + startTime, + duration, + sampledPosition, + playbackSpeed, + seekRangeEnd, + seekRangeStart, + data, + audioAdvanceUnmuted + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt index e5a17a96700fca..4ae90661a7b56b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationCompletionEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -43,17 +42,17 @@ class OperationalStateClusterOperationCompletionEvent( put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } } else { putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) } if (pausedTime != null) { if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } } else { putNull(ContextSpecificTag(TAG_PAUSED_TIME)) } @@ -66,33 +65,42 @@ class OperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return OperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt index 10bd2f4144b114..fc6e4797a28b46 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OperationalStateClusterOperationalErrorEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -44,10 +42,14 @@ class OperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OperationalStateClusterOperationalErrorEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = matter.controller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + matter.controller.cluster.structs.OperationalStateClusterErrorStateStruct.fromTlv( + ContextSpecificTag(TAG_ERROR_STATE), + tlvReader + ) + tlvReader.exitContainer() return OperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt index 3cdebe626405a4..e3fbe9c5bf247f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterDownloadErrorEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -64,26 +62,36 @@ class OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( private const val TAG_PROGRESS_PERCENT = 2 private const val TAG_PLATFORM_CODE = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterDownloadErrorEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val bytesDownloaded = tlvReader.getULong(ContextSpecificTag(TAG_BYTES_DOWNLOADED)) - val progressPercent = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) - null - } - val platformCode = if (!tlvReader.isNull()) { - tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) - null - } - + val progressPercent = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRESS_PERCENT)) + null + } + val platformCode = + if (!tlvReader.isNull()) { + tlvReader.getLong(ContextSpecificTag(TAG_PLATFORM_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PLATFORM_CODE)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent(softwareVersion, bytesDownloaded, progressPercent, platformCode) + return OtaSoftwareUpdateRequestorClusterDownloadErrorEvent( + softwareVersion, + bytesDownloaded, + progressPercent, + platformCode + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt index cacab69022c9c7..52ff425323115b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterStateTransitionEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,21 +58,30 @@ class OtaSoftwareUpdateRequestorClusterStateTransitionEvent( private const val TAG_REASON = 2 private const val TAG_TARGET_SOFTWARE_VERSION = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterStateTransitionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterStateTransitionEvent { tlvReader.enterStructure(tlvTag) val previousState = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_STATE)) val newState = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_STATE)) val reason = tlvReader.getUByte(ContextSpecificTag(TAG_REASON)) - val targetSoftwareVersion = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) - null - } - + val targetSoftwareVersion = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGET_SOFTWARE_VERSION)) + null + } + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterStateTransitionEvent(previousState, newState, reason, targetSoftwareVersion) + return OtaSoftwareUpdateRequestorClusterStateTransitionEvent( + previousState, + newState, + reason, + targetSoftwareVersion + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt index 227e0915fba374..cd39219a42e3bf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OtaSoftwareUpdateRequestorClusterVersionAppliedEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,14 @@ class OtaSoftwareUpdateRequestorClusterVersionAppliedEvent( private const val TAG_SOFTWARE_VERSION = 0 private const val TAG_PRODUCT_I_D = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterVersionAppliedEvent { tlvReader.enterStructure(tlvTag) val softwareVersion = tlvReader.getUInt(ContextSpecificTag(TAG_SOFTWARE_VERSION)) val productID = tlvReader.getUShort(ContextSpecificTag(TAG_PRODUCT_I_D)) - + tlvReader.exitContainer() return OtaSoftwareUpdateRequestorClusterVersionAppliedEvent(softwareVersion, productID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt index c2f767d8be59a5..7220e0afa693d2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationCompletionEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -43,17 +42,17 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent( put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } } else { putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) } if (pausedTime != null) { if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } } else { putNull(ContextSpecificTag(TAG_PAUSED_TIME)) } @@ -66,33 +65,42 @@ class OvenCavityOperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return OvenCavityOperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt index ee5fe0b442932f..bfaa8f75b3b597 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/OvenCavityOperationalStateClusterOperationalErrorEvent.kt @@ -16,16 +16,15 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter class OvenCavityOperationalStateClusterOperationalErrorEvent( - val errorState: matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct + val errorState: + matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct ) { override fun toString(): String = buildString { append("OvenCavityOperationalStateClusterOperationalErrorEvent {\n") @@ -44,10 +43,17 @@ class OvenCavityOperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : OvenCavityOperationalStateClusterOperationalErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + matter.controller.cluster.structs.OvenCavityOperationalStateClusterErrorStateStruct.fromTlv( + ContextSpecificTag(TAG_ERROR_STATE), + tlvReader + ) + tlvReader.exitContainer() return OvenCavityOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt index 6669a84bd6ec2e..8e189c26173639 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatChargeFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,23 +55,25 @@ class PowerSourceClusterBatChargeFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatChargeFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt index 50752bc8ce3d78..7aa1a81b862fd5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterBatFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -24,10 +23,7 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatFaultChangeEvent( - val current: List, - val previous: List -) { +class PowerSourceClusterBatFaultChangeEvent(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeEvent {\n") append("\tcurrent : $current\n") @@ -56,23 +52,25 @@ class PowerSourceClusterBatFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterBatFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt index 9f125a71de6a58..5dc6444f06cd51 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/PowerSourceClusterWiredFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -24,10 +23,7 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterWiredFaultChangeEvent( - val current: List, - val previous: List -) { +class PowerSourceClusterWiredFaultChangeEvent(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeEvent {\n") append("\tcurrent : $current\n") @@ -56,23 +52,25 @@ class PowerSourceClusterWiredFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : PowerSourceClusterWiredFaultChangeEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt index 75df72186f31ce..8bfdf23df2be69 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RefrigeratorAlarmClusterNotifyEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -56,13 +54,13 @@ class RefrigeratorAlarmClusterNotifyEvent( private const val TAG_STATE = 2 private const val TAG_MASK = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RefrigeratorAlarmClusterNotifyEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAlarmClusterNotifyEvent { tlvReader.enterStructure(tlvTag) val active = tlvReader.getUInt(ContextSpecificTag(TAG_ACTIVE)) val inactive = tlvReader.getUInt(ContextSpecificTag(TAG_INACTIVE)) val state = tlvReader.getUInt(ContextSpecificTag(TAG_STATE)) val mask = tlvReader.getUInt(ContextSpecificTag(TAG_MASK)) - + tlvReader.exitContainer() return RefrigeratorAlarmClusterNotifyEvent(active, inactive, state, mask) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt index 82db20e092df34..eaafde5a0c8c68 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationCompletionEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -43,17 +42,17 @@ class RvcOperationalStateClusterOperationCompletionEvent( put(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE), completionErrorCode) if (totalOperationalTime != null) { if (totalOperationalTime.isPresent) { - val opttotalOperationalTime = totalOperationalTime.get() - put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) - } + val opttotalOperationalTime = totalOperationalTime.get() + put(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME), opttotalOperationalTime) + } } else { putNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) } if (pausedTime != null) { if (pausedTime.isPresent) { - val optpausedTime = pausedTime.get() - put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) - } + val optpausedTime = pausedTime.get() + put(ContextSpecificTag(TAG_PAUSED_TIME), optpausedTime) + } } else { putNull(ContextSpecificTag(TAG_PAUSED_TIME)) } @@ -66,33 +65,42 @@ class RvcOperationalStateClusterOperationCompletionEvent( private const val TAG_TOTAL_OPERATIONAL_TIME = 1 private const val TAG_PAUSED_TIME = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationCompletionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationCompletionEvent { tlvReader.enterStructure(tlvTag) val completionErrorCode = tlvReader.getUByte(ContextSpecificTag(TAG_COMPLETION_ERROR_CODE)) - val totalOperationalTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) - null - } - val pausedTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) - null - } - + val totalOperationalTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TOTAL_OPERATIONAL_TIME)) + null + } + val pausedTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PAUSED_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_PAUSED_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PAUSED_TIME)) + null + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationCompletionEvent(completionErrorCode, totalOperationalTime, pausedTime) + return RvcOperationalStateClusterOperationCompletionEvent( + completionErrorCode, + totalOperationalTime, + pausedTime + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt index 092b9234e3b44d..7a78710f647235 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/RvcOperationalStateClusterOperationalErrorEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -44,10 +42,17 @@ class RvcOperationalStateClusterOperationalErrorEvent( companion object { private const val TAG_ERROR_STATE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : RvcOperationalStateClusterOperationalErrorEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationalErrorEvent { tlvReader.enterStructure(tlvTag) - val errorState = matter.controller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv(ContextSpecificTag(TAG_ERROR_STATE), tlvReader) - + val errorState = + matter.controller.cluster.structs.RvcOperationalStateClusterErrorStateStruct.fromTlv( + ContextSpecificTag(TAG_ERROR_STATE), + tlvReader + ) + tlvReader.exitContainer() return RvcOperationalStateClusterOperationalErrorEvent(errorState) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt index e6853817f212a1..5570ba7a3af4a3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SampleMeiClusterPingCountEventEvent.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SampleMeiClusterPingCountEventEvent( - val count: UInt, - val fabricIndex: UByte -) { +class SampleMeiClusterPingCountEventEvent(val count: UInt, val fabricIndex: UByte) { override fun toString(): String = buildString { append("SampleMeiClusterPingCountEventEvent {\n") append("\tcount : $count\n") @@ -48,11 +43,11 @@ class SampleMeiClusterPingCountEventEvent( private const val TAG_COUNT = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SampleMeiClusterPingCountEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SampleMeiClusterPingCountEventEvent { tlvReader.enterStructure(tlvTag) val count = tlvReader.getUInt(ContextSpecificTag(TAG_COUNT)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return SampleMeiClusterPingCountEventEvent(count, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt index ab23f8de4499fc..52c7a19053aacb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterCOAlarmEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterCOAlarmEvent( - val alarmSeverityLevel: UByte -) { +class SmokeCoAlarmClusterCOAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -44,10 +40,10 @@ class SmokeCoAlarmClusterCOAlarmEvent( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt index 3ccd697a30d045..80c6a860b1ccc0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectCOAlarmEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterInterconnectCOAlarmEvent( - val alarmSeverityLevel: UByte -) { +class SmokeCoAlarmClusterInterconnectCOAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectCOAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -44,10 +40,10 @@ class SmokeCoAlarmClusterInterconnectCOAlarmEvent( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectCOAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectCOAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectCOAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt index 3edfa2543f5b3f..2a3f3f2d05c730 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterInterconnectSmokeAlarmEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent( - val alarmSeverityLevel: UByte -) { +class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterInterconnectSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -44,10 +40,10 @@ class SmokeCoAlarmClusterInterconnectSmokeAlarmEvent( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterInterconnectSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterInterconnectSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt index 42579fecbdda42..3930c40935d0ef 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterLowBatteryEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterLowBatteryEvent( - val alarmSeverityLevel: UByte -) { +class SmokeCoAlarmClusterLowBatteryEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterLowBatteryEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -44,10 +40,10 @@ class SmokeCoAlarmClusterLowBatteryEvent( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterLowBatteryEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterLowBatteryEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterLowBatteryEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt index 25a54c367090c2..934c42da5479a2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SmokeCoAlarmClusterSmokeAlarmEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SmokeCoAlarmClusterSmokeAlarmEvent( - val alarmSeverityLevel: UByte -) { +class SmokeCoAlarmClusterSmokeAlarmEvent(val alarmSeverityLevel: UByte) { override fun toString(): String = buildString { append("SmokeCoAlarmClusterSmokeAlarmEvent {\n") append("\talarmSeverityLevel : $alarmSeverityLevel\n") @@ -44,10 +40,10 @@ class SmokeCoAlarmClusterSmokeAlarmEvent( companion object { private const val TAG_ALARM_SEVERITY_LEVEL = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SmokeCoAlarmClusterSmokeAlarmEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SmokeCoAlarmClusterSmokeAlarmEvent { tlvReader.enterStructure(tlvTag) val alarmSeverityLevel = tlvReader.getUByte(ContextSpecificTag(TAG_ALARM_SEVERITY_LEVEL)) - + tlvReader.exitContainer() return SmokeCoAlarmClusterSmokeAlarmEvent(alarmSeverityLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt index 5d78915d64828a..c7ac6b65eae4dc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SoftwareDiagnosticsClusterSoftwareFaultEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -58,20 +57,22 @@ class SoftwareDiagnosticsClusterSoftwareFaultEvent( private const val TAG_NAME = 1 private const val TAG_FAULT_RECORDING = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SoftwareDiagnosticsClusterSoftwareFaultEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterSoftwareFaultEvent { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val faultRecording = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val faultRecording = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FAULT_RECORDING))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_FAULT_RECORDING))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return SoftwareDiagnosticsClusterSoftwareFaultEvent(id, name, faultRecording) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt index eef9c3864807ea..f7a74f79826494 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterInitialPressEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterInitialPressEvent( - val newPosition: UByte -) { +class SwitchClusterInitialPressEvent(val newPosition: UByte) { override fun toString(): String = buildString { append("SwitchClusterInitialPressEvent {\n") append("\tnewPosition : $newPosition\n") @@ -44,10 +40,10 @@ class SwitchClusterInitialPressEvent( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterInitialPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterInitialPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterInitialPressEvent(newPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt index 42cd9c501135bc..bacc49c76bbc53 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongPressEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterLongPressEvent( - val newPosition: UByte -) { +class SwitchClusterLongPressEvent(val newPosition: UByte) { override fun toString(): String = buildString { append("SwitchClusterLongPressEvent {\n") append("\tnewPosition : $newPosition\n") @@ -44,10 +40,10 @@ class SwitchClusterLongPressEvent( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongPressEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongPressEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongPressEvent(newPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt index 8de4860fe1f299..cbd0166269542b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterLongReleaseEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterLongReleaseEvent( - val previousPosition: UByte -) { +class SwitchClusterLongReleaseEvent(val previousPosition: UByte) { override fun toString(): String = buildString { append("SwitchClusterLongReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") @@ -44,10 +40,10 @@ class SwitchClusterLongReleaseEvent( companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterLongReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterLongReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterLongReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt index 49d9b22f9b45ff..4a82b4914ea426 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressCompleteEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,12 @@ class SwitchClusterMultiPressCompleteEvent( private const val TAG_PREVIOUS_POSITION = 0 private const val TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressCompleteEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressCompleteEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - val totalNumberOfPressesCounted = tlvReader.getUByte(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) - + val totalNumberOfPressesCounted = + tlvReader.getUByte(ContextSpecificTag(TAG_TOTAL_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressCompleteEvent(previousPosition, totalNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt index 104be8f4fb63ee..4bf6776e64f14a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterMultiPressOngoingEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,12 @@ class SwitchClusterMultiPressOngoingEvent( private const val TAG_NEW_POSITION = 0 private const val TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterMultiPressOngoingEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterMultiPressOngoingEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - val currentNumberOfPressesCounted = tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) - + val currentNumberOfPressesCounted = + tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_NUMBER_OF_PRESSES_COUNTED)) + tlvReader.exitContainer() return SwitchClusterMultiPressOngoingEvent(newPosition, currentNumberOfPressesCounted) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt index 156c253a485af1..c08c0e63f8b5e1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterShortReleaseEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterShortReleaseEvent( - val previousPosition: UByte -) { +class SwitchClusterShortReleaseEvent(val previousPosition: UByte) { override fun toString(): String = buildString { append("SwitchClusterShortReleaseEvent {\n") append("\tpreviousPosition : $previousPosition\n") @@ -44,10 +40,10 @@ class SwitchClusterShortReleaseEvent( companion object { private const val TAG_PREVIOUS_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterShortReleaseEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterShortReleaseEvent { tlvReader.enterStructure(tlvTag) val previousPosition = tlvReader.getUByte(ContextSpecificTag(TAG_PREVIOUS_POSITION)) - + tlvReader.exitContainer() return SwitchClusterShortReleaseEvent(previousPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt index f08eaeee96a617..4aae22fb446979 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/SwitchClusterSwitchLatchedEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class SwitchClusterSwitchLatchedEvent( - val newPosition: UByte -) { +class SwitchClusterSwitchLatchedEvent(val newPosition: UByte) { override fun toString(): String = buildString { append("SwitchClusterSwitchLatchedEvent {\n") append("\tnewPosition : $newPosition\n") @@ -44,10 +40,10 @@ class SwitchClusterSwitchLatchedEvent( companion object { private const val TAG_NEW_POSITION = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : SwitchClusterSwitchLatchedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SwitchClusterSwitchLatchedEvent { tlvReader.enterStructure(tlvTag) val newPosition = tlvReader.getUByte(ContextSpecificTag(TAG_NEW_POSITION)) - + tlvReader.exitContainer() return SwitchClusterSwitchLatchedEvent(newPosition) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt index 86a03eb5080eba..0d56be60d4b36e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TargetNavigatorClusterTargetUpdatedEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,18 +55,24 @@ class TargetNavigatorClusterTargetUpdatedEvent( private const val TAG_CURRENT_TARGET = 1 private const val TAG_DATA = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TargetNavigatorClusterTargetUpdatedEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TargetNavigatorClusterTargetUpdatedEvent { tlvReader.enterStructure(tlvTag) - val targetList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) - while(!tlvReader.isEndOfContainer()) { - this.add(matter.controller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv(AnonymousTag, tlvReader)) + val targetList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGET_LIST)) + while (!tlvReader.isEndOfContainer()) { + this.add( + matter.controller.cluster.structs.TargetNavigatorClusterTargetInfoStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } val currentTarget = tlvReader.getUByte(ContextSpecificTag(TAG_CURRENT_TARGET)) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetUpdatedEvent(targetList, currentTarget, data) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt index 823b3eb003da4a..8acbb4b6aea971 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterConnectionStatusEvent( - val connectionStatus: UByte -) { +class ThreadNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UByte) { override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") @@ -44,10 +40,13 @@ class ThreadNetworkDiagnosticsClusterConnectionStatusEvent( companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUByte(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt index 01a5989a931f38..3bea74d8323077 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,23 +55,28 @@ class ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent( private const val TAG_CURRENT = 0 private const val TAG_PREVIOUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterNetworkFaultChangeEvent(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt index e8870c27fe9ff6..1f92e4003e280a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterDSTStatusEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterDSTStatusEvent( - val DSTOffsetActive: Boolean -) { +class TimeSynchronizationClusterDSTStatusEvent(val DSTOffsetActive: Boolean) { override fun toString(): String = buildString { append("TimeSynchronizationClusterDSTStatusEvent {\n") append("\tDSTOffsetActive : $DSTOffsetActive\n") @@ -44,10 +40,10 @@ class TimeSynchronizationClusterDSTStatusEvent( companion object { private const val TAG_D_S_T_OFFSET_ACTIVE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterDSTStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterDSTStatusEvent { tlvReader.enterStructure(tlvTag) val DSTOffsetActive = tlvReader.getBoolean(ContextSpecificTag(TAG_D_S_T_OFFSET_ACTIVE)) - + tlvReader.exitContainer() return TimeSynchronizationClusterDSTStatusEvent(DSTOffsetActive) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt index 0a12d142db0443..0ef92440535c0a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/TimeSynchronizationClusterTimeZoneStatusEvent.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TimeSynchronizationClusterTimeZoneStatusEvent( - val offset: Int, - val name: Optional -) { +class TimeSynchronizationClusterTimeZoneStatusEvent(val offset: Int, val name: Optional) { override fun toString(): String = buildString { append("TimeSynchronizationClusterTimeZoneStatusEvent {\n") append("\toffset : $offset\n") @@ -51,15 +47,16 @@ class TimeSynchronizationClusterTimeZoneStatusEvent( private const val TAG_OFFSET = 0 private const val TAG_NAME = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : TimeSynchronizationClusterTimeZoneStatusEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTimeZoneStatusEvent { tlvReader.enterStructure(tlvTag) val offset = tlvReader.getInt(ContextSpecificTag(TAG_OFFSET)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStatusEvent(offset, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt index 2294e08b8377db..b95fb1a6114b7f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestEventEvent.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -72,27 +71,38 @@ class UnitTestingClusterTestEventEvent( private const val TAG_ARG5 = 5 private const val TAG_ARG6 = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestEventEvent { tlvReader.enterStructure(tlvTag) val arg1 = tlvReader.getUByte(ContextSpecificTag(TAG_ARG1)) val arg2 = tlvReader.getUByte(ContextSpecificTag(TAG_ARG2)) val arg3 = tlvReader.getBoolean(ContextSpecificTag(TAG_ARG3)) - val arg4 = matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_ARG4), tlvReader) - val arg5 = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) - while(!tlvReader.isEndOfContainer()) { - this.add(matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + val arg4 = + matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_ARG4), + tlvReader + ) + val arg5 = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG5)) + while (!tlvReader.isEndOfContainer()) { + this.add( + matter.controller.cluster.structs.UnitTestingClusterSimpleStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - val arg6 = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) - while(!tlvReader.isEndOfContainer()) { - this.add(tlvReader.getUByte(AnonymousTag)) + val arg6 = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ARG6)) + while (!tlvReader.isEndOfContainer()) { + this.add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() } - tlvReader.exitContainer() - } - + tlvReader.exitContainer() return UnitTestingClusterTestEventEvent(arg1, arg2, arg3, arg4, arg5, arg6) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt index a52b06cd5cbd96..b0ac8683c99209 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/UnitTestingClusterTestFabricScopedEventEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterTestFabricScopedEventEvent( - val fabricIndex: UByte -) { +class UnitTestingClusterTestFabricScopedEventEvent(val fabricIndex: UByte) { override fun toString(): String = buildString { append("UnitTestingClusterTestFabricScopedEventEvent {\n") append("\tfabricIndex : $fabricIndex\n") @@ -44,10 +40,10 @@ class UnitTestingClusterTestFabricScopedEventEvent( companion object { private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : UnitTestingClusterTestFabricScopedEventEvent { + fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScopedEventEvent { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return UnitTestingClusterTestFabricScopedEventEvent(fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt index a740d0e35331fe..6c207e60058efa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveFaultEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ValveConfigurationAndControlClusterValveFaultEvent( - val valveFault: UShort -) { +class ValveConfigurationAndControlClusterValveFaultEvent(val valveFault: UShort) { override fun toString(): String = buildString { append("ValveConfigurationAndControlClusterValveFaultEvent {\n") append("\tvalveFault : $valveFault\n") @@ -44,10 +40,13 @@ class ValveConfigurationAndControlClusterValveFaultEvent( companion object { private const val TAG_VALVE_FAULT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveFaultEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ValveConfigurationAndControlClusterValveFaultEvent { tlvReader.enterStructure(tlvTag) val valveFault = tlvReader.getUShort(ContextSpecificTag(TAG_VALVE_FAULT)) - + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveFaultEvent(valveFault) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt index 2331135586801c..c12b94b0e375bf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/ValveConfigurationAndControlClusterValveStateChangedEvent.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.eventstructs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,15 +50,19 @@ class ValveConfigurationAndControlClusterValveStateChangedEvent( private const val TAG_VALVE_STATE = 0 private const val TAG_VALVE_LEVEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : ValveConfigurationAndControlClusterValveStateChangedEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ValveConfigurationAndControlClusterValveStateChangedEvent { tlvReader.enterStructure(tlvTag) val valveState = tlvReader.getUByte(ContextSpecificTag(TAG_VALVE_STATE)) - val valveLevel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_VALVE_LEVEL))) - } else { - Optional.empty() - } - + val valveLevel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_VALVE_LEVEL))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_VALVE_LEVEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ValveConfigurationAndControlClusterValveStateChangedEvent(valveState, valveLevel) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt index fddf6cdad7a8a6..677577429c1796 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterAssociationFailureEvent.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,15 @@ class WiFiNetworkDiagnosticsClusterAssociationFailureEvent( private const val TAG_ASSOCIATION_FAILURE_CAUSE = 0 private const val TAG_STATUS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterAssociationFailureEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterAssociationFailureEvent { tlvReader.enterStructure(tlvTag) - val associationFailureCause = tlvReader.getUByte(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) + val associationFailureCause = + tlvReader.getUByte(ContextSpecificTag(TAG_ASSOCIATION_FAILURE_CAUSE)) val status = tlvReader.getUShort(ContextSpecificTag(TAG_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterAssociationFailureEvent(associationFailureCause, status) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt index 0e668adcf859dd..af8d2c296abe2e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterConnectionStatusEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsClusterConnectionStatusEvent( - val connectionStatus: UByte -) { +class WiFiNetworkDiagnosticsClusterConnectionStatusEvent(val connectionStatus: UByte) { override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterConnectionStatusEvent {\n") append("\tconnectionStatus : $connectionStatus\n") @@ -44,10 +40,13 @@ class WiFiNetworkDiagnosticsClusterConnectionStatusEvent( companion object { private const val TAG_CONNECTION_STATUS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterConnectionStatusEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterConnectionStatusEvent { tlvReader.enterStructure(tlvTag) val connectionStatus = tlvReader.getUByte(ContextSpecificTag(TAG_CONNECTION_STATUS)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterConnectionStatusEvent(connectionStatus) diff --git a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt index 40a4bf1d3cc947..a61a9742ede95a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/eventstructs/WiFiNetworkDiagnosticsClusterDisconnectionEvent.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.eventstructs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class WiFiNetworkDiagnosticsClusterDisconnectionEvent( - val reasonCode: UShort -) { +class WiFiNetworkDiagnosticsClusterDisconnectionEvent(val reasonCode: UShort) { override fun toString(): String = buildString { append("WiFiNetworkDiagnosticsClusterDisconnectionEvent {\n") append("\treasonCode : $reasonCode\n") @@ -44,10 +40,13 @@ class WiFiNetworkDiagnosticsClusterDisconnectionEvent( companion object { private const val TAG_REASON_CODE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader) : WiFiNetworkDiagnosticsClusterDisconnectionEvent { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): WiFiNetworkDiagnosticsClusterDisconnectionEvent { tlvReader.enterStructure(tlvTag) val reasonCode = tlvReader.getUShort(ContextSpecificTag(TAG_REASON_CODE)) - + tlvReader.exitContainer() return WiFiNetworkDiagnosticsClusterDisconnectionEvent(reasonCode) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt index bd703215de0a5b..f177b65134c50c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlEntryStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -48,19 +47,19 @@ class AccessControlClusterAccessControlEntryStruct( put(ContextSpecificTag(TAG_AUTH_MODE), authMode) if (subjects != null) { startArray(ContextSpecificTag(TAG_SUBJECTS)) - for (item in subjects.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in subjects.iterator()) { + put(AnonymousTag, item) + } + endArray() } else { putNull(ContextSpecificTag(TAG_SUBJECTS)) } if (targets != null) { startArray(ContextSpecificTag(TAG_TARGETS)) - for (item in targets.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in targets.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } else { putNull(ContextSpecificTag(TAG_TARGETS)) } @@ -80,35 +79,43 @@ class AccessControlClusterAccessControlEntryStruct( tlvReader.enterStructure(tlvTag) val privilege = tlvReader.getUByte(ContextSpecificTag(TAG_PRIVILEGE)) val authMode = tlvReader.getUByte(ContextSpecificTag(TAG_AUTH_MODE)) - val subjects = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getULong(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) - null - } - val targets = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) - while(!tlvReader.isEndOfContainer()) { - add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) - null - } + val subjects = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SUBJECTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getULong(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SUBJECTS)) + null + } + val targets = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TARGETS)) + while (!tlvReader.isEndOfContainer()) { + add(AccessControlClusterAccessControlTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TARGETS)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return AccessControlClusterAccessControlEntryStruct(privilege, authMode, subjects, targets, fabricIndex) + return AccessControlClusterAccessControlEntryStruct( + privilege, + authMode, + subjects, + targets, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt index 8ffb7a94a61ed1..4427b4a4671abe 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlExtensionStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,14 @@ class AccessControlClusterAccessControlExtensionStruct( private const val TAG_DATA = 1 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlExtensionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): AccessControlClusterAccessControlExtensionStruct { tlvReader.enterStructure(tlvTag) val data = tlvReader.getByteArray(ContextSpecificTag(TAG_DATA)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return AccessControlClusterAccessControlExtensionStruct(data, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt index dc275d27e5f803..c0197f9d712c79 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AccessControlClusterAccessControlTargetStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -66,25 +64,28 @@ class AccessControlClusterAccessControlTargetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): AccessControlClusterAccessControlTargetStruct { tlvReader.enterStructure(tlvTag) - val cluster = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) - null - } - val endpoint = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) - null - } - val deviceType = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_TYPE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) - null - } - + val cluster = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLUSTER)) + null + } + val endpoint = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENDPOINT)) + null + } + val deviceType = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_TYPE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DEVICE_TYPE)) + null + } + tlvReader.exitContainer() return AccessControlClusterAccessControlTargetStruct(cluster, endpoint, deviceType) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt index 8b13dbce2d91cf..73476687b0478e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterActionStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,10 +70,17 @@ class ActionsClusterActionStruct( val endpointListID = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val supportedCommands = tlvReader.getUShort(ContextSpecificTag(TAG_SUPPORTED_COMMANDS)) val state = tlvReader.getUByte(ContextSpecificTag(TAG_STATE)) - + tlvReader.exitContainer() - return ActionsClusterActionStruct(actionID, name, type, endpointListID, supportedCommands, state) + return ActionsClusterActionStruct( + actionID, + name, + type, + endpointListID, + supportedCommands, + state + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt index 33c1848cd172d3..94dda8930854be 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActionsClusterEndpointListStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -65,14 +64,15 @@ class ActionsClusterEndpointListStruct( val endpointListID = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT_LIST_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) - val endpoints = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val endpoints = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ActionsClusterEndpointListStruct(endpointListID, name, type, endpoints) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt index c43c172f39ad4a..afa7a17f5647c8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ActivatedCarbonFilterMonitoringClusterReplacementProductStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,14 +46,22 @@ class ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ActivatedCarbonFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) - val productIdentifierType = tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierType = + tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) + val productIdentifierValue = + tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) + return ActivatedCarbonFilterMonitoringClusterReplacementProductStruct( + productIdentifierType, + productIdentifierValue + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt index e9566b36b3ab97..2172fbb67b699f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationBasicClusterApplicationStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,7 +50,7 @@ class ApplicationBasicClusterApplicationStruct( tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUShort(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationBasicClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt index eeca3b79254426..9329e2a02a429b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationEPStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -53,13 +52,18 @@ class ApplicationLauncherClusterApplicationEPStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ApplicationLauncherClusterApplicationEPStruct { tlvReader.enterStructure(tlvTag) - val application = ApplicationLauncherClusterApplicationStruct.fromTlv(ContextSpecificTag(TAG_APPLICATION), tlvReader) - val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - + val application = + ApplicationLauncherClusterApplicationStruct.fromTlv( + ContextSpecificTag(TAG_APPLICATION), + tlvReader + ) + val endpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationEPStruct(application, endpoint) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt index 4ca21f08b941b7..823ca308e47dde 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ApplicationLauncherClusterApplicationStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,7 +50,7 @@ class ApplicationLauncherClusterApplicationStruct( tlvReader.enterStructure(tlvTag) val catalogVendorID = tlvReader.getUShort(ContextSpecificTag(TAG_CATALOG_VENDOR_I_D)) val applicationID = tlvReader.getString(ContextSpecificTag(TAG_APPLICATION_I_D)) - + tlvReader.exitContainer() return ApplicationLauncherClusterApplicationStruct(catalogVendorID, applicationID) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt index 2a48b0b450bf4a..03f59264fc2501 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/AudioOutputClusterOutputInfoStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,7 +55,7 @@ class AudioOutputClusterOutputInfoStruct( val index = tlvReader.getUByte(ContextSpecificTag(TAG_INDEX)) val outputType = tlvReader.getUByte(ContextSpecificTag(TAG_OUTPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return AudioOutputClusterOutputInfoStruct(index, outputType, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt index aa977b5fdb8578..a25807e0c8d155 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterCapabilityMinimaStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -50,12 +48,17 @@ class BasicInformationClusterCapabilityMinimaStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterCapabilityMinimaStruct { tlvReader.enterStructure(tlvTag) - val caseSessionsPerFabric = tlvReader.getUShort(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) - val subscriptionsPerFabric = tlvReader.getUShort(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) - + val caseSessionsPerFabric = + tlvReader.getUShort(ContextSpecificTag(TAG_CASE_SESSIONS_PER_FABRIC)) + val subscriptionsPerFabric = + tlvReader.getUShort(ContextSpecificTag(TAG_SUBSCRIPTIONS_PER_FABRIC)) + tlvReader.exitContainer() - return BasicInformationClusterCapabilityMinimaStruct(caseSessionsPerFabric, subscriptionsPerFabric) + return BasicInformationClusterCapabilityMinimaStruct( + caseSessionsPerFabric, + subscriptionsPerFabric + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt index d5cc1315e520cd..56583564b0c687 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BasicInformationClusterProductAppearanceStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class BasicInformationClusterProductAppearanceStruct( - val finish: UByte, - val primaryColor: UByte? -) { +class BasicInformationClusterProductAppearanceStruct(val finish: UByte, val primaryColor: UByte?) { override fun toString(): String = buildString { append("BasicInformationClusterProductAppearanceStruct {\n") append("\tfinish : $finish\n") @@ -55,13 +50,14 @@ class BasicInformationClusterProductAppearanceStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUByte(ContextSpecificTag(TAG_FINISH)) - val primaryColor = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt index 1a382bd10ab5a0..84be9b6dd69995 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BindingClusterTargetStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -74,28 +73,32 @@ class BindingClusterTargetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BindingClusterTargetStruct { tlvReader.enterStructure(tlvTag) - val node = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) - } else { - Optional.empty() - } - val group = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_GROUP))) - } else { - Optional.empty() - } - val endpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) - } else { - Optional.empty() - } - val cluster = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER))) - } else { - Optional.empty() - } + val node = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NODE))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_NODE))) + } else { + Optional.empty() + } + val group = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_GROUP))) + } else { + Optional.empty() + } + val endpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENDPOINT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT))) + } else { + Optional.empty() + } + val cluster = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLUSTER))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return BindingClusterTargetStruct(node, group, endpoint, cluster, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt index 9e9eabc793ef94..94e9b134c06b09 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/BridgedDeviceBasicInformationClusterProductAppearanceStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,16 +50,20 @@ class BridgedDeviceBasicInformationClusterProductAppearanceStruct( private const val TAG_FINISH = 0 private const val TAG_PRIMARY_COLOR = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): BridgedDeviceBasicInformationClusterProductAppearanceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): BridgedDeviceBasicInformationClusterProductAppearanceStruct { tlvReader.enterStructure(tlvTag) val finish = tlvReader.getUByte(ContextSpecificTag(TAG_FINISH)) - val primaryColor = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) - null - } - + val primaryColor = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_PRIMARY_COLOR)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRIMARY_COLOR)) + null + } + tlvReader.exitContainer() return BridgedDeviceBasicInformationClusterProductAppearanceStruct(finish, primaryColor) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt index 9c504e9f434b18..cd2eacc749cb0d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterAdditionalInfoStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterAdditionalInfoStruct( - val name: String, - val value: String -) { +class ChannelClusterAdditionalInfoStruct(val name: String, val value: String) { override fun toString(): String = buildString { append("ChannelClusterAdditionalInfoStruct {\n") append("\tname : $name\n") @@ -52,7 +47,7 @@ class ChannelClusterAdditionalInfoStruct( tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ChannelClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt index 914bcad0e6cc7f..627dcdcbefa16f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelInfoStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -87,35 +86,48 @@ class ChannelClusterChannelInfoStruct( tlvReader.enterStructure(tlvTag) val majorNumber = tlvReader.getUShort(ContextSpecificTag(TAG_MAJOR_NUMBER)) val minorNumber = tlvReader.getUShort(ContextSpecificTag(TAG_MINOR_NUMBER)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val callSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) - } else { - Optional.empty() - } - val affiliateCallSign = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) - } else { - Optional.empty() - } - val identifier = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) - } else { - Optional.empty() - } - val type = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TYPE))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val callSign = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_CALL_SIGN))) + } else { + Optional.empty() + } + val affiliateCallSign = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFFILIATE_CALL_SIGN))) + } else { + Optional.empty() + } + val identifier = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IDENTIFIER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER))) + } else { + Optional.empty() + } + val type = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TYPE))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TYPE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterChannelInfoStruct(majorNumber, minorNumber, name, callSign, affiliateCallSign, identifier, type) + return ChannelClusterChannelInfoStruct( + majorNumber, + minorNumber, + name, + callSign, + affiliateCallSign, + identifier, + type + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt index f3b7c7d5f51755..3d190489316d4a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterChannelPagingStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -40,17 +39,17 @@ class ChannelClusterChannelPagingStruct( startStructure(tlvTag) if (previousToken != null) { if (previousToken.isPresent) { - val optpreviousToken = previousToken.get() - optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) - } + val optpreviousToken = previousToken.get() + optpreviousToken.toTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), this) + } } else { putNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) } if (nextToken != null) { if (nextToken.isPresent) { - val optnextToken = nextToken.get() - optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) - } + val optnextToken = nextToken.get() + optnextToken.toTlv(ContextSpecificTag(TAG_NEXT_TOKEN), this) + } } else { putNull(ContextSpecificTag(TAG_NEXT_TOKEN)) } @@ -64,27 +63,36 @@ class ChannelClusterChannelPagingStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterChannelPagingStruct { tlvReader.enterStructure(tlvTag) - val previousToken = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { - Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_PREVIOUS_TOKEN), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) - null - } - val nextToken = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { - Optional.of(ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) - null - } - + val previousToken = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PREVIOUS_TOKEN))) { + Optional.of( + ChannelClusterPageTokenStruct.fromTlv( + ContextSpecificTag(TAG_PREVIOUS_TOKEN), + tlvReader + ) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PREVIOUS_TOKEN)) + null + } + val nextToken = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NEXT_TOKEN))) { + Optional.of( + ChannelClusterPageTokenStruct.fromTlv(ContextSpecificTag(TAG_NEXT_TOKEN), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NEXT_TOKEN)) + null + } + tlvReader.exitContainer() return ChannelClusterChannelPagingStruct(previousToken, nextToken) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt index 21eb682b010a20..e8e25f3fe16a7e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterLineupInfoStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -65,18 +64,20 @@ class ChannelClusterLineupInfoStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterLineupInfoStruct { tlvReader.enterStructure(tlvTag) val operatorName = tlvReader.getString(ContextSpecificTag(TAG_OPERATOR_NAME)) - val lineupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) - } else { - Optional.empty() - } - val postalCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) - } else { - Optional.empty() - } + val lineupName = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LINEUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LINEUP_NAME))) + } else { + Optional.empty() + } + val postalCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTAL_CODE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTAL_CODE))) + } else { + Optional.empty() + } val lineupInfoType = tlvReader.getUByte(ContextSpecificTag(TAG_LINEUP_INFO_TYPE)) - + tlvReader.exitContainer() return ChannelClusterLineupInfoStruct(operatorName, lineupName, postalCode, lineupInfoType) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt index 963a7c2beb5ffa..e9712955df7799 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterPageTokenStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -63,22 +62,25 @@ class ChannelClusterPageTokenStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterPageTokenStruct { tlvReader.enterStructure(tlvTag) - val limit = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_LIMIT))) - } else { - Optional.empty() - } - val after = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) - } else { - Optional.empty() - } - val before = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) - } else { - Optional.empty() - } - + val limit = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LIMIT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_LIMIT))) + } else { + Optional.empty() + } + val after = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AFTER))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_AFTER))) + } else { + Optional.empty() + } + val before = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BEFORE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_BEFORE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterPageTokenStruct(limit, after, before) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt index 54568f0b775970..45b0a22100ef25 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCastStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterProgramCastStruct( - val name: String, - val role: String -) { +class ChannelClusterProgramCastStruct(val name: String, val role: String) { override fun toString(): String = buildString { append("ChannelClusterProgramCastStruct {\n") append("\tname : $name\n") @@ -52,7 +47,7 @@ class ChannelClusterProgramCastStruct( tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val role = tlvReader.getString(ContextSpecificTag(TAG_ROLE)) - + tlvReader.exitContainer() return ChannelClusterProgramCastStruct(name, role) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt index 3ffaea537244dc..6e89f24cd39e25 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramCategoryStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterProgramCategoryStruct( - val category: String, - val subCategory: Optional -) { +class ChannelClusterProgramCategoryStruct(val category: String, val subCategory: Optional) { override fun toString(): String = buildString { append("ChannelClusterProgramCategoryStruct {\n") append("\tcategory : $category\n") @@ -54,12 +50,13 @@ class ChannelClusterProgramCategoryStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramCategoryStruct { tlvReader.enterStructure(tlvTag) val category = tlvReader.getString(ContextSpecificTag(TAG_CATEGORY)) - val subCategory = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) - } else { - Optional.empty() - } - + val subCategory = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUB_CATEGORY))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUB_CATEGORY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ChannelClusterProgramCategoryStruct(category, subCategory) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt index 327c6622543aff..f40e13d0894446 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterProgramStruct.kt @@ -88,18 +88,18 @@ class ChannelClusterProgramStruct( if (audioLanguages.isPresent) { val optaudioLanguages = audioLanguages.get() startArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - for (item in optaudioLanguages.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optaudioLanguages.iterator()) { + put(AnonymousTag, item) + } + endArray() } if (ratings.isPresent) { val optratings = ratings.get() startArray(ContextSpecificTag(TAG_RATINGS)) - for (item in optratings.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optratings.iterator()) { + put(AnonymousTag, item) + } + endArray() } if (thumbnailUrl.isPresent) { val optthumbnailUrl = thumbnailUrl.get() @@ -127,35 +127,35 @@ class ChannelClusterProgramStruct( } if (seriesInfo != null) { if (seriesInfo.isPresent) { - val optseriesInfo = seriesInfo.get() - optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) - } + val optseriesInfo = seriesInfo.get() + optseriesInfo.toTlv(ContextSpecificTag(TAG_SERIES_INFO), this) + } } else { putNull(ContextSpecificTag(TAG_SERIES_INFO)) } if (categoryList.isPresent) { val optcategoryList = categoryList.get() startArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - for (item in optcategoryList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optcategoryList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } if (castList.isPresent) { val optcastList = castList.get() startArray(ContextSpecificTag(TAG_CAST_LIST)) - for (item in optcastList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optcastList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } if (externalIDList.isPresent) { val optexternalIDList = externalIDList.get() startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } endStructure() } @@ -185,119 +185,166 @@ class ChannelClusterProgramStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ChannelClusterProgramStruct { tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getString(ContextSpecificTag(TAG_IDENTIFIER)) - val channel = ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) + val channel = + ChannelClusterChannelInfoStruct.fromTlv(ContextSpecificTag(TAG_CHANNEL), tlvReader) val startTime = tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getUInt(ContextSpecificTag(TAG_END_TIME)) val title = tlvReader.getString(ContextSpecificTag(TAG_TITLE)) - val subtitle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) - } else { - Optional.empty() - } - val description = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) - } else { - Optional.empty() - } - val audioLanguages = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val ratings = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getString(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val thumbnailUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) - } else { - Optional.empty() - } - val posterArtUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) - } else { - Optional.empty() - } - val dvbiUrl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) - } else { - Optional.empty() - } - val releaseDate = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) - } else { - Optional.empty() - } - val parentalGuidanceText = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) - } else { - Optional.empty() - } - val recordingFlag = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_RECORDING_FLAG))) - } else { - Optional.empty() - } - val seriesInfo = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { - Optional.of(ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) - null - } - val categoryList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val castList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val subtitle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SUBTITLE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_SUBTITLE))) + } else { + Optional.empty() + } + val description = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DESCRIPTION))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION))) + } else { + Optional.empty() + } + val audioLanguages = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_LANGUAGES))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_LANGUAGES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val ratings = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATINGS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_RATINGS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getString(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val thumbnailUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_THUMBNAIL_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_THUMBNAIL_URL))) + } else { + Optional.empty() + } + val posterArtUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POSTER_ART_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_POSTER_ART_URL))) + } else { + Optional.empty() + } + val dvbiUrl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DVBI_URL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DVBI_URL))) + } else { + Optional.empty() + } + val releaseDate = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RELEASE_DATE))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RELEASE_DATE))) + } else { + Optional.empty() + } + val parentalGuidanceText = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_PARENTAL_GUIDANCE_TEXT))) + } else { + Optional.empty() + } + val recordingFlag = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RECORDING_FLAG))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_RECORDING_FLAG))) + } else { + Optional.empty() + } + val seriesInfo = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SERIES_INFO))) { + Optional.of( + ChannelClusterSeriesInfoStruct.fromTlv(ContextSpecificTag(TAG_SERIES_INFO), tlvReader) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SERIES_INFO)) + null + } + val categoryList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CATEGORY_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CATEGORY_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCategoryStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val castList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CAST_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CAST_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val externalIDList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ChannelClusterProgramCastStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ChannelClusterProgramStruct(identifier, channel, startTime, endTime, title, subtitle, description, audioLanguages, ratings, thumbnailUrl, posterArtUrl, dvbiUrl, releaseDate, parentalGuidanceText, recordingFlag, seriesInfo, categoryList, castList, externalIDList) + return ChannelClusterProgramStruct( + identifier, + channel, + startTime, + endTime, + title, + subtitle, + description, + audioLanguages, + ratings, + thumbnailUrl, + posterArtUrl, + dvbiUrl, + releaseDate, + parentalGuidanceText, + recordingFlag, + seriesInfo, + categoryList, + castList, + externalIDList + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt index c0445d55460703..9e3928a48de8a5 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ChannelClusterSeriesInfoStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ChannelClusterSeriesInfoStruct( - val season: String, - val episode: String -) { +class ChannelClusterSeriesInfoStruct(val season: String, val episode: String) { override fun toString(): String = buildString { append("ChannelClusterSeriesInfoStruct {\n") append("\tseason : $season\n") @@ -52,7 +47,7 @@ class ChannelClusterSeriesInfoStruct( tlvReader.enterStructure(tlvTag) val season = tlvReader.getString(ContextSpecificTag(TAG_SEASON)) val episode = tlvReader.getString(ContextSpecificTag(TAG_EPISODE)) - + tlvReader.exitContainer() return ChannelClusterSeriesInfoStruct(season, episode) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt index fe5058eb533a87..c47570f255caaa 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentControlClusterRatingNameStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -54,12 +53,13 @@ class ContentControlClusterRatingNameStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentControlClusterRatingNameStruct { tlvReader.enterStructure(tlvTag) val ratingName = tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME)) - val ratingNameDesc = if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) - } else { - Optional.empty() - } - + val ratingNameDesc = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_RATING_NAME_DESC))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_RATING_NAME_DESC))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentControlClusterRatingNameStruct(ratingName, ratingNameDesc) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt index 504997933652c9..af51becfe86381 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterAdditionalInfoStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ContentLauncherClusterAdditionalInfoStruct( - val name: String, - val value: String -) { +class ContentLauncherClusterAdditionalInfoStruct(val name: String, val value: String) { override fun toString(): String = buildString { append("ContentLauncherClusterAdditionalInfoStruct {\n") append("\tname : $name\n") @@ -52,7 +47,7 @@ class ContentLauncherClusterAdditionalInfoStruct( tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ContentLauncherClusterAdditionalInfoStruct(name, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt index e94826e1eb40d8..4470b659b2e59f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterBrandingInformationStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -79,38 +78,78 @@ class ContentLauncherClusterBrandingInformationStruct( private const val TAG_SPLASH = 4 private const val TAG_WATER_MARK = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterBrandingInformationStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ContentLauncherClusterBrandingInformationStruct { tlvReader.enterStructure(tlvTag) val providerName = tlvReader.getString(ContextSpecificTag(TAG_PROVIDER_NAME)) - val background = if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_BACKGROUND), tlvReader)) - } else { - Optional.empty() - } - val logo = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_LOGO), tlvReader)) - } else { - Optional.empty() - } - val progressBar = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_PROGRESS_BAR), tlvReader)) - } else { - Optional.empty() - } - val splash = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_SPLASH), tlvReader)) - } else { - Optional.empty() - } - val waterMark = if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { - Optional.of(ContentLauncherClusterStyleInformationStruct.fromTlv(ContextSpecificTag(TAG_WATER_MARK), tlvReader)) - } else { - Optional.empty() - } - + val background = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BACKGROUND))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_BACKGROUND), + tlvReader + ) + ) + } else { + Optional.empty() + } + val logo = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOGO))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_LOGO), + tlvReader + ) + ) + } else { + Optional.empty() + } + val progressBar = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PROGRESS_BAR))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_PROGRESS_BAR), + tlvReader + ) + ) + } else { + Optional.empty() + } + val splash = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SPLASH))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_SPLASH), + tlvReader + ) + ) + } else { + Optional.empty() + } + val waterMark = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_WATER_MARK))) { + Optional.of( + ContentLauncherClusterStyleInformationStruct.fromTlv( + ContextSpecificTag(TAG_WATER_MARK), + tlvReader + ) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterBrandingInformationStruct(providerName, background, logo, progressBar, splash, waterMark) + return ContentLauncherClusterBrandingInformationStruct( + providerName, + background, + logo, + progressBar, + splash, + waterMark + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt index 052e4f66723755..1fe0fc71463ee6 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterContentSearchStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -50,14 +49,15 @@ class ContentLauncherClusterContentSearchStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterContentSearchStruct { tlvReader.enterStructure(tlvTag) - val parameterList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val parameterList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PARAMETER_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterParameterStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ContentLauncherClusterContentSearchStruct(parameterList) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt index 5870e4079531e8..f9c4eb2d6f4502 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterDimensionStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,7 +55,7 @@ class ContentLauncherClusterDimensionStruct( val width = tlvReader.getDouble(ContextSpecificTag(TAG_WIDTH)) val height = tlvReader.getDouble(ContextSpecificTag(TAG_HEIGHT)) val metric = tlvReader.getUByte(ContextSpecificTag(TAG_METRIC)) - + tlvReader.exitContainer() return ContentLauncherClusterDimensionStruct(width, height, metric) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt index 9b85de042f0a94..e0975b8e1c6c9f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterParameterStruct.kt @@ -45,10 +45,10 @@ class ContentLauncherClusterParameterStruct( if (externalIDList.isPresent) { val optexternalIDList = externalIDList.get() startArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - for (item in optexternalIDList.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optexternalIDList.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } endStructure() } @@ -63,18 +63,21 @@ class ContentLauncherClusterParameterStruct( tlvReader.enterStructure(tlvTag) val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - val externalIDList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val externalIDList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_EXTERNAL_I_D_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterAdditionalInfoStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterParameterStruct(type, value, externalIDList) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt index adba8615ee2d73..694f35fc4364d1 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterPlaybackPreferencesStruct.kt @@ -45,10 +45,10 @@ class ContentLauncherClusterPlaybackPreferencesStruct( if (audioTracks.isPresent) { val optaudioTracks = audioTracks.get() startArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - for (item in optaudioTracks.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optaudioTracks.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } endStructure() } @@ -59,25 +59,39 @@ class ContentLauncherClusterPlaybackPreferencesStruct( private const val TAG_TEXT_TRACK = 1 private const val TAG_AUDIO_TRACKS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterPlaybackPreferencesStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ContentLauncherClusterPlaybackPreferencesStruct { tlvReader.enterStructure(tlvTag) val playbackPosition = tlvReader.getULong(ContextSpecificTag(TAG_PLAYBACK_POSITION)) - val textTrack = ContentLauncherClusterTrackPreferenceStruct.fromTlv(ContextSpecificTag(TAG_TEXT_TRACK), tlvReader) - val audioTracks = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) - while(!tlvReader.isEndOfContainer()) { - add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - + val textTrack = + ContentLauncherClusterTrackPreferenceStruct.fromTlv( + ContextSpecificTag(TAG_TEXT_TRACK), + tlvReader + ) + val audioTracks = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AUDIO_TRACKS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_AUDIO_TRACKS)) + while (!tlvReader.isEndOfContainer()) { + add(ContentLauncherClusterTrackPreferenceStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ContentLauncherClusterPlaybackPreferencesStruct(playbackPosition, textTrack, audioTracks) + return ContentLauncherClusterPlaybackPreferencesStruct( + playbackPosition, + textTrack, + audioTracks + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt index 6c0f03344a31eb..e57d04e099fb44 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterStyleInformationStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -63,22 +62,27 @@ class ContentLauncherClusterStyleInformationStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterStyleInformationStruct { tlvReader.enterStructure(tlvTag) - val imageURL = if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) - } else { - Optional.empty() - } - val color = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) - } else { - Optional.empty() - } - val size = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { - Optional.of(ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader)) - } else { - Optional.empty() - } - + val imageURL = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_IMAGE_U_R_L))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_IMAGE_U_R_L))) + } else { + Optional.empty() + } + val color = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COLOR))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_COLOR))) + } else { + Optional.empty() + } + val size = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SIZE))) { + Optional.of( + ContentLauncherClusterDimensionStruct.fromTlv(ContextSpecificTag(TAG_SIZE), tlvReader) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() return ContentLauncherClusterStyleInformationStruct(imageURL, color, size) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt index 47dadc45c6f0b3..74c3088d135bcc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ContentLauncherClusterTrackPreferenceStruct.kt @@ -44,10 +44,10 @@ class ContentLauncherClusterTrackPreferenceStruct( if (characteristics.isPresent) { val optcharacteristics = characteristics.get() startArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - for (item in optcharacteristics.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optcharacteristics.iterator()) { + put(AnonymousTag, item) + } + endArray() } put(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX), audioOutputIndex) endStructure() @@ -62,22 +62,29 @@ class ContentLauncherClusterTrackPreferenceStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ContentLauncherClusterTrackPreferenceStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val characteristics = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } + val characteristics = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CHARACTERISTICS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARACTERISTICS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } val audioOutputIndex = tlvReader.getUByte(ContextSpecificTag(TAG_AUDIO_OUTPUT_INDEX)) - + tlvReader.exitContainer() - return ContentLauncherClusterTrackPreferenceStruct(languageCode, characteristics, audioOutputIndex) + return ContentLauncherClusterTrackPreferenceStruct( + languageCode, + characteristics, + audioOutputIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt index 5a055dd4270923..4473bd4520dcd2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterAverageLoadControlStruct.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterAverageLoadControlStruct( - val loadAdjustment: Byte -) { +class DemandResponseLoadControlClusterAverageLoadControlStruct(val loadAdjustment: Byte) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterAverageLoadControlStruct {\n") append("\tloadAdjustment : $loadAdjustment\n") @@ -44,10 +40,13 @@ class DemandResponseLoadControlClusterAverageLoadControlStruct( companion object { private const val TAG_LOAD_ADJUSTMENT = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterAverageLoadControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterAverageLoadControlStruct { tlvReader.enterStructure(tlvTag) val loadAdjustment = tlvReader.getByte(ContextSpecificTag(TAG_LOAD_ADJUSTMENT)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterAverageLoadControlStruct(loadAdjustment) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt index 9573a4e3ff11fa..7e53d779dda4e3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterDutyCycleControlStruct.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterDutyCycleControlStruct( - val dutyCycle: UByte -) { +class DemandResponseLoadControlClusterDutyCycleControlStruct(val dutyCycle: UByte) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterDutyCycleControlStruct {\n") append("\tdutyCycle : $dutyCycle\n") @@ -44,10 +40,13 @@ class DemandResponseLoadControlClusterDutyCycleControlStruct( companion object { private const val TAG_DUTY_CYCLE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterDutyCycleControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterDutyCycleControlStruct { tlvReader.enterStructure(tlvTag) val dutyCycle = tlvReader.getUByte(ContextSpecificTag(TAG_DUTY_CYCLE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterDutyCycleControlStruct(dutyCycle) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt index ed90e36f3a637e..aeae2026e12db2 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterHeatingSourceControlStruct.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterHeatingSourceControlStruct( - val heatingSource: UByte -) { +class DemandResponseLoadControlClusterHeatingSourceControlStruct(val heatingSource: UByte) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterHeatingSourceControlStruct {\n") append("\theatingSource : $heatingSource\n") @@ -44,10 +40,13 @@ class DemandResponseLoadControlClusterHeatingSourceControlStruct( companion object { private const val TAG_HEATING_SOURCE = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterHeatingSourceControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterHeatingSourceControlStruct { tlvReader.enterStructure(tlvTag) val heatingSource = tlvReader.getUByte(ContextSpecificTag(TAG_HEATING_SOURCE)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterHeatingSourceControlStruct(heatingSource) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt index f0a1f42885e734..e8f15e8cdb0064 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventStruct.kt @@ -87,40 +87,61 @@ class DemandResponseLoadControlClusterLoadControlEventStruct( private const val TAG_START_TIME = 6 private const val TAG_TRANSITIONS = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterLoadControlEventStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventStruct { tlvReader.enterStructure(tlvTag) val eventID = tlvReader.getByteArray(ContextSpecificTag(TAG_EVENT_I_D)) - val programID = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) - null - } + val programID = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PROGRAM_I_D)) + null + } val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) val deviceClass = tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_CLASS)) - val enrollmentGroup = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) - } else { - Optional.empty() - } + val enrollmentGroup = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP))) + } else { + Optional.empty() + } val criticality = tlvReader.getUByte(ContextSpecificTag(TAG_CRITICALITY)) - val startTime = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) - null - } - val transitions = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while(!tlvReader.isEndOfContainer()) { - add(DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val startTime = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_START_TIME)) + null + } + val transitions = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while (!tlvReader.isEndOfContainer()) { + add( + DemandResponseLoadControlClusterLoadControlEventTransitionStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventStruct(eventID, programID, control, deviceClass, enrollmentGroup, criticality, startTime, transitions) + return DemandResponseLoadControlClusterLoadControlEventStruct( + eventID, + programID, + control, + deviceClass, + enrollmentGroup, + criticality, + startTime, + transitions + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt index 8b11bb21f1b0a0..1bad4e81db4b9a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlEventTransitionStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -83,39 +82,80 @@ class DemandResponseLoadControlClusterLoadControlEventTransitionStruct( private const val TAG_POWER_SAVINGS_CONTROL = 5 private const val TAG_HEATING_SOURCE_CONTROL = 6 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterLoadControlEventTransitionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlEventTransitionStruct { tlvReader.enterStructure(tlvTag) val duration = tlvReader.getUShort(ContextSpecificTag(TAG_DURATION)) val control = tlvReader.getUShort(ContextSpecificTag(TAG_CONTROL)) - val temperatureControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv(ContextSpecificTag(TAG_TEMPERATURE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val averageLoadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val dutyCycleControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val powerSavingsControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), tlvReader)) - } else { - Optional.empty() - } - val heatingSourceControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { - Optional.of(DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), tlvReader)) - } else { - Optional.empty() - } - + val temperatureControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TEMPERATURE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterTemperatureControlStruct.fromTlv( + ContextSpecificTag(TAG_TEMPERATURE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val averageLoadControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterAverageLoadControlStruct.fromTlv( + ContextSpecificTag(TAG_AVERAGE_LOAD_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val dutyCycleControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterDutyCycleControlStruct.fromTlv( + ContextSpecificTag(TAG_DUTY_CYCLE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val powerSavingsControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterPowerSavingsControlStruct.fromTlv( + ContextSpecificTag(TAG_POWER_SAVINGS_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + val heatingSourceControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL))) { + Optional.of( + DemandResponseLoadControlClusterHeatingSourceControlStruct.fromTlv( + ContextSpecificTag(TAG_HEATING_SOURCE_CONTROL), + tlvReader + ) + ) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlEventTransitionStruct(duration, control, temperatureControl, averageLoadControl, dutyCycleControl, powerSavingsControl, heatingSourceControl) + return DemandResponseLoadControlClusterLoadControlEventTransitionStruct( + duration, + control, + temperatureControl, + averageLoadControl, + dutyCycleControl, + powerSavingsControl, + heatingSourceControl + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt index b40fac86f3abf0..d3aea5654d479b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterLoadControlProgramStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,32 +70,44 @@ class DemandResponseLoadControlClusterLoadControlProgramStruct( private const val TAG_RANDOM_START_MINUTES = 3 private const val TAG_RANDOM_DURATION_MINUTES = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterLoadControlProgramStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterLoadControlProgramStruct { tlvReader.enterStructure(tlvTag) val programID = tlvReader.getByteArray(ContextSpecificTag(TAG_PROGRAM_I_D)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - val enrollmentGroup = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) - null - } - val randomStartMinutes = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) - null - } - val randomDurationMinutes = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) - null - } - + val enrollmentGroup = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ENROLLMENT_GROUP)) + null + } + val randomStartMinutes = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_START_MINUTES)) + null + } + val randomDurationMinutes = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_RANDOM_DURATION_MINUTES)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterLoadControlProgramStruct(programID, name, enrollmentGroup, randomStartMinutes, randomDurationMinutes) + return DemandResponseLoadControlClusterLoadControlProgramStruct( + programID, + name, + enrollmentGroup, + randomStartMinutes, + randomDurationMinutes + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt index 08d7bc21262e2e..485257eb7dbf1c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterPowerSavingsControlStruct.kt @@ -16,17 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DemandResponseLoadControlClusterPowerSavingsControlStruct( - val powerSavings: UByte -) { +class DemandResponseLoadControlClusterPowerSavingsControlStruct(val powerSavings: UByte) { override fun toString(): String = buildString { append("DemandResponseLoadControlClusterPowerSavingsControlStruct {\n") append("\tpowerSavings : $powerSavings\n") @@ -44,10 +40,13 @@ class DemandResponseLoadControlClusterPowerSavingsControlStruct( companion object { private const val TAG_POWER_SAVINGS = 0 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterPowerSavingsControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterPowerSavingsControlStruct { tlvReader.enterStructure(tlvTag) val powerSavings = tlvReader.getUByte(ContextSpecificTag(TAG_POWER_SAVINGS)) - + tlvReader.exitContainer() return DemandResponseLoadControlClusterPowerSavingsControlStruct(powerSavings) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt index d6bd0cd2524906..635b2541684b05 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DemandResponseLoadControlClusterTemperatureControlStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -44,33 +43,33 @@ class DemandResponseLoadControlClusterTemperatureControlStruct( startStructure(tlvTag) if (coolingTempOffset != null) { if (coolingTempOffset.isPresent) { - val optcoolingTempOffset = coolingTempOffset.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) - } + val optcoolingTempOffset = coolingTempOffset.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET), optcoolingTempOffset) + } } else { putNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) } if (heatingtTempOffset != null) { if (heatingtTempOffset.isPresent) { - val optheatingtTempOffset = heatingtTempOffset.get() - put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) - } + val optheatingtTempOffset = heatingtTempOffset.get() + put(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET), optheatingtTempOffset) + } } else { putNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) } if (coolingTempSetpoint != null) { if (coolingTempSetpoint.isPresent) { - val optcoolingTempSetpoint = coolingTempSetpoint.get() - put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) - } + val optcoolingTempSetpoint = coolingTempSetpoint.get() + put(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT), optcoolingTempSetpoint) + } } else { putNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) } if (heatingTempSetpoint != null) { if (heatingTempSetpoint.isPresent) { - val optheatingTempSetpoint = heatingTempSetpoint.get() - put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) - } + val optheatingTempSetpoint = heatingTempSetpoint.get() + put(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT), optheatingTempSetpoint) + } } else { putNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) } @@ -84,52 +83,64 @@ class DemandResponseLoadControlClusterTemperatureControlStruct( private const val TAG_COOLING_TEMP_SETPOINT = 2 private const val TAG_HEATING_TEMP_SETPOINT = 3 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DemandResponseLoadControlClusterTemperatureControlStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DemandResponseLoadControlClusterTemperatureControlStruct { tlvReader.enterStructure(tlvTag) - val coolingTempOffset = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) - null - } - val heatingtTempOffset = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) - null - } - val coolingTempSetpoint = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) - null - } - val heatingTempSetpoint = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) - null - } - + val coolingTempOffset = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_OFFSET)) + null + } + val heatingtTempOffset = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATINGT_TEMP_OFFSET)) + null + } + val coolingTempSetpoint = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOLING_TEMP_SETPOINT)) + null + } + val heatingTempSetpoint = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEATING_TEMP_SETPOINT)) + null + } + tlvReader.exitContainer() - return DemandResponseLoadControlClusterTemperatureControlStruct(coolingTempOffset, heatingtTempOffset, coolingTempSetpoint, heatingTempSetpoint) + return DemandResponseLoadControlClusterTemperatureControlStruct( + coolingTempOffset, + heatingtTempOffset, + coolingTempSetpoint, + heatingTempSetpoint + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt index 3b1d50b42659e8..c8cc82e04d50eb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterDeviceTypeStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DescriptorClusterDeviceTypeStruct( - val deviceType: UInt, - val revision: UShort -) { +class DescriptorClusterDeviceTypeStruct(val deviceType: UInt, val revision: UShort) { override fun toString(): String = buildString { append("DescriptorClusterDeviceTypeStruct {\n") append("\tdeviceType : $deviceType\n") @@ -52,7 +47,7 @@ class DescriptorClusterDeviceTypeStruct( tlvReader.enterStructure(tlvTag) val deviceType = tlvReader.getUInt(ContextSpecificTag(TAG_DEVICE_TYPE)) val revision = tlvReader.getUShort(ContextSpecificTag(TAG_REVISION)) - + tlvReader.exitContainer() return DescriptorClusterDeviceTypeStruct(deviceType, revision) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt index cc8a218a8840a6..70a83556618698 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DescriptorClusterSemanticTagStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,9 +50,9 @@ class DescriptorClusterSemanticTagStruct( put(ContextSpecificTag(TAG_TAG), tag) if (label != null) { if (label.isPresent) { - val optlabel = label.get() - put(ContextSpecificTag(TAG_LABEL), optlabel) - } + val optlabel = label.get() + put(ContextSpecificTag(TAG_LABEL), optlabel) + } } else { putNull(ContextSpecificTag(TAG_LABEL)) } @@ -69,25 +68,27 @@ class DescriptorClusterSemanticTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DescriptorClusterSemanticTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) - null - } + val mfgCode = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_MFG_CODE)) + null + } val namespaceID = tlvReader.getUByte(ContextSpecificTag(TAG_NAMESPACE_I_D)) val tag = tlvReader.getUByte(ContextSpecificTag(TAG_TAG)) - val label = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) - null - } - + val label = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LABEL)) + null + } + tlvReader.exitContainer() return DescriptorClusterSemanticTagStruct(mfgCode, namespaceID, tag, label) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt index 0972701ad34688..4649721a71284b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterConstraintsStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -73,25 +72,34 @@ class DeviceEnergyManagementClusterConstraintsStruct( tlvReader.enterStructure(tlvTag) val startTime = tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) - val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val maximumEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) - } else { - Optional.empty() - } - val loadControl = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { - Optional.of(tlvReader.getByte(ContextSpecificTag(TAG_LOAD_CONTROL))) - } else { - Optional.empty() - } - + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val maximumEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAXIMUM_ENERGY))) + } else { + Optional.empty() + } + val loadControl = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LOAD_CONTROL))) { + Optional.of(tlvReader.getByte(ContextSpecificTag(TAG_LOAD_CONTROL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterConstraintsStruct(startTime, duration, nominalPower, maximumEnergy, loadControl) + return DeviceEnergyManagementClusterConstraintsStruct( + startTime, + duration, + nominalPower, + maximumEnergy, + loadControl + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt index f75628b28ac4f9..c08ce3a1eaf582 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterCostStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -64,12 +63,13 @@ class DeviceEnergyManagementClusterCostStruct( val costType = tlvReader.getUByte(ContextSpecificTag(TAG_COST_TYPE)) val value = tlvReader.getInt(ContextSpecificTag(TAG_VALUE)) val decimalPoints = tlvReader.getUByte(ContextSpecificTag(TAG_DECIMAL_POINTS)) - val currency = if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_CURRENCY))) - } else { - Optional.empty() - } - + val currency = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CURRENCY))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_CURRENCY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return DeviceEnergyManagementClusterCostStruct(costType, value, decimalPoints, currency) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt index eaab7da96a369e..a83d26ee3815d0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterForecastStruct.kt @@ -62,9 +62,9 @@ class DeviceEnergyManagementClusterForecastStruct( put(ContextSpecificTag(TAG_END_TIME), endTime) if (earliestStartTime != null) { if (earliestStartTime.isPresent) { - val optearliestStartTime = earliestStartTime.get() - put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) - } + val optearliestStartTime = earliestStartTime.get() + put(ContextSpecificTag(TAG_EARLIEST_START_TIME), optearliestStartTime) + } } else { putNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) } @@ -97,42 +97,56 @@ class DeviceEnergyManagementClusterForecastStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterForecastStruct { tlvReader.enterStructure(tlvTag) val forecastId = tlvReader.getUShort(ContextSpecificTag(TAG_FORECAST_ID)) - val activeSlotNumber = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) - null - } + val activeSlotNumber = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ACTIVE_SLOT_NUMBER)) + null + } val startTime = tlvReader.getUInt(ContextSpecificTag(TAG_START_TIME)) val endTime = tlvReader.getUInt(ContextSpecificTag(TAG_END_TIME)) - val earliestStartTime = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_EARLIEST_START_TIME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) - null - } - val latestEndTime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LATEST_END_TIME))) - } else { - Optional.empty() - } + val earliestStartTime = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_EARLIEST_START_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_EARLIEST_START_TIME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EARLIEST_START_TIME)) + null + } + val latestEndTime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LATEST_END_TIME))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_LATEST_END_TIME))) + } else { + Optional.empty() + } val isPauseable = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_PAUSEABLE)) - val slots = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } + val slots = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SLOTS)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterSlotStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } val forecastUpdateReason = tlvReader.getUByte(ContextSpecificTag(TAG_FORECAST_UPDATE_REASON)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterForecastStruct(forecastId, activeSlotNumber, startTime, endTime, earliestStartTime, latestEndTime, isPauseable, slots, forecastUpdateReason) + return DeviceEnergyManagementClusterForecastStruct( + forecastId, + activeSlotNumber, + startTime, + endTime, + earliestStartTime, + latestEndTime, + isPauseable, + slots, + forecastUpdateReason + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt index f03165bcf17f94..c1822bb573e344 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterPowerAdjustStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -62,10 +60,15 @@ class DeviceEnergyManagementClusterPowerAdjustStruct( val maxPower = tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER)) val minDuration = tlvReader.getUInt(ContextSpecificTag(TAG_MIN_DURATION)) val maxDuration = tlvReader.getUInt(ContextSpecificTag(TAG_MAX_DURATION)) - + tlvReader.exitContainer() - return DeviceEnergyManagementClusterPowerAdjustStruct(minPower, maxPower, minDuration, maxDuration) + return DeviceEnergyManagementClusterPowerAdjustStruct( + minPower, + maxPower, + minDuration, + maxDuration + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt index 8cf41014cac8bd..e11febdfd6a489 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotAdjustmentStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,12 +50,15 @@ class DeviceEnergyManagementClusterSlotAdjustmentStruct( private const val TAG_NOMINAL_POWER = 1 private const val TAG_DURATION = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DeviceEnergyManagementClusterSlotAdjustmentStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): DeviceEnergyManagementClusterSlotAdjustmentStruct { tlvReader.enterStructure(tlvTag) val slotIndex = tlvReader.getUByte(ContextSpecificTag(TAG_SLOT_INDEX)) val nominalPower = tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER)) val duration = tlvReader.getUInt(ContextSpecificTag(TAG_DURATION)) - + tlvReader.exitContainer() return DeviceEnergyManagementClusterSlotAdjustmentStruct(slotIndex, nominalPower, duration) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt index b973f2c0fcb3e5..992a41573e295e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DeviceEnergyManagementClusterSlotStruct.kt @@ -110,10 +110,10 @@ class DeviceEnergyManagementClusterSlotStruct( if (costs.isPresent) { val optcosts = costs.get() startArray(ContextSpecificTag(TAG_COSTS)) - for (item in optcosts.iterator()) { - item.toTlv(AnonymousTag, this) - } - endArray() + for (item in optcosts.iterator()) { + item.toTlv(AnonymousTag, this) + } + endArray() } if (minPowerAdjustment.isPresent) { val optminPowerAdjustment = minPowerAdjustment.get() @@ -162,81 +162,115 @@ class DeviceEnergyManagementClusterSlotStruct( val defaultDuration = tlvReader.getUInt(ContextSpecificTag(TAG_DEFAULT_DURATION)) val elapsedSlotTime = tlvReader.getUInt(ContextSpecificTag(TAG_ELAPSED_SLOT_TIME)) val remainingSlotTime = tlvReader.getUInt(ContextSpecificTag(TAG_REMAINING_SLOT_TIME)) - val slotIsPauseable = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) - } else { - Optional.empty() - } - val minPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) - } else { - Optional.empty() - } - val maxPauseDuration = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) - } else { - Optional.empty() - } - val manufacturerESAState = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) - } else { - Optional.empty() - } - val nominalPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) - } else { - Optional.empty() - } - val minPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) - } else { - Optional.empty() - } - val maxPower = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) - } else { - Optional.empty() - } - val nominalEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) - } else { - Optional.empty() - } - val costs = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) - while(!tlvReader.isEndOfContainer()) { - add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val minPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxPowerAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) - } else { - Optional.empty() - } - val minDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - val maxDurationAdjustment = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) - } else { - Optional.empty() - } - + val slotIsPauseable = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_SLOT_IS_PAUSEABLE))) + } else { + Optional.empty() + } + val minPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_PAUSE_DURATION))) + } else { + Optional.empty() + } + val maxPauseDuration = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_PAUSE_DURATION))) + } else { + Optional.empty() + } + val manufacturerESAState = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MANUFACTURER_E_S_A_STATE))) + } else { + Optional.empty() + } + val nominalPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_POWER))) + } else { + Optional.empty() + } + val minPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER))) + } else { + Optional.empty() + } + val maxPower = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER))) + } else { + Optional.empty() + } + val nominalEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NOMINAL_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_NOMINAL_ENERGY))) + } else { + Optional.empty() + } + val costs = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COSTS))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_COSTS)) + while (!tlvReader.isEndOfContainer()) { + add(DeviceEnergyManagementClusterCostStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val minPowerAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MIN_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxPowerAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_MAX_POWER_ADJUSTMENT))) + } else { + Optional.empty() + } + val minDurationAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MIN_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + val maxDurationAdjustment = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_MAX_DURATION_ADJUSTMENT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return DeviceEnergyManagementClusterSlotStruct(minDuration, maxDuration, defaultDuration, elapsedSlotTime, remainingSlotTime, slotIsPauseable, minPauseDuration, maxPauseDuration, manufacturerESAState, nominalPower, minPower, maxPower, nominalEnergy, costs, minPowerAdjustment, maxPowerAdjustment, minDurationAdjustment, maxDurationAdjustment) + return DeviceEnergyManagementClusterSlotStruct( + minDuration, + maxDuration, + defaultDuration, + elapsedSlotTime, + remainingSlotTime, + slotIsPauseable, + minPauseDuration, + maxPauseDuration, + manufacturerESAState, + nominalPower, + minPower, + maxPower, + nominalEnergy, + costs, + minPowerAdjustment, + maxPowerAdjustment, + minDurationAdjustment, + maxDurationAdjustment + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt index d250f1c10ccccc..3d61c5bccf50cf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class DishwasherModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(DishwasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return DishwasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt index 033e60f5419f37..584dc79028182c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DishwasherModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DishwasherModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class DishwasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("DishwasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class DishwasherModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): DishwasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return DishwasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt index 5f2b5c37f2d96e..f66b57f47660ca 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/DoorLockClusterCredentialStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class DoorLockClusterCredentialStruct( - val credentialType: UByte, - val credentialIndex: UShort -) { +class DoorLockClusterCredentialStruct(val credentialType: UByte, val credentialIndex: UShort) { override fun toString(): String = buildString { append("DoorLockClusterCredentialStruct {\n") append("\tcredentialType : $credentialType\n") @@ -52,7 +47,7 @@ class DoorLockClusterCredentialStruct( tlvReader.enterStructure(tlvTag) val credentialType = tlvReader.getUByte(ContextSpecificTag(TAG_CREDENTIAL_TYPE)) val credentialIndex = tlvReader.getUShort(ContextSpecificTag(TAG_CREDENTIAL_INDEX)) - + tlvReader.exitContainer() return DoorLockClusterCredentialStruct(credentialType, credentialIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt index 397f1eab428ecf..46dff94ff6a1cb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterEnergyMeasurementStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,33 +71,46 @@ class ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( private const val TAG_START_SYSTIME = 3 private const val TAG_END_SYSTIME = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterEnergyMeasurementStruct { tlvReader.enterStructure(tlvTag) val energy = tlvReader.getLong(ContextSpecificTag(TAG_ENERGY)) - val startTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_START_TIMESTAMP))) - } else { - Optional.empty() - } - val endTimestamp = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_END_TIMESTAMP))) - } else { - Optional.empty() - } - val startSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) - } else { - Optional.empty() - } - val endSystime = if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) - } else { - Optional.empty() - } - + val startTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_START_TIMESTAMP))) + } else { + Optional.empty() + } + val endTimestamp = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_TIMESTAMP))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_END_TIMESTAMP))) + } else { + Optional.empty() + } + val startSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_START_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_START_SYSTIME))) + } else { + Optional.empty() + } + val endSystime = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_END_SYSTIME))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_END_SYSTIME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct(energy, startTimestamp, endTimestamp, startSystime, endSystime) + return ElectricalEnergyMeasurementClusterEnergyMeasurementStruct( + energy, + startTimestamp, + endTimestamp, + startSystime, + endSystime + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt index 4e0ca217ce09fe..65ed89eee4272d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -90,44 +89,62 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( private const val TAG_FIXED_MIN = 6 private const val TAG_FIXED_TYPICAL = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct { tlvReader.enterStructure(tlvTag) val rangeMin = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MIN)) val rangeMax = tlvReader.getLong(ContextSpecificTag(TAG_RANGE_MAX)) - val percentMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MAX))) - } else { - Optional.empty() - } - val percentMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MIN))) - } else { - Optional.empty() - } - val percentTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_TYPICAL))) - } else { - Optional.empty() - } - val fixedMax = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) - } else { - Optional.empty() - } - val fixedMin = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) - } else { - Optional.empty() - } - val fixedTypical = if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { - Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) - } else { - Optional.empty() - } - + val percentMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MAX))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MAX))) + } else { + Optional.empty() + } + val percentMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_MIN))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_MIN))) + } else { + Optional.empty() + } + val percentTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PERCENT_TYPICAL))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_PERCENT_TYPICAL))) + } else { + Optional.empty() + } + val fixedMax = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MAX))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MAX))) + } else { + Optional.empty() + } + val fixedMin = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_MIN))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_MIN))) + } else { + Optional.empty() + } + val fixedTypical = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_FIXED_TYPICAL))) { + Optional.of(tlvReader.getULong(ContextSpecificTag(TAG_FIXED_TYPICAL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct(rangeMin, rangeMax, percentMax, percentMin, percentTypical, fixedMax, fixedMin, fixedTypical) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct( + rangeMin, + rangeMax, + percentMax, + percentMin, + percentTypical, + fixedMax, + fixedMin, + fixedTypical + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt index b0ec26832b7c2d..b8f7a0f8ff429e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -64,23 +63,38 @@ class ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( private const val TAG_MAX_MEASURED_VALUE = 3 private const val TAG_ACCURACY_RANGES = 4 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct { tlvReader.enterStructure(tlvTag) val measurementType = tlvReader.getUShort(ContextSpecificTag(TAG_MEASUREMENT_TYPE)) val measured = tlvReader.getBoolean(ContextSpecificTag(TAG_MEASURED)) val minMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MIN_MEASURED_VALUE)) val maxMeasuredValue = tlvReader.getLong(ContextSpecificTag(TAG_MAX_MEASURED_VALUE)) - val accuracyRanges = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) - while(!tlvReader.isEndOfContainer()) { - add(ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val accuracyRanges = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ACCURACY_RANGES)) + while (!tlvReader.isEndOfContainer()) { + add( + ElectricalEnergyMeasurementClusterMeasurementAccuracyRangeStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct(measurementType, measured, minMeasuredValue, maxMeasuredValue, accuracyRanges) + return ElectricalEnergyMeasurementClusterMeasurementAccuracyStruct( + measurementType, + measured, + minMeasuredValue, + maxMeasuredValue, + accuracyRanges + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt index 3ed256441cd2ff..eaa06f527c652f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetScheduleStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -54,15 +53,17 @@ class EnergyEvseClusterChargingTargetScheduleStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetScheduleStruct { tlvReader.enterStructure(tlvTag) - val dayOfWeekForSequence = tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) - val chargingTargets = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) - while(!tlvReader.isEndOfContainer()) { - add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val dayOfWeekForSequence = + tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEK_FOR_SEQUENCE)) + val chargingTargets = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CHARGING_TARGETS)) + while (!tlvReader.isEndOfContainer()) { + add(EnergyEvseClusterChargingTargetStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return EnergyEvseClusterChargingTargetScheduleStruct(dayOfWeekForSequence, chargingTargets) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt index 72826868a15260..db61226e1adf55 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyEvseClusterChargingTargetStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,21 +59,28 @@ class EnergyEvseClusterChargingTargetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyEvseClusterChargingTargetStruct { tlvReader.enterStructure(tlvTag) - val targetTimeMinutesPastMidnight = tlvReader.getUShort(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) - val targetSoC = if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TARGET_SO_C))) - } else { - Optional.empty() - } - val addedEnergy = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { - Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) - } else { - Optional.empty() - } - + val targetTimeMinutesPastMidnight = + tlvReader.getUShort(ContextSpecificTag(TAG_TARGET_TIME_MINUTES_PAST_MIDNIGHT)) + val targetSoC = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_TARGET_SO_C))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_TARGET_SO_C))) + } else { + Optional.empty() + } + val addedEnergy = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ADDED_ENERGY))) { + Optional.of(tlvReader.getLong(ContextSpecificTag(TAG_ADDED_ENERGY))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return EnergyEvseClusterChargingTargetStruct(targetTimeMinutesPastMidnight, targetSoC, addedEnergy) + return EnergyEvseClusterChargingTargetStruct( + targetTimeMinutesPastMidnight, + targetSoC, + addedEnergy + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt index 80e4c2b06d9cad..29980664d4cbec 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/EnergyPreferenceClusterBalanceStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class EnergyPreferenceClusterBalanceStruct( - val step: UByte, - val label: Optional -) { +class EnergyPreferenceClusterBalanceStruct(val step: UByte, val label: Optional) { override fun toString(): String = buildString { append("EnergyPreferenceClusterBalanceStruct {\n") append("\tstep : $step\n") @@ -54,12 +50,13 @@ class EnergyPreferenceClusterBalanceStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): EnergyPreferenceClusterBalanceStruct { tlvReader.enterStructure(tlvTag) val step = tlvReader.getUByte(ContextSpecificTag(TAG_STEP)) - val label = if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) - } else { - Optional.empty() - } - + val label = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return EnergyPreferenceClusterBalanceStruct(step, label) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt index 2465dd492ace99..b5181c44417b6d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/FixedLabelClusterLabelStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class FixedLabelClusterLabelStruct( - val label: String, - val value: String -) { +class FixedLabelClusterLabelStruct(val label: String, val value: String) { override fun toString(): String = buildString { append("FixedLabelClusterLabelStruct {\n") append("\tlabel : $label\n") @@ -52,7 +47,7 @@ class FixedLabelClusterLabelStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return FixedLabelClusterLabelStruct(label, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt index b2d6b7e97638e6..aa7528a466dece 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralCommissioningClusterBasicCommissioningInfo.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,14 +46,22 @@ class GeneralCommissioningClusterBasicCommissioningInfo( private const val TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS = 0 private const val TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GeneralCommissioningClusterBasicCommissioningInfo { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): GeneralCommissioningClusterBasicCommissioningInfo { tlvReader.enterStructure(tlvTag) - val failSafeExpiryLengthSeconds = tlvReader.getUShort(ContextSpecificTag(TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS)) - val maxCumulativeFailsafeSeconds = tlvReader.getUShort(ContextSpecificTag(TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS)) - + val failSafeExpiryLengthSeconds = + tlvReader.getUShort(ContextSpecificTag(TAG_FAIL_SAFE_EXPIRY_LENGTH_SECONDS)) + val maxCumulativeFailsafeSeconds = + tlvReader.getUShort(ContextSpecificTag(TAG_MAX_CUMULATIVE_FAILSAFE_SECONDS)) + tlvReader.exitContainer() - return GeneralCommissioningClusterBasicCommissioningInfo(failSafeExpiryLengthSeconds, maxCumulativeFailsafeSeconds) + return GeneralCommissioningClusterBasicCommissioningInfo( + failSafeExpiryLengthSeconds, + maxCumulativeFailsafeSeconds + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt index 61f8691c5f053a..200b75dde048f4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GeneralDiagnosticsClusterNetworkInterface.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -53,12 +52,18 @@ class GeneralDiagnosticsClusterNetworkInterface( put(ContextSpecificTag(TAG_NAME), name) put(ContextSpecificTag(TAG_IS_OPERATIONAL), isOperational) if (offPremiseServicesReachableIPv4 != null) { - put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), offPremiseServicesReachableIPv4) + put( + ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4), + offPremiseServicesReachableIPv4 + ) } else { putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) } if (offPremiseServicesReachableIPv6 != null) { - put(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), offPremiseServicesReachableIPv6) + put( + ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6), + offPremiseServicesReachableIPv6 + ) } else { putNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) } @@ -92,38 +97,51 @@ class GeneralDiagnosticsClusterNetworkInterface( tlvReader.enterStructure(tlvTag) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val isOperational = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_OPERATIONAL)) - val offPremiseServicesReachableIPv4 = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) - null - } - val offPremiseServicesReachableIPv6 = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) - null - } + val offPremiseServicesReachableIPv4 = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV4)) + null + } + val offPremiseServicesReachableIPv6 = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_OFF_PREMISE_SERVICES_REACHABLE_I_PV6)) + null + } val hardwareAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_HARDWARE_ADDRESS)) - val IPv4Addresses = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val IPv6Addresses = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } + val IPv4Addresses = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV4_ADDRESSES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val IPv6Addresses = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_I_PV6_ADDRESSES)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } val type = tlvReader.getUByte(ContextSpecificTag(TAG_TYPE)) - + tlvReader.exitContainer() - return GeneralDiagnosticsClusterNetworkInterface(name, isOperational, offPremiseServicesReachableIPv4, offPremiseServicesReachableIPv6, hardwareAddress, IPv4Addresses, IPv6Addresses, type) + return GeneralDiagnosticsClusterNetworkInterface( + name, + isOperational, + offPremiseServicesReachableIPv4, + offPremiseServicesReachableIPv6, + hardwareAddress, + IPv4Addresses, + IPv6Addresses, + type + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt index ef8286072bfcfd..9d0155111d4207 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupInfoMapStruct.kt @@ -66,20 +66,22 @@ class GroupKeyManagementClusterGroupInfoMapStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupInfoMapStruct { tlvReader.enterStructure(tlvTag) val groupId = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_ID)) - val endpoints = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUShort(AnonymousTag)) - } - tlvReader.exitContainer() - } - val groupName = if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) - } else { - Optional.empty() - } + val endpoints = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ENDPOINTS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUShort(AnonymousTag)) + } + tlvReader.exitContainer() + } + val groupName = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_GROUP_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_GROUP_NAME))) + } else { + Optional.empty() + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupInfoMapStruct(groupId, endpoints, groupName, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt index b40a261be6a411..e5f8ecb177a11b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeyMapStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,7 +55,7 @@ class GroupKeyManagementClusterGroupKeyMapStruct( val groupId = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_ID)) val groupKeySetID = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return GroupKeyManagementClusterGroupKeyMapStruct(groupId, groupKeySetID, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt index 86cb6fb3510b09..d68d0536b9bd30 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/GroupKeyManagementClusterGroupKeySetStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -99,47 +97,63 @@ class GroupKeyManagementClusterGroupKeySetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): GroupKeyManagementClusterGroupKeySetStruct { tlvReader.enterStructure(tlvTag) val groupKeySetID = tlvReader.getUShort(ContextSpecificTag(TAG_GROUP_KEY_SET_I_D)) - val groupKeySecurityPolicy = tlvReader.getUByte(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) - val epochKey0 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) - null - } - val epochStartTime0 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) - null - } - val epochKey1 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) - null - } - val epochStartTime1 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) - null - } - val epochKey2 = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) - null - } - val epochStartTime2 = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) - null - } - + val groupKeySecurityPolicy = + tlvReader.getUByte(ContextSpecificTag(TAG_GROUP_KEY_SECURITY_POLICY)) + val epochKey0 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY0)) + null + } + val epochStartTime0 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME0)) + null + } + val epochKey1 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY1)) + null + } + val epochStartTime1 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME1)) + null + } + val epochKey2 = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_EPOCH_KEY2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_KEY2)) + null + } + val epochStartTime2 = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_EPOCH_START_TIME2)) + null + } + tlvReader.exitContainer() - return GroupKeyManagementClusterGroupKeySetStruct(groupKeySetID, groupKeySecurityPolicy, epochKey0, epochStartTime0, epochKey1, epochStartTime1, epochKey2, epochStartTime2) + return GroupKeyManagementClusterGroupKeySetStruct( + groupKeySetID, + groupKeySecurityPolicy, + epochKey0, + epochStartTime0, + epochKey1, + epochStartTime1, + epochKey2, + epochStartTime2 + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt index c838f5450b4c90..99d8d0dfd05c83 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/HepaFilterMonitoringClusterReplacementProductStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,14 +46,22 @@ class HepaFilterMonitoringClusterReplacementProductStruct( private const val TAG_PRODUCT_IDENTIFIER_TYPE = 0 private const val TAG_PRODUCT_IDENTIFIER_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): HepaFilterMonitoringClusterReplacementProductStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): HepaFilterMonitoringClusterReplacementProductStruct { tlvReader.enterStructure(tlvTag) - val productIdentifierType = tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) - val productIdentifierValue = tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) - + val productIdentifierType = + tlvReader.getUByte(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_TYPE)) + val productIdentifierValue = + tlvReader.getString(ContextSpecificTag(TAG_PRODUCT_IDENTIFIER_VALUE)) + tlvReader.exitContainer() - return HepaFilterMonitoringClusterReplacementProductStruct(productIdentifierType, productIdentifierValue) + return HepaFilterMonitoringClusterReplacementProductStruct( + productIdentifierType, + productIdentifierValue + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt index 8d8e02194628e3..d3f81f766efb96 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/IcdManagementClusterMonitoringRegistrationStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,15 +50,22 @@ class IcdManagementClusterMonitoringRegistrationStruct( private const val TAG_MONITORED_SUBJECT = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): IcdManagementClusterMonitoringRegistrationStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): IcdManagementClusterMonitoringRegistrationStruct { tlvReader.enterStructure(tlvTag) val checkInNodeID = tlvReader.getULong(ContextSpecificTag(TAG_CHECK_IN_NODE_I_D)) val monitoredSubject = tlvReader.getULong(ContextSpecificTag(TAG_MONITORED_SUBJECT)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return IcdManagementClusterMonitoringRegistrationStruct(checkInNodeID, monitoredSubject, fabricIndex) + return IcdManagementClusterMonitoringRegistrationStruct( + checkInNodeID, + monitoredSubject, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt index 869fc790e2c371..e8392fab770bf0 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class LaundryWasherModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(LaundryWasherModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return LaundryWasherModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt index 1b9aaf99f45c57..a12e2840ead4ab 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/LaundryWasherModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class LaundryWasherModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class LaundryWasherModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("LaundryWasherModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class LaundryWasherModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): LaundryWasherModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return LaundryWasherModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt index 13d46092d3725f..2aaef4b767542e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaInputClusterInputInfoStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -62,7 +60,7 @@ class MediaInputClusterInputInfoStruct( val inputType = tlvReader.getUByte(ContextSpecificTag(TAG_INPUT_TYPE)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) val description = tlvReader.getString(ContextSpecificTag(TAG_DESCRIPTION)) - + tlvReader.exitContainer() return MediaInputClusterInputInfoStruct(index, inputType, name, description) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt index 6df4407304fc0d..518da6b739efc8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterPlaybackPositionStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MediaPlaybackClusterPlaybackPositionStruct( - val updatedAt: ULong, - val position: ULong? -) { +class MediaPlaybackClusterPlaybackPositionStruct(val updatedAt: ULong, val position: ULong?) { override fun toString(): String = buildString { append("MediaPlaybackClusterPlaybackPositionStruct {\n") append("\tupdatedAt : $updatedAt\n") @@ -55,13 +50,14 @@ class MediaPlaybackClusterPlaybackPositionStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterPlaybackPositionStruct { tlvReader.enterStructure(tlvTag) val updatedAt = tlvReader.getULong(ContextSpecificTag(TAG_UPDATED_AT)) - val position = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) - null - } - + val position = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_POSITION)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_POSITION)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterPlaybackPositionStruct(updatedAt, position) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt index b82ec49c17f735..dfd99da8565408 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackAttributesStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -41,9 +40,9 @@ class MediaPlaybackClusterTrackAttributesStruct( put(ContextSpecificTag(TAG_LANGUAGE_CODE), languageCode) if (displayName != null) { if (displayName.isPresent) { - val optdisplayName = displayName.get() - put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) - } + val optdisplayName = displayName.get() + put(ContextSpecificTag(TAG_DISPLAY_NAME), optdisplayName) + } } else { putNull(ContextSpecificTag(TAG_DISPLAY_NAME)) } @@ -58,17 +57,18 @@ class MediaPlaybackClusterTrackAttributesStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackAttributesStruct { tlvReader.enterStructure(tlvTag) val languageCode = tlvReader.getString(ContextSpecificTag(TAG_LANGUAGE_CODE)) - val displayName = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) - null - } - + val displayName = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_DISPLAY_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_DISPLAY_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_DISPLAY_NAME)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackAttributesStruct(languageCode, displayName) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt index f4c43f16e2337f..0571df7456c16e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MediaPlaybackClusterTrackStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -55,13 +53,17 @@ class MediaPlaybackClusterTrackStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MediaPlaybackClusterTrackStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getString(ContextSpecificTag(TAG_ID)) - val trackAttributes = if (!tlvReader.isNull()) { - MediaPlaybackClusterTrackAttributesStruct.fromTlv(ContextSpecificTag(TAG_TRACK_ATTRIBUTES), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) - null - } - + val trackAttributes = + if (!tlvReader.isNull()) { + MediaPlaybackClusterTrackAttributesStruct.fromTlv( + ContextSpecificTag(TAG_TRACK_ATTRIBUTES), + tlvReader + ) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRACK_ATTRIBUTES)) + null + } + tlvReader.exitContainer() return MediaPlaybackClusterTrackStruct(id, trackAttributes) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt index 90d2e905cad2b1..8af30d0c768cf7 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class MicrowaveOvenModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(MicrowaveOvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt index 6ac44a062ca27a..ee00730c425f47 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/MicrowaveOvenModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class MicrowaveOvenModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class MicrowaveOvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("MicrowaveOvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class MicrowaveOvenModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): MicrowaveOvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return MicrowaveOvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt index ee501cf2d85532..558980bb83460a 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class ModeSelectClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val semanticTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val semanticTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_SEMANTIC_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(ModeSelectClusterSemanticTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ModeSelectClusterModeOptionStruct(label, mode, semanticTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt index 323f73c99e7820..fe6cdd3b787f01 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ModeSelectClusterSemanticTagStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ModeSelectClusterSemanticTagStruct( - val mfgCode: UShort, - val value: UShort -) { +class ModeSelectClusterSemanticTagStruct(val mfgCode: UShort, val value: UShort) { override fun toString(): String = buildString { append("ModeSelectClusterSemanticTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -52,7 +47,7 @@ class ModeSelectClusterSemanticTagStruct( tlvReader.enterStructure(tlvTag) val mfgCode = tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE)) val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return ModeSelectClusterSemanticTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt index 443d3e377f6837..ebb7d9c32e5609 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterNetworkInfoStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -46,17 +45,17 @@ class NetworkCommissioningClusterNetworkInfoStruct( put(ContextSpecificTag(TAG_CONNECTED), connected) if (networkIdentifier != null) { if (networkIdentifier.isPresent) { - val optnetworkIdentifier = networkIdentifier.get() - put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) - } + val optnetworkIdentifier = networkIdentifier.get() + put(ContextSpecificTag(TAG_NETWORK_IDENTIFIER), optnetworkIdentifier) + } } else { putNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) } if (clientIdentifier != null) { if (clientIdentifier.isPresent) { - val optclientIdentifier = clientIdentifier.get() - put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) - } + val optclientIdentifier = clientIdentifier.get() + put(ContextSpecificTag(TAG_CLIENT_IDENTIFIER), optclientIdentifier) + } } else { putNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) } @@ -74,30 +73,37 @@ class NetworkCommissioningClusterNetworkInfoStruct( tlvReader.enterStructure(tlvTag) val networkID = tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_I_D)) val connected = tlvReader.getBoolean(ContextSpecificTag(TAG_CONNECTED)) - val networkIdentifier = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) - null - } - val clientIdentifier = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) - null - } - + val networkIdentifier = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_NETWORK_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NETWORK_IDENTIFIER)) + null + } + val clientIdentifier = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_CLIENT_IDENTIFIER))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_CLIENT_IDENTIFIER)) + null + } + tlvReader.exitContainer() - return NetworkCommissioningClusterNetworkInfoStruct(networkID, connected, networkIdentifier, clientIdentifier) + return NetworkCommissioningClusterNetworkInfoStruct( + networkID, + connected, + networkIdentifier, + clientIdentifier + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt index c052531cdda164..93df116f49e63e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterThreadInterfaceScanResultStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,7 +70,10 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct( private const val TAG_RSSI = 6 private const val TAG_LQI = 7 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): NetworkCommissioningClusterThreadInterfaceScanResultStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): NetworkCommissioningClusterThreadInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val panId = tlvReader.getUShort(ContextSpecificTag(TAG_PAN_ID)) val extendedPanId = tlvReader.getULong(ContextSpecificTag(TAG_EXTENDED_PAN_ID)) @@ -82,10 +83,19 @@ class NetworkCommissioningClusterThreadInterfaceScanResultStruct( val extendedAddress = tlvReader.getByteArray(ContextSpecificTag(TAG_EXTENDED_ADDRESS)) val rssi = tlvReader.getByte(ContextSpecificTag(TAG_RSSI)) val lqi = tlvReader.getUByte(ContextSpecificTag(TAG_LQI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterThreadInterfaceScanResultStruct(panId, extendedPanId, networkName, channel, version, extendedAddress, rssi, lqi) + return NetworkCommissioningClusterThreadInterfaceScanResultStruct( + panId, + extendedPanId, + networkName, + channel, + version, + extendedAddress, + rssi, + lqi + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt index 85c6cf71f7c47b..ffbb05f45a6b51 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/NetworkCommissioningClusterWiFiInterfaceScanResultStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -64,7 +62,10 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( private const val TAG_WI_FI_BAND = 4 private const val TAG_RSSI = 5 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): NetworkCommissioningClusterWiFiInterfaceScanResultStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): NetworkCommissioningClusterWiFiInterfaceScanResultStruct { tlvReader.enterStructure(tlvTag) val security = tlvReader.getUByte(ContextSpecificTag(TAG_SECURITY)) val ssid = tlvReader.getByteArray(ContextSpecificTag(TAG_SSID)) @@ -72,10 +73,17 @@ class NetworkCommissioningClusterWiFiInterfaceScanResultStruct( val channel = tlvReader.getUShort(ContextSpecificTag(TAG_CHANNEL)) val wiFiBand = tlvReader.getUByte(ContextSpecificTag(TAG_WI_FI_BAND)) val rssi = tlvReader.getByte(ContextSpecificTag(TAG_RSSI)) - + tlvReader.exitContainer() - return NetworkCommissioningClusterWiFiInterfaceScanResultStruct(security, ssid, bssid, channel, wiFiBand, rssi) + return NetworkCommissioningClusterWiFiInterfaceScanResultStruct( + security, + ssid, + bssid, + channel, + wiFiBand, + rssi + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt index 7c980f2eaa2d01..89b9428c741564 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterFabricDescriptorStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -64,7 +62,10 @@ class OperationalCredentialsClusterFabricDescriptorStruct( private const val TAG_LABEL = 5 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalCredentialsClusterFabricDescriptorStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OperationalCredentialsClusterFabricDescriptorStruct { tlvReader.enterStructure(tlvTag) val rootPublicKey = tlvReader.getByteArray(ContextSpecificTag(TAG_ROOT_PUBLIC_KEY)) val vendorID = tlvReader.getUShort(ContextSpecificTag(TAG_VENDOR_I_D)) @@ -72,10 +73,17 @@ class OperationalCredentialsClusterFabricDescriptorStruct( val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OperationalCredentialsClusterFabricDescriptorStruct(rootPublicKey, vendorID, fabricID, nodeID, label, fabricIndex) + return OperationalCredentialsClusterFabricDescriptorStruct( + rootPublicKey, + vendorID, + fabricID, + nodeID, + label, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt index 1a27ee6624fe40..3a104b0d78b127 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalCredentialsClusterNOCStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -59,14 +57,15 @@ class OperationalCredentialsClusterNOCStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalCredentialsClusterNOCStruct { tlvReader.enterStructure(tlvTag) val noc = tlvReader.getByteArray(ContextSpecificTag(TAG_NOC)) - val icac = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) - null - } + val icac = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_ICAC)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_ICAC)) + null + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() return OperationalCredentialsClusterNOCStruct(noc, icac, fabricIndex) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt index 24ddb76ae228ca..f1d7a22e7e757b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterErrorStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -61,20 +60,26 @@ class OperationalStateClusterErrorStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return OperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt index 95645f734ce9ef..d08dc7aa0df6e9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OperationalStateClusterOperationalStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -54,15 +53,19 @@ class OperationalStateClusterOperationalStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return OperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt index a8363ebd687c3d..f9dd92cc8640f3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OtaSoftwareUpdateRequestorClusterProviderLocation.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,15 +50,22 @@ class OtaSoftwareUpdateRequestorClusterProviderLocation( private const val TAG_ENDPOINT = 2 private const val TAG_FABRIC_INDEX = 254 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OtaSoftwareUpdateRequestorClusterProviderLocation { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OtaSoftwareUpdateRequestorClusterProviderLocation { tlvReader.enterStructure(tlvTag) val providerNodeID = tlvReader.getULong(ContextSpecificTag(TAG_PROVIDER_NODE_I_D)) val endpoint = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return OtaSoftwareUpdateRequestorClusterProviderLocation(providerNodeID, endpoint, fabricIndex) + return OtaSoftwareUpdateRequestorClusterProviderLocation( + providerNodeID, + endpoint, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt index 825b5246771055..3ca1059ea25628 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterErrorStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -58,23 +57,32 @@ class OvenCavityOperationalStateClusterErrorStateStruct( private const val TAG_ERROR_STATE_LABEL = 1 private const val TAG_ERROR_STATE_DETAILS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenCavityOperationalStateClusterErrorStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return OvenCavityOperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt index 2c051ce55bad80..f66b7a09928db4 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenCavityOperationalStateClusterOperationalStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,18 +50,25 @@ class OvenCavityOperationalStateClusterOperationalStateStruct( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenCavityOperationalStateClusterOperationalStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): OvenCavityOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return OvenCavityOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return OvenCavityOperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt index 47fda3f789599e..ba8bad6b42ff54 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class OvenModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(OvenModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return OvenModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt index 3715c9253bd394..4ba9d368de022f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/OvenModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class OvenModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class OvenModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("OvenModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class OvenModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): OvenModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return OvenModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt index 93b2e01e8dcd67..8b9487ac66f3e3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatChargeFaultChangeType.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -58,21 +57,23 @@ class PowerSourceClusterBatChargeFaultChangeType( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatChargeFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatChargeFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt index f5c4803e0482ac..6b849cc5874313 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterBatFaultChangeType.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -24,10 +23,7 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterBatFaultChangeType( - val current: List, - val previous: List -) { +class PowerSourceClusterBatFaultChangeType(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterBatFaultChangeType {\n") append("\tcurrent : $current\n") @@ -58,21 +54,23 @@ class PowerSourceClusterBatFaultChangeType( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterBatFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterBatFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt index 0eb132ceb49b1e..9354883b16e760 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/PowerSourceClusterWiredFaultChangeType.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -24,10 +23,7 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class PowerSourceClusterWiredFaultChangeType( - val current: List, - val previous: List -) { +class PowerSourceClusterWiredFaultChangeType(val current: List, val previous: List) { override fun toString(): String = buildString { append("PowerSourceClusterWiredFaultChangeType {\n") append("\tcurrent : $current\n") @@ -58,21 +54,23 @@ class PowerSourceClusterWiredFaultChangeType( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): PowerSourceClusterWiredFaultChangeType { tlvReader.enterStructure(tlvTag) - val current = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - val previous = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val current = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_CURRENT)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + val previous = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_PREVIOUS)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return PowerSourceClusterWiredFaultChangeType(current, previous) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt index 59482e83c5039d..cd01932bc3f167 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -56,21 +55,34 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( private const val TAG_MODE = 1 private const val TAG_MODE_TAGS = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct { tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add( + RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.fromTlv( + AnonymousTag, + tlvReader + ) + ) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() - return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct(label, mode, modeTags) + return RefrigeratorAndTemperatureControlledCabinetModeClusterModeOptionStruct( + label, + mode, + modeTags + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt index 2ec589a6c0df35..9faf469741368c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,15 +50,19 @@ class RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct( private const val TAG_MFG_CODE = 0 private const val TAG_VALUE = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RefrigeratorAndTemperatureControlledCabinetModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt index a79f2a02599eba..a8e74c89f3ad1d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class RvcCleanModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(RvcCleanModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcCleanModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt index 88ea7b7b2f7002..ce35ad9a5a9960 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcCleanModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcCleanModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class RvcCleanModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("RvcCleanModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class RvcCleanModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcCleanModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcCleanModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt index 20e4ab7ba0a318..6fa68a81b810ad 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterErrorStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -61,20 +60,26 @@ class RvcOperationalStateClusterErrorStateStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcOperationalStateClusterErrorStateStruct { tlvReader.enterStructure(tlvTag) val errorStateID = tlvReader.getUByte(ContextSpecificTag(TAG_ERROR_STATE_I_D)) - val errorStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) - } else { - Optional.empty() - } - val errorStateDetails = if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) - } else { - Optional.empty() - } - + val errorStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_LABEL))) + } else { + Optional.empty() + } + val errorStateDetails = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_ERROR_STATE_DETAILS))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterErrorStateStruct(errorStateID, errorStateLabel, errorStateDetails) + return RvcOperationalStateClusterErrorStateStruct( + errorStateID, + errorStateLabel, + errorStateDetails + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt index 1d7445a75f0ac5..f21d5ecb4da1cf 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcOperationalStateClusterOperationalStateStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -51,18 +50,25 @@ class RvcOperationalStateClusterOperationalStateStruct( private const val TAG_OPERATIONAL_STATE_I_D = 0 private const val TAG_OPERATIONAL_STATE_LABEL = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcOperationalStateClusterOperationalStateStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): RvcOperationalStateClusterOperationalStateStruct { tlvReader.enterStructure(tlvTag) val operationalStateID = tlvReader.getUByte(ContextSpecificTag(TAG_OPERATIONAL_STATE_I_D)) - val operationalStateLabel = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) - } else { - Optional.empty() - } - + val operationalStateLabel = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPERATIONAL_STATE_LABEL))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return RvcOperationalStateClusterOperationalStateStruct(operationalStateID, operationalStateLabel) + return RvcOperationalStateClusterOperationalStateStruct( + operationalStateID, + operationalStateLabel + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt index c98a49235c774f..f4193b91fac485 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeOptionStruct.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -60,14 +59,15 @@ class RvcRunModeClusterModeOptionStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val mode = tlvReader.getUByte(ContextSpecificTag(TAG_MODE)) - val modeTags = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) - while(!tlvReader.isEndOfContainer()) { - add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val modeTags = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_MODE_TAGS)) + while (!tlvReader.isEndOfContainer()) { + add(RvcRunModeClusterModeTagStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return RvcRunModeClusterModeOptionStruct(label, mode, modeTags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt index d9c65679552d63..7ad69693847d17 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/RvcRunModeClusterModeTagStruct.kt @@ -18,16 +18,12 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class RvcRunModeClusterModeTagStruct( - val mfgCode: Optional, - val value: UShort -) { +class RvcRunModeClusterModeTagStruct(val mfgCode: Optional, val value: UShort) { override fun toString(): String = buildString { append("RvcRunModeClusterModeTagStruct {\n") append("\tmfgCode : $mfgCode\n") @@ -53,13 +49,14 @@ class RvcRunModeClusterModeTagStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): RvcRunModeClusterModeTagStruct { tlvReader.enterStructure(tlvTag) - val mfgCode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) - } else { - Optional.empty() - } + val mfgCode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_MFG_CODE))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_MFG_CODE))) + } else { + Optional.empty() + } val value = tlvReader.getUShort(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return RvcRunModeClusterModeTagStruct(mfgCode, value) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt index 90b6fb8bfb24d9..1a14970ba2bd58 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterAttributeValuePair.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ScenesManagementClusterAttributeValuePair( - val attributeID: UInt, - val attributeValue: UInt -) { +class ScenesManagementClusterAttributeValuePair(val attributeID: UInt, val attributeValue: UInt) { override fun toString(): String = buildString { append("ScenesManagementClusterAttributeValuePair {\n") append("\tattributeID : $attributeID\n") @@ -52,7 +47,7 @@ class ScenesManagementClusterAttributeValuePair( tlvReader.enterStructure(tlvTag) val attributeID = tlvReader.getUInt(ContextSpecificTag(TAG_ATTRIBUTE_I_D)) val attributeValue = tlvReader.getUInt(ContextSpecificTag(TAG_ATTRIBUTE_VALUE)) - + tlvReader.exitContainer() return ScenesManagementClusterAttributeValuePair(attributeID, attributeValue) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt index 9a7e49546361d1..516c53bfb62604 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterExtensionFieldSet.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -55,14 +54,15 @@ class ScenesManagementClusterExtensionFieldSet( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ScenesManagementClusterExtensionFieldSet { tlvReader.enterStructure(tlvTag) val clusterID = tlvReader.getUInt(ContextSpecificTag(TAG_CLUSTER_I_D)) - val attributeValueList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val attributeValueList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_ATTRIBUTE_VALUE_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(ScenesManagementClusterAttributeValuePair.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return ScenesManagementClusterExtensionFieldSet(clusterID, attributeValueList) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt index ea23bcb97924f6..5a753f4acf803d 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ScenesManagementClusterSceneInfoStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -72,10 +70,17 @@ class ScenesManagementClusterSceneInfoStruct( val sceneValid = tlvReader.getBoolean(ContextSpecificTag(TAG_SCENE_VALID)) val remainingCapacity = tlvReader.getUByte(ContextSpecificTag(TAG_REMAINING_CAPACITY)) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return ScenesManagementClusterSceneInfoStruct(sceneCount, currentScene, currentGroup, sceneValid, remainingCapacity, fabricIndex) + return ScenesManagementClusterSceneInfoStruct( + sceneCount, + currentScene, + currentGroup, + sceneValid, + remainingCapacity, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt index 75b362e21df943..b8f67a51a60beb 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/SoftwareDiagnosticsClusterThreadMetricsStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -75,30 +74,40 @@ class SoftwareDiagnosticsClusterThreadMetricsStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): SoftwareDiagnosticsClusterThreadMetricsStruct { tlvReader.enterStructure(tlvTag) val id = tlvReader.getULong(ContextSpecificTag(TAG_ID)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val stackFreeCurrent = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) - } else { - Optional.empty() - } - val stackFreeMinimum = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) - } else { - Optional.empty() - } - val stackSize = if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { - Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_SIZE))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val stackFreeCurrent = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_CURRENT))) + } else { + Optional.empty() + } + val stackFreeMinimum = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_FREE_MINIMUM))) + } else { + Optional.empty() + } + val stackSize = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_STACK_SIZE))) { + Optional.of(tlvReader.getUInt(ContextSpecificTag(TAG_STACK_SIZE))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return SoftwareDiagnosticsClusterThreadMetricsStruct(id, name, stackFreeCurrent, stackFreeMinimum, stackSize) + return SoftwareDiagnosticsClusterThreadMetricsStruct( + id, + name, + stackFreeCurrent, + stackFreeMinimum, + stackSize + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt index 804fa744fe4660..d1c115ff44e58e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TargetNavigatorClusterTargetInfoStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class TargetNavigatorClusterTargetInfoStruct( - val identifier: UByte, - val name: String -) { +class TargetNavigatorClusterTargetInfoStruct(val identifier: UByte, val name: String) { override fun toString(): String = buildString { append("TargetNavigatorClusterTargetInfoStruct {\n") append("\tidentifier : $identifier\n") @@ -52,7 +47,7 @@ class TargetNavigatorClusterTargetInfoStruct( tlvReader.enterStructure(tlvTag) val identifier = tlvReader.getUByte(ContextSpecificTag(TAG_IDENTIFIER)) val name = tlvReader.getString(ContextSpecificTag(TAG_NAME)) - + tlvReader.exitContainer() return TargetNavigatorClusterTargetInfoStruct(identifier, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt index be590ab0cbc7f8..498a7a1ee039f9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -54,9 +53,9 @@ class ThermostatClusterPresetStruct( put(ContextSpecificTag(TAG_PRESET_SCENARIO), presetScenario) if (name != null) { if (name.isPresent) { - val optname = name.get() - put(ContextSpecificTag(TAG_NAME), optname) - } + val optname = name.get() + put(ContextSpecificTag(TAG_NAME), optname) + } } else { putNull(ContextSpecificTag(TAG_NAME)) } @@ -87,43 +86,55 @@ class ThermostatClusterPresetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } + val presetHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } val presetScenario = tlvReader.getUByte(ContextSpecificTag(TAG_PRESET_SCENARIO)) - val name = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NAME)) - null - } - val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - val builtIn = if (!tlvReader.isNull()) { - tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NAME)) + null + } + val coolingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + val builtIn = + if (!tlvReader.isNull()) { + tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterPresetStruct(presetHandle, presetScenario, name, coolingSetpoint, heatingSetpoint, builtIn) + return ThermostatClusterPresetStruct( + presetHandle, + presetScenario, + name, + coolingSetpoint, + heatingSetpoint, + builtIn + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt index e9d029d6a542f3..d33ca6f93fdd6b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterPresetTypeStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,7 +55,7 @@ class ThermostatClusterPresetTypeStruct( val presetScenario = tlvReader.getUByte(ContextSpecificTag(TAG_PRESET_SCENARIO)) val numberOfPresets = tlvReader.getUByte(ContextSpecificTag(TAG_NUMBER_OF_PRESETS)) val presetTypeFeatures = tlvReader.getUShort(ContextSpecificTag(TAG_PRESET_TYPE_FEATURES)) - + tlvReader.exitContainer() return ThermostatClusterPresetTypeStruct(presetScenario, numberOfPresets, presetTypeFeatures) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt index 1ebb7e6e3c7e03..80a2e263806dda 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterQueuedPresetStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -58,19 +56,21 @@ class ThermostatClusterQueuedPresetStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterQueuedPresetStruct { tlvReader.enterStructure(tlvTag) - val presetHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) - null - } - val transitionTimestamp = if (!tlvReader.isNull()) { - tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) - null - } - + val presetHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_PRESET_HANDLE)) + null + } + val transitionTimestamp = + if (!tlvReader.isNull()) { + tlvReader.getUInt(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_TRANSITION_TIMESTAMP)) + null + } + tlvReader.exitContainer() return ThermostatClusterQueuedPresetStruct(presetHandle, transitionTimestamp) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt index 29c6a46bc3850e..25b8ff012cf7bc 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleStruct.kt @@ -67,9 +67,9 @@ class ThermostatClusterScheduleStruct( endArray() if (builtIn != null) { if (builtIn.isPresent) { - val optbuiltIn = builtIn.get() - put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) - } + val optbuiltIn = builtIn.get() + put(ContextSpecificTag(TAG_BUILT_IN), optbuiltIn) + } } else { putNull(ContextSpecificTag(TAG_BUILT_IN)) } @@ -87,44 +87,56 @@ class ThermostatClusterScheduleStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterScheduleStruct { tlvReader.enterStructure(tlvTag) - val scheduleHandle = if (!tlvReader.isNull()) { - tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) - null - } + val scheduleHandle = + if (!tlvReader.isNull()) { + tlvReader.getByteArray(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_SCHEDULE_HANDLE)) + null + } val systemMode = tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val transitions = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) - while(!tlvReader.isEndOfContainer()) { - add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val builtIn = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { - Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) - null - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + val presetHandle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val transitions = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_TRANSITIONS)) + while (!tlvReader.isEndOfContainer()) { + add(ThermostatClusterScheduleTransitionStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val builtIn = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_BUILT_IN))) { + Optional.of(tlvReader.getBoolean(ContextSpecificTag(TAG_BUILT_IN))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_BUILT_IN)) + null + } + tlvReader.exitContainer() - return ThermostatClusterScheduleStruct(scheduleHandle, systemMode, name, presetHandle, transitions, builtIn) + return ThermostatClusterScheduleStruct( + scheduleHandle, + systemMode, + name, + presetHandle, + transitions, + builtIn + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt index 1bd8bfe8cbf3be..bd9e4b6e3ca842 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTransitionStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -80,30 +79,41 @@ class ThermostatClusterScheduleTransitionStruct( tlvReader.enterStructure(tlvTag) val dayOfWeek = tlvReader.getUByte(ContextSpecificTag(TAG_DAY_OF_WEEK)) val transitionTime = tlvReader.getUShort(ContextSpecificTag(TAG_TRANSITION_TIME)) - val presetHandle = if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { - Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) - } else { - Optional.empty() - } - val systemMode = if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE))) - } else { - Optional.empty() - } - val coolingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) - } else { - Optional.empty() - } - val heatingSetpoint = if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { - Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) - } else { - Optional.empty() - } - + val presetHandle = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_PRESET_HANDLE))) { + Optional.of(tlvReader.getByteArray(ContextSpecificTag(TAG_PRESET_HANDLE))) + } else { + Optional.empty() + } + val systemMode = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_SYSTEM_MODE))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE))) + } else { + Optional.empty() + } + val coolingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_COOLING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_COOLING_SETPOINT))) + } else { + Optional.empty() + } + val heatingSetpoint = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_HEATING_SETPOINT))) { + Optional.of(tlvReader.getShort(ContextSpecificTag(TAG_HEATING_SETPOINT))) + } else { + Optional.empty() + } + tlvReader.exitContainer() - return ThermostatClusterScheduleTransitionStruct(dayOfWeek, transitionTime, presetHandle, systemMode, coolingSetpoint, heatingSetpoint) + return ThermostatClusterScheduleTransitionStruct( + dayOfWeek, + transitionTime, + presetHandle, + systemMode, + coolingSetpoint, + heatingSetpoint + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt index 781f9fdd1aee97..91135f990547ff 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterScheduleTypeStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,10 +55,14 @@ class ThermostatClusterScheduleTypeStruct( val systemMode = tlvReader.getUByte(ContextSpecificTag(TAG_SYSTEM_MODE)) val numberOfSchedules = tlvReader.getUByte(ContextSpecificTag(TAG_NUMBER_OF_SCHEDULES)) val scheduleTypeFeatures = tlvReader.getUShort(ContextSpecificTag(TAG_SCHEDULE_TYPE_FEATURES)) - + tlvReader.exitContainer() - return ThermostatClusterScheduleTypeStruct(systemMode, numberOfSchedules, scheduleTypeFeatures) + return ThermostatClusterScheduleTypeStruct( + systemMode, + numberOfSchedules, + scheduleTypeFeatures + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt index 98721edcba9faa..597fce1f35e644 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThermostatClusterWeeklyScheduleTransitionStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,25 +58,34 @@ class ThermostatClusterWeeklyScheduleTransitionStruct( private const val TAG_HEAT_SETPOINT = 1 private const val TAG_COOL_SETPOINT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThermostatClusterWeeklyScheduleTransitionStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThermostatClusterWeeklyScheduleTransitionStruct { tlvReader.enterStructure(tlvTag) val transitionTime = tlvReader.getUShort(ContextSpecificTag(TAG_TRANSITION_TIME)) - val heatSetpoint = if (!tlvReader.isNull()) { - tlvReader.getShort(ContextSpecificTag(TAG_HEAT_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) - null - } - val coolSetpoint = if (!tlvReader.isNull()) { - tlvReader.getShort(ContextSpecificTag(TAG_COOL_SETPOINT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) - null - } - + val heatSetpoint = + if (!tlvReader.isNull()) { + tlvReader.getShort(ContextSpecificTag(TAG_HEAT_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_HEAT_SETPOINT)) + null + } + val coolSetpoint = + if (!tlvReader.isNull()) { + tlvReader.getShort(ContextSpecificTag(TAG_COOL_SETPOINT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_COOL_SETPOINT)) + null + } + tlvReader.exitContainer() - return ThermostatClusterWeeklyScheduleTransitionStruct(transitionTime, heatSetpoint, coolSetpoint) + return ThermostatClusterWeeklyScheduleTransitionStruct( + transitionTime, + heatSetpoint, + coolSetpoint + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt index 21ee03ed5e51b3..c3fc752f705a55 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterNeighborTableStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -104,7 +102,10 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct( private const val TAG_FULL_NETWORK_DATA = 12 private const val TAG_IS_CHILD = 13 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterNeighborTableStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterNeighborTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val age = tlvReader.getUInt(ContextSpecificTag(TAG_AGE)) @@ -112,28 +113,45 @@ class ThreadNetworkDiagnosticsClusterNeighborTableStruct( val linkFrameCounter = tlvReader.getUInt(ContextSpecificTag(TAG_LINK_FRAME_COUNTER)) val mleFrameCounter = tlvReader.getUInt(ContextSpecificTag(TAG_MLE_FRAME_COUNTER)) val lqi = tlvReader.getUByte(ContextSpecificTag(TAG_LQI)) - val averageRssi = if (!tlvReader.isNull()) { - tlvReader.getByte(ContextSpecificTag(TAG_AVERAGE_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) - null - } - val lastRssi = if (!tlvReader.isNull()) { - tlvReader.getByte(ContextSpecificTag(TAG_LAST_RSSI)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) - null - } + val averageRssi = + if (!tlvReader.isNull()) { + tlvReader.getByte(ContextSpecificTag(TAG_AVERAGE_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_AVERAGE_RSSI)) + null + } + val lastRssi = + if (!tlvReader.isNull()) { + tlvReader.getByte(ContextSpecificTag(TAG_LAST_RSSI)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_LAST_RSSI)) + null + } val frameErrorRate = tlvReader.getUByte(ContextSpecificTag(TAG_FRAME_ERROR_RATE)) val messageErrorRate = tlvReader.getUByte(ContextSpecificTag(TAG_MESSAGE_ERROR_RATE)) val rxOnWhenIdle = tlvReader.getBoolean(ContextSpecificTag(TAG_RX_ON_WHEN_IDLE)) val fullThreadDevice = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_THREAD_DEVICE)) val fullNetworkData = tlvReader.getBoolean(ContextSpecificTag(TAG_FULL_NETWORK_DATA)) val isChild = tlvReader.getBoolean(ContextSpecificTag(TAG_IS_CHILD)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterNeighborTableStruct(extAddress, age, rloc16, linkFrameCounter, mleFrameCounter, lqi, averageRssi, lastRssi, frameErrorRate, messageErrorRate, rxOnWhenIdle, fullThreadDevice, fullNetworkData, isChild) + return ThreadNetworkDiagnosticsClusterNeighborTableStruct( + extAddress, + age, + rloc16, + linkFrameCounter, + mleFrameCounter, + lqi, + averageRssi, + lastRssi, + frameErrorRate, + messageErrorRate, + rxOnWhenIdle, + fullThreadDevice, + fullNetworkData, + isChild + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt index 91975101984aaa..8babb9d7bc1680 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterOperationalDatasetComponents.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -88,24 +86,45 @@ class ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( private const val TAG_SECURITY_POLICY_PRESENT = 10 private const val TAG_CHANNEL_MASK_PRESENT = 11 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterOperationalDatasetComponents { tlvReader.enterStructure(tlvTag) - val activeTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) - val pendingTimestampPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) + val activeTimestampPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_ACTIVE_TIMESTAMP_PRESENT)) + val pendingTimestampPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_PENDING_TIMESTAMP_PRESENT)) val masterKeyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MASTER_KEY_PRESENT)) val networkNamePresent = tlvReader.getBoolean(ContextSpecificTag(TAG_NETWORK_NAME_PRESENT)) - val extendedPanIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) - val meshLocalPrefixPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) + val extendedPanIdPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_EXTENDED_PAN_ID_PRESENT)) + val meshLocalPrefixPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_MESH_LOCAL_PREFIX_PRESENT)) val delayPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_DELAY_PRESENT)) val panIdPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PAN_ID_PRESENT)) val channelPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_PRESENT)) val pskcPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_PSKC_PRESENT)) - val securityPolicyPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) + val securityPolicyPresent = + tlvReader.getBoolean(ContextSpecificTag(TAG_SECURITY_POLICY_PRESENT)) val channelMaskPresent = tlvReader.getBoolean(ContextSpecificTag(TAG_CHANNEL_MASK_PRESENT)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents(activeTimestampPresent, pendingTimestampPresent, masterKeyPresent, networkNamePresent, extendedPanIdPresent, meshLocalPrefixPresent, delayPresent, panIdPresent, channelPresent, pskcPresent, securityPolicyPresent, channelMaskPresent) + return ThreadNetworkDiagnosticsClusterOperationalDatasetComponents( + activeTimestampPresent, + pendingTimestampPresent, + masterKeyPresent, + networkNamePresent, + extendedPanIdPresent, + meshLocalPrefixPresent, + delayPresent, + panIdPresent, + channelPresent, + pskcPresent, + securityPolicyPresent, + channelMaskPresent + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt index b2b470b5765c0d..21bfbb8c4e950c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterRouteTableStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -80,7 +78,10 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct( private const val TAG_ALLOCATED = 8 private const val TAG_LINK_ESTABLISHED = 9 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): ThreadNetworkDiagnosticsClusterRouteTableStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): ThreadNetworkDiagnosticsClusterRouteTableStruct { tlvReader.enterStructure(tlvTag) val extAddress = tlvReader.getULong(ContextSpecificTag(TAG_EXT_ADDRESS)) val rloc16 = tlvReader.getUShort(ContextSpecificTag(TAG_RLOC16)) @@ -92,10 +93,21 @@ class ThreadNetworkDiagnosticsClusterRouteTableStruct( val age = tlvReader.getUByte(ContextSpecificTag(TAG_AGE)) val allocated = tlvReader.getBoolean(ContextSpecificTag(TAG_ALLOCATED)) val linkEstablished = tlvReader.getBoolean(ContextSpecificTag(TAG_LINK_ESTABLISHED)) - + tlvReader.exitContainer() - return ThreadNetworkDiagnosticsClusterRouteTableStruct(extAddress, rloc16, routerId, nextHop, pathCost, LQIIn, LQIOut, age, allocated, linkEstablished) + return ThreadNetworkDiagnosticsClusterRouteTableStruct( + extAddress, + rloc16, + routerId, + nextHop, + pathCost, + LQIIn, + LQIOut, + age, + allocated, + linkEstablished + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt index 3228a78b13b000..720cdd6c854a72 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/ThreadNetworkDiagnosticsClusterSecurityPolicy.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class ThreadNetworkDiagnosticsClusterSecurityPolicy( - val rotationTime: UShort, - val flags: UShort -) { +class ThreadNetworkDiagnosticsClusterSecurityPolicy(val rotationTime: UShort, val flags: UShort) { override fun toString(): String = buildString { append("ThreadNetworkDiagnosticsClusterSecurityPolicy {\n") append("\trotationTime : $rotationTime\n") @@ -52,7 +47,7 @@ class ThreadNetworkDiagnosticsClusterSecurityPolicy( tlvReader.enterStructure(tlvTag) val rotationTime = tlvReader.getUShort(ContextSpecificTag(TAG_ROTATION_TIME)) val flags = tlvReader.getUShort(ContextSpecificTag(TAG_FLAGS)) - + tlvReader.exitContainer() return ThreadNetworkDiagnosticsClusterSecurityPolicy(rotationTime, flags) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt index 366d9e19dc429b..b74d29b91fbebe 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterDSTOffsetStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -60,13 +58,14 @@ class TimeSynchronizationClusterDSTOffsetStruct( tlvReader.enterStructure(tlvTag) val offset = tlvReader.getInt(ContextSpecificTag(TAG_OFFSET)) val validStarting = tlvReader.getULong(ContextSpecificTag(TAG_VALID_STARTING)) - val validUntil = if (!tlvReader.isNull()) { - tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) - null - } - + val validUntil = + if (!tlvReader.isNull()) { + tlvReader.getULong(ContextSpecificTag(TAG_VALID_UNTIL)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_VALID_UNTIL)) + null + } + tlvReader.exitContainer() return TimeSynchronizationClusterDSTOffsetStruct(offset, validStarting, validUntil) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt index 7c6440f0f2a618..6681fb2948b29b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -48,11 +46,14 @@ class TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct( private const val TAG_NODE_I_D = 0 private const val TAG_ENDPOINT = 1 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct(nodeID, endpoint) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt index d8b7a7a33d130e..ac2e8efd626715 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTimeZoneStruct.kt @@ -18,7 +18,6 @@ package matter.controller.cluster.structs import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -59,12 +58,13 @@ class TimeSynchronizationClusterTimeZoneStruct( tlvReader.enterStructure(tlvTag) val offset = tlvReader.getInt(ContextSpecificTag(TAG_OFFSET)) val validAt = tlvReader.getULong(ContextSpecificTag(TAG_VALID_AT)) - val name = if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) - } else { - Optional.empty() - } - + val name = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NAME))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NAME))) + } else { + Optional.empty() + } + tlvReader.exitContainer() return TimeSynchronizationClusterTimeZoneStruct(offset, validAt, name) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt index 1e91548ed51086..4e966f6c36021e 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/TimeSynchronizationClusterTrustedTimeSourceStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -52,12 +50,15 @@ class TimeSynchronizationClusterTrustedTimeSourceStruct( private const val TAG_NODE_I_D = 1 private const val TAG_ENDPOINT = 2 - fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): TimeSynchronizationClusterTrustedTimeSourceStruct { + fun fromTlv( + tlvTag: Tag, + tlvReader: TlvReader + ): TimeSynchronizationClusterTrustedTimeSourceStruct { tlvReader.enterStructure(tlvTag) val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) val nodeID = tlvReader.getULong(ContextSpecificTag(TAG_NODE_I_D)) val endpoint = tlvReader.getUShort(ContextSpecificTag(TAG_ENDPOINT)) - + tlvReader.exitContainer() return TimeSynchronizationClusterTrustedTimeSourceStruct(fabricIndex, nodeID, endpoint) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt index a78f035f9d5e70..b308907db2a90c 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterDoubleNestedStructList.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -24,9 +23,7 @@ import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterDoubleNestedStructList( - val a: List -) { +class UnitTestingClusterDoubleNestedStructList(val a: List) { override fun toString(): String = buildString { append("UnitTestingClusterDoubleNestedStructList {\n") append("\ta : $a\n") @@ -50,14 +47,15 @@ class UnitTestingClusterDoubleNestedStructList( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterDoubleNestedStructList { tlvReader.enterStructure(tlvTag) - val a = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_A)) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - + val a = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_A)) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterNestedStructList.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterDoubleNestedStructList(a) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt index 21b9bab077f473..d1bb92e17a739b 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -57,7 +55,7 @@ class UnitTestingClusterNestedStruct( val a = tlvReader.getUByte(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - + tlvReader.exitContainer() return UnitTestingClusterNestedStruct(a, b, c) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt index 653e0e8f3a39d8..3e58a31e5c24f3 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNestedStructList.kt @@ -16,7 +16,6 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag @@ -89,35 +88,39 @@ class UnitTestingClusterNestedStructList( val a = tlvReader.getUByte(ContextSpecificTag(TAG_A)) val b = tlvReader.getBoolean(ContextSpecificTag(TAG_B)) val c = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_C), tlvReader) - val d = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_D)) - while(!tlvReader.isEndOfContainer()) { - add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) - } - tlvReader.exitContainer() - } - val e = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_E)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUInt(AnonymousTag)) - } - tlvReader.exitContainer() - } - val f = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_F)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getByteArray(AnonymousTag)) - } - tlvReader.exitContainer() - } - val g = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_G)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - + val d = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_D)) + while (!tlvReader.isEndOfContainer()) { + add(UnitTestingClusterSimpleStruct.fromTlv(AnonymousTag, tlvReader)) + } + tlvReader.exitContainer() + } + val e = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_E)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUInt(AnonymousTag)) + } + tlvReader.exitContainer() + } + val f = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_F)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getByteArray(AnonymousTag)) + } + tlvReader.exitContainer() + } + val g = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_G)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + tlvReader.exitContainer() return UnitTestingClusterNestedStructList(a, b, c, d, e, f, g) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt index 279d19e7f4ed48..719fc4459ca37f 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterNullablesAndOptionalsStruct.kt @@ -69,9 +69,9 @@ class UnitTestingClusterNullablesAndOptionalsStruct( } if (nullableOptionalInt != null) { if (nullableOptionalInt.isPresent) { - val optnullableOptionalInt = nullableOptionalInt.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) - } + val optnullableOptionalInt = nullableOptionalInt.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT), optnullableOptionalInt) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) } @@ -86,9 +86,9 @@ class UnitTestingClusterNullablesAndOptionalsStruct( } if (nullableOptionalString != null) { if (nullableOptionalString.isPresent) { - val optnullableOptionalString = nullableOptionalString.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) - } + val optnullableOptionalString = nullableOptionalString.get() + put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING), optnullableOptionalString) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) } @@ -103,38 +103,38 @@ class UnitTestingClusterNullablesAndOptionalsStruct( } if (nullableOptionalStruct != null) { if (nullableOptionalStruct.isPresent) { - val optnullableOptionalStruct = nullableOptionalStruct.get() - optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) - } + val optnullableOptionalStruct = nullableOptionalStruct.get() + optnullableOptionalStruct.toTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), this) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) } if (nullableList != null) { startArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - for (item in nullableList.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in nullableList.iterator()) { + put(AnonymousTag, item) + } + endArray() } else { putNull(ContextSpecificTag(TAG_NULLABLE_LIST)) } if (optionalList.isPresent) { val optoptionalList = optionalList.get() startArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - for (item in optoptionalList.iterator()) { - put(AnonymousTag, item) - } - endArray() + for (item in optoptionalList.iterator()) { + put(AnonymousTag, item) + } + endArray() } if (nullableOptionalList != null) { if (nullableOptionalList.isPresent) { - val optnullableOptionalList = nullableOptionalList.get() - startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - for (item in optnullableOptionalList.iterator()) { - put(AnonymousTag, item) - } - endArray() - } + val optnullableOptionalList = nullableOptionalList.get() + startArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + for (item in optnullableOptionalList.iterator()) { + put(AnonymousTag, item) + } + endArray() + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) } @@ -158,112 +158,151 @@ class UnitTestingClusterNullablesAndOptionalsStruct( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterNullablesAndOptionalsStruct { tlvReader.enterStructure(tlvTag) - val nullableInt = if (!tlvReader.isNull()) { - tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_INT)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) - null - } - val optionalInt = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_OPTIONAL_INT))) - } else { - Optional.empty() - } - val nullableOptionalInt = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { - Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) - null - } - val nullableString = if (!tlvReader.isNull()) { - tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) - null - } - val optionalString = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) - } else { - Optional.empty() - } - val nullableOptionalString = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { - Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) - null - } - val nullableStruct = if (!tlvReader.isNull()) { - UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) - null - } - val optionalStruct = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { - Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_OPTIONAL_STRUCT), tlvReader)) - } else { - Optional.empty() - } - val nullableOptionalStruct = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { - Optional.of(UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), tlvReader)) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) - null - } - val nullableList = if (!tlvReader.isNull()) { - buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) - null - } - val optionalList = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - val nullableOptionalList = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { - Optional.of(buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - }) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) - null - } - + val nullableInt = + if (!tlvReader.isNull()) { + tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_INT)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_INT)) + null + } + val optionalInt = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_INT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_OPTIONAL_INT))) + } else { + Optional.empty() + } + val nullableOptionalInt = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) { + Optional.of(tlvReader.getUShort(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_INT)) + null + } + val nullableString = + if (!tlvReader.isNull()) { + tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_STRING)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRING)) + null + } + val optionalString = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_OPTIONAL_STRING))) + } else { + Optional.empty() + } + val nullableOptionalString = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) { + Optional.of(tlvReader.getString(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING))) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRING)) + null + } + val nullableStruct = + if (!tlvReader.isNull()) { + UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_NULLABLE_STRUCT), tlvReader) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_STRUCT)) + null + } + val optionalStruct = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_STRUCT))) { + Optional.of( + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_OPTIONAL_STRUCT), + tlvReader + ) + ) + } else { + Optional.empty() + } + val nullableOptionalStruct = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT))) { + Optional.of( + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT), + tlvReader + ) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_STRUCT)) + null + } + val nullableList = + if (!tlvReader.isNull()) { + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_LIST)) + null + } + val optionalList = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_OPTIONAL_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + val nullableOptionalList = + if (!tlvReader.isNull()) { + if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST))) { + Optional.of( + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_LIST)) + null + } + tlvReader.exitContainer() - return UnitTestingClusterNullablesAndOptionalsStruct(nullableInt, optionalInt, nullableOptionalInt, nullableString, optionalString, nullableOptionalString, nullableStruct, optionalStruct, nullableOptionalStruct, nullableList, optionalList, nullableOptionalList) + return UnitTestingClusterNullablesAndOptionalsStruct( + nullableInt, + optionalInt, + nullableOptionalInt, + nullableString, + optionalString, + nullableOptionalString, + nullableStruct, + optionalStruct, + nullableOptionalStruct, + nullableList, + optionalList, + nullableOptionalList + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt index 3b541c8d11d6b0..7266ca0054d7d8 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterSimpleStruct.kt @@ -16,9 +16,7 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader @@ -82,7 +80,7 @@ class UnitTestingClusterSimpleStruct( val f = tlvReader.getUByte(ContextSpecificTag(TAG_F)) val g = tlvReader.getFloat(ContextSpecificTag(TAG_G)) val h = tlvReader.getDouble(ContextSpecificTag(TAG_H)) - + tlvReader.exitContainer() return UnitTestingClusterSimpleStruct(a, b, c, d, e, f, g, h) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt index 1f38827ddec220..4e4b00571da5d9 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestFabricScoped.kt @@ -53,7 +53,10 @@ class UnitTestingClusterTestFabricScoped( put(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U), fabricSensitiveInt8u) if (optionalFabricSensitiveInt8u.isPresent) { val optoptionalFabricSensitiveInt8u = optionalFabricSensitiveInt8u.get() - put(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), optoptionalFabricSensitiveInt8u) + put( + ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U), + optoptionalFabricSensitiveInt8u + ) } if (nullableFabricSensitiveInt8u != null) { put(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U), nullableFabricSensitiveInt8u) @@ -62,9 +65,12 @@ class UnitTestingClusterTestFabricScoped( } if (nullableOptionalFabricSensitiveInt8u != null) { if (nullableOptionalFabricSensitiveInt8u.isPresent) { - val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() - put(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), optnullableOptionalFabricSensitiveInt8u) - } + val optnullableOptionalFabricSensitiveInt8u = nullableOptionalFabricSensitiveInt8u.get() + put( + ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U), + optnullableOptionalFabricSensitiveInt8u + ) + } } else { putNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) } @@ -93,41 +99,63 @@ class UnitTestingClusterTestFabricScoped( fun fromTlv(tlvTag: Tag, tlvReader: TlvReader): UnitTestingClusterTestFabricScoped { tlvReader.enterStructure(tlvTag) val fabricSensitiveInt8u = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U)) - val optionalFabricSensitiveInt8u = if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) - } else { - Optional.empty() - } - val nullableFabricSensitiveInt8u = if (!tlvReader.isNull()) { - tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) - null - } - val nullableOptionalFabricSensitiveInt8u = if (!tlvReader.isNull()) { - if (tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { - Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U))) - } else { - Optional.empty() - } - } else { - tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) - null - } - val fabricSensitiveCharString = tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) - val fabricSensitiveStruct = UnitTestingClusterSimpleStruct.fromTlv(ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), tlvReader) - val fabricSensitiveInt8uList = buildList { - tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) - while(!tlvReader.isEndOfContainer()) { - add(tlvReader.getUByte(AnonymousTag)) - } - tlvReader.exitContainer() - } + val optionalFabricSensitiveInt8u = + if (tlvReader.isNextTag(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) { + Optional.of(tlvReader.getUByte(ContextSpecificTag(TAG_OPTIONAL_FABRIC_SENSITIVE_INT8U))) + } else { + Optional.empty() + } + val nullableFabricSensitiveInt8u = + if (!tlvReader.isNull()) { + tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_FABRIC_SENSITIVE_INT8U)) + null + } + val nullableOptionalFabricSensitiveInt8u = + if (!tlvReader.isNull()) { + if ( + tlvReader.isNextTag(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + ) { + Optional.of( + tlvReader.getUByte(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + ) + } else { + Optional.empty() + } + } else { + tlvReader.getNull(ContextSpecificTag(TAG_NULLABLE_OPTIONAL_FABRIC_SENSITIVE_INT8U)) + null + } + val fabricSensitiveCharString = + tlvReader.getString(ContextSpecificTag(TAG_FABRIC_SENSITIVE_CHAR_STRING)) + val fabricSensitiveStruct = + UnitTestingClusterSimpleStruct.fromTlv( + ContextSpecificTag(TAG_FABRIC_SENSITIVE_STRUCT), + tlvReader + ) + val fabricSensitiveInt8uList = + buildList { + tlvReader.enterArray(ContextSpecificTag(TAG_FABRIC_SENSITIVE_INT8U_LIST)) + while (!tlvReader.isEndOfContainer()) { + add(tlvReader.getUByte(AnonymousTag)) + } + tlvReader.exitContainer() + } val fabricIndex = tlvReader.getUByte(ContextSpecificTag(TAG_FABRIC_INDEX)) - + tlvReader.exitContainer() - return UnitTestingClusterTestFabricScoped(fabricSensitiveInt8u, optionalFabricSensitiveInt8u, nullableFabricSensitiveInt8u, nullableOptionalFabricSensitiveInt8u, fabricSensitiveCharString, fabricSensitiveStruct, fabricSensitiveInt8uList, fabricIndex) + return UnitTestingClusterTestFabricScoped( + fabricSensitiveInt8u, + optionalFabricSensitiveInt8u, + nullableFabricSensitiveInt8u, + nullableOptionalFabricSensitiveInt8u, + fabricSensitiveCharString, + fabricSensitiveStruct, + fabricSensitiveInt8uList, + fabricIndex + ) } } } diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt index 5478f2bd44b175..9a7f7d3ba58b08 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UnitTestingClusterTestListStructOctet.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UnitTestingClusterTestListStructOctet( - val member1: ULong, - val member2: ByteArray -) { +class UnitTestingClusterTestListStructOctet(val member1: ULong, val member2: ByteArray) { override fun toString(): String = buildString { append("UnitTestingClusterTestListStructOctet {\n") append("\tmember1 : $member1\n") @@ -52,7 +47,7 @@ class UnitTestingClusterTestListStructOctet( tlvReader.enterStructure(tlvTag) val member1 = tlvReader.getULong(ContextSpecificTag(TAG_MEMBER1)) val member2 = tlvReader.getByteArray(ContextSpecificTag(TAG_MEMBER2)) - + tlvReader.exitContainer() return UnitTestingClusterTestListStructOctet(member1, member2) diff --git a/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt b/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt index fd4efa9375bbe4..8840aec05a78bd 100644 --- a/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt +++ b/src/controller/java/generated/java/matter/controller/cluster/structs/UserLabelClusterLabelStruct.kt @@ -16,18 +16,13 @@ */ package matter.controller.cluster.structs -import java.util.Optional import matter.controller.cluster.* -import matter.tlv.AnonymousTag import matter.tlv.ContextSpecificTag import matter.tlv.Tag import matter.tlv.TlvReader import matter.tlv.TlvWriter -class UserLabelClusterLabelStruct( - val label: String, - val value: String -) { +class UserLabelClusterLabelStruct(val label: String, val value: String) { override fun toString(): String = buildString { append("UserLabelClusterLabelStruct {\n") append("\tlabel : $label\n") @@ -52,7 +47,7 @@ class UserLabelClusterLabelStruct( tlvReader.enterStructure(tlvTag) val label = tlvReader.getString(ContextSpecificTag(TAG_LABEL)) val value = tlvReader.getString(ContextSpecificTag(TAG_VALUE)) - + tlvReader.exitContainer() return UserLabelClusterLabelStruct(label, value) diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index dfc992b03ac6b6..12a7bb3d93ac7a 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -186,7 +186,6 @@ class TestList : public Command { printf("Test_TC_OO_2_4\n"); printf("Test_TC_OPSTATE_1_1\n"); printf("Test_TC_OVENOPSTATE_1_1\n"); - printf("Test_TC_OVENOPSTATE_2_2\n"); printf("Test_TC_OVENOPSTATE_2_4\n"); printf("Test_TC_PS_1_1\n"); printf("Test_TC_PS_2_1\n"); @@ -90415,118 +90414,6 @@ class Test_TC_OVENOPSTATE_1_1 : public TestCommandBridge { } }; -class Test_TC_OVENOPSTATE_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OVENOPSTATE_2_2() - : TestCommandBridge("Test_TC_OVENOPSTATE_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OVENOPSTATE_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 3: TH reads from the DUT the OperationalStateList attribute\n"); - if (ShouldSkip("OVENOPSTATE.S.A0003")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_0(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 1; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_0() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the OperationalStateList attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the OperationalStateList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); - } - - VerifyOrReturn(CheckConstraintType("operationalStateList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - class Test_TC_OVENOPSTATE_2_4 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced @@ -195138,7 +195025,6 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), - make_unique(), make_unique(), make_unique(), make_unique(), From 76bcc49035ebee07f530e4e2f657551c39243731 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Fri, 19 Jan 2024 14:46:36 -0300 Subject: [PATCH 29/89] removed zap gen --- .../zap-generated/test/Commands.h | 195156 --------------- 1 file changed, 195156 deletions(-) delete mode 100644 zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h deleted file mode 100644 index 12a7bb3d93ac7a..00000000000000 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ /dev/null @@ -1,195156 +0,0 @@ -/* - * - * Copyright (c) 2022 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// THIS FILE IS GENERATED BY ZAP - -#pragma once - -#if CONFIG_ENABLE_YAML_TESTS - -#include -#include -#include -#include - -#include // For INFINITY - -typedef void (^ResponseHandler)(id _Nullable value, NSError * _Nullable error); - -class TestList : public Command { -public: - TestList() - : Command("list") {}; - CHIP_ERROR Run() override - { - printf("TestAccessControlCluster\n"); - printf("Test_TC_ACL_1_1\n"); - printf("Test_TC_ACL_2_1\n"); - printf("Test_TC_ACL_2_3\n"); - printf("Test_TC_ACE_1_1\n"); - printf("Test_TC_ACE_1_5\n"); - printf("Test_TC_AIRQUAL_1_1\n"); - printf("Test_TC_AIRQUAL_2_1\n"); - printf("Test_TC_BOOL_1_1\n"); - printf("Test_TC_BOOL_2_1\n"); - printf("Test_TC_BRBINFO_1_1\n"); - printf("Test_TC_ACT_1_1\n"); - printf("Test_TC_BIND_1_1\n"); - printf("Test_TC_CC_1_1\n"); - printf("Test_TC_CC_2_1\n"); - printf("Test_TC_CC_3_2\n"); - printf("Test_TC_CC_3_3\n"); - printf("Test_TC_CC_4_1\n"); - printf("Test_TC_CC_4_2\n"); - printf("Test_TC_CC_4_3\n"); - printf("Test_TC_CC_4_4\n"); - printf("Test_TC_CC_5_1\n"); - printf("Test_TC_CC_5_2\n"); - printf("Test_TC_CC_5_3\n"); - printf("Test_TC_CC_6_1\n"); - printf("Test_TC_CC_6_5\n"); - printf("Test_TC_CC_7_3\n"); - printf("Test_TC_CC_7_4\n"); - printf("TestColorControl_9_1\n"); - printf("TestColorControl_9_2\n"); - printf("Test_TC_CDOCONC_1_1\n"); - printf("Test_TC_CDOCONC_2_1\n"); - printf("Test_TC_CMOCONC_1_1\n"); - printf("Test_TC_CMOCONC_2_1\n"); - printf("Test_TC_FLDCONC_1_1\n"); - printf("Test_TC_FLDCONC_2_1\n"); - printf("Test_TC_NDOCONC_1_1\n"); - printf("Test_TC_NDOCONC_2_1\n"); - printf("Test_TC_OZCONC_1_1\n"); - printf("Test_TC_OZCONC_2_1\n"); - printf("Test_TC_PMHCONC_1_1\n"); - printf("Test_TC_PMHCONC_2_1\n"); - printf("Test_TC_PMICONC_1_1\n"); - printf("Test_TC_PMICONC_2_1\n"); - printf("Test_TC_PMKCONC_1_1\n"); - printf("Test_TC_PMKCONC_2_1\n"); - printf("Test_TC_RNCONC_1_1\n"); - printf("Test_TC_RNCONC_2_1\n"); - printf("Test_TC_TVOCCONC_1_1\n"); - printf("Test_TC_TVOCCONC_2_1\n"); - printf("Test_TC_OPCREDS_1_2\n"); - printf("Test_TC_BINFO_1_1\n"); - printf("Test_TC_CNET_1_3\n"); - printf("Test_TC_DESC_1_1\n"); - printf("Test_TC_DLOG_1_1\n"); - printf("Test_TC_DGETH_1_1\n"); - printf("Test_TC_DGETH_2_1\n"); - printf("Test_TC_DGETH_2_2\n"); - printf("Test_TC_FLW_1_1\n"); - printf("Test_TC_FLABEL_1_1\n"); - printf("Test_TC_FAN_1_1\n"); - printf("Test_TC_FAN_2_1\n"); - printf("Test_TC_FAN_2_2\n"); - printf("Test_TC_FAN_2_3\n"); - printf("Test_TC_FAN_2_4\n"); - printf("Test_TC_FAN_3_1\n"); - printf("Test_TC_FAN_3_2\n"); - printf("Test_TC_FAN_3_6\n"); - printf("Test_TC_CGEN_1_1\n"); - printf("Test_TC_CGEN_2_1\n"); - printf("Test_TC_DGGEN_1_1\n"); - printf("Test_TC_GRPKEY_1_1\n"); - printf("Test_TC_GRPKEY_2_2\n"); - printf("Test_TC_ICDM_1_1\n"); - printf("Test_TC_I_1_1\n"); - printf("Test_TC_I_2_1\n"); - printf("Test_TC_I_2_2\n"); - printf("Test_TC_I_2_3\n"); - printf("Test_TC_ILL_1_1\n"); - printf("Test_TC_ILL_2_1\n"); - printf("Test_TC_ILL_2_2\n"); - printf("Test_TC_LVL_1_1\n"); - printf("Test_TC_LVL_2_1\n"); - printf("Test_TC_LVL_2_2\n"); - printf("Test_TC_LVL_3_1\n"); - printf("Test_TC_LVL_4_1\n"); - printf("Test_TC_LVL_5_1\n"); - printf("Test_TC_LVL_6_1\n"); - printf("Test_TC_LVL_7_1\n"); - printf("Test_TC_LCFG_1_1\n"); - printf("Test_TC_LUNIT_1_2\n"); - printf("Test_TC_LUNIT_3_1\n"); - printf("Test_TC_LTIME_1_2\n"); - printf("Test_TC_LTIME_3_1\n"); - printf("Test_TC_LWM_1_1\n"); - printf("Test_TC_LWM_2_1\n"); - printf("Test_TC_WASHERCTRL_1_1\n"); - printf("Test_TC_WASHERCTRL_2_1\n"); - printf("Test_TC_WASHERCTRL_2_2\n"); - printf("Test_TC_DRYERCTRL_1_1\n"); - printf("Test_TC_DRYERCTRL_2_1\n"); - printf("Test_TC_LOWPOWER_1_1\n"); - printf("Test_TC_KEYPADINPUT_1_2\n"); - printf("Test_TC_APPLAUNCHER_1_3\n"); - printf("Test_TC_MEDIAINPUT_1_4\n"); - printf("Test_TC_WAKEONLAN_1_5\n"); - printf("Test_TC_CHANNEL_1_6\n"); - printf("Test_TC_MEDIAPLAYBACK_1_7\n"); - printf("Test_TC_AUDIOOUTPUT_1_8\n"); - printf("Test_TC_TGTNAV_1_9\n"); - printf("Test_TC_APBSC_1_10\n"); - printf("Test_TC_CONTENTLAUNCHER_1_11\n"); - printf("Test_TC_ALOGIN_1_12\n"); - printf("Test_TC_LOWPOWER_2_1\n"); - printf("Test_TC_KEYPADINPUT_3_2\n"); - printf("Test_TC_KEYPADINPUT_3_3\n"); - printf("Test_TC_APPLAUNCHER_3_5\n"); - printf("Test_TC_APPLAUNCHER_3_6\n"); - printf("Test_TC_MEDIAINPUT_3_10\n"); - printf("Test_TC_MEDIAINPUT_3_11\n"); - printf("Test_TC_MEDIAINPUT_3_12\n"); - printf("Test_TC_MEDIAINPUT_3_13\n"); - printf("Test_TC_CHANNEL_5_1\n"); - printf("Test_TC_CHANNEL_5_2\n"); - printf("Test_TC_CHANNEL_5_3\n"); - printf("Test_TC_MEDIAPLAYBACK_6_1\n"); - printf("Test_TC_MEDIAPLAYBACK_6_2\n"); - printf("Test_TC_MEDIAPLAYBACK_6_3\n"); - printf("Test_TC_MEDIAPLAYBACK_6_4\n"); - printf("Test_TC_AUDIOOUTPUT_7_1\n"); - printf("Test_TC_AUDIOOUTPUT_7_2\n"); - printf("Test_TC_TGTNAV_8_1\n"); - printf("Test_TC_APBSC_9_1\n"); - printf("Test_TC_CONTENTLAUNCHER_10_1\n"); - printf("Test_TC_WAKEONLAN_4_1\n"); - printf("Test_TC_ALOGIN_12_1\n"); - printf("Test_TC_CONTENTLAUNCHER_10_3\n"); - printf("Test_TC_CONTENTLAUNCHER_10_5\n"); - printf("Test_TC_CONTENTLAUNCHER_10_7\n"); - printf("Test_TC_MOD_1_1\n"); - printf("OTA_SuccessfulTransfer\n"); - printf("Test_TC_OCC_1_1\n"); - printf("Test_TC_OCC_2_1\n"); - printf("Test_TC_OCC_2_3\n"); - printf("Test_TC_OO_1_1\n"); - printf("Test_TC_OO_2_1\n"); - printf("Test_TC_OO_2_2\n"); - printf("Test_TC_OO_2_4\n"); - printf("Test_TC_OPSTATE_1_1\n"); - printf("Test_TC_OVENOPSTATE_1_1\n"); - printf("Test_TC_OVENOPSTATE_2_4\n"); - printf("Test_TC_PS_1_1\n"); - printf("Test_TC_PS_2_1\n"); - printf("Test_TC_PRS_1_1\n"); - printf("Test_TC_PRS_2_1\n"); - printf("Test_TC_PRS_2_2\n"); - printf("Test_TC_PCC_1_1\n"); - printf("Test_TC_PCC_2_1\n"); - printf("Test_TC_PCC_2_2\n"); - printf("Test_TC_PCC_2_3\n"); - printf("Test_TC_PCC_2_4\n"); - printf("Test_TC_REFALM_1_1\n"); - printf("Test_TC_REFALM_2_1\n"); - printf("Test_TC_RH_1_1\n"); - printf("Test_TC_RVCCLEANM_1_1\n"); - printf("Test_TC_RVCRUNM_1_1\n"); - printf("Test_TC_RVCOPSTATE_1_1\n"); - printf("Test_TC_SMOKECO_1_1\n"); - printf("Test_TC_SMOKECO_2_1\n"); - printf("Test_TC_SWTCH_1_1\n"); - printf("Test_TC_TCCM_1_1\n"); - printf("Test_TC_TCTL_1_1\n"); - printf("Test_TC_TCTL_2_2\n"); - printf("Test_TC_TCTL_2_3\n"); - printf("Test_TC_TCTL_3_2\n"); - printf("Test_TC_TCTL_3_3\n"); - printf("Test_TC_TMP_1_1\n"); - printf("Test_TC_TMP_2_1\n"); - printf("Test_TC_TSTAT_1_1\n"); - printf("Test_TC_TSUIC_1_1\n"); - printf("Test_TC_TSUIC_2_1\n"); - printf("Test_TC_TSUIC_2_2\n"); - printf("Test_TC_DGTHREAD_1_1\n"); - printf("Test_TC_TIMESYNC_1_1\n"); - printf("Test_TC_TIMESYNC_2_3\n"); - printf("Test_TC_ULABEL_1_1\n"); - printf("Test_TC_ULABEL_2_1\n"); - printf("Test_TC_ULABEL_2_2\n"); - printf("Test_TC_ULABEL_2_3\n"); - printf("Test_TC_ULABEL_2_4\n"); - printf("Test_TC_DGWIFI_1_1\n"); - printf("Test_TC_DGWIFI_2_1\n"); - printf("Test_TC_DGWIFI_2_3\n"); - printf("Test_TC_WNCV_1_1\n"); - printf("Test_TC_WNCV_2_1\n"); - printf("Test_TC_WNCV_2_2\n"); - printf("Test_TC_WNCV_2_3\n"); - printf("Test_TC_WNCV_2_5\n"); - printf("Test_TC_WNCV_3_1\n"); - printf("Test_TC_WNCV_3_2\n"); - printf("Test_TC_WNCV_3_3\n"); - printf("Test_TC_WNCV_3_4\n"); - printf("Test_TC_WNCV_3_5\n"); - printf("Test_TC_WNCV_4_1\n"); - printf("Test_TC_WNCV_4_2\n"); - printf("Test_TC_WNCV_4_3\n"); - printf("Test_TC_WNCV_4_4\n"); - printf("Test_TC_WNCV_4_5\n"); - printf("TV_TargetNavigatorCluster\n"); - printf("TV_AudioOutputCluster\n"); - printf("TV_ApplicationLauncherCluster\n"); - printf("TV_KeypadInputCluster\n"); - printf("TV_AccountLoginCluster\n"); - printf("TV_WakeOnLanCluster\n"); - printf("TV_ApplicationBasicCluster\n"); - printf("TV_MediaPlaybackCluster\n"); - printf("TV_ChannelCluster\n"); - printf("TV_LowPowerCluster\n"); - printf("TV_ContentLauncherCluster\n"); - printf("TV_MediaInputCluster\n"); - printf("TestCASERecovery\n"); - printf("TestCluster\n"); - printf("TestConstraints\n"); - printf("TestDelayCommands\n"); - printf("TestLogCommands\n"); - printf("TestSaveAs\n"); - printf("TestConfigVariables\n"); - printf("TestDescriptorCluster\n"); - printf("TestFabricRemovalWhileSubscribed\n"); - printf("TestGeneralCommissioning\n"); - printf("TestIdentifyCluster\n"); - printf("TestOperationalCredentialsCluster\n"); - printf("TestModeSelectCluster\n"); - printf("TestTemperatureControl\n"); - printf("TestSelfFabricRemoval\n"); - printf("TestSystemCommands\n"); - printf("TestBinding\n"); - printf("TestUserLabelCluster\n"); - printf("TestUserLabelClusterConstraints\n"); - printf("TestArmFailSafe\n"); - printf("TestFanControl\n"); - printf("TestAccessControlConstraints\n"); - printf("TestLevelControlWithOnOffDependency\n"); - printf("TestCommissioningWindow\n"); - printf("TestCommissionerNodeId\n"); - printf("TestTimeSynchronization\n"); - printf("TestOperationalState\n"); - printf("TestRVCOperationalState\n"); - printf("TestDishwasherAlarm\n"); - printf("TestMultiAdmin\n"); - printf("Test_TC_DGSW_1_1\n"); - printf("TestSubscribe_OnOff\n"); - printf("TestSubscribe_AdministratorCommissioning\n"); - printf("DL_UsersAndCredentials\n"); - printf("DL_Schedules\n"); - printf("Test_TC_DRLK_1_1\n"); - printf("Test_TC_DRLK_2_4\n"); - printf("Test_TC_DRLK_2_5\n"); - printf("Test_TC_DRLK_2_6\n"); - printf("Test_TC_DRLK_2_7\n"); - printf("Test_TC_DRLK_2_8\n"); - printf("Test_TC_DRLK_2_11\n"); - printf("TestGroupsCluster\n"); - printf("Test_TC_G_1_1\n"); - printf("TestScenesFabricRemoval\n"); - printf("Test_TC_S_1_1\n"); - printf("Test_TC_S_2_1\n"); - printf("Test_TC_S_2_4\n"); - printf("TestActivatedCarbonFilterMonitoring\n"); - printf("TestHepaFilterMonitoring\n"); - printf("Test_TC_ACFREMON_1_1\n"); - printf("Test_TC_ACFREMON_2_1\n"); - printf("Test_TC_HEPAFREMON_1_1\n"); - printf("Test_TC_HEPAFREMON_2_1\n"); - - return CHIP_NO_ERROR; - } -}; - -class ManualTestList : public Command { -public: - ManualTestList() - : Command("list-manual") {}; - CHIP_ERROR Run() override - { - - return CHIP_NO_ERROR; - } -}; - -class TestAccessControlCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestAccessControlCluster() - : TestCommandBridge("TestAccessControlCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestAccessControlCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestAccessControlCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestAccessControlCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for commissionee\n"); - err = TestWaitForCommissionee_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write entries\n"); - err = TestWriteEntries_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify\n"); - err = TestVerify_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write entries empty lists\n"); - err = TestWriteEntriesEmptyLists_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify\n"); - err = TestVerify_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write entry invalid privilege\n"); - err = TestWriteEntryInvalidPrivilege_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Verify\n"); - err = TestVerify_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write entry invalid auth mode\n"); - err = TestWriteEntryInvalidAuthMode_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify\n"); - err = TestVerify_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write entry invalid subject\n"); - err = TestWriteEntryInvalidSubject_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify\n"); - err = TestVerify_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Write entry invalid target\n"); - err = TestWriteEntryInvalidTarget_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Verify\n"); - err = TestVerify_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Write entry too many subjects\n"); - err = TestWriteEntryTooManySubjects_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Verify\n"); - err = TestVerify_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Write entry too many targets\n"); - err = TestWriteEntryTooManyTargets_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify\n"); - err = TestVerify_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write too many entries\n"); - err = TestWriteTooManyEntries_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Verify\n"); - err = TestVerify_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Restore ACL\n"); - err = TestRestoreAcl_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Verify\n"); - err = TestVerify_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Validate resource minima (SubjectsPerAccessControlEntry)\n"); - err = TestValidateResourceMinimaSubjectsPerAccessControlEntry_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Validate resource minima (TargetsPerAccessControlEntry)\n"); - err = TestValidateResourceMinimaTargetsPerAccessControlEntry_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Validate resource minima (AccessControlEntriesPerFabric)\n"); - err = TestValidateResourceMinimaAccessControlEntriesPerFabric_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForCommissionee_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteEntries_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:1UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:2UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:4ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:5ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:6ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:7ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:9UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:10UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:12ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:13ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:14ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:15ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:16U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:17UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:18UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:19U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[3] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:20ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:21ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:22ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:23ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:24U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:25UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:26UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:27U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entries: Error: %@", err); - } else { - NSLog(@"Write entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint, 0U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster, 1UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster, 2UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint, 3U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[0], 4ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[1], 5ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[2], 6ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[3], 7ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint, 8U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster, 9UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster, 10UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint, 11U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).privilege, 3U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).authMode, 3U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[0], 12ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[1], 13ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[2], 14ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[3], 15ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint, 16U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster, 17UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster, 18UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint, 19U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).privilege, 3U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[0], 20ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[1], 21ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[2], 22ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[3], 23ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint, 24U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster, 25UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster, 26UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint, 27U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntriesEmptyLists_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entries empty lists: Error: %@", err); - } else { - NSLog(@"Write entries empty lists: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidPrivilege_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid privilege: Error: %@", err); - } else { - NSLog(@"Write entry invalid privilege: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidAuthMode_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid auth mode: Error: %@", err); - } else { - NSLog(@"Write entry invalid auth mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidSubject_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid subject: Error: %@", err); - } else { - NSLog(@"Write entry invalid subject: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryInvalidTarget_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry invalid target: Error: %@", err); - } else { - NSLog(@"Write entry invalid target: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryTooManySubjects_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:1ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:2ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:3ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:4ULL]; - temp_3[4] = - [NSNumber numberWithUnsignedLongLong:5ULL]; - temp_3[5] = - [NSNumber numberWithUnsignedLongLong:6ULL]; - temp_3[6] = - [NSNumber numberWithUnsignedLongLong:7ULL]; - temp_3[7] = - [NSNumber numberWithUnsignedLongLong:8ULL]; - temp_3[8] = - [NSNumber numberWithUnsignedLongLong:9ULL]; - temp_3[9] = - [NSNumber numberWithUnsignedLongLong:10ULL]; - temp_3[10] = - [NSNumber numberWithUnsignedLongLong:11ULL]; - temp_3[11] = - [NSNumber numberWithUnsignedLongLong:12ULL]; - temp_3[12] = - [NSNumber numberWithUnsignedLongLong:13ULL]; - temp_3[13] = - [NSNumber numberWithUnsignedLongLong:14ULL]; - temp_3[14] = - [NSNumber numberWithUnsignedLongLong:15ULL]; - temp_3[15] = - [NSNumber numberWithUnsignedLongLong:16ULL]; - temp_3[16] = - [NSNumber numberWithUnsignedLongLong:17ULL]; - temp_3[17] = - [NSNumber numberWithUnsignedLongLong:18ULL]; - temp_3[18] = - [NSNumber numberWithUnsignedLongLong:19ULL]; - temp_3[19] = - [NSNumber numberWithUnsignedLongLong:20ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry too many subjects: Error: %@", err); - } else { - NSLog(@"Write entry too many subjects: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteEntryTooManyTargets_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = - [NSNumber numberWithUnsignedShort:2U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - temp_3[3] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).endpoint = - [NSNumber numberWithUnsignedShort:4U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).deviceType = nil; - - temp_3[4] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).endpoint = - [NSNumber numberWithUnsignedShort:5U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).deviceType = nil; - - temp_3[5] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).endpoint = - [NSNumber numberWithUnsignedShort:6U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).deviceType = nil; - - temp_3[6] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).endpoint = - [NSNumber numberWithUnsignedShort:7U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).deviceType = nil; - - temp_3[7] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).deviceType = nil; - - temp_3[8] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).endpoint = - [NSNumber numberWithUnsignedShort:9U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).deviceType = nil; - - temp_3[9] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).endpoint = - [NSNumber numberWithUnsignedShort:10U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).deviceType = nil; - - temp_3[10] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).deviceType = nil; - - temp_3[11] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).endpoint = - [NSNumber numberWithUnsignedShort:12U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).deviceType = nil; - - temp_3[12] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).endpoint = - [NSNumber numberWithUnsignedShort:13U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).deviceType = nil; - - temp_3[13] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).endpoint = - [NSNumber numberWithUnsignedShort:14U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).deviceType = nil; - - temp_3[14] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).endpoint = - [NSNumber numberWithUnsignedShort:15U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).deviceType = nil; - - temp_3[15] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).endpoint = - [NSNumber numberWithUnsignedShort:16U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).deviceType = nil; - - temp_3[16] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).endpoint = - [NSNumber numberWithUnsignedShort:17U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).deviceType = nil; - - temp_3[17] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).endpoint = - [NSNumber numberWithUnsignedShort:18U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).deviceType = nil; - - temp_3[18] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).endpoint = - [NSNumber numberWithUnsignedShort:19U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).deviceType = nil; - - temp_3[19] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).endpoint = - [NSNumber numberWithUnsignedShort:20U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write entry too many targets: Error: %@", err); - } else { - NSLog(@"Write entry too many targets: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTooManyEntries_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:1UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:2UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:4ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:5ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:6ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:7ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:9UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:10UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:12ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:13ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:14ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:15ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:16U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:17UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:18UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:19U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[3] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:20ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:21ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:22ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:23ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:24U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:25UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:26UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:27U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[4] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:28ULL]; - temp_3[1] = - [NSNumber numberWithUnsignedLongLong:29ULL]; - temp_3[2] = - [NSNumber numberWithUnsignedLongLong:30ULL]; - temp_3[3] = - [NSNumber numberWithUnsignedLongLong:31ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:32U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = - [NSNumber numberWithUnsignedInt:33UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; - - temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = - [NSNumber numberWithUnsignedInt:34UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = - [NSNumber numberWithUnsignedShort:35U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write too many entries: Error: %@", err); - } else { - NSLog(@"Write too many entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint, 0U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster, 1UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster, 2UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint, 3U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[0], 4ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[1], 5ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[2], 6ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[3], 7ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint, 8U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster, 9UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster, 10UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint, 11U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).privilege, 3U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).authMode, 3U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[0], 12ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[1], 13ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[2], 14ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[3], 15ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint, 16U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster, 17UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster, 18UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint, 19U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).privilege, 1U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects count], static_cast(4))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[0], 20ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[1], 21ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[2], 22ULL)); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[3], 23ULL)); - VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets)); - VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets count], static_cast(3))); - VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).cluster)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint, 24U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster, 25UL)); - VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).endpoint)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).deviceType)); - VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster)); - VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster, 26UL)); - VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint, 27U)); - VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).deviceType)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreAcl_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore ACL: Error: %@", err); - } else { - NSLog(@"Restore ACL: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerify_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify: Error: %@", err); - } else { - NSLog(@"Verify: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidateResourceMinimaSubjectsPerAccessControlEntry_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSubjectsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate resource minima (SubjectsPerAccessControlEntry): Error: %@", err); - } else { - NSLog(@"Validate resource minima (SubjectsPerAccessControlEntry): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidateResourceMinimaTargetsPerAccessControlEntry_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate resource minima (TargetsPerAccessControlEntry): Error: %@", err); - } else { - NSLog(@"Validate resource minima (TargetsPerAccessControlEntry): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("targetsPerAccessControlEntry", [value unsignedShortValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidateResourceMinimaAccessControlEntriesPerFabric_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAccessControlEntriesPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate resource minima (AccessControlEntriesPerFabric): Error: %@", err); - } else { - NSLog(@"Validate resource minima (AccessControlEntriesPerFabric): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("accessControlEntriesPerFabric", [value unsignedShortValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACL_1_1() - : TestCommandBridge("Test_TC_ACL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from DUT\n"); - err = TestStep2ThReadsClusterRevisionAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from DUT\n"); - err = TestStep3ThReadsFeatureMapAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute (Extension) in AttributeList\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeExtensionInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeExtensionInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute (Extension) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute (Extension) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACL_2_1() - : TestCommandBridge("Test_TC_ACL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads SubjectsPerAccessControlEntry attribute from DUT\n"); - if (ShouldSkip("ACL.S.A0002")) { - NextTest(); - return; - } - err = TestStep2ThReadsSubjectsPerAccessControlEntryAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads TargetsPerAccessControlEntry attribute from DUT\n"); - if (ShouldSkip("ACL.S.A0003")) { - NextTest(); - return; - } - err = TestStep3ThReadsTargetsPerAccessControlEntryAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads AccessControlEntriesPerFabric attribute from DUT\n"); - if (ShouldSkip("ACL.S.A0004")) { - NextTest(); - return; - } - err = TestStep4ThReadsAccessControlEntriesPerFabricAttributeFromDut_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsSubjectsPerAccessControlEntryAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSubjectsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads SubjectsPerAccessControlEntry attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads SubjectsPerAccessControlEntry attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("subjectsPerAccessControlEntry", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 4U)); - VerifyOrReturn(CheckConstraintMaxValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTargetsPerAccessControlEntryAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads TargetsPerAccessControlEntry attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads TargetsPerAccessControlEntry attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("targetsPerAccessControlEntry", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("targetsPerAccessControlEntry", [value unsignedShortValue], 3U)); - VerifyOrReturn(CheckConstraintMaxValue("targetsPerAccessControlEntry", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAccessControlEntriesPerFabricAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAccessControlEntriesPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AccessControlEntriesPerFabric attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AccessControlEntriesPerFabric attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("accessControlEntriesPerFabric", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("accessControlEntriesPerFabric", [value unsignedShortValue], 3U)); - VerifyOrReturn(CheckConstraintMaxValue("accessControlEntriesPerFabric", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACL_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACL_2_3() - : TestCommandBridge("Test_TC_ACL_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("D_OK_EMPTY", &mDOkEmpty); - AddArgument("D_OK_SINGLE", &mDOkSingle); - AddArgument("D_OK_FULL", &mDOkFull); - AddArgument("D_BAD_LENGTH", &mDBadLength); - AddArgument("D_BAD_STRUCT", &mDBadStruct); - AddArgument("D_BAD_LIST", &mDBadList); - AddArgument("D_BAD_ELEM", &mDBadElem); - AddArgument("D_BAD_OVERFLOW", &mDBadOverflow); - AddArgument("D_BAD_UNDERFLOW", &mDBadUnderflow); - AddArgument("D_BAD_NONE", &mDBadNone); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACL_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute\n"); - err = TestStep2Th1ReadsDutEndpoint0OperationalCredentialsClusterCurrentFabricIndexAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDOkEmpty1718_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep5Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep6Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep7Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep8Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkFull17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003148656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e0018_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep9Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep10Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadLength17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003248656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e2e0018_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep11Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadStruct1518_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep12Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadList3701d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep13Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadElem17103d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep14Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadOverflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018ff_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep15Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadUnderflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep16Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadNone_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep17Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining2ElementsValueIsListOfAccessControlExtensionStructContaining2ElementsFirstElementContainsDataFieldDOkEmpty1718SecondElementContainsDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep18Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep19Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsAnEmptyList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); - if (ShouldSkip("ACL.S.A0001")) { - NextTest(); - return; - } - err = TestStep20Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mDOkEmpty; - chip::Optional mDOkSingle; - chip::Optional mDOkFull; - chip::Optional mDBadLength; - chip::Optional mDBadStruct; - chip::Optional mDBadList; - chip::Optional mDBadElem; - chip::Optional mDBadOverflow; - chip::Optional mDBadUnderflow; - chip::Optional mDBadNone; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull CurrentFabricIndexValue; - - CHIP_ERROR TestStep2Th1ReadsDutEndpoint0OperationalCredentialsClusterCurrentFabricIndexAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - CurrentFabricIndexValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDOkEmpty1718_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718: Error: %@", err); - } else { - NSLog(@"Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkFull17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003148656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e0018_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkFull.HasValue() ? [NSData dataWithBytes:mDOkFull.Value().data() length:mDOkFull.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x31\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:128]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018: Error: %@", err); - } else { - NSLog(@"Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkFull.HasValue() ? [NSData dataWithBytes:mDOkFull.Value().data() length:mDOkFull.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x31\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:128] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadLength17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003248656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e2e0018_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadLength.HasValue() ? [NSData dataWithBytes:mDBadLength.Value().data() length:mDBadLength.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x32\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:129]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018: Error: %@", err); - } else { - NSLog(@"Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadStruct1518_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadStruct.HasValue() ? [NSData dataWithBytes:mDBadStruct.Value().data() length:mDBadStruct.Value().size()] : [[NSData alloc] initWithBytes:"\x15\x18" length:2]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518: Error: %@", err); - } else { - NSLog(@"Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadList3701d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadList.HasValue() ? [NSData dataWithBytes:mDBadList.Value().data() length:mDBadList.Value().size()] : [[NSData alloc] initWithBytes:"\x37\x01\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:72]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadElem17103d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadElem.HasValue() ? [NSData dataWithBytes:mDBadElem.Value().data() length:mDBadElem.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x10\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:65]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadOverflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018ff_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadOverflow.HasValue() ? [NSData dataWithBytes:mDBadOverflow.Value().data() length:mDBadOverflow.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18\xFF" length:72]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF: Error: %@", err); - } else { - NSLog(@"Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadUnderflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadUnderflow.HasValue() ? [NSData dataWithBytes:mDBadUnderflow.Value().data() length:mDBadUnderflow.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00" length:70]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700: Error: %@", err); - } else { - NSLog(@"Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadNone_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadNone.HasValue() ? [NSData dataWithBytes:mDBadNone.Value().data() length:mDBadNone.Value().size()] : [[NSData alloc] initWithBytes:"" length:0]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE: Error: %@", err); - } else { - NSLog(@"Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining2ElementsValueIsListOfAccessControlExtensionStructContaining2ElementsFirstElementContainsDataFieldDOkEmpty1718SecondElementContainsDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = - [CurrentFabricIndexValue copy]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[1]).data = mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71]; - ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[1]).fabricIndex = - [CurrentFabricIndexValue copy]; - - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); - } else { - NSLog(@"Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2] - - )); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsAnEmptyList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id extensionArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - extensionArgument = temp_0; - } - [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list: Error: %@", err); - } else { - NSLog(@"Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); - } else { - NSLog(@"Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACE_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACE_1_1() - : TestCommandBridge("Test_TC_ACE_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACE_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACE_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACE_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); - err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read the commissioner node ID\n"); - err = TestReadTheCommissionerNodeId_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]\n"); - err = TestStep2ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining1ElementsGrantingItselfAdministerPrivilegesOnAllOfEndpoint0StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterNullEndpoint0DeviceTypeNull_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege)\n"); - err = TestStep3ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricScopedReadRequiresAdministerPrivilege_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep4ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep5ThSendsTheUpdateFabricLabelCommandToTheNodeOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); - err = TestStep6ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.\n"); - err = TestStep7ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilegeNoteThatThisWillCauseAnErrorToBeReturnedBecauseTheEnableKeyIsInvalidButStillIndicatesThatTheThPassedTheAclCheck_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); - err = TestStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); - err = TestStep9ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndManagePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldManage4CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); - err = TestStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 13a: Write NodeLabel attribute (Basic - requires manage)\n"); - err = TestStep13aWriteNodeLabelAttributeBasicRequiresManage_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 13b: Send TestEventTrigger (General Diagnostics - requires manage)\n"); - err = TestStep13bSendTestEventTriggerGeneralDiagnosticsRequiresManage_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 13c: Tead the VendorID attribute (Basic - requires view)\n"); - err = TestStep13cTeadTheVendorIDAttributeBasicRequiresView_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); - err = TestStep14ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndOperatePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldOperate3CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); - err = TestStep15aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesStep10PThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep15bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) \n"); - err = TestStep15cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); - err = TestStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); - err = TestStep17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); - err = TestStep18RepeatStep8ToConfirmThatTheThStillHasViewPrivilegesStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); - err = TestStep19Th1WritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndViewPrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); - err = TestStep20aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestStep20bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep20cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) \n"); - err = TestStep21aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); - err = TestStep21bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 22: Tead the VendorID attribute (Basic - requires view)\n"); - err = TestStep22TeadTheVendorIDAttributeBasicRequiresView_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]\n"); - err = TestStep23ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementGrantingAdministerPrivilegeOnOnlyTheAccessControlClusterAndNoOtherAccess1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint0_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) \n"); - err = TestStep24aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); - err = TestTStep24bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); - err = TestStep24cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); - err = TestStep25aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); - err = TestStep25bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); - err = TestStep26ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null\n"); - err = TestStep27ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementRestoringFullAccessToTheNodeStructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_37(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 38; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull commissionerNodeId; - - CHIP_ERROR TestReadTheCommissionerNodeId_1() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeId = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep2ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining1ElementsGrantingItselfAdministerPrivilegesOnAllOfEndpoint0StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterNullEndpoint0DeviceTypeNull_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]: Error: %@", err); - } else { - NSLog(@"Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricScopedReadRequiresAdministerPrivilege_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("NOCs", value, 1)); - VerifyOrReturn(CheckConstraintMaxLength("NOCs", value, 1)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsTheUpdateFabricLabelCommandToTheNodeOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilegeNoteThatThisWillCauseAnErrorToBeReturnedBecauseTheEnableKeyIsInvalidButStillIndicatesThatTheThPassedTheAclCheck_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndManagePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldManage4CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13aWriteNodeLabelAttributeBasicRequiresManage_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13a: Write NodeLabel attribute (Basic - requires manage): Error: %@", err); - } else { - NSLog(@"Step 13a: Write NodeLabel attribute (Basic - requires manage): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13bSendTestEventTriggerGeneralDiagnosticsRequiresManage_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13b: Send TestEventTrigger (General Diagnostics - requires manage): Error: %@", err); - } else { - NSLog(@"Step 13b: Send TestEventTrigger (General Diagnostics - requires manage): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13cTeadTheVendorIDAttributeBasicRequiresView_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13c: Tead the VendorID attribute (Basic - requires view): Error: %@", err); - } else { - NSLog(@"Step 13c: Tead the VendorID attribute (Basic - requires view): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndOperatePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldOperate3CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesStep10PThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) : Error: %@", err); - } else { - NSLog(@"Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18RepeatStep8ToConfirmThatTheThStillHasViewPrivilegesStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); - } else { - NSLog(@"Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19Th1WritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndViewPrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) : Error: %@", err); - } else { - NSLog(@"Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22TeadTheVendorIDAttributeBasicRequiresView_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: Tead the VendorID attribute (Basic - requires view): Error: %@", err); - } else { - NSLog(@"Step 22: Tead the VendorID attribute (Basic - requires view): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementGrantingAdministerPrivilegeOnOnlyTheAccessControlClusterAndNoOtherAccess1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint0_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) : Error: %@", err); - } else { - NSLog(@"Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTStep24bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id locationArgument; - locationArgument = @"XX"; - [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"TestFabric"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); - } else { - NSLog(@"Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"TestNode"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; - params.enableKey = - [[NSData alloc] initWithBytes:"0" length:1]; - params.eventTrigger = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster testEventTriggerWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); - } else { - NSLog(@"Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep26ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); - } else { - NSLog(@"Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep27ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementRestoringFullAccessToTheNodeStructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeId copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Error: %@", err); - } else { - NSLog(@"Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACE_1_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACE_1_5() - : TestCommandBridge("Test_TC_ACE_1_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("payload", &mPayload); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("waitAfterCommissioning", 0, UINT16_MAX, &mWaitAfterCommissioning); - AddArgument("PakeVerifier", &mPakeVerifier); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACE_1_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACE_1_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACE_1_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); - err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH1 reads the fabric index\n"); - err = TestTh1ReadsTheFabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2 & 3: TH1 puts DUT into commissioning mode, TH2 commissions DUT using admin node ID N2\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep23Th1PutsDutIntoCommissioningModeTh2CommissionsDutUsingAdminNodeIdN2_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH1 opens the commissioning window on the DUT\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep2Th1OpensTheCommissioningWindowOnTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Waiting after opening commissioning window\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestWaitingAfterOpeningCommissioningWindow_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH2 commissions DUT using admin node ID N2\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3Th2CommissionsDutUsingAdminNodeIdN2_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved for TH2\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4Th2ReadsItsFabricIndexFromTheOperationalCredentialsClusterCurrentFabricIndexAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH2 reads the fabric index\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4Th2ReadsTheFabricIndex_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read the commissioner node ID from the alpha fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheAlphaFabric_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]\n"); - err = TestStep5Th1WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterAccessControl0x001fEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldNullETargetsFieldClusterDescriptor0x001dEndpoint0_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read the commissioner node ID from the beta fabric\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestReadTheCommissionerNodeIdFromTheBetaFabric_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6Th2WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndexTh2FabricIndexBPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn2ETargetsFieldClusterAccessControl0x001fEndpoint0_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH2 writes ACL giving view privilge for basic cluster\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6Th2WritesAclGivingViewPrivilgeForBasicCluster_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute\n"); - err = TestStep7Th1ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute\n"); - err = TestStep8Th1ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep9Th2ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 9: TH2 reads descriptor cluster - expect UNSUPPORTED_ACCESS\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep9Th2ReadsDescriptorClusterExpectUnsupportedAccess_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute - expect SUCCESS\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttributeExpectSuccess_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null\n"); - err = TestStep11Th1ResetsTheACLsToTheDefaultValueBywritingDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining1Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandToTheDutWithTheFabricIndexSetToTh2FabricIndex_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric commandto the DUT with the FabricIndex set to th2FabricIndex\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandtoTheDutWithTheFabricIndexSetToTh2FabricIndex_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPayload; - chip::Optional mDiscriminator; - chip::Optional mWaitAfterCommissioning; - chip::Optional mPakeVerifier; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull th1FabricIndex; - - CHIP_ERROR TestTh1ReadsTheFabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 reads the fabric index: Error: %@", err); - } else { - NSLog(@"TH1 reads the fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th1FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23Th1PutsDutIntoCommissioningModeTh2CommissionsDutUsingAdminNodeIdN2_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2Th1OpensTheCommissioningWindowOnTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - params.pakePasscodeVerifier = mPakeVerifier.HasValue() ? [NSData dataWithBytes:mPakeVerifier.Value().data() length:mPakeVerifier.Value().size()] : [[NSData alloc] initWithBytes:"\xb9\x61\x70\xaa\xe8\x03\x34\x68\x84\x72\x4f\xe9\xa3\xb2\x87\xc3\x03\x30\xc2\xa6\x60\x37\x5d\x17\xbb\x20\x5a\x8c\xf1\xae\xcb\x35\x04\x57\xf8\xab\x79\xee\x25\x3a\xb6\xa8\xe4\x6b\xb0\x9e\x54\x3a\xe4\x22\x73\x6d\xe5\x01\xe3\xdb\x37\xd4\x41\xfe\x34\x49\x20\xd0\x95\x48\xe4\xc1\x82\x40\x63\x0c\x4f\xf4\x91\x3c\x53\x51\x38\x39\xb7\xc0\x7f\xcc\x06\x27\xa1\xb8\x57\x3a\x14\x9f\xcd\x1f\xa4\x66\xcf" length:97]; - params.discriminator = mDiscriminator.HasValue() ? [NSNumber numberWithUnsignedShort:mDiscriminator.Value()] : [NSNumber numberWithUnsignedShort:3840U]; - params.iterations = - [NSNumber numberWithUnsignedInt:1000UL]; - params.salt = - [[NSData alloc] initWithBytes:"SPAKE2P Key Salt" length:16]; - [cluster openCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH1 opens the commissioning window on the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH1 opens the commissioning window on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitingAfterOpeningCommissioningWindow_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mWaitAfterCommissioning.HasValue() ? mWaitAfterCommissioning.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3Th2CommissionsDutUsingAdminNodeIdN2_5() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("beta", value); - } - NSNumber * _Nonnull th2FabricIndex; - - CHIP_ERROR TestStep4Th2ReadsItsFabricIndexFromTheOperationalCredentialsClusterCurrentFabricIndexAttribute_7() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th2FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4Th2ReadsTheFabricIndex_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull commissionerNodeIdAlpha; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheAlphaFabric_9() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdAlpha = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep5Th1WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterAccessControl0x001fEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldNullETargetsFieldClusterDescriptor0x001dEndpoint0_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [th1FabricIndex copy]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:29UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [th1FabricIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdBeta; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheBetaFabric_11() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("beta", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdBeta = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep6Th2WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndexTh2FabricIndexBPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn2ETargetsFieldClusterAccessControl0x001fEndpoint0_12() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdBeta copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:31UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [th2FabricIndex copy]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:40UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [th2FabricIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]: Error: %@", err); - } else { - NSLog(@"Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6Th2WritesAclGivingViewPrivilgeForBasicCluster_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7Th1ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8Th1ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9Th2ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9Th2ReadsDescriptorClusterExpectUnsupportedAccess_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_18() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttributeExpectSuccess_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep11Th1ResetsTheACLsToTheDefaultValueBywritingDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining1Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdAlpha copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Error: %@", err); - } else { - NSLog(@"Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandToTheDutWithTheFabricIndexSetToTh2FabricIndex_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [th2FabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex: Error: %@", err); - } else { - NSLog(@"Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandtoTheDutWithTheFabricIndexSetToTh2FabricIndex_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_AIRQUAL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AIRQUAL_1_1() - : TestCommandBridge("Test_TC_AIRQUAL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AIRQUAL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AIRQUAL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AIRQUAL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!AIRQUAL.S.F00 && !AIRQUAL.S.F01 && !AIRQUAL.S.F02 && !AIRQUAL.S.F03")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenAIRQUALSF00FairEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenAIRQUALSF01ModerateEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenAIRQUALSF02VeryPoorEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("AIRQUAL.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenAIRQUALSF03ExtremelyPoorEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenAIRQUALSF00FairEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenAIRQUALSF01ModerateEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenAIRQUALSF02VeryPoorEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenAIRQUALSF03ExtremelyPoorEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_AIRQUAL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AIRQUAL_2_1() - : TestCommandBridge("Test_TC_AIRQUAL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AIRQUAL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AIRQUAL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AIRQUAL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the AirQuality attribute.\n"); - if (ShouldSkip("AIRQUAL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheAirQualityAttribute_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheAirQualityAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAirQualityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the AirQuality attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the AirQuality attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("airQuality", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("airQuality", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("airQuality", [value unsignedCharValue], 6U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BOOL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BOOL_1_1() - : TestCommandBridge("Test_TC_BOOL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BOOL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BOOL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BOOL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Read the global attribute: FeatureMap\n"); - err = TestStep3ReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ReadTheGlobalAttributeAttributeList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ReadTheGlobalAttributeAttributeList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("BOOL.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip(" !BOOL.S.E00 && PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BOOL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BOOL_2_1() - : TestCommandBridge("Test_TC_BOOL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BOOL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BOOL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BOOL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the StateValue attribute from the DUT\n"); - if (ShouldSkip("BOOL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheStateValueAttributeFromTheDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheStateValueAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the StateValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the StateValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("stateValue", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BRBINFO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BRBINFO_1_1() - : TestCommandBridge("Test_TC_BRBINFO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BRBINFO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BRBINFO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BRBINFO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(VendorName) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0001")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeVendorNameInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(VendorID) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeVendorIDInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(ProductName) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0003")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeProductNameInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(NodeLabel) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0005")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeNodeLabelInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0007")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeHardwareVersionInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0008")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeHardwareVersionStringInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0009")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributeSoftwareVersionInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000a")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeSoftwareVersionStringInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000b")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributeManufacturingDateInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4k: TH reads optional attribute(PartNumber) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000c")) { - NextTest(); - return; - } - err = TestStep4kThReadsOptionalAttributePartNumberInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4l: TH reads optional attribute(ProductURL) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000d")) { - NextTest(); - return; - } - err = TestStep4lThReadsOptionalAttributeProductURLInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4m: TH reads optional attribute(ProductLabel) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000e")) { - NextTest(); - return; - } - err = TestStep4mThReadsOptionalAttributeProductLabelInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4n: TH reads optional attribute(SerialNumber) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A000f")) { - NextTest(); - return; - } - err = TestStep4nThReadsOptionalAttributeSerialNumberInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4o: TH reads optional attribute(UniqueID) in AttributeList\n"); - if (ShouldSkip("BRBINFO.S.A0012")) { - NextTest(); - return; - } - err = TestStep4oThReadsOptionalAttributeUniqueIDInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5a: TH reads optional event(StartUp) in EventList\n"); - if (ShouldSkip("BRBINFO.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5b: TH reads optional attribute(ShutDown) in EventList\n"); - if (ShouldSkip("BRBINFO.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5c: TH reads optional attribute(Leave) in EventList\n"); - if (ShouldSkip("BRBINFO.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 6: TH reads AcceptedCommandList from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 7: TH1 reads GeneratedCommandList from DUT\n"); - err = TestStep7Th1ReadsGeneratedCommandListFromDut_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeVendorNameInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(VendorName) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(VendorName) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeVendorIDInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(VendorID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(VendorID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeProductNameInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(ProductName) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(ProductName) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeNodeLabelInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(NodeLabel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(NodeLabel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeHardwareVersionInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeHardwareVersionStringInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributeSoftwareVersionInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeSoftwareVersionStringInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributeManufacturingDateInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsOptionalAttributePartNumberInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads optional attribute(PartNumber) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads optional attribute(PartNumber) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsOptionalAttributeProductURLInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads optional attribute(ProductURL) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads optional attribute(ProductURL) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsOptionalAttributeProductLabelInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads optional attribute(ProductLabel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads optional attribute(ProductLabel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsOptionalAttributeSerialNumberInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads optional attribute(SerialNumber) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads optional attribute(SerialNumber) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsOptionalAttributeUniqueIDInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads optional attribute(UniqueID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads optional attribute(UniqueID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7Th1ReadsGeneratedCommandListFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACT_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACT_1_1() - : TestCommandBridge("Test_TC_ACT_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACT_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACT_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACT_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Read the global attribute: FeatureMap\n"); - err = TestStep3ReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: Read the optional attribute(SetupURL) in AttributeList\n"); - if (ShouldSkip("ACT.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeSetupURLInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_USER_PROMPT && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep5ThReadsEventListAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeSetupURLInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute(SetupURL) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute(SetupURL) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsEventListAttributeFromDut_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("acceptedCommandList", value, 11)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BIND_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BIND_1_1() - : TestCommandBridge("Test_TC_BIND_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BIND_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BIND_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BIND_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_1_1() - : TestCommandBridge("Test_TC_CC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); - if (ShouldSkip("( !CC.S.F00 && !CC.S.F01 && !CC.S.F02 && !CC.S.F03 && !CC.S.F04 )")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenCcsf00hsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenCCSF01EHueEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenCcsf02clEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenCcsf03xyEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenCcsf04ctEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentAttributeCurrentHueInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentAttributeCurrentSaturationInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList\n"); - if (ShouldSkip("CC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeRemainingTimeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003")) { - NextTest(); - return; - } - err = TestStep4eThReadsFeatureDependentAttributeCurrentXInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004")) { - NextTest(); - return; - } - err = TestStep4fThReadsFeatureDependentAttributeCurrentYInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList\n"); - if (ShouldSkip("CC.S.A0005")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeDriftCompensationInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4h: TH reads the optional attribute(CompensationText) in AttributeList\n"); - if (ShouldSkip("CC.S.A0006")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalAttributeCompensationTextInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep4iThReadsFeatureDependentAttributeColorTemperatureMiredsInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4j: TH reads the Primary1X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0011")) { - NextTest(); - return; - } - err = TestStep4jThReadsThePrimary1XAttributeInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4k: TH reads the Primary1Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0012")) { - NextTest(); - return; - } - err = TestStep4kThReadsThePrimary1YAttributeInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4l: TH reads the Primary1Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0013")) { - NextTest(); - return; - } - err = TestStep4lThReadsThePrimary1IntensityAttributeInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4m: TH reads the Primary2X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4mThReadsThePrimary2XAttributeInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4n: TH reads the Primary2Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0016")) { - NextTest(); - return; - } - err = TestStep4nThReadsThePrimary2YAttributeInAttributeList_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4o: TH reads the Primary2Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0017")) { - NextTest(); - return; - } - err = TestStep4oThReadsThePrimary2IntensityAttributeInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4p: TH reads the Primary3X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0019")) { - NextTest(); - return; - } - err = TestStep4pThReadsThePrimary3XAttributeInAttributeList_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4q: TH reads the Primary3Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A001a")) { - NextTest(); - return; - } - err = TestStep4qThReadsThePrimary3YAttributeInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4r: TH reads the Primary3Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A001b")) { - NextTest(); - return; - } - err = TestStep4rThReadsThePrimary3IntensityAttributeInAttributeList_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4s: TH reads the Primary4X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0020")) { - NextTest(); - return; - } - err = TestStep4sThReadsThePrimary4XAttributeInAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4t: TH reads the Primary4Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4tThReadsThePrimary4YAttributeInAttributeList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4u: TH reads the Primary4Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0022")) { - NextTest(); - return; - } - err = TestStep4uThReadsThePrimary4IntensityAttributeInAttributeList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4v: TH reads the Primary5X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0024")) { - NextTest(); - return; - } - err = TestStep4vThReadsThePrimary5XAttributeInAttributeList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4w: TH reads the Primary5Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0025")) { - NextTest(); - return; - } - err = TestStep4wThReadsThePrimary5YAttributeInAttributeList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4x: TH reads the Primary5Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0026")) { - NextTest(); - return; - } - err = TestStep4xThReadsThePrimary5IntensityAttributeInAttributeList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4y: TH reads the Primary6X attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0028")) { - NextTest(); - return; - } - err = TestStep4yThReadsThePrimary6XAttributeInAttributeList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4z: TH reads the Primary6Y attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A0029")) { - NextTest(); - return; - } - err = TestStep4zThReadsThePrimary6YAttributeInAttributeList_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4a1: TH reads the Primary6Intensity attribute in AttributeList\n"); - if (ShouldSkip("CC.S.A002a")) { - NextTest(); - return; - } - err = TestStep4a1ThReadsThePrimary6IntensityAttributeInAttributeList_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList\n"); - if (ShouldSkip("CC.S.A0030")) { - NextTest(); - return; - } - err = TestStep4a2ThReadsTheOptionalAttributeWhitePointXInAttributeList_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList\n"); - if (ShouldSkip("CC.S.A0031")) { - NextTest(); - return; - } - err = TestStep4a3ThReadsTheOptionalAttributeWhitePointYInAttributeList_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList\n"); - if (ShouldSkip("CC.S.A0032")) { - NextTest(); - return; - } - err = TestStep4a4ThReadsTheOptionalAttributeColorPointRXInAttributeList_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList\n"); - if (ShouldSkip("CC.S.A0033")) { - NextTest(); - return; - } - err = TestStep4a5ThReadsTheOptionalAttributeColorPointRYInAttributeList_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList\n"); - if (ShouldSkip("CC.S.A0034")) { - NextTest(); - return; - } - err = TestStep4a6ThReadsTheOptionalAttributeColorPointRIntensityInAttributeList_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList\n"); - if (ShouldSkip("CC.S.A0036")) { - NextTest(); - return; - } - err = TestStep4a7ThReadsTheOptionalAttributeColorPointGXInAttributeList_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList\n"); - if (ShouldSkip("CC.S.A0037")) { - NextTest(); - return; - } - err = TestStep4a8ThReadsTheOptionalAttributeColorPointGYInAttributeList_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList\n"); - if (ShouldSkip("CC.S.A0038")) { - NextTest(); - return; - } - err = TestStep4a9ThReadsTheOptionalAttributeColorPointGIntensityInAttributeList_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList\n"); - if (ShouldSkip("CC.S.A003a")) { - NextTest(); - return; - } - err = TestStep4a10ThReadsTheOptionalAttributeColorPointBXInAttributeList_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList\n"); - if (ShouldSkip("CC.S.A003b")) { - NextTest(); - return; - } - err = TestStep4a11ThReadsTheOptionalAttributeColorPointBYInAttributeList_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList\n"); - if (ShouldSkip("CC.S.A003c")) { - NextTest(); - return; - } - err = TestStep4a12ThReadsTheOptionalAttributeColorPointBIntensityInAttributeList_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep4a13ThReadsFeatureDependentAttributeEnhancedCurrentHueInAttributeList_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4002")) { - NextTest(); - return; - } - err = TestStep4a14ThReadsFeatureDependentAttributeColorLoopActiveInAttributeList_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4003")) { - NextTest(); - return; - } - err = TestStep4a15ThReadsFeatureDependentAttributeColorLoopDirectionInAttributeList_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4004")) { - NextTest(); - return; - } - err = TestStep4a16ThReadsFeatureDependentAttributeColorLoopTimeInAttributeList_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4005")) { - NextTest(); - return; - } - err = TestStep4a17ThReadsFeatureDependentAttributeColorLoopStartEnhancedHueInAttributeList_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.A4006")) { - NextTest(); - return; - } - err = TestStep4a18ThReadsFeatureDependentAttributeColorLoopStoredEnhancedHueInAttributeList_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep4a19ThReadsFeatureDependentAttributeColorTempPhysicalMinMiredsInAttributeList_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep4a20ThReadsFeatureDependentAttributeColorTempPhysicalMaxMiredsInAttributeList_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400d")) { - NextTest(); - return; - } - err = TestStep4a21THReadsFeatureDependentAttributeCoupleColorTempToLevelMinMiredsInAttributeList_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4010")) { - NextTest(); - return; - } - err = TestStep4a22ThReadsFeatureDependentAttributeStartUpColorTemperatureMiredsInAttributeList_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsFeatureDependentCommandMoveToHueInAcceptedCommandList_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentCommandMoveHueInAcceptedCommandList_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsFeatureDependentCommandStepHueInAcceptedCommandList_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadsFeatureDependentCommandMoveToSaturationInAcceptedCommandList_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep6eThReadsFeatureDependentCommandMoveSaturationInAcceptedCommandList_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep6fThReadsFeatureDependentCommandStepSaturationInAcceptedCommandList_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep6gThReadsFeatureDependentCommandMoveToHueAndSaturationInAcceptedCommandList_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep6hThReadsFeatureDependentCommandMoveToColorInAcceptedCommandList_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep6iThReadsFeatureDependentCommandMoveColorInAcceptedCommandList_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep6jThReadsFeatureDependentCommandStepColorInAcceptedCommandList_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep6kThReadsFeatureDependentCommandMoveToColorTemperatureInAcceptedCommandList_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep6lThReadsFeatureDependentCommandEnhancedMoveToHueInAcceptedCommandList_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep6mThReadsFeatureDependentCommandEnhancedMoveHueInAcceptedCommandList_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { - NextTest(); - return; - } - err = TestStep6nThReadsFeatureDependentCommandEnhancedStepHueInAcceptedCommandList_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { - NextTest(); - return; - } - err = TestStep6oTHReadsFeatureDependentCommandEnhancedMoveToHueAndSaturationInAcceptedCommandList_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F02 && CC.S.C44.Rsp")) { - NextTest(); - return; - } - err = TestStep6pThReadsFeatureDependentCommandColorLoopSetInAcceptedCommandList_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F00 && CC.S.F03 && CC.S.F04 && CC.S.C47.Rsp")) { - NextTest(); - return; - } - err = TestStep6qThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C4b.Rsp")) { - NextTest(); - return; - } - err = TestStep6rThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C4c.Rsp")) { - NextTest(); - return; - } - err = TestStep6sThReadsFeatureDependentCommandStepColorTemperatureInAcceptedCommandList_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_77(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 78; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 6U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenCcsf00hsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenCCSF01EHueEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenCcsf02clEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenCcsf03xyEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenCcsf04ctEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16394UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16394UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeCurrentHueInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeCurrentSaturationInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeRemainingTimeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFeatureDependentAttributeCurrentXInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsFeatureDependentAttributeCurrentYInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeDriftCompensationInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalAttributeCompensationTextInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional attribute(CompensationText) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional attribute(CompensationText) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsFeatureDependentAttributeColorTemperatureMiredsInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsThePrimary1XAttributeInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the Primary1X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the Primary1X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsThePrimary1YAttributeInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads the Primary1Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads the Primary1Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsThePrimary1IntensityAttributeInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads the Primary1Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads the Primary1Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsThePrimary2XAttributeInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads the Primary2X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads the Primary2X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsThePrimary2YAttributeInAttributeList_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads the Primary2Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads the Primary2Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsThePrimary2IntensityAttributeInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads the Primary2Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads the Primary2Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsThePrimary3XAttributeInAttributeList_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads the Primary3X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads the Primary3X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsThePrimary3YAttributeInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: TH reads the Primary3Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4q: TH reads the Primary3Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rThReadsThePrimary3IntensityAttributeInAttributeList_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4r: TH reads the Primary3Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4r: TH reads the Primary3Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4sThReadsThePrimary4XAttributeInAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4s: TH reads the Primary4X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4s: TH reads the Primary4X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4tThReadsThePrimary4YAttributeInAttributeList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4t: TH reads the Primary4Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4t: TH reads the Primary4Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4uThReadsThePrimary4IntensityAttributeInAttributeList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4u: TH reads the Primary4Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4u: TH reads the Primary4Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4vThReadsThePrimary5XAttributeInAttributeList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4v: TH reads the Primary5X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4v: TH reads the Primary5X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4wThReadsThePrimary5YAttributeInAttributeList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4w: TH reads the Primary5Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4w: TH reads the Primary5Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4xThReadsThePrimary5IntensityAttributeInAttributeList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4x: TH reads the Primary5Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4x: TH reads the Primary5Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4yThReadsThePrimary6XAttributeInAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4y: TH reads the Primary6X attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4y: TH reads the Primary6X attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4zThReadsThePrimary6YAttributeInAttributeList_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4z: TH reads the Primary6Y attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4z: TH reads the Primary6Y attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a1ThReadsThePrimary6IntensityAttributeInAttributeList_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a1: TH reads the Primary6Intensity attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a1: TH reads the Primary6Intensity attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a2ThReadsTheOptionalAttributeWhitePointXInAttributeList_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a3ThReadsTheOptionalAttributeWhitePointYInAttributeList_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a4ThReadsTheOptionalAttributeColorPointRXInAttributeList_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a5ThReadsTheOptionalAttributeColorPointRYInAttributeList_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a6ThReadsTheOptionalAttributeColorPointRIntensityInAttributeList_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a7ThReadsTheOptionalAttributeColorPointGXInAttributeList_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a8ThReadsTheOptionalAttributeColorPointGYInAttributeList_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a9ThReadsTheOptionalAttributeColorPointGIntensityInAttributeList_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a10ThReadsTheOptionalAttributeColorPointBXInAttributeList_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a11ThReadsTheOptionalAttributeColorPointBYInAttributeList_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a12ThReadsTheOptionalAttributeColorPointBIntensityInAttributeList_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a13ThReadsFeatureDependentAttributeEnhancedCurrentHueInAttributeList_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a14ThReadsFeatureDependentAttributeColorLoopActiveInAttributeList_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16386UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a15ThReadsFeatureDependentAttributeColorLoopDirectionInAttributeList_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16387UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a16ThReadsFeatureDependentAttributeColorLoopTimeInAttributeList_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16388UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a17ThReadsFeatureDependentAttributeColorLoopStartEnhancedHueInAttributeList_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16389UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a18ThReadsFeatureDependentAttributeColorLoopStoredEnhancedHueInAttributeList_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16390UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a19ThReadsFeatureDependentAttributeColorTempPhysicalMinMiredsInAttributeList_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16395UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a20ThReadsFeatureDependentAttributeColorTempPhysicalMaxMiredsInAttributeList_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16396UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a21THReadsFeatureDependentAttributeCoupleColorTempToLevelMinMiredsInAttributeList_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16397UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a22ThReadsFeatureDependentAttributeStartUpColorTemperatureMiredsInAttributeList_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16400UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFeatureDependentCommandMoveToHueInAcceptedCommandList_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentCommandMoveHueInAcceptedCommandList_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsFeatureDependentCommandStepHueInAcceptedCommandList_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsFeatureDependentCommandMoveToSaturationInAcceptedCommandList_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThReadsFeatureDependentCommandMoveSaturationInAcceptedCommandList_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThReadsFeatureDependentCommandStepSaturationInAcceptedCommandList_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gThReadsFeatureDependentCommandMoveToHueAndSaturationInAcceptedCommandList_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6hThReadsFeatureDependentCommandMoveToColorInAcceptedCommandList_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6iThReadsFeatureDependentCommandMoveColorInAcceptedCommandList_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6jThReadsFeatureDependentCommandStepColorInAcceptedCommandList_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6kThReadsFeatureDependentCommandMoveToColorTemperatureInAcceptedCommandList_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6lThReadsFeatureDependentCommandEnhancedMoveToHueInAcceptedCommandList_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6mThReadsFeatureDependentCommandEnhancedMoveHueInAcceptedCommandList_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 65UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6nThReadsFeatureDependentCommandEnhancedStepHueInAcceptedCommandList_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 66UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6oTHReadsFeatureDependentCommandEnhancedMoveToHueAndSaturationInAcceptedCommandList_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 67UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6pThReadsFeatureDependentCommandColorLoopSetInAcceptedCommandList_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 68UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6qThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 71UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6rThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 75UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6sThReadsFeatureDependentCommandStepColorTemperatureInAcceptedCommandList_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 76UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_2_1() - : TestCommandBridge("Test_TC_CC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute\n"); - if (ShouldSkip("CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutThe0x0000CurrentHueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute\n"); - if (ShouldSkip("CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutThe0x0001CurrentSaturationAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute\n"); - if (ShouldSkip("CC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutThe0x0002RemainingTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the (0x0003) CurrentX attribute\n"); - if (ShouldSkip("CC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThe0x0003CurrentXAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the (0x0004) CurrentY attribute\n"); - if (ShouldSkip("CC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThe0x0004CurrentYAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute\n"); - if (ShouldSkip("CC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutThe0x0005DriftCompensationAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the (0x0006) CompensationText attribute\n"); - if (ShouldSkip("CC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutThe0x0006CompensationTextAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutThe0x0007ColorTemperatureMiredsAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the (0x0008) ColorMode attribute\n"); - if (ShouldSkip("CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutThe0x0008ColorModeAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the (0x000f) Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutThe0x000fOptionsAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute\n"); - if (ShouldSkip("CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutThe0x4000EnhancedCurrentHueAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute\n"); - if (ShouldSkip("CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutThe0x4001EnhancedColorModeAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute\n"); - if (ShouldSkip("CC.S.A4002")) { - NextTest(); - return; - } - err = TestStep14thReadsFromTheDutThe0x4002ColorLoopActiveAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute\n"); - if (ShouldSkip("CC.S.A4003")) { - NextTest(); - return; - } - err = TestStep15ThReadsFromTheDutThe0x4003ColorLoopDirectionAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute\n"); - if (ShouldSkip("CC.S.A4004")) { - NextTest(); - return; - } - err = TestStep16ThReadsFromTheDutThe0x4004ColorLoopTimeAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute\n"); - if (ShouldSkip("CC.S.A4005")) { - NextTest(); - return; - } - err = TestStep17ThReadsFromTheDutThe0x4005ColorLoopStartEnhancedHueAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT\n"); - if (ShouldSkip("CC.S.A4006")) { - NextTest(); - return; - } - err = TestStep18ThReadsFromTheDutThe0x4006ColorLoopStoredEnhancedHueAttributeT_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT\n"); - err = TestStep18aSavingForComparisionInStep19ReadsFeatureMapAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute\n"); - if (ShouldSkip("CC.S.A400a")) { - NextTest(); - return; - } - err = TestStep19ThReadsFromTheDutThe0x400aColorCapabilitiesAttribute_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute\n"); - if (ShouldSkip("CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep20ThReadsFromTheDutThe0x400bColorTempPhysicalMinMiredsAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute\n"); - if (ShouldSkip("CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep21ThReadsFromTheDutThe0x400cColorTempPhysicalMaxMiredsAttribute_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute\n"); - if (ShouldSkip("CC.S.A400d")) { - NextTest(); - return; - } - err = TestStep22ThReadsFromTheDutThe0x400dCoupleColorTempToLevelMinMiredsAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.A4010")) { - NextTest(); - return; - } - err = TestStep23ThReadsFromTheDutThe0x4010StartUpColorTemperatureMiredsAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute\n"); - if (ShouldSkip("CC.S.A0010")) { - NextTest(); - return; - } - err = TestStep24ThReadsFromTheDutThe0x0010NumberOfPrimariesAttribute_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 25: TH reads Primary1X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 1 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0011")) { - NextTest(); - return; - } - err = TestStep25ThReadsPrimary1XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 26: TH reads Primary1Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 1 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0012")) { - NextTest(); - return; - } - err = TestStep26ThReadsPrimary1YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 27: TH reads Primary1Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 1 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0013")) { - NextTest(); - return; - } - err = TestStep27ThReadsPrimary1IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs1OrMore_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 28: TH reads Primary2X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 2 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0015")) { - NextTest(); - return; - } - err = TestStep28ThReadsPrimary2XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 29: TH reads Primary2Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 2 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0016")) { - NextTest(); - return; - } - err = TestStep29ThReadsPrimary2YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 30: TH reads Primary2Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 2 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0017")) { - NextTest(); - return; - } - err = TestStep30ThReadsPrimary2IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs2OrMore_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 31: TH reads Primary3X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 3 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0019")) { - NextTest(); - return; - } - err = TestStep31ThReadsPrimary3XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 32: TH reads Primary3Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 3 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A001a")) { - NextTest(); - return; - } - err = TestStep32ThReadsPrimary3YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 33: TH reads Primary3Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 3 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A001b")) { - NextTest(); - return; - } - err = TestStep33ThReadsPrimary3IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs3OrMore_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 34: TH reads Primary4X attribute from DUT Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 4 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0020")) { - NextTest(); - return; - } - err = TestStep34ThReadsPrimary4XAttributeFromDutVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 35: TH reads Primary4Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 4 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0021")) { - NextTest(); - return; - } - err = TestStep35ThReadsPrimary4YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 36: TH reads Primary4Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 4 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0022")) { - NextTest(); - return; - } - err = TestStep36ThReadsPrimary4IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs4OrMore_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 37: TH reads Primary5X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 5 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0024")) { - NextTest(); - return; - } - err = TestStep37ThReadsPrimary5XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 38: TH reads Primary5Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 5 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0025")) { - NextTest(); - return; - } - err = TestStep38ThReadsPrimary5YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 39: TH reads Primary5Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 5 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0026")) { - NextTest(); - return; - } - err = TestStep39ThReadsPrimary5IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs5OrMore_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 40: TH reads Primary6X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 6 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0028")) { - NextTest(); - return; - } - err = TestStep40ThReadsPrimary6XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 41: TH reads Primary6Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 6 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0029")) { - NextTest(); - return; - } - err = TestStep41ThReadsPrimary6YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 42: TH reads Primary6Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 6 or more\n"); - if (ShouldSkip("PICS_USER_PROMPT && CC.S.A002a")) { - NextTest(); - return; - } - err = TestStep42ThReadsPrimary6IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs6OrMore_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute\n"); - if (ShouldSkip("CC.S.A0030")) { - NextTest(); - return; - } - err = TestStep43ThReadsFromTheDutThe0x0030WhitePointXAttribute_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute\n"); - if (ShouldSkip("CC.S.A0031")) { - NextTest(); - return; - } - err = TestStep44ThReadsFromTheDutThe0x0031WhitePointYAttribute_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute\n"); - if (ShouldSkip("CC.S.A0032")) { - NextTest(); - return; - } - err = TestStep45ThReadsFromTheDutThe0x0032ColorPointRXAttribute_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute\n"); - if (ShouldSkip("CC.S.A0033")) { - NextTest(); - return; - } - err = TestStep46ThReadsFromTheDutThe0x0033ColorPointRYAttribute_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute\n"); - if (ShouldSkip("CC.S.A0034")) { - NextTest(); - return; - } - err = TestStep47ThReadsFromTheDutThe0x0034ColorPointRIntensityAttribute_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute\n"); - if (ShouldSkip("CC.S.A0036")) { - NextTest(); - return; - } - err = TestStep48ThReadsFromTheDutThe0x0036ColorPointGXAttribute_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute\n"); - if (ShouldSkip("CC.S.A0037")) { - NextTest(); - return; - } - err = TestStep49ThReadsFromTheDutThe0x0037ColorPointGYAttribute_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute\n"); - if (ShouldSkip("CC.S.A0038")) { - NextTest(); - return; - } - err = TestStep50ThReadsFromTheDutThe0x0038ColorPointGIntensityAttribute_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute\n"); - if (ShouldSkip("CC.S.A003a")) { - NextTest(); - return; - } - err = TestStep51ThReadsFromTheDutThe0x003aColorPointBXAttribute_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute\n"); - if (ShouldSkip("CC.S.A003b")) { - NextTest(); - return; - } - err = TestStep52ThReadsFromTheDutThe0x003bColorPointBYAttribute_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute\n"); - if (ShouldSkip("CC.S.A003c")) { - NextTest(); - return; - } - err = TestStep53ThReadsFromTheDutThe0x003cColorPointBIntensityAttribute_53(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 54; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0x0000CurrentHueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentHue", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutThe0x0001CurrentSaturationAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentSaturation", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutThe0x0002RemainingTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRemainingTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("remainingTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("remainingTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("remainingTime", [value unsignedShortValue], 65534U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThe0x0003CurrentXAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the (0x0003) CurrentX attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the (0x0003) CurrentX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThe0x0004CurrentYAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the (0x0004) CurrentY attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the (0x0004) CurrentY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0x0005DriftCompensationAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDriftCompensationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("driftCompensation", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("driftCompensation", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("driftCompensation", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutThe0x0006CompensationTextAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCompensationTextWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the (0x0006) CompensationText attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the (0x0006) CompensationText attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("compensationText", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("compensationText", value, 254)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutThe0x0007ColorTemperatureMiredsAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutThe0x0008ColorModeAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the (0x0008) ColorMode attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the (0x0008) ColorMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutThe0x000fOptionsAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the (0x000f) Options attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the (0x000f) Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("options", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("options", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("options", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutThe0x4000EnhancedCurrentHueAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutThe0x4001EnhancedColorModeAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedColorMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14thReadsFromTheDutThe0x4002ColorLoopActiveAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute: Error: %@", err); - } else { - NSLog(@"Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopActive", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopActive", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopActive", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15ThReadsFromTheDutThe0x4003ColorLoopDirectionAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute: Error: %@", err); - } else { - NSLog(@"Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopDirection", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopDirection", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopDirection", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThReadsFromTheDutThe0x4004ColorLoopTimeAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute: Error: %@", err); - } else { - NSLog(@"Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThReadsFromTheDutThe0x4005ColorLoopStartEnhancedHueAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute: Error: %@", err); - } else { - NSLog(@"Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopStartEnhancedHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopStartEnhancedHue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopStartEnhancedHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18ThReadsFromTheDutThe0x4006ColorLoopStoredEnhancedHueAttributeT_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT: Error: %@", err); - } else { - NSLog(@"Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorLoopStoredEnhancedHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorLoopStoredEnhancedHue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorLoopStoredEnhancedHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull FeatureMapValue; - - CHIP_ERROR TestStep18aSavingForComparisionInStep19ReadsFeatureMapAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - FeatureMapValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19ThReadsFromTheDutThe0x400aColorCapabilitiesAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorCapabilitiesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute: Error: %@", err); - } else { - NSLog(@"Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorCapabilities", actualValue, FeatureMapValue)); - } - - VerifyOrReturn(CheckConstraintType("colorCapabilities", "bitmap16", "bitmap16")); - VerifyOrReturn(CheckConstraintMinValue("colorCapabilities", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorCapabilities", [value unsignedShortValue], 31U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20ThReadsFromTheDutThe0x400bColorTempPhysicalMinMiredsAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21ThReadsFromTheDutThe0x400cColorTempPhysicalMaxMiredsAttribute_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22ThReadsFromTheDutThe0x400dCoupleColorTempToLevelMinMiredsAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCoupleColorTempToLevelMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("coupleColorTempToLevelMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("coupleColorTempToLevelMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("coupleColorTempToLevelMinMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThReadsFromTheDutThe0x4010StartUpColorTemperatureMiredsAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24ThReadsFromTheDutThe0x0010NumberOfPrimariesAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfPrimariesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute: Error: %@", err); - } else { - NSLog(@"Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("numberOfPrimaries", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("numberOfPrimaries", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfPrimaries", [value unsignedCharValue], 6U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25ThReadsPrimary1XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_25() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep26ThReadsPrimary1YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_26() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep27ThReadsPrimary1IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs1OrMore_27() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep28ThReadsPrimary2XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_28() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep29ThReadsPrimary2YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_29() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep30ThReadsPrimary2IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs2OrMore_30() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep31ThReadsPrimary3XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_31() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep32ThReadsPrimary3YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_32() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep33ThReadsPrimary3IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs3OrMore_33() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep34ThReadsPrimary4XAttributeFromDutVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_34() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep35ThReadsPrimary4YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_35() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep36ThReadsPrimary4IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs4OrMore_36() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep37ThReadsPrimary5XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_37() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep38ThReadsPrimary5YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_38() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep39ThReadsPrimary5IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs5OrMore_39() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep40ThReadsPrimary6XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_40() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep41ThReadsPrimary6YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_41() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep42ThReadsPrimary6IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs6OrMore_42() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep43ThReadsFromTheDutThe0x0030WhitePointXAttribute_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWhitePointXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute: Error: %@", err); - } else { - NSLog(@"Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("whitePointX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("whitePointX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("whitePointX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep44ThReadsFromTheDutThe0x0031WhitePointYAttribute_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWhitePointYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute: Error: %@", err); - } else { - NSLog(@"Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("whitePointY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("whitePointY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("whitePointY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep45ThReadsFromTheDutThe0x0032ColorPointRXAttribute_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointRXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute: Error: %@", err); - } else { - NSLog(@"Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointRX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointRX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointRX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep46ThReadsFromTheDutThe0x0033ColorPointRYAttribute_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointRYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute: Error: %@", err); - } else { - NSLog(@"Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointRY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointRY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointRY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep47ThReadsFromTheDutThe0x0034ColorPointRIntensityAttribute_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointRIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute: Error: %@", err); - } else { - NSLog(@"Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("colorPointRIntensity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointRIntensity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointRIntensity", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep48ThReadsFromTheDutThe0x0036ColorPointGXAttribute_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointGXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute: Error: %@", err); - } else { - NSLog(@"Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointGX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointGX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointGX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep49ThReadsFromTheDutThe0x0037ColorPointGYAttribute_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointGYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute: Error: %@", err); - } else { - NSLog(@"Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointGY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointGY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointGY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep50ThReadsFromTheDutThe0x0038ColorPointGIntensityAttribute_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointGIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute: Error: %@", err); - } else { - NSLog(@"Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("colorPointGIntensity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointGIntensity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointGIntensity", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep51ThReadsFromTheDutThe0x003aColorPointBXAttribute_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointBXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute: Error: %@", err); - } else { - NSLog(@"Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointBX", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointBX", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointBX", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep52ThReadsFromTheDutThe0x003bColorPointBYAttribute_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointBYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute: Error: %@", err); - } else { - NSLog(@"Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorPointBY", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointBY", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointBY", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep53ThReadsFromTheDutThe0x003cColorPointBIntensityAttribute_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorPointBIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute: Error: %@", err); - } else { - NSLog(@"Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("colorPointBIntensity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("colorPointBIntensity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorPointBIntensity", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_3_2() - : TestCommandBridge("Test_TC_CC_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveHueCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentHueAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2fThReadsCurrentHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 2s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait2s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2g: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2gThReadsCurrentHueAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToHueCommandToDutWithHue60Direction0x00ShortestDistanceAndTransitionTime0Immediately_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsMoveHueCommandToDutWithMoveMode0x03DownAndRate5UnitsS_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentHueAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentHueAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3f: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3fThReadsCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Wait 2s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait2s_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3g: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3gThReadsCurrentHueAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 31; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:200U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveHueCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:1U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentHueAttributeFromDut_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 38U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 52U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsCurrentHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 80U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 110U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2gThReadsCurrentHueAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2g: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 80U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 110U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToHueCommandToDutWithHue60Direction0x00ShortestDistanceAndTransitionTime0Immediately_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:60U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsMoveHueCommandToDutWithMoveMode0x03DownAndRate5UnitsS_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:3U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 4U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 16U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 183U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 247U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 140U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 190U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2s_25() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3gThReadsCurrentHueAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 140U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 190U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_3_3() - : TestCommandBridge("Test_TC_CC_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsStepHueCommandToDutWithStepMode0x01UpStepSize60AndTransitionTime20020s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentHueAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentHueAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToHueCommandToDutWithHue50Direction0x00ShortestDistanceAndTransitionTime0Immediately_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsStepHueCommandToDutWithStepMode0x03DownStepSize60AndTransitionTime20020s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentHueAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentHueAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentHueAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_24(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 25; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:200U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsStepHueCommandToDutWithStepMode0x01UpStepSize60AndTransitionTime20020s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:60U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentHueAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 195U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentHueAttributeFromDut_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait5s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentHueAttributeFromDut_11() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3aThSendsMoveToHueCommandToDutWithHue50Direction0x00ShortestDistanceAndTransitionTime0Immediately_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:50U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsStepHueCommandToDutWithStepMode0x03DownStepSize60AndTransitionTime20020s_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:60U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 17U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 23U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 208U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentHueAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 208U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_1() - : TestCommandBridge("Test_TC_CC_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("SaturationConfigValue", 0, UINT8_MAX, &mSaturationConfigValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation60AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime30030s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2f: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2fThReadsCurrentSaturationAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep3aThReadsColorModeAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep3bThReadsEnhancedColorModeAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mSaturationConfigValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation60AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:60U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime30030s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 80U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 115U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 102U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 138U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsCurrentSaturationAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 102U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 138U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsColorModeAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsEnhancedColorModeAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_2() - : TestCommandBridge("Test_TC_CC_4_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime0Immediately_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsMoveSaturationCommandToDutWithMoveMode0x03DownAndRate5UnitsS_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentSaturationAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentSaturationAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentSaturationAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsCurrentSaturationAttributeFromDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThSendsMoveSaturationCommandToDutWithMoveMode0x00StopAndRate5UnitsS_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4eThReadsCurrentSaturationAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Wait 2s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait2s_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4f: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep4fThReadsCurrentSaturationAttributeFromDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep5aThReadsColorModeAttributeFromDut_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep5bThReadsEnhancedColorModeAttributeFromDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_33(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 34; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:150U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:1U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime0Immediately_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsMoveSaturationCommandToDutWithMoveMode0x03DownAndRate5UnitsS_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:3U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentSaturationAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 59U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 81U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 5U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 35U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentSaturationAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 10U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:150U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:1U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_24() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cThReadsCurrentSaturationAttributeFromDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThSendsMoveSaturationCommandToDutWithMoveMode0x00StopAndRate5UnitsS_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsCurrentSaturationAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2s_28() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4fThReadsCurrentSaturationAttributeFromDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThReadsColorModeAttributeFromDut_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsEnhancedColorModeAttributeFromDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_3() - : TestCommandBridge("Test_TC_CC_4_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation200AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize40AndTransitionTime20020s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize20AndTransitionTime10010s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2g: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2gThReadsCurrentSaturationAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation50AndTransitionTime0Immediately_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize40AndTransitionTime20020s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3c: H reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cHReadsCurrentSaturationAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentSaturationAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3e: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentSaturationAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep3fThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize20AndTransitionTime10010S_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3g: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3gThReadsCurrentSaturationAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4b: H reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bHReadsEnhancedColorModeAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 31; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation200AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize40AndTransitionTime20020s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:40U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 187U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 253U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 204U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 204U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize20AndTransitionTime10010s_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:20U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:100U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s): Error: %@", err); - } else { - NSLog(@"Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2gThReadsCurrentSaturationAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2g: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation50AndTransitionTime0Immediately_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; - params.saturation = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize40AndTransitionTime20020s_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:40U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cHReadsCurrentSaturationAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: H reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: H reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 25U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 35U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 8U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 12U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentSaturationAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 8U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 12U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize20AndTransitionTime10010S_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:20U]; - params.transitionTime = - [NSNumber numberWithUnsignedChar:100U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s): Error: %@", err); - } else { - NSLog(@"Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_25() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3gThReadsCurrentSaturationAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentSaturation", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bHReadsEnhancedColorModeAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: H reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: H reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_4_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_4_4() - : TestCommandBridge("Test_TC_CC_4_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_4_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToHueAndSaturationCommandToDutWithHue200Saturation50AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentHue attribute from DUT.\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentHueAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2b1ThReadsCurrentSaturationAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToHueAndSaturationCommandToDutWithHue160Saturation80AndTransitionTime20020s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3b1ThReadsCurrentSaturationAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3c1ThReadsCurrentSaturationAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); - if (ShouldSkip("CC.S.F00")) { - NextTest(); - return; - } - err = TestWait5s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads CurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d1: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3d1ThReadsCurrentSaturationAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToHueAndSaturationCommandToDutWithHue200Saturation50AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueAndSaturationParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:200U]; - params.saturation = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsCurrentHueAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 230U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2b1ThReadsCurrentSaturationAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 42U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 58U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToHueAndSaturationCommandToDutWithHue160Saturation80AndTransitionTime20020s_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToHueAndSaturationParams alloc] init]; - params.hue = - [NSNumber numberWithUnsignedChar:160U]; - params.saturation = - [NSNumber numberWithUnsignedChar:80U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 160U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3b1ThReadsCurrentSaturationAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 50U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 80U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 135U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 185U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3c1ThReadsCurrentSaturationAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentSaturation", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 135U)); - VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 185U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3d1ThReadsCurrentSaturationAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d1: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_5_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_5_1() - : TestCommandBridge("Test_TC_CC_5_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_5_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentXAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b1: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004")) { - NextTest(); - return; - } - err = TestStep2b1ThReadsCurrentYAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime20020s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentXAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentYAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentXAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentYAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait5s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentXAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentYAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep4aThWrites0ToTheOptionsAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH read Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep4bThReadOptionsAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4cThSendsOnCommandToDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThSendsAMoveToColorCommandToTheDutWithColorX327680x8000X05PurpleColorY196600x4CCCY03TransitionTime0Immediate_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4e: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4eThReadsCurrentXAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4e: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4eThReadsCurrentYAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4fThSendsOffCommandToDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4h: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4hThReadsCurrentXAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4h: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4hThReadsCurrentYAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4j: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4jThReadsCurrentXAttributeFromDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4j: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4jThReadsCurrentYAttributeFromDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4i: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThReadsCurrentXAttributeFromDut_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4i: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThReadsCurrentYAttributeFromDut_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5a: TH writes 1 to the Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep5aThWrites1ToTheOptionsAttribute_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 5b: TH read Options attribute\n"); - if (ShouldSkip("CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep5bThReadOptionsAttribute_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 5c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThSendsOnCommandToDut_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5dThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 5e: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5eThReadsCurrentXAttributeFromDut_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 5e: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5eThReadsCurrentYAttributeFromDut_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 5f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5fThSendsOffCommandToDut_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 5h: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5hThReadsCurrentXAttributeFromDut_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 5h: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5hThReadsCurrentYAttributeFromDut_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 5j: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5jThReadsCurrentXAttributeFromDut_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 5j: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5jThReadsCurrentYAttributeFromDut_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Step 5l: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5lThReadsCurrentXAttributeFromDut_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Step 5l: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5lThReadsCurrentYAttributeFromDut_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Step 6a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep6aThReadsColorModeAttributeFromDut_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Step 6b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep6bThReadsEnhancedColorModeAttributeFromDut_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_60(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 61; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:32768U]; - params.colorY = - [NSNumber numberWithUnsignedShort:19660U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsCurrentXAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2b1ThReadsCurrentYAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b1: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b1: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime20020s_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:13107U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 13107U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 32768U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 13107U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 19660U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentXAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentYAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentXAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsCurrentYAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrites0ToTheOptionsAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadOptionsAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH read Options attribute: Error: %@", err); - } else { - NSLog(@"Step 4b: TH read Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThSendsOnCommandToDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThSendsAMoveToColorCommandToTheDutWithColorX327680x8000X05PurpleColorY196600x4CCCY03TransitionTime0Immediate_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:32768U]; - params.colorY = - [NSNumber numberWithUnsignedShort:19660U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eThReadsCurrentXAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsCurrentYAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThSendsOffCommandToDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:13107U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_26() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4hThReadsCurrentXAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentX", actualValue, 32768U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsCurrentYAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentY", actualValue, 19660U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4jThReadsCurrentXAttributeFromDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentX", actualValue, 32768U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsCurrentYAttributeFromDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentY", actualValue, 19660U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:26214U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_34() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4iThReadsCurrentXAttributeFromDut_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 22282U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 30146U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsCurrentYAttributeFromDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrites1ToTheOptionsAttribute_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH writes 1 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 5a: TH writes 1 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadOptionsAttribute_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH read Options attribute: Error: %@", err); - } else { - NSLog(@"Step 5b: TH read Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsOnCommandToDut_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:32768U]; - params.colorY = - [NSNumber numberWithUnsignedShort:19660U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_41() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5eThReadsCurrentXAttributeFromDut_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5e: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5e: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5eThReadsCurrentYAttributeFromDut_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5e: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5e: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5fThSendsOffCommandToDut_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:13107U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_46() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5hThReadsCurrentXAttributeFromDut_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5h: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5h: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5hThReadsCurrentYAttributeFromDut_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5h: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5h: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:13107U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_50() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5jThReadsCurrentXAttributeFromDut_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5j: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5j: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentX", actualValue, 13107U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5jThReadsCurrentYAttributeFromDut_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5j: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5j: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentY", actualValue, 13107U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:26214U]; - params.colorY = - [NSNumber numberWithUnsignedShort:32768U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_54() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5lThReadsCurrentXAttributeFromDut_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5l: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5l: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 22282U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 30146U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5lThReadsCurrentYAttributeFromDut_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5l: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5l: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 27853U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 37683U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsColorModeAttributeFromDut_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsEnhancedColorModeAttributeFromDut_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_5_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_5_2() - : TestCommandBridge("Test_TC_CC_5_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_5_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsMoveToColorCommandToDutWithColorX33000ColorY26000TransitionTime0Immediate_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH sends MoveColor command to DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveColorCommandToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentXAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentYAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentXAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsCurrentYAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2d: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentXAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2d: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentYAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends StopMoveStep command to DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C47.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsStopMoveStepCommandToDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentXAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentYAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThSendsMoveToColorCommandToDutWithColorX33000ColorY26000TransitionTime0Immediate_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:33000U]; - params.colorY = - [NSNumber numberWithUnsignedShort:26000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsMoveColorCommandToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveColorParams alloc] init]; - params.rateX = - [NSNumber numberWithShort:-100]; - params.rateY = - [NSNumber numberWithShort:100]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveColor command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveColor command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsCurrentXAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27200U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 36800U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsCurrentYAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 22900U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 31100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsCurrentXAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 26350U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 35650U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsCurrentYAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 23800U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 32200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull CurrentXValue; - - CHIP_ERROR TestStep2dThReadsCurrentXAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 25500U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 34500U)); - { - CurrentXValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull CurrentYValue; - - CHIP_ERROR TestStep2dThReadsCurrentYAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 24650U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 33350U)); - { - CurrentYValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsStopMoveStepCommandToDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStopMoveStepParams alloc] init]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stopMoveStepWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends StopMoveStep command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends StopMoveStep command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 25500U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 34500U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 24650U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 33350U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_5_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_5_3() - : TestCommandBridge("Test_TC_CC_5_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_5_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToColorCommandToDutWithColorX33000ColorY20000TransitionTime0Immediate_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s)\n"); - if (ShouldSkip("CC.S.F03 && CC.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsStepColorCommandToDutWithStepX20000StepY6000TransitionTime20020s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentXAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentYAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait10s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3c: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentXAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3c: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentYAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); - if (ShouldSkip("CC.S.F03")) { - NextTest(); - return; - } - err = TestWait5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3d: TH reads CurrentX attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentXAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: TH reads CurrentY attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentYAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Turn off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_18(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 19; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToColorCommandToDutWithColorX33000ColorY20000TransitionTime0Immediate_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; - params.colorX = - [NSNumber numberWithUnsignedShort:33000U]; - params.colorY = - [NSNumber numberWithUnsignedShort:20000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3aThSendsStepColorCommandToDutWithStepX20000StepY6000TransitionTime20020s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterStepColorParams alloc] init]; - params.stepX = - [NSNumber numberWithShort:-20000]; - params.stepY = - [NSNumber numberWithShort:-6000]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepColorWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 13000U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 33000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 14000U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 20000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsCurrentXAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11050U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 14950U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentYAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11900U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 16100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsCurrentXAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11050U)); - VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 14950U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsCurrentYAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11900U)); - VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 16100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_6_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_6_1() - : TestCommandBridge("Test_TC_CC_6_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigWait", 0, UINT16_MAX, &mConfigWait); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_6_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_6_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_6_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep1aThReadsColorTempPhysicalMinMiredsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep1bThReadsColorTempPhysicalMaxMiredsAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1c: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep1cThReadsColorTemperatureMiredsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsMoveToColorTemperatureCommandToDutWithColorTemperatureMireds310AndTransitionTime0Immediately_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait100ms_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).\n"); - if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsMoveToColorTemperaturCommandToDutWithColorTemperatureMireds250AndTransitionTime30030s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait10s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsColorTemperatureMiredsAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsColorTemperatureMiredsAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 10s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait10s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2e: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThReadsColorTemperatureMiredsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 5s\n"); - if (ShouldSkip("CC.S.F04")) { - NextTest(); - return; - } - err = TestWait5s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 2f: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThReadsColorTemperatureMiredsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep3aThReadsColorModeAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep3bThReadsEnhancedColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait to turn Off light\n"); - err = TestWaitToTurnOffLight_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mConfigWait; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorTempPhysicalMinMiredsValue; - - CHIP_ERROR TestStep1aThReadsColorTempPhysicalMinMiredsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); - { - ColorTempPhysicalMinMiredsValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorTempPhysicalMaxMiredsValue; - - CHIP_ERROR TestStep1bThReadsColorTempPhysicalMaxMiredsAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); - { - ColorTempPhysicalMaxMiredsValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsColorTemperatureMiredsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], ColorTempPhysicalMinMiredsValue)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], ColorTempPhysicalMaxMiredsValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsMoveToColorTemperatureCommandToDutWithColorTemperatureMireds310AndTransitionTime0Immediately_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorTemperatureParams alloc] init]; - params.colorTemperatureMireds = - [NSNumber numberWithUnsignedShort:310U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsMoveToColorTemperaturCommandToDutWithColorTemperatureMireds250AndTransitionTime30030s_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterMoveToColorTemperatureParams alloc] init]; - params.colorTemperatureMireds = - [NSNumber numberWithUnsignedShort:250U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToColorTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsColorTemperatureMiredsAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 246U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 334U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsColorTemperatureMiredsAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 230U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 310U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsColorTemperatureMiredsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 212U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 288U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsColorTemperatureMiredsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 212U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 288U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsColorModeAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsEnhancedColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitToTurnOffLight_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigWait.HasValue() ? mConfigWait.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_6_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_6_5() - : TestCommandBridge("Test_TC_CC_6_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigWait", 0, UINT16_MAX, &mConfigWait); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_6_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_6_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_6_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0c: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep0cThReadsColorTemperatureMiredsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { - NextTest(); - return; - } - err = TestStep0dThReadsColorTempPhysicalMinMiredsAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { - NextTest(); - return; - } - err = TestStep0eThReadsColorTempPhysicalMaxMiredsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.A4010 && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep1ThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH writes to StartUpColorTemperatureMireds attribute with value StartUpColorTemperatureMireds\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && CC.S.A4010 && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep2aThWritesToStartUpColorTemperatureMiredsAttributeWithValueStartUpColorTemperatureMireds_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT\n"); - if (ShouldSkip("CC.S.A4010 && CC.S.F04")) { - NextTest(); - return; - } - err = TestStep2bThReadsStartUpColorTemperatureMiredsAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2b: Verify that the DUT response contains StartUpColorTemperatureMireds that matches the StartUpColorTemperatureMireds set in Step 2a\n"); - if (ShouldSkip("CC.S.A4010 && CC.S.F04 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2bVerifyThatTheDutResponseContainsStartUpColorTemperatureMiredsThatMatchesTheStartUpColorTemperatureMiredsSetInStep2a_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3aRebootTargetDevice_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep3bRebootTargetDeviceDUT_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4010")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4b: TH reads ColorTemperatureMireds attribute from DUT.\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { - NextTest(); - return; - } - err = TestStep4bThReadsColorTemperatureMiredsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep5aThReadsColorModeAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F04 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep5bThReadsEnhancedColorModeAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait to turn Off light\n"); - err = TestWaitToTurnOffLight_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mConfigWait; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0cThReadsColorTemperatureMiredsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 0c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0dThReadsColorTempPhysicalMinMiredsAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0eThReadsColorTempPhysicalMaxMiredsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThWritesToStartUpColorTemperatureMiredsAttributeWithValueStartUpColorTemperatureMireds_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nullable StartUpColorTemperatureMiredsValue; - - CHIP_ERROR TestStep2bThReadsStartUpColorTemperatureMiredsAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); - } - { - StartUpColorTemperatureMiredsValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bVerifyThatTheDutResponseContainsStartUpColorTemperatureMiredsThatMatchesTheStartUpColorTemperatureMiredsSetInStep2a_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3aRebootTargetDevice_10() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep3bRebootTargetDeviceDUT_11() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (StartUpColorTemperatureMiredsValue == nil) { - VerifyOrReturn(CheckValueNull("StartUpColorTemperatureMireds", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("StartUpColorTemperatureMireds", actualValue)); - VerifyOrReturn(CheckValue("StartUpColorTemperatureMireds", actualValue, StartUpColorTemperatureMiredsValue)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsColorTemperatureMiredsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads ColorTemperatureMireds attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorTemperatureMireds", actualValue, StartUpColorTemperatureMiredsValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThReadsColorModeAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsEnhancedColorModeAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitToTurnOffLight_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mConfigWait.HasValue() ? mConfigWait.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_7_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_7_3() - : TestCommandBridge("Test_TC_CC_7_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_7_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_7_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_7_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue6000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsEnhancedStepHueCommandToDutWithStepMode0x01UpStepSize6000AndTransitionTime30030s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsEnhancedCurrentHueAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2f: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep5aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue12000Direction0x00ShortestDistanceAndTransitionTime0Immediately_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait100ms_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s)\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { - NextTest(); - return; - } - err = TestStep5bThSendsEnhancedStepHueCommandToDutWithStepMode0x03DownStepSize6000AndTransitionTime30030s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5c: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThReadsEnhancedCurrentHueAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 2d: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 2e: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Wait 5s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait5s_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 2f: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 6a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep6aThReadsColorModeAttributeFromDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 6b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep6bThReadsEnhancedColorModeAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_28(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 29; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue6000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:6000U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsEnhancedStepHueCommandToDutWithStepMode0x01UpStepSize6000AndTransitionTime30030s_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:1U]; - params.stepSize = - [NSNumber numberWithUnsignedShort:6000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedStepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsEnhancedCurrentHueAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 6800U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 9200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 8500U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 11500U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 10200U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 13800U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 10200U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 13800U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue12000Direction0x00ShortestDistanceAndTransitionTime0Immediately_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:12000U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bThSendsEnhancedStepHueCommandToDutWithStepMode0x03DownStepSize6000AndTransitionTime30030s_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedStepHueParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:3U]; - params.stepSize = - [NSNumber numberWithUnsignedShort:6000U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedStepHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s): Error: %@", err); - } else { - NSLog(@"Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5cThReadsEnhancedCurrentHueAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 8500U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 11500U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 6800U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 9200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 5100U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 6900U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_23() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 5100U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 6900U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsColorModeAttributeFromDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsEnhancedColorModeAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CC_7_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CC_7_4() - : TestCommandBridge("Test_TC_CC_7_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CC_7_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_7_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_7_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately)\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue20000Saturation50AndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep2bThReadsEnhancedCurrentHueAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestThReadsCurrentSaturationAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s)\n"); - if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue16000Saturation80AndTransitionTime20020s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep3bThReadsEnhancedCurrentHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentSaturationAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait10s_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep3cThReadsEnhancedCurrentHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentSaturationAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); - if (ShouldSkip("CC.S.F01")) { - NextTest(); - return; - } - err = TestWait5s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads EnhancedCurrentHue attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { - NextTest(); - return; - } - err = TestStep3dThReadsEnhancedCurrentHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsCurrentSaturationAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH reads ColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4aThReadsColorModeAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); - if (ShouldSkip("CC.S.F01 && CC.S.A4001")) { - NextTest(); - return; - } - err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Turn Off light that we turned on\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestTurnOffLightThatWeTurnedOn_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue20000Saturation50AndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueAndSaturationParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:20000U]; - params.saturation = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsEnhancedCurrentHueAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 17000U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 23000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThReadsCurrentSaturationAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 42U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 58U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue16000Saturation80AndTransitionTime20020s_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueAndSaturationParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16000U]; - params.saturation = - [NSNumber numberWithUnsignedChar:80U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:200U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueAndSaturationWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s): Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsEnhancedCurrentHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 16000U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 20000U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsCurrentSaturationAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 50U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 80U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3cThReadsEnhancedCurrentHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 13600U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 18400U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentSaturationAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); - VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsEnhancedCurrentHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, 16000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentSaturation", actualValue, 80U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light that we turned on: Error: %@", err); - } else { - NSLog(@"Turn Off light that we turned on: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestColorControl_9_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestColorControl_9_1() - : TestCommandBridge("TestColorControl_9_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestColorControl_9_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestColorControl_9_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestColorControl_9_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH writes 0 to the Options attribute\n"); - err = TestThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : TH sends On command to DUT\n"); - err = TestThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 100ms\n"); - err = TestWaitFor100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x4UpdateTimeAndTimeAttributeTo55sForOneLoopToDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read ColorLoopTime attribute from DUT\n"); - err = TestReadColorLoopTimeAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x8UpdateStartHueAndStartHueAttributeTo0x00A0ToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStartEnhancedHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait for 5S\n"); - err = TestWaitFor5s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisonInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait for 5S\n"); - err = TestWaitFor5s_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisonInStep6cReadColorLoopStoredEnhancedHueAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for 5S\n"); - err = TestWaitFor5s_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Wait for 5S\n"); - err = TestWaitFor5s_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep9cReadColorLoopStoredEnhancedHueAttributeFromDut_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Wait 10ms\n"); - err = TestWait10ms_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Wait for 5S\n"); - err = TestWaitFor5s_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep12dReadColorLoopStartEnhancedHueAttributeFromDut_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Wait for 5S\n"); - err = TestWaitFor5s_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionInStep13cReadColorLoopStoredEnhancedHueAttributeFromDut_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Read ColorLoopDirection attribute from DUT\n"); - err = TestReadColorLoopDirectionAttributeFromDut_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Wait for 5S\n"); - err = TestWaitFor5s_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT\n"); - err = TestSavingValueForComparisionInStep15dReadColorLoopStartEnhancedHueAttributeFromDut_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Wait for 5S\n"); - err = TestWaitFor5s_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionInStep16bReadColorLoopStoredEnhancedHueAttributeFromDut_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Turn Off light for color control tests\n"); - err = TestTurnOffLightForColorControlTests_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_71(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(400)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 72; - - chip::Optional mNodeId; - chip::Optional mTimeout; - chip::Optional mCluster; - chip::Optional mEndpoint; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16384U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x4UpdateTimeAndTimeAttributeTo55sForOneLoopToDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:4U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:5U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopTimeAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopTime", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x8UpdateStartHueAndStartHueAttributeTo0x00A0ToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:8U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:160U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStartEnhancedHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStartEnhancedHue", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:1U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep5d; - - CHIP_ERROR TestSavingValueForComparisonInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep5d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep5d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep5d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep6c; - - CHIP_ERROR TestSavingValueForComparisonInStep6cReadColorLoopStoredEnhancedHueAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep6c = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep6c)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:1U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:1U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep8d; - - CHIP_ERROR TestSavingValueForComparisionInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep8d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep8d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_33() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep8d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep9c; - - CHIP_ERROR TestSavingValueForComparisionInStep9cReadColorLoopStoredEnhancedHueAttributeFromDut_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep9c = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep9c)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16384U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10ms_40() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:2U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_47() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep12d; - - CHIP_ERROR TestSavingValueForComparisionInStep12dReadColorLoopStartEnhancedHueAttributeFromDut_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep12d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep12d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_50() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep12d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep13c; - - CHIP_ERROR TestSavingValueForComparisionInStep13cReadColorLoopStoredEnhancedHueAttributeFromDut_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep13c = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep13c)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:1U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:2U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_61() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueStep15d; - - CHIP_ERROR TestSavingValueForComparisionInStep15dReadColorLoopStartEnhancedHueAttributeFromDut_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueStep15d = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep15d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_64() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep15d)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep16b; - - CHIP_ERROR TestSavingValueForComparisionInStep16bReadColorLoopStoredEnhancedHueAttributeFromDut_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueStep16b = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep16b)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightForColorControlTests_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off light for color control tests: Error: %@", err); - } else { - NSLog(@"Turn Off light for color control tests: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestColorControl_9_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestColorControl_9_2() - : TestCommandBridge("TestColorControl_9_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestColorControl_9_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestColorControl_9_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestColorControl_9_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH writes 0 to the Options attribute\n"); - err = TestThWrites0ToTheOptionsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : TH sends On command to DUT\n"); - err = TestThSendsOnCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); - err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 100ms\n"); - err = TestWaitFor100ms_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0xFActionAttributeTo0x0DeActivateDirectionAttributeTo0x0DecrementHueTimeAttributeTo30AndStartHueAttributeTo0x00A0ToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read ColorLoopDirection attribute from DUT.\n"); - err = TestReadColorLoopDirectionAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read ColorLoopTime attribute from DUT.\n"); - err = TestReadColorLoopTimeAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read ColorLoopStartEnhancedHue attribute from DUT.\n"); - err = TestReadColorLoopStartEnhancedHueAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read ColorLoopActive attribute from DUT.\n"); - err = TestReadColorLoopActiveAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for 5S\n"); - err = TestWaitFor5s_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait for 5S\n"); - err = TestWaitFor5s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read ColorLoopDirection attribute from DUT.\n"); - err = TestReadColorLoopDirectionAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait for 5S\n"); - err = TestWaitFor5s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Wait for 5S\n"); - err = TestWaitFor5s_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read EnhancedCurrentHue attribute from DUT\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); - err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read ColorLoopActive attribute from DUT\n"); - err = TestReadColorLoopActiveAttributeFromDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.\n"); - err = TestSavingValueForComparisionReadColorLoopStoredEnhancedHueAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read EnhancedCurrentHue attribute from DUT.\n"); - err = TestReadEnhancedCurrentHueAttributeFromDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light for color control tests\n"); - err = TestTurnOffLightForColorControlTests_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(400)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 31; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestThWrites0ToTheOptionsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsOnCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; - params.enhancedHue = - [NSNumber numberWithUnsignedShort:16384U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster enhancedMoveToHueWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); - } else { - NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor100ms_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0xFActionAttributeTo0x0DeActivateDirectionAttributeTo0x0DecrementHueTimeAttributeTo30AndStartHueAttributeTo0x00A0ToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:15U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:5U]; - params.startHue = - [NSNumber numberWithUnsignedShort:160U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopTimeAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopTime attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopTime attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopTime", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStartEnhancedHueAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStartEnhancedHue", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:1U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueValue; - - CHIP_ERROR TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:2U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:1U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read ColorLoopDirection attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull ColorLoopStartEnhancedHueValue2; - - CHIP_ERROR TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStartEnhancedHueValue2 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue2)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_23() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue2)); - VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; - params.updateFlags = - [NSNumber numberWithUnsignedChar:1U]; - params.action = - [NSNumber numberWithUnsignedChar:0U]; - params.direction = - [NSNumber numberWithUnsignedChar:0U]; - params.time = - [NSNumber numberWithUnsignedShort:0U]; - params.startHue = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster colorLoopSetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); - } else { - NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); - } else { - NSLog(@"Read ColorLoopActive attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ColorLoopStoredEnhancedHueValue3; - - CHIP_ERROR TestSavingValueForComparisionReadColorLoopStoredEnhancedHueAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ColorLoopStoredEnhancedHueValue3 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read EnhancedCurrentHue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Read EnhancedCurrentHue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueValue3)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffLightForColorControlTests_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn off light for color control tests: Error: %@", err); - } else { - NSLog(@"Turn off light for color control tests: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CDOCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CDOCONC_1_1() - : TestCommandBridge("Test_TC_CDOCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CDOCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CDOCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CDOCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenCdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenCdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenCdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenCdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CDOCONC.S.F02 && CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenCdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F02 && !CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenCdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CDOCONC.S.F03 && CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenCdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F03 && !CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenCdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CDOCONC.S.F04 && CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenCdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F04 && !CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenCdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CDOCONC.S.F05 && CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenCdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CDOCONC.S.F05 && !CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenCdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.A0007 && CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !CDOCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCdoconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCdoconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("CDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !CDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCdoconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenCdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenCdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenCdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenCdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenCdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenCdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenCdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenCdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenCdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenCdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenCdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenCdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCdoconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCdoconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCdoconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CDOCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CDOCONC_2_1() - : TestCommandBridge("Test_TC_CDOCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CDOCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CDOCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CDOCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("CDOCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("CDOCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CMOCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CMOCONC_1_1() - : TestCommandBridge("Test_TC_CMOCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CMOCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CMOCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CMOCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenCmoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenCmoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenCmoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenCmoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CMOCONC.S.F02 && CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenCmoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F02 && !CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenCmoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CMOCONC.S.F03 && CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenCmoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F03 && !CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenCmoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CMOCONC.S.F04 && CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenCmoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F04 && !CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenCmoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("CMOCONC.S.F05 && CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenCmoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !CMOCONC.S.F05 && !CMOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenCmoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.A0007 && CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !CMOCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCmoconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCmoconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("CMOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !CMOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCmoconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenCmoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenCmoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenCmoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenCmoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenCmoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenCmoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenCmoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenCmoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenCmoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenCmoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenCmoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenCmoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCmoconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCmoconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCmoconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CMOCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CMOCONC_2_1() - : TestCommandBridge("Test_TC_CMOCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CMOCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CMOCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CMOCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("CMOCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("CMOCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLDCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLDCONC_1_1() - : TestCommandBridge("Test_TC_FLDCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLDCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLDCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLDCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenFldconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenFldconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenFldconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenFldconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FLDCONC.S.F02 && FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenFldconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F02 && !FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenFldconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("FLDCONC.S.F03 && FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenFldconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F03 && !FLDCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenFldconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("FLDCONC.S.F04 && FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenFldconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F04 && !FLDCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenFldconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("FLDCONC.S.F05 && FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenFldconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !FLDCONC.S.F05 && !FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenFldconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.A0007 && FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !FLDCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenFldconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenFldconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("FLDCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !FLDCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenFldconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenFldconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenFldconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenFldconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenFldconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenFldconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenFldconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenFldconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenFldconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenFldconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenFldconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenFldconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenFldconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenFldconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenFldconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenFldconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLDCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLDCONC_2_1() - : TestCommandBridge("Test_TC_FLDCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLDCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLDCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLDCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("FLDCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("FLDCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_NDOCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_NDOCONC_1_1() - : TestCommandBridge("Test_TC_NDOCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_NDOCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_NDOCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_NDOCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenNdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenNdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenNdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenNdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("NDOCONC.S.F02 && NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenNdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F02 && !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3gGivenNdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("NDOCONC.S.F03 && NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenNdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F03 && !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenNdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("NDOCONC.S.F04 && NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenNdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F04 && NDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenNdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("NDOCONC.S.F05 && NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenNdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !NDOCONC.S.F05 && !NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenNdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.A0007 && NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !NDOCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenNdoconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenNdoconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iThReadsThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("NDOCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !NDOCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenNdoconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenNdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenNdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenNdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenNdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenNdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenNdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenNdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenNdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenNdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenNdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenNdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenNdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenNdoconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenNdoconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenNdoconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_NDOCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_NDOCONC_2_1() - : TestCommandBridge("Test_TC_NDOCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_NDOCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_NDOCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_NDOCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("NDOCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("NDOCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OZCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OZCONC_1_1() - : TestCommandBridge("Test_TC_OZCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OZCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OZCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OZCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenOzconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenOzconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenOzconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenOzconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OZCONC.S.F02 && OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenOzconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F02 && !OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenOzconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("OZCONC.S.F03 && OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenOzconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F03 && !OZCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenOzconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("OZCONC.S.F04 && OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenOzconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F04 && !OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenOzconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("OZCONC.S.F05 && OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenOzconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !OZCONC.S.F05 && !OZCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenOzconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("OZCONC.S.A0007 && OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !OZCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenOzconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenOzconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("OZCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !OZCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenOzconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenOzconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenOzconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenOzconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenOzconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenOzconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenOzconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenOzconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenOzconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenOzconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenOzconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenOzconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenOzconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenOzconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenOzconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenOzconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OZCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OZCONC_2_1() - : TestCommandBridge("Test_TC_OZCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OZCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OZCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OZCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("OZCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("OZCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("OZCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("OZCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("OZCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("OZCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMHCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMHCONC_1_1() - : TestCommandBridge("Test_TC_PMHCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMHCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMHCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMHCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPmhconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenPmhconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenPmhconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenPmhconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMHCONC.S.F02 && PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenPmhconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F02 && !PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenPmhconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMHCONC.S.F03 && PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenPmhconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F03 && !PMHCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3iGivenPmhconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMHCONC.S.F04 && PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenPmhconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F04 && PMHCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenPmhconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMHCONC.S.F05 && PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenPmhconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMHCONC.S.F05 && !PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenPmhconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.A0007 && PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !PMHCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmhconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmhconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("PMHCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !PMHCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmhconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPmhconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPmhconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPmhconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPmhconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPmhconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPmhconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPmhconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenPmhconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenPmhconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenPmhconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenPmhconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenPmhconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmhconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmhconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmhconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMHCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMHCONC_2_1() - : TestCommandBridge("Test_TC_PMHCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMHCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMHCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMHCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("PMHCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("PMHCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMICONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMICONC_1_1() - : TestCommandBridge("Test_TC_PMICONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMICONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMICONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMICONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPmiconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenPmiconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenPmiconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenPmiconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMICONC.S.F02 && PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenPmiconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F02 && !PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenPmiconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMICONC.S.F03 && PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenPmiconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F03 && !PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenPmiconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMICONC.S.F04 && PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenPmiconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F04 && !PMICONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenPmiconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMICONC.S.F05 && PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenPmiconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMICONC.S.F05 && !PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenPmiconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("PMICONC.S.A0007 && PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set\n"); - if (ShouldSkip(" !PMICONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmiconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmiconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("PMICONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !PMICONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmiconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPmiconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPmiconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPmiconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPmiconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPmiconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPmiconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPmiconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenPmiconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenPmiconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenPmiconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenPmiconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenPmiconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmiconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmiconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmiconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMICONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMICONC_2_1() - : TestCommandBridge("Test_TC_PMICONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMICONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMICONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMICONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMICONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMICONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("PMICONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("PMICONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("PMICONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("PMICONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMKCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMKCONC_1_1() - : TestCommandBridge("Test_TC_PMKCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMKCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMKCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMKCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); - err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPmkconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenPmkconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenPmkconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenPmkconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PMKCONC.S.F02 && PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenPmkconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F02 && !PMKCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3gGivenPmkconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMKCONC.S.F03 && PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenPmkconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F03 && !PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenPmkconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMKCONC.S.F04 && PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenPmkconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F04 && !PMKCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenPmkconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("PMKCONC.S.F05 && PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenPmkconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !PMKCONC.S.F05 && !PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3mGivenPmkconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.A0007 && PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !PMKCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmkconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmkconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("PMKCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !PMKCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmkconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPmkconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPmkconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPmkconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPmkconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPmkconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPmkconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPmkconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenPmkconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenPmkconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenPmkconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenPmkconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenPmkconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmkconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmkconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmkconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PMKCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PMKCONC_2_1() - : TestCommandBridge("Test_TC_PMKCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PMKCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMKCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMKCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("PMKCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("PMKCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RNCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RNCONC_1_1() - : TestCommandBridge("Test_TC_RNCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RNCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RNCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RNCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenRnconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenRnconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenRnconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenRnconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RNCONC.S.F02 && RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenRnconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F02 && !RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3gGivenRnconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("RNCONC.S.F03 && RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenRnconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F03 && !RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenRnconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("RNCONC.S.F04 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenRnconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F04 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3kGivenRnconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("RNCONC.S.F05 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenRnconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !RNCONC.S.F05 && !RNCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenRnconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("RNCONC.S.A0007 && RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !RNCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenRnconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenRnconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("RNCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !RNCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenRnconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenRnconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenRnconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenRnconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenRnconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenRnconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenRnconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenRnconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenRnconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenRnconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenRnconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenRnconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenRnconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenRnconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenRnconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenRnconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RNCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RNCONC_2_1() - : TestCommandBridge("Test_TC_RNCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RNCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RNCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RNCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("RNCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: H reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7HReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("RNCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("RNCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("RNCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("RNCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("RNCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7HReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: H reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: H reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TVOCCONC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TVOCCONC_1_1() - : TestCommandBridge("Test_TC_TVOCCONC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TVOCCONC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TVOCCONC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TVOCCONC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); - err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenTvocconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3cGivenTvocconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGivenTvocconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3eGivenTvocconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TVOCCONC.S.F02 && TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3fGivenTvocconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F02 && !TVOCCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep3gGivenTvocconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("TVOCCONC.S.F03 && TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3hGivenTvocconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F03 && !TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep3iGivenTvocconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("TVOCCONC.S.F04 && TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3jGivenTvocconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F04 && !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3kGivenTvocconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); - if (ShouldSkip("TVOCCONC.S.F05 && TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep3lGivenTvocconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); - if (ShouldSkip(" !TVOCCONC.S.F05 && !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3mGivenTvocconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.A0007 && TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.A0007 ")) { - NextTest(); - return; - } - err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenTvocconcsa0007IsNotSet_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenTvocconcsf00MeaIsNotSet_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F04 ")) { - NextTest(); - return; - } - err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf04PeaIsNotSet_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F05")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F05 ")) { - NextTest(); - return; - } - err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf05AvgIsNotSet_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); - if (ShouldSkip("TVOCCONC.S.F01")) { - NextTest(); - return; - } - err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set\n"); - if (ShouldSkip(" !TVOCCONC.S.F01 ")) { - NextTest(); - return; - } - err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenTvocconcsf01LevIsNotSet_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 30; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenTvocconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenTvocconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenTvocconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenTvocconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenTvocconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenTvocconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenTvocconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenTvocconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenTvocconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenTvocconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenTvocconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mGivenTvocconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenTvocconcsa0007IsNotSet_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set: Error: %@", err); - } else { - NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenTvocconcsf00MeaIsNotSet_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf04PeaIsNotSet_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set: Error: %@", err); - } else { - NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf05AvgIsNotSet_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set: Error: %@", err); - } else { - NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenTvocconcsf01LevIsNotSet_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set: Error: %@", err); - } else { - NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TVOCCONC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TVOCCONC_2_1() - : TestCommandBridge("Test_TC_TVOCCONC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TVOCCONC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TVOCCONC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TVOCCONC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0008")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0009")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A000a")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); - if (ShouldSkip("TVOCCONC.S.A0007")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); - VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); - VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OPCREDS_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OPCREDS_1_2() - : TestCommandBridge("Test_TC_OPCREDS_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OPCREDS_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OPCREDS_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OPCREDS_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_BINFO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_BINFO_1_1() - : TestCommandBridge("Test_TC_BINFO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_BINFO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_BINFO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BINFO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000b")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeManufacturingDateInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(PartNumber) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000c")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributePartNumberInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(ProductURL) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000d")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeProductURLInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(ProductLabel) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000e")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeProductLabelInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(SerialNumber) in attributeList\n"); - if (ShouldSkip("BINFO.S.A000f")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeSerialNumberInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList\n"); - if (ShouldSkip("BINFO.S.A0010")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeLocalConfigDisabledInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(Reachable) in attributeList\n"); - if (ShouldSkip("BINFO.S.A0011")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributeReachableInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads optional attribute(UniqueID) in attributeList\n"); - if (ShouldSkip("BINFO.S.A0012")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeUniqueIDInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip(" !BINFO.S.E00 && !BINFO.S.E01 && !BINFO.S.E02 && !BINFO.S.A0011 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: Read BINFO.S.E00(StartUp) event in EventList\n"); - if (ShouldSkip("BINFO.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5c: Read BINFO.S.E01(ShutDown) event in EventList\n"); - if (ShouldSkip("BINFO.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5d: Read BINFO.S.E02(Leave) event in EventList\n"); - if (ShouldSkip("BINFO.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5e: Read (ReachableChanged) event in EventList\n"); - if (ShouldSkip("BINFO.S.A0011 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeManufacturingDateInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributePartNumberInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(PartNumber) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(PartNumber) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeProductURLInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(ProductURL) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(ProductURL) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeProductLabelInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(ProductLabel) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(ProductLabel) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeSerialNumberInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(SerialNumber) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(SerialNumber) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeLocalConfigDisabledInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributeReachableInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(Reachable) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(Reachable) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeUniqueIDInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(UniqueID) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(UniqueID) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CNET_1_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CNET_1_3() - : TestCommandBridge("Test_TC_CNET_1_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CNET_1_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CNET_1_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CNET_1_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap\n"); - if (ShouldSkip(" !CNET.S.F00 && !CNET.S.F01 && !CNET.S.F02 ")) { - NextTest(); - return; - } - err = TestStep3aReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Read the global attribute: FeatureMap when CNET.S.F00 is set\n"); - if (ShouldSkip("CNET.S.F00")) { - NextTest(); - return; - } - err = TestStep3bReadTheGlobalAttributeFeatureMapWhenCnetsf00IsSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Read the global attribute: FeatureMap when CNET.S.F01 is set\n"); - if (ShouldSkip("CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep3cReadTheGlobalAttributeFeatureMapWhenCnetsf01IsSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Read the global attribute: FeatureMap when CNET.S.F02 is set\n"); - if (ShouldSkip("CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep3dReadTheGlobalAttributeFeatureMapWhenCnetsf02IsSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: Read mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true\n"); - if (ShouldSkip("CNET.S.F00 || CNET.S.F01 || CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep4bReadMandatoryAttributesInAttributeListIfCnetsf00wiCnetsf01thCnetsf02etIsTrue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: Read the optional attribute(ScanMaxTimeSeconds): AttributeList\n"); - if (ShouldSkip("CNET.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cReadTheOptionalAttributeScanMaxTimeSecondsAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: Reading optional attribute(ConnectMaxTimeSeconds) in AttributeList\n"); - if (ShouldSkip("CNET.S.A0003")) { - NextTest(); - return; - } - err = TestStep4dReadingOptionalAttributeConnectMaxTimeSecondsInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6a: Read AcceptedCommandList If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH)\n"); - if (ShouldSkip("( CNET.S.F00 || CNET.S.F01 )")) { - NextTest(); - return; - } - err = TestStep6aReadAcceptedCommandListIfDutSupportsWiFiThreadRelatedFeaturesCnetsf00wicnetsf01th_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6b: Read AcceptedCommandList If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true)\n"); - if (ShouldSkip("CNET.S.F00")) { - NextTest(); - return; - } - err = TestStep6bReadAcceptedCommandListIfDutSupportsWiFiRelatedFeaturesCnetsf00wiIsTrue_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6c: Read AcceptedCommandList If DUT supports Thread related features(CNET.S.F01(TH) is true)\n"); - if (ShouldSkip("CNET.S.F01")) { - NextTest(); - return; - } - err = TestStep6cReadAcceptedCommandListIfDutSupportsThreadRelatedFeaturesCNETSF01THIsTrue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6d: Read AcceptedCommandList If DUT supports Ethernet related features(CNET.S.F02(TH) is true)\n"); - if (ShouldSkip("CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep6dReadAcceptedCommandListIfDutSupportsEthernetRelatedFeaturesCNETSF02THIsTrue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7a: Read the GeneratedCommandList If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true)\n"); - if (ShouldSkip("( CNET.S.F00 || CNET.S.F01 )")) { - NextTest(); - return; - } - err = TestStep7aReadTheGeneratedCommandListIfDutSupportsWiFiThreadRelatedFeaturesCNETSF00WIOrCnetsf01thIsTrue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 7b: Read the GeneratedCommandList If DUT supports Ethernet related features(CNET.S.F02(ET) must be true)\n"); - if (ShouldSkip("CNET.S.F02")) { - NextTest(); - return; - } - err = TestStep7bReadTheGeneratedCommandListIfDutSupportsEthernetRelatedFeaturesCNETSF02ETMustBeTrue_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bReadTheGlobalAttributeFeatureMapWhenCnetsf00IsSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Read the global attribute: FeatureMap when CNET.S.F00 is set: Error: %@", err); - } else { - NSLog(@"Step 3b: Read the global attribute: FeatureMap when CNET.S.F00 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cReadTheGlobalAttributeFeatureMapWhenCnetsf01IsSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Read the global attribute: FeatureMap when CNET.S.F01 is set: Error: %@", err); - } else { - NSLog(@"Step 3c: Read the global attribute: FeatureMap when CNET.S.F01 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 2UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dReadTheGlobalAttributeFeatureMapWhenCnetsf02IsSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Read the global attribute: FeatureMap when CNET.S.F02 is set: Error: %@", err); - } else { - NSLog(@"Step 3d: Read the global attribute: FeatureMap when CNET.S.F02 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 4UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadMandatoryAttributesInAttributeListIfCnetsf00wiCnetsf01thCnetsf02etIsTrue_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true: Error: %@", err); - } else { - NSLog(@"Step 4b: Read mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheOptionalAttributeScanMaxTimeSecondsAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read the optional attribute(ScanMaxTimeSeconds): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read the optional attribute(ScanMaxTimeSeconds): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadingOptionalAttributeConnectMaxTimeSecondsInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Reading optional attribute(ConnectMaxTimeSeconds) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Reading optional attribute(ConnectMaxTimeSeconds) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aReadAcceptedCommandListIfDutSupportsWiFiThreadRelatedFeaturesCnetsf00wicnetsf01th_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: Read AcceptedCommandList If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH): Error: %@", err); - } else { - NSLog(@"Step 6a: Read AcceptedCommandList If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bReadAcceptedCommandListIfDutSupportsWiFiRelatedFeaturesCnetsf00wiIsTrue_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: Read AcceptedCommandList If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true): Error: %@", err); - } else { - NSLog(@"Step 6b: Read AcceptedCommandList If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cReadAcceptedCommandListIfDutSupportsThreadRelatedFeaturesCNETSF01THIsTrue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: Read AcceptedCommandList If DUT supports Thread related features(CNET.S.F01(TH) is true): Error: %@", err); - } else { - NSLog(@"Step 6c: Read AcceptedCommandList If DUT supports Thread related features(CNET.S.F01(TH) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dReadAcceptedCommandListIfDutSupportsEthernetRelatedFeaturesCNETSF02THIsTrue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: Read AcceptedCommandList If DUT supports Ethernet related features(CNET.S.F02(TH) is true): Error: %@", err); - } else { - NSLog(@"Step 6d: Read AcceptedCommandList If DUT supports Ethernet related features(CNET.S.F02(TH) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aReadTheGeneratedCommandListIfDutSupportsWiFiThreadRelatedFeaturesCNETSF00WIOrCnetsf01thIsTrue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: Read the GeneratedCommandList If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true): Error: %@", err); - } else { - NSLog(@"Step 7a: Read the GeneratedCommandList If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bReadTheGeneratedCommandListIfDutSupportsEthernetRelatedFeaturesCNETSF02ETMustBeTrue_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: Read the GeneratedCommandList If DUT supports Ethernet related features(CNET.S.F02(ET) must be true): Error: %@", err); - } else { - NSLog(@"Step 7b: Read the GeneratedCommandList If DUT supports Ethernet related features(CNET.S.F02(ET) must be true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DESC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DESC_1_1() - : TestCommandBridge("Test_TC_DESC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DESC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DESC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DESC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!DESC.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList)\n"); - if (ShouldSkip("DESC.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute0x0001ShallBeIncludedIfAndOnlyIfDESCSF00TagList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00\n"); - if (ShouldSkip("DESC.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0004ShallBeIncludedIfAndOnlyIfDescsf00_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute0x0001ShallBeIncludedIfAndOnlyIfDESCSF00TagList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0004ShallBeIncludedIfAndOnlyIfDescsf00_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DLOG_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DLOG_1_1() - : TestCommandBridge("Test_TC_DLOG_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DLOG_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DLOG_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DLOG_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); - err = TestStep3ThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads AcceptedCommandList from DUT\n"); - err = TestStep6ThReadsAcceptedCommandListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGETH_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGETH_1_1() - : TestCommandBridge("Test_TC_DGETH_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGETH_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DGETH.S.F00 && !DGETH.S.F01")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGETH.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDgethsf00EnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGETH.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDgethsf01EnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads optional attribute(PHYRate) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributePHYRateInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads optional attribute(FullDuplex) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeFullDuplexInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0007")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeCarrierDetectInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList\n"); - if (ShouldSkip("DGETH.S.A0008")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributeTimeSinceResetInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip("( DGETH.S.F00 || DGETH.S.F01 )")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGETH.S.F00 && !DGETH.S.F01 ")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDgethsf00EnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDgethsf01EnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributePHYRateInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(PHYRate) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(PHYRate) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeFullDuplexInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(FullDuplex) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(FullDuplex) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeCarrierDetectInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributeTimeSinceResetInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGETH_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGETH_2_1() - : TestCommandBridge("Test_TC_DGETH_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGETH_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads PHYRate attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsPHYRateAttributeConstraints_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FullDuplex attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFullDuplexAttributeConstraints_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads PacketRxCount attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep4aThReadsPacketRxCountAttributeConstraints_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4bRebootTargetDevice_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4cRebootTargetDeviceDUT_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: Upon a node reboot, PacketRxCount attribute value will be reset to 0\n"); - if (ShouldSkip("PICS_USER_PROMPT && DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dUponANodeRebootPacketRxCountAttributeValueWillBeResetTo0_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5a: TH reads PacketTxCount attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep5aThReadsPacketTxCountAttributeConstraints_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5b: TH reads PacketTxCount attribute constraints, Upon a node reboot, the value will be reset to 0\n"); - if (ShouldSkip("PICS_USER_PROMPT && DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep5bThReadsPacketTxCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsTxErrCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsCollisionCountAttributeUponANodeRebootTheValueWillBeResetTo0_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 8: TH reads OverrunCount attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsOverrunCountAttributeConstraints_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 9: TH reads CarrierDetect attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsCarrierDetectAttributeConstraints_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 10: TH reads TimeSinceReset attribute constraints\n"); - if (ShouldSkip("DGETH.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsTimeSinceResetAttributeConstraints_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsPHYRateAttributeConstraints_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads PHYRate attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads PHYRate attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFullDuplexAttributeConstraints_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFullDuplexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FullDuplex attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FullDuplex attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("fullDuplex", "boolean", "boolean")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsPacketRxCountAttributeConstraints_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads PacketRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads PacketRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("packetRxCount", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("packetRxCount", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("packetRxCount", [value unsignedLongLongValue], 18446744073709551615ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bRebootTargetDevice_4() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep4cRebootTargetDeviceDUT_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep4dUponANodeRebootPacketRxCountAttributeValueWillBeResetTo0_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5aThReadsPacketTxCountAttributeConstraints_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads PacketTxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads PacketTxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("packetTxCount", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("packetTxCount", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("packetTxCount", [value unsignedLongLongValue], 18446744073709551615ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsPacketTxCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6ThReadsTxErrCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TxErrCount", actualValue, 0ULL)); - } - - VerifyOrReturn(CheckConstraintType("txErrCount", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsCollisionCountAttributeUponANodeRebootTheValueWillBeResetTo0_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CollisionCount", actualValue, 0ULL)); - } - - VerifyOrReturn(CheckConstraintType("collisionCount", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsOverrunCountAttributeConstraints_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads OverrunCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads OverrunCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OverrunCount", actualValue, 0ULL)); - } - - VerifyOrReturn(CheckConstraintType("overrunCount", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsCarrierDetectAttributeConstraints_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCarrierDetectWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads CarrierDetect attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads CarrierDetect attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("carrierDetect", "boolean", "boolean")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsTimeSinceResetAttributeConstraints_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeSinceResetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads TimeSinceReset attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads TimeSinceReset attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("timeSinceReset", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("timeSinceReset", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("timeSinceReset", [value unsignedLongLongValue], 18446744073709551615ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGETH_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGETH_2_2() - : TestCommandBridge("Test_TC_DGETH_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGETH_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a.1: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a1ThReadsPHYRateAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a.2: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a2ThReadsPHYRateAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a.3: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a3ThReadsPHYRateAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a.4: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a4ThReadsPHYRateAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a.5: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a5ThReadsPHYRateAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a.6: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a6ThReadsPHYRateAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a.7: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a7ThReadsPHYRateAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2a.8: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a8ThReadsPHYRateAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a.9: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a9ThReadsPHYRateAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2a.10: TH reads PHYRate attribute from DUT\n"); - if (ShouldSkip("DGETH.S.A0000")) { - NextTest(); - return; - } - err = TestStep2a10ThReadsPHYRateAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2b: TH reads PacketRxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0002")) { - NextTest(); - return; - } - err = TestStep2bThReadsPacketRxCountAttributeValueFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2c: TH reads PacketTxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0003")) { - NextTest(); - return; - } - err = TestStep2cThReadsPacketTxCountAttributeValueFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2d: TH reads TxErrCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep2dThReadsTxErrCountAttributeValueFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2e: TH reads CollisionCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep2eThReadsCollisionCountAttributeValueFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 2f: TH reads OverrunCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep2fThReadsOverrunCountAttributeValueFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 2g: Sends ResetCounts command\n"); - if (ShouldSkip("DGETH.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2gSendsResetCountsCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 2h: TH reads PacketRxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0002 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2hThReadsPacketRxCountAttributeValueFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 2i: TH reads PacketTxCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0003 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2iThReadsPacketTxCountAttributeValueFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 2j: TH reads TxErrCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0004")) { - NextTest(); - return; - } - err = TestStep2jThReadsTxErrCountAttributeValueFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 2k: TH reads CollisionCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0005")) { - NextTest(); - return; - } - err = TestStep2kThReadsCollisionCountAttributeValueFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 2l: TH reads OverrunCount attribute value from DUT\n"); - if (ShouldSkip("DGETH.S.A0006")) { - NextTest(); - return; - } - err = TestStep2lThReadsOverrunCountAttributeValueFromDut_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2a1ThReadsPHYRateAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.1: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.1: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a2ThReadsPHYRateAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.2: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.2: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a3ThReadsPHYRateAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.3: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.3: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a4ThReadsPHYRateAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.4: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.4: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a5ThReadsPHYRateAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.5: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.5: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a6ThReadsPHYRateAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.6: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.6: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a7ThReadsPHYRateAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.7: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.7: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a8ThReadsPHYRateAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.8: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.8: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a9ThReadsPHYRateAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.9: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.9: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2a10ThReadsPHYRateAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a.10: TH reads PHYRate attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a.10: TH reads PHYRate attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull PacketRxCountValue; - - CHIP_ERROR TestStep2bThReadsPacketRxCountAttributeValueFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads PacketRxCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads PacketRxCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - PacketRxCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull PacketTxCountValue; - - CHIP_ERROR TestStep2cThReadsPacketTxCountAttributeValueFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads PacketTxCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads PacketTxCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - PacketTxCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull TxErrCountValue; - - CHIP_ERROR TestStep2dThReadsTxErrCountAttributeValueFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads TxErrCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads TxErrCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - TxErrCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull CollisionCountValue; - - CHIP_ERROR TestStep2eThReadsCollisionCountAttributeValueFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads CollisionCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads CollisionCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - CollisionCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull OverrunCountValue; - - CHIP_ERROR TestStep2fThReadsOverrunCountAttributeValueFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads OverrunCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads OverrunCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - OverrunCountValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2gSendsResetCountsCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resetCountsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: Sends ResetCounts command: Error: %@", err); - } else { - NSLog(@"Step 2g: Sends ResetCounts command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2hThReadsPacketRxCountAttributeValueFromDut_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2iThReadsPacketTxCountAttributeValueFromDut_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2jThReadsTxErrCountAttributeValueFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2j: TH reads TxErrCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2j: TH reads TxErrCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("txErrCount", [value unsignedLongLongValue], TxErrCountValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2kThReadsCollisionCountAttributeValueFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2k: TH reads CollisionCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2k: TH reads CollisionCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("collisionCount", [value unsignedLongLongValue], CollisionCountValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2lThReadsOverrunCountAttributeValueFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2l: TH reads OverrunCount attribute value from DUT: Error: %@", err); - } else { - NSLog(@"Step 2l: TH reads OverrunCount attribute value from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("overrunCount", [value unsignedLongLongValue], OverrunCountValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLW_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLW_1_1() - : TestCommandBridge("Test_TC_FLW_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLW_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLW_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLW_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("FLW.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FLABEL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FLABEL_1_1() - : TestCommandBridge("Test_TC_FLABEL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FLABEL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLABEL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLABEL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_1_1() - : TestCommandBridge("Test_TC_FAN_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !FAN.S.F00 && !FAN.S.F01 && !FAN.S.F02 && !FAN.S.F03 && !FAN.S.F04 && !FAN.S.F05 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenFansf00spdEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenFansf01autEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenFansf02rckEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenFansf03wndEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenFansf04stepEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("FAN.S.F05")) { - NextTest(); - return; - } - err = TestStep3gGivenFansf05dirEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentFansf00SpdAttributeInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F02")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentFansf02rckAttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F03")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheFeatureDependentFansf03wndAttributeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList\n"); - if (ShouldSkip("FAN.S.F05")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheFeatureDependentFansf05dirAttributeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6:TH reads from the DUT the AcceptedCommandList attribute.\n"); - if (ShouldSkip(" !FAN.S.C00.Rsp ")) { - NextTest(); - return; - } - err = TestStep6thReadsFromTheDutTheAcceptedCommandListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6: TH Reads the optional command (Step) in AcceptedCommandList\n"); - if (ShouldSkip("FAN.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheOptionalCommandStepInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_18(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 19; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenFansf00spdEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenFansf01autEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenFansf02rckEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenFansf03wndEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenFansf04stepEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenFansf05dirEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentFansf00SpdAttributeInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentFansf02rckAttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheFeatureDependentFansf03wndAttributeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheFeatureDependentFansf05dirAttributeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6thReadsFromTheDutTheAcceptedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6:TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6:TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheOptionalCommandStepInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH Reads the optional command (Step) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: TH Reads the optional command (Step) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_1() - : TestCommandBridge("Test_TC_FAN_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the FanMode attribute\n"); - if (ShouldSkip("FAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheFanModeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the FanModeSequence attribute\n"); - if (ShouldSkip("FAN.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheFanModeSequenceAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the the PercentSetting attribute\n"); - if (ShouldSkip("FAN.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheThePercentSettingAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the the PercentCurrent attribute\n"); - if (ShouldSkip("FAN.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheThePercentCurrentAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheFanModeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the FanMode attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the FanMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fanMode", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheFanModeSequenceAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFanModeSequenceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the FanModeSequence attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the FanModeSequence attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fanModeSequence", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("fanModeSequence", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("fanModeSequence", [value unsignedCharValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheThePercentSettingAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the the PercentSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the the PercentSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("percentSetting", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("percentSetting", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("percentSetting", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheThePercentCurrentAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the the PercentCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the the PercentCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("percentCurrent", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("percentCurrent", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("percentCurrent", [value unsignedCharValue], 100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_2() - : TestCommandBridge("Test_TC_FAN_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the SpeedMax attribute\n"); - if (ShouldSkip("FAN.S.A0004")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheSpeedMaxAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SpeedSetting attribute\n"); - if (ShouldSkip("FAN.S.A0005 && FAN.S.A0004")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheSpeedSettingAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the the SpeedCurrent attribute\n"); - if (ShouldSkip("FAN.S.A0006 && FAN.S.A0004")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheTheSpeedCurrentAttribute_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull SpeedMaxValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheSpeedMaxAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedMaxWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the SpeedMax attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the SpeedMax attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("speedMax", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("speedMax", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speedMax", [value unsignedCharValue], 100U)); - { - SpeedMaxValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSpeedSettingAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the SpeedSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the SpeedSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("speedSetting", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("speedSetting", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speedSetting", [value unsignedCharValue], SpeedMaxValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheTheSpeedCurrentAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the the SpeedCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the the SpeedCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("speedCurrent", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("speedCurrent", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speedCurrent", [value unsignedCharValue], SpeedMaxValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_3() - : TestCommandBridge("Test_TC_FAN_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the RockSupport attribute\n"); - if (ShouldSkip("FAN.S.A0007")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheRockSupportAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the RockSetting attribute\n"); - if (ShouldSkip("FAN.S.A0008")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheRockSettingAttribute_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheRockSupportAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRockSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the RockSupport attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the RockSupport attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("rockSupport", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheRockSettingAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRockSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the RockSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the RockSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("rockSetting", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_2_4() - : TestCommandBridge("Test_TC_FAN_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the WindSupport attribute\n"); - if (ShouldSkip("FAN.S.A0009")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheWindSupportAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the WindSetting attribute\n"); - if (ShouldSkip("FAN.S.A000A")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheWindSettingAttribute_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheWindSupportAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the WindSupport attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the WindSupport attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("windSupport", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheWindSettingAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the WindSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the WindSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("windSetting", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_3_1() - : TestCommandBridge("Test_TC_FAN_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ConfigPercentSetting", 0, UINT8_MAX, &mConfigPercentSetting); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH writes a supported FanMode attribute that is other than off to DUT\n"); - if (ShouldSkip("FAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep2aThWritesASupportedFanModeAttributeThatIsOtherThanOffToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 1000ms\n"); - if (ShouldSkip("FAN.S.A0000")) { - NextTest(); - return; - } - err = TestWait1000ms_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: after a few seconds, TH reads from the DUT the the FanMode attribute\n"); - if (ShouldSkip("FAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep2bAfterAFewSecondsThReadsFromTheDutTheTheFanModeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2.1a: TH writes the Off value of FanMode attribute to DUT\n"); - if (ShouldSkip("FAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep21aThWritesTheOffValueOfFanModeAttributeToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 1000ms\n"); - if (ShouldSkip("FAN.S.A0000")) { - NextTest(); - return; - } - err = TestWait1000ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2.1b: TH reads from the DUT the PercentSetting attribute\n"); - if (ShouldSkip("FAN.S.A0002")) { - NextTest(); - return; - } - err = TestStep21bThReadsFromTheDutThePercentSettingAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2.1c: TH reads from the DUT the PercentCurrent attribute\n"); - if (ShouldSkip("FAN.S.A0003")) { - NextTest(); - return; - } - err = TestStep21cThReadsFromTheDutThePercentCurrentAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3a: TH writes PercentSetting attribute a non-zero value to DUT\n"); - if (ShouldSkip("FAN.S.A0002")) { - NextTest(); - return; - } - err = TestStep3aThWritesPercentSettingAttributeANonZeroValueToDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 1000ms\n"); - if (ShouldSkip("FAN.S.A0002")) { - NextTest(); - return; - } - err = TestWait1000ms_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b: TH reads from the DUT the PercentCurrent attribute\n"); - if (ShouldSkip("FAN.S.A0003")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutThePercentCurrentAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3c: TH reads from the DUT the PercentSetting attribute\n"); - if (ShouldSkip("FAN.S.A0002")) { - NextTest(); - return; - } - err = TestStep3cThReadsFromTheDutThePercentSettingAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3.1a: TH writes PercentSetting attribute a zero value to DUT\n"); - if (ShouldSkip("FAN.S.A0002")) { - NextTest(); - return; - } - err = TestStep31aThWritesPercentSettingAttributeAZeroValueToDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 1000ms\n"); - if (ShouldSkip("FAN.S.A0002")) { - NextTest(); - return; - } - err = TestWait1000ms_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3.1b: after a few seconds, TH reads from the DUT the the FanMode attribute\n"); - if (ShouldSkip("FAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep31bAfterAFewSecondsThReadsFromTheDutTheTheFanModeAttribute_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mConfigPercentSetting; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWritesASupportedFanModeAttributeThatIsOtherThanOffToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id fanModeArgument; - fanModeArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH writes a supported FanMode attribute that is other than off to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH writes a supported FanMode attribute that is other than off to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2bAfterAFewSecondsThReadsFromTheDutTheTheFanModeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: after a few seconds, TH reads from the DUT the the FanMode attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: after a few seconds, TH reads from the DUT the the FanMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FanMode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21aThWritesTheOffValueOfFanModeAttributeToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id fanModeArgument; - fanModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2.1a: TH writes the Off value of FanMode attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 2.1a: TH writes the Off value of FanMode attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep21bThReadsFromTheDutThePercentSettingAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2.1b: TH reads from the DUT the PercentSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 2.1b: TH reads from the DUT the PercentSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21cThReadsFromTheDutThePercentCurrentAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2.1c: TH reads from the DUT the PercentCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 2.1c: TH reads from the DUT the PercentCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PercentCurrent", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWritesPercentSettingAttributeANonZeroValueToDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id percentSettingArgument; - percentSettingArgument = mConfigPercentSetting.HasValue() ? [NSNumber numberWithUnsignedChar:mConfigPercentSetting.Value()] : [NSNumber numberWithUnsignedChar:30U]; - [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH writes PercentSetting attribute a non-zero value to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH writes PercentSetting attribute a non-zero value to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsFromTheDutThePercentCurrentAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the PercentCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the PercentCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PercentCurrent", actualValue, mConfigPercentSetting.HasValue() ? mConfigPercentSetting.Value() : 30U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFromTheDutThePercentSettingAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads from the DUT the PercentSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads from the DUT the PercentSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, mConfigPercentSetting.HasValue() ? mConfigPercentSetting.Value() : 30U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep31aThWritesPercentSettingAttributeAZeroValueToDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id percentSettingArgument; - percentSettingArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3.1a: TH writes PercentSetting attribute a zero value to DUT: Error: %@", err); - } else { - NSLog(@"Step 3.1a: TH writes PercentSetting attribute a zero value to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep31bAfterAFewSecondsThReadsFromTheDutTheTheFanModeAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3.1b: after a few seconds, TH reads from the DUT the the FanMode attribute: Error: %@", err); - } else { - NSLog(@"Step 3.1b: after a few seconds, TH reads from the DUT the the FanMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FanMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_3_2() - : TestCommandBridge("Test_TC_FAN_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SpeedMax attribute\n"); - if (ShouldSkip("FAN.S.A0004")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheSpeedMaxAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH writes to the DUT the a value less than or equal to the value read in step 2\n"); - if (ShouldSkip("FAN.S.A0005")) { - NextTest(); - return; - } - err = TestStep3ThWritesToTheDutTheAValueLessThanOrEqualToTheValueReadInStep2_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Wait 1000ms\n"); - if (ShouldSkip("FAN.S.A0005")) { - NextTest(); - return; - } - err = TestWait1000ms_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: After a few seconds, TH reads from the DUT the SpeedSetting attribute\n"); - if (ShouldSkip("FAN.S.A0005")) { - NextTest(); - return; - } - err = TestStep4AfterAFewSecondsThReadsFromTheDutTheSpeedSettingAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the SpeedCurrent attribute\n"); - if (ShouldSkip("FAN.S.A0006")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheSpeedCurrentAttribute_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull rSpeedMax; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheSpeedMaxAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedMaxWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the SpeedMax attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the SpeedMax attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - rSpeedMax = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThWritesToTheDutTheAValueLessThanOrEqualToTheValueReadInStep2_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id speedSettingArgument; - speedSettingArgument = - [rSpeedMax copy]; - [cluster writeAttributeSpeedSettingWithValue:speedSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH writes to the DUT the a value less than or equal to the value read in step 2: Error: %@", err); - } else { - NSLog(@"Step 3: TH writes to the DUT the a value less than or equal to the value read in step 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4AfterAFewSecondsThReadsFromTheDutTheSpeedSettingAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: After a few seconds, TH reads from the DUT the SpeedSetting attribute: Error: %@", err); - } else { - NSLog(@"Step 4: After a few seconds, TH reads from the DUT the SpeedSetting attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (rSpeedMax == nil) { - VerifyOrReturn(CheckValueNull("SpeedSetting", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, rSpeedMax)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheSpeedCurrentAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the SpeedCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the SpeedCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SpeedCurrent", actualValue, rSpeedMax)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_FAN_3_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_FAN_3_6() - : TestCommandBridge("Test_TC_FAN_3_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_FAN_3_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_3_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_3_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH writes a value of Forward to the DUT\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep2ThWritesAValueOfForwardToTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 1000ms\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestWait1000ms_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep3AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes a value of Reverse to the DUT\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep4ThWritesAValueOfReverseToTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 1000ms\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestWait1000ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute\n"); - if (ShouldSkip("FAN.S.A000B")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThWritesAValueOfForwardToTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id airflowDirectionArgument; - airflowDirectionArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeAirflowDirectionWithValue:airflowDirectionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes a value of Forward to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH writes a value of Forward to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAirflowDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Error: %@", err); - } else { - NSLog(@"Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AirflowDirection", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWritesAValueOfReverseToTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id airflowDirectionArgument; - airflowDirectionArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeAirflowDirectionWithValue:airflowDirectionArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes a value of Reverse to the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH writes a value of Reverse to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAirflowDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AirflowDirection", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CGEN_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CGEN_1_1() - : TestCommandBridge("Test_TC_CGEN_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CGEN_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CGEN_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CGEN_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Read the global attribute: FeatureMap\n"); - err = TestStep3ReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ReadTheGlobalAttributeAttributeList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ReadTheGlobalAttributeAttributeList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CGEN_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CGEN_2_1() - : TestCommandBridge("Test_TC_CGEN_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CGEN_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CGEN_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CGEN_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH1 reads the BreadCrumb Attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0000")) { - NextTest(); - return; - } - err = TestStep1Th1ReadsTheBreadCrumbAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT\n"); - if (ShouldSkip("CGEN.S.A0000")) { - NextTest(); - return; - } - err = TestStep2Th1WritesTheBreadCrumbAttributeAs1ToTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH1 reads the BreadCrumb attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0000")) { - NextTest(); - return; - } - err = TestStep3Th1ReadsTheBreadCrumbAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH1 reads the RegulatoryConfig attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0002")) { - NextTest(); - return; - } - err = TestStep4Th1ReadsTheRegulatoryConfigAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH1 reads the LocationCapability attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0003")) { - NextTest(); - return; - } - err = TestStep5Th1ReadsTheLocationCapabilityAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535\n"); - if (ShouldSkip("CGEN.S.A0001")) { - NextTest(); - return; - } - err = TestStep6Th1ReadsBasicCommissioningInfoAttributeFromDutAndVerifyThatTheBasicCommissioningInfoAttributeHasTheFollowingFieldFailSafeExpiryLengthSecondsFieldValueIsWithinADurationRangeOf0To65535_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT\n"); - if (ShouldSkip("CGEN.S.A0004")) { - NextTest(); - return; - } - err = TestStep7Th1ReadsSupportsConcurrentConnectionAttributeFromTheDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1Th1ReadsTheBreadCrumbAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH1 reads the BreadCrumb Attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH1 reads the BreadCrumb Attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("breadcrumb", "int64u", "int64u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2Th1WritesTheBreadCrumbAttributeAs1ToTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3Th1ReadsTheBreadCrumbAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH1 reads the BreadCrumb attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH1 reads the BreadCrumb attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4Th1ReadsTheRegulatoryConfigAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRegulatoryConfigWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH1 reads the RegulatoryConfig attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH1 reads the RegulatoryConfig attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("regulatoryConfig", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("regulatoryConfig", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5Th1ReadsTheLocationCapabilityAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationCapabilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH1 reads the LocationCapability attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH1 reads the LocationCapability attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("locationCapability", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("locationCapability", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6Th1ReadsBasicCommissioningInfoAttributeFromDutAndVerifyThatTheBasicCommissioningInfoAttributeHasTheFollowingFieldFailSafeExpiryLengthSecondsFieldValueIsWithinADurationRangeOf0To65535_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBasicCommissioningInfoWithCompletion:^(MTRGeneralCommissioningClusterBasicCommissioningInfo * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535: Error: %@", err); - } else { - NSLog(@"Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7Th1ReadsSupportsConcurrentConnectionAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportsConcurrentConnectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportsConcurrentConnection", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGGEN_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGGEN_1_1() - : TestCommandBridge("Test_TC_DGGEN_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGGEN_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGGEN_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGGEN_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Read the global attribute: FeatureMap\n"); - err = TestStep3ReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList\n"); - err = TestStep4bValidatePresenceOfMandatoryAttributeUpTimeInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: Read optional attribute(TotalOperationalHours) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0003")) { - NextTest(); - return; - } - err = TestStep4cReadOptionalAttributeTotalOperationalHoursInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: Read optional attribute(BootReason) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dReadOptionalAttributeBootReasonInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: Read optional attribute(ActiveHardwareFaults) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0005")) { - NextTest(); - return; - } - err = TestStep4eReadOptionalAttributeActiveHardwareFaultsInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: Read optional attribute(ActiveRadioFaults) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0006")) { - NextTest(); - return; - } - err = TestStep4fReadOptionalAttributeActiveRadioFaultsInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: Read optional attribute(ActiveNetworkFaults) in AttributeList\n"); - if (ShouldSkip("DGGEN.S.A0007")) { - NextTest(); - return; - } - err = TestStep4gReadOptionalAttributeActiveNetworkFaultsInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5a: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5b: Read optional event(HardwareFaultChange) in EventList\n"); - if (ShouldSkip("DGGEN.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5c: Read optional event(RadioFaultChange) in EventList\n"); - if (ShouldSkip("DGGEN.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5d: Read optional event(NetworkFaultChange) in EventList\n"); - if (ShouldSkip("DGGEN.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 3: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bValidatePresenceOfMandatoryAttributeUpTimeInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadOptionalAttributeTotalOperationalHoursInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read optional attribute(TotalOperationalHours) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read optional attribute(TotalOperationalHours) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadOptionalAttributeBootReasonInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read optional attribute(BootReason) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read optional attribute(BootReason) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eReadOptionalAttributeActiveHardwareFaultsInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Read optional attribute(ActiveHardwareFaults) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: Read optional attribute(ActiveHardwareFaults) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadOptionalAttributeActiveRadioFaultsInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read optional attribute(ActiveRadioFaults) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read optional attribute(ActiveRadioFaults) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gReadOptionalAttributeActiveNetworkFaultsInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Read optional attribute(ActiveNetworkFaults) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: Read optional attribute(ActiveNetworkFaults) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 2UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_GRPKEY_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_GRPKEY_1_1() - : TestCommandBridge("Test_TC_GRPKEY_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_GRPKEY_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_GRPKEY_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_GRPKEY_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !GRPKEY.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("GRPKEY.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenGrpkeysf00csEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenGrpkeysf00csEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_GRPKEY_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_GRPKEY_2_2() - : TestCommandBridge("Test_TC_GRPKEY_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_GRPKEY_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_GRPKEY_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_GRPKEY_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.\n"); - if (ShouldSkip("GRPKEY.S.A0003")) { - NextTest(); - return; - } - err = TestStep1ThReadsMaxGroupKeysPerFabricAttributeFromGroupKeyManagementClusterOnDutUsingAFabricFilteredReadSaveTheValueAsMaxGrpKeyForFutureUse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a\n"); - if (ShouldSkip("GRPKEY.S.C01.Rsp && GRPKEY.S.C02.Tx")) { - NextTest(); - return; - } - err = TestStep3ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1null7EpochKey2Null8EpochStartTime2null_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime2null_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithCommandFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0Null4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0Null5EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0184467440737095516135EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime117EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep12ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614NoteEpochKey1AndEpochStartTime1AreNullWhenEpochKey2AndEpochStartTime2AreNotNull_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime218446744073709551614NoteEpochKey2IsSetToNullAndEpochStartTime2IsNotNull_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep14ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime2NullNoteEpochKey2IsNotNullAndEpochStartTime2IsNull_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep15ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime016EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf7EpochStartTime1184467440737095516138EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf9EpochStartTime21NoteEpochStartTime2IsEarlierThanEpochStartTime1_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D04EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime21Note1RepeatTheStepBySendingEpochKey1AndEpochKey2With1ByteValue16Bytes_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16RepeatTheStepBySendingEpochKey1With1ByteValue16Bytes_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16NoteRepeatTheStepBySendingEpochKey2With1ByteValue16Bytes_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having15BytesValue16Byte_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey1Having15BytesValue16Byte_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey2Having15BytesValue16Byte_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16bThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having17BytesValue16Bytes_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey1Having17BytesValue16Bytes_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes)\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey2Having17BytesValue16Bytes_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep17ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D3d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D4d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1174467440737095516137EpochKey2D5d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime217446744073709551614NoteKeySetWriteCommandIsSentWithDifferentEpochKeysEpochStartTime1AndEpochStartTime2Values_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a\n"); - if (ShouldSkip("GRPKEY.S.C01.Rsp && GRPKEY.S.C02.Tx")) { - NextTest(); - return; - } - err = TestStep18ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.\n"); - if (ShouldSkip("GRPKEY.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep19ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.\n"); - if (ShouldSkip("GRPKEY.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep20ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 21: TH sends KeySetWrite command to DUT until size of list for TH’s fabric in GroupKeyMap attribute contains Max_GrpKey entries, starting with GroupKeySetID 1 and incrementing by 1 each time.\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep21ThSendsKeySetWriteCommandToDutUntilSizeOfListForTHsFabricInGroupKeyMapAttributeContainsMaxGrpKeyEntriesStartingWithGroupKeySetID1AndIncrementingBy1EachTime_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.\n"); - if (ShouldSkip("GRPKEY.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep22ThAgainSendsKeySetWriteCommandToDutWithAnyOtherGroupKeySetIDNotUsedYet_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 23: TH sends KeySetReadAllIndices command to DUT.\n"); - if (ShouldSkip("GRPKEY.S.C04.Rsp && GRPKEY.S.C05.Tx && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep23ThSendsKeySetReadAllIndicesCommandToDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0\n"); - if (ShouldSkip("GRPKEY.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep24ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x0_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.\n"); - if (ShouldSkip("GRPKEY.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep25ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_33(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 34; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull Max_GrpKey; - - CHIP_ERROR TestStep1ThReadsMaxGroupKeysPerFabricAttributeFromGroupKeyManagementClusterOnDutUsingAFabricFilteredReadSaveTheValueAsMaxGrpKeyForFutureUse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxGroupKeysPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - Max_GrpKey = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - [cluster keySetReadWithParams:params completion: - ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.groupKeySet; - VerifyOrReturn(CheckValue("GroupKeySetID", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySetID, 26U)); - VerifyOrReturn(CheckValue("GroupKeySecurityPolicy", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySecurityPolicy, 0U)); - VerifyOrReturn(CheckValueNull("EpochKey0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey0)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0)); - VerifyOrReturn(CheckValue("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0, 1ULL)); - VerifyOrReturn(CheckValueNull("EpochKey1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey1)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1)); - VerifyOrReturn(CheckValue("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1, 18446744073709551613ULL)); - VerifyOrReturn(CheckValueNull("EpochKey2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey2)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2)); - VerifyOrReturn(CheckValue("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1null7EpochKey2Null8EpochStartTime2null_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime2null_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithCommandFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0Null4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0Null5EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0184467440737095516135EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime117EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614NoteEpochKey1AndEpochStartTime1AreNullWhenEpochKey2AndEpochStartTime2AreNotNull_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null: Error: %@", err); - } else { - NSLog(@"Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime218446744073709551614NoteEpochKey2IsSetToNullAndEpochStartTime2IsNotNull_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime2NullNoteEpochKey2IsNotNullAndEpochStartTime2IsNull_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null: Error: %@", err); - } else { - NSLog(@"Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime016EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf7EpochStartTime1184467440737095516138EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf9EpochStartTime21NoteEpochStartTime2IsEarlierThanEpochStartTime1_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1: Error: %@", err); - } else { - NSLog(@"Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D04EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime21Note1RepeatTheStepBySendingEpochKey1AndEpochKey2With1ByteValue16Bytes_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0" length:1]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16RepeatTheStepBySendingEpochKey1With1ByteValue16Bytes_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1" length:1]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16NoteRepeatTheStepBySendingEpochKey2With1ByteValue16Bytes_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2" length:1]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having15BytesValue16Byte_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte): Error: %@", err); - } else { - NSLog(@"Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey1Having15BytesValue16Byte_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte): Error: %@", err); - } else { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey2Having15BytesValue16Byte_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte): Error: %@", err); - } else { - NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16bThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having17BytesValue16Bytes_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey1Having17BytesValue16Bytes_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey2Having17BytesValue16Bytes_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes): Error: %@", err); - } else { - NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D3d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D4d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1174467440737095516137EpochKey2D5d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime217446744073709551614NoteKeySetWriteCommandIsSentWithDifferentEpochKeysEpochStartTime1AndEpochStartTime2Values_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd3\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd4\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:17446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd5\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:17446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values: Error: %@", err); - } else { - NSLog(@"Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - [cluster keySetReadWithParams:params completion: - ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Error: %@", err); - } else { - NSLog(@"Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.groupKeySet; - VerifyOrReturn(CheckValue("GroupKeySetID", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySetID, 26U)); - VerifyOrReturn(CheckValue("GroupKeySecurityPolicy", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySecurityPolicy, 0U)); - VerifyOrReturn(CheckValueNull("EpochKey0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey0)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0)); - VerifyOrReturn(CheckValue("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0, 1ULL)); - VerifyOrReturn(CheckValueNull("EpochKey1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey1)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1)); - VerifyOrReturn(CheckValue("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1, 17446744073709551613ULL)); - VerifyOrReturn(CheckValueNull("EpochKey2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey2)); - VerifyOrReturn(CheckValueNonNull("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2)); - VerifyOrReturn(CheckValue("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2, 17446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:27U]; - [cluster keySetReadWithParams:params completion: - ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.: Error: %@", err); - } else { - NSLog(@"Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_NOT_FOUND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:26U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.: Error: %@", err); - } else { - NSLog(@"Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21ThSendsKeySetWriteCommandToDutUntilSizeOfListForTHsFabricInGroupKeyMapAttributeContainsMaxGrpKeyEntriesStartingWithGroupKeySetID1AndIncrementingBy1EachTime_29() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep22ThAgainSendsKeySetWriteCommandToDutWithAnyOtherGroupKeySetIDNotUsedYet_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.: Error: %@", err); - } else { - NSLog(@"Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThSendsKeySetReadAllIndicesCommandToDut_31() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep24ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x0_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:0U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0: Error: %@", err); - } else { - NSLog(@"Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:27U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.: Error: %@", err); - } else { - NSLog(@"Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_NOT_FOUND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ICDM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ICDM_1_1() - : TestCommandBridge("Test_TC_ICDM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ICDM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ICDM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ICDM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from DUT\n"); - err = TestStep2ThReadsClusterRevisionAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from DUT\n"); - if (ShouldSkip("ICDM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads FeatureMap attribute from DUT\n"); - if (ShouldSkip(" !ICDM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFeatureMapAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList attribute from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: Read the optional attribute(RegisteredClients) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeRegisteredClientsInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: Read the optional attribute(IcdCounter) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0004")) { - NextTest(); - return; - } - err = TestStep4cReadTheOptionalAttributeIcdCounterInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList\n"); - if (ShouldSkip("ICDM.S.A0005")) { - NextTest(); - return; - } - err = TestStep4dReadTheOptionalAttributeClientsSupportedPerFabricInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6a: TH reads AcceptedCommandList attribute from DUT\n"); - if (ShouldSkip(" !ICDM.S.F00 && !ICDM.S.C03.Rsp ")) { - NextTest(); - return; - } - err = TestStep6aThReadsAcceptedCommandListAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true\n"); - if (ShouldSkip("ICDM.S.F00")) { - NextTest(); - return; - } - err = TestStep6bThReadsAcceptedCommandListAttributeFromDutIfIcdmsf00IsTrue_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6c: Read the optional command (StayActiveRequest) in AttributeList\n"); - if (ShouldSkip("ICDM.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6cReadTheOptionalCommandStayActiveRequestInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - if (ShouldSkip(" !ICDM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); - if (ShouldSkip("ICDM.S.F00")) { - NextTest(); - return; - } - err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeRegisteredClientsInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional attribute(RegisteredClients) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional attribute(RegisteredClients) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheOptionalAttributeIcdCounterInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read the optional attribute(IcdCounter) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read the optional attribute(IcdCounter) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheOptionalAttributeClientsSupportedPerFabricInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsAcceptedCommandListAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsAcceptedCommandListAttributeFromDutIfIcdmsf00IsTrue_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cReadTheOptionalCommandStayActiveRequestInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: Read the optional command (StayActiveRequest) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 6c: Read the optional command (StayActiveRequest) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_I_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_1_1() - : TestCommandBridge("Test_TC_I_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheOptionalCommandTriggerEffectInAcceptedCommandList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheOptionalCommandTriggerEffectInAcceptedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_I_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_2_1() - : TestCommandBridge("Test_TC_I_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the IdentifyTime attribute from the DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheIdentifyTimeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the IdentifyType attribute from the DUT\n"); - if (ShouldSkip("I.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheIdentifyTypeAttributeFromTheDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheIdentifyTimeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the IdentifyTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the IdentifyTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("identifyTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheIdentifyTypeAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the IdentifyType attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the IdentifyType attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("identifyType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("identifyType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyType", [value unsignedCharValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_I_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_2_2() - : TestCommandBridge("Test_TC_I_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1a: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1aCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1b: TH reads the IdentifyType attribute from the DUT.\n"); - if (ShouldSkip("I.S.A0001")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheIdentifyTypeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that the device enters its identification state using the IdentifyType from Step 1b, in order to indicate to an observer which of several nodes and/or endpoints it is.\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).\n"); - if (ShouldSkip("I.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x003c60s_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH reads immediately IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep2bThReadsImmediatelyIdentifyTimeAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 10000ms\n"); - err = TestWait10000ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep2cAfter10SecondsTheThReadsIdentifyTimeAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).\n"); - if (ShouldSkip("I.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aBefore60SecondsExpireThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x0000StopIdentifying_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads immediately IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsImmediatelyIdentifyTimeAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep6aThWritesAValueOf0x000f15sToIdentifyTimeAttributeOfDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 15000ms\n"); - err = TestWait15000ms_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT\n"); - if (ShouldSkip("I.S.A0000")) { - NextTest(); - return; - } - err = TestStep6bAfter15SecondsTheThReadsIdentifyTimeAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Verify that the device enters its identification state using the IdentifyType from Step 1b, in order to indicate to an observer which of several nodes and/or endpoints it is.\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1aCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull IdentifyTypeValue; - - CHIP_ERROR TestStep1bThReadsTheIdentifyTypeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the IdentifyType attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the IdentifyType attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("identifyType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("identifyType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyType", [value unsignedCharValue], 5U)); - { - IdentifyTypeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x003c60s_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; - params.identifyTime = - [NSNumber numberWithUnsignedShort:60U]; - [cluster identifyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsImmediatelyIdentifyTimeAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads immediately IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads immediately IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 51U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 69U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cAfter10SecondsTheThReadsIdentifyTimeAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 42U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 58U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aBefore60SecondsExpireThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x0000StopIdentifying_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; - params.identifyTime = - [NSNumber numberWithUnsignedShort:0U]; - [cluster identifyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).: Error: %@", err); - } else { - NSLog(@"Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsImmediatelyIdentifyTimeAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads immediately IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads immediately IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("IdentifyTime", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWritesAValueOf0x000f15sToIdentifyTimeAttributeOfDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id identifyTimeArgument; - identifyTimeArgument = - [NSNumber numberWithUnsignedShort:15U]; - [cluster writeAttributeIdentifyTimeWithValue:identifyTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait15000ms_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 15000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6bAfter15SecondsTheThReadsIdentifyTimeAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_I_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_I_2_3() - : TestCommandBridge("Test_TC_I_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_I_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x00 default\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x00Default_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : DUT executes a blink effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABlinkEffect_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : DUT executes a breathe effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABreatheEffect_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x02 okay and the effect variant field set to 0x00 default\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x02OkayAndTheEffectVariantFieldSetTo0x00Default_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : DUT executes an okay effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesAnOkayEffect_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2d: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x0b channel change and the effect variant field set to 0x00 default\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2dThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x0bChannelChangeAndTheEffectVariantFieldSetTo0x00Default_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : DUT executes a channel change effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesAChannelChangeEffect_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2e: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2eThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : DUT executes a breathe effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABreatheEffect_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2f: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xfe finish effect and the effect variant field set to 0x00 default\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2fThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xfeFinishEffectAndTheEffectVariantFieldSetTo0x00Default_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : DUT stops the breathe effect after the current effect sequence\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutStopsTheBreatheEffectAfterTheCurrentEffectSequence_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2g: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2gThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : DUT executes a breathe effect\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutExecutesABreatheEffect_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 2h: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep2hThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : DUT stops the breathe effect as soon as possible.\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutStopsTheBreatheEffectAsSoonAsPossible_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x42 unknown\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x42Unknown_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Check DUT executes a blink effect.\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestCheckDutExecutesABlinkEffect_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default\n"); - if (ShouldSkip("I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : DUT stops any effect that may be still running as soon as possible\n"); - if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestDutStopsAnyEffectThatMayBeStillRunningAsSoonAsPossible_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x00Default_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:0U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x00 default: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x00 default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABlinkEffect_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:1U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABreatheEffect_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2cThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x02OkayAndTheEffectVariantFieldSetTo0x00Default_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:2U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x02 okay and the effect variant field set to 0x00 default: Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x02 okay and the effect variant field set to 0x00 default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesAnOkayEffect_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2dThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x0bChannelChangeAndTheEffectVariantFieldSetTo0x00Default_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:11U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x0b channel change and the effect variant field set to 0x00 default: Error: %@", err); - } else { - NSLog(@"Step 2d: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x0b channel change and the effect variant field set to 0x00 default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesAChannelChangeEffect_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2eThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:1U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Error: %@", err); - } else { - NSLog(@"Step 2e: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABreatheEffect_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2fThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xfeFinishEffectAndTheEffectVariantFieldSetTo0x00Default_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:254U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xfe finish effect and the effect variant field set to 0x00 default: Error: %@", err); - } else { - NSLog(@"Step 2f: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xfe finish effect and the effect variant field set to 0x00 default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutStopsTheBreatheEffectAfterTheCurrentEffectSequence_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2gThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:1U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Error: %@", err); - } else { - NSLog(@"Step 2g: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutExecutesABreatheEffect_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2hThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:255U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2h: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default: Error: %@", err); - } else { - NSLog(@"Step 2h: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutStopsTheBreatheEffectAsSoonAsPossible_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x42Unknown_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:0U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:66U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x42 unknown: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x42 unknown: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckDutExecutesABlinkEffect_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; - params.effectIdentifier = - [NSNumber numberWithUnsignedChar:255U]; - params.effectVariant = - [NSNumber numberWithUnsignedChar:0U]; - [cluster triggerEffectWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default: Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutStopsAnyEffectThatMayBeStillRunningAsSoonAsPossible_20() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_ILL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ILL_1_1() - : TestCommandBridge("Test_TC_ILL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ILL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT.\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap attribute from the DUT.\n"); - err = TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("ILL.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList\n"); - if (ShouldSkip("ILL.S.A0004")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeLightSensorTypeInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the AcceptedCommandList attribute from the DUT.\n"); - err = TestStep6ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads the GeneratedCommandList attribute from the DUT.\n"); - err = TestStep7ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeLightSensorTypeInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the AcceptedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the AcceptedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the GeneratedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the GeneratedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ILL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ILL_2_1() - : TestCommandBridge("Test_TC_ILL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ILL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2TestHarnessClientReadsMinMeasuredValueAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3TestHarnessClientReadsMaxMeasuredValueAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Test Harness Client reads MeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4TestHarnessClientReadsMeasuredValueAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the Tolerance attribute from the DUT.\n"); - if (ShouldSkip("ILL.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheToleranceAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads the LightSensorType attribute from the DUT\n"); - if (ShouldSkip("ILL.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheLightSensorTypeAttributeFromTheDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2TestHarnessClientReadsMinMeasuredValueAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value unsignedShortValue], 65533U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3TestHarnessClientReadsMaxMeasuredValueAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value unsignedShortValue], 2U)); - VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4TestHarnessClientReadsMeasuredValueAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Test Harness Client reads MeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4: Test Harness Client reads MeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheToleranceAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheLightSensorTypeAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLightSensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the LightSensorType attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the LightSensorType attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lightSensorType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("lightSensorType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("lightSensorType", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ILL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ILL_2_2() - : TestCommandBridge("Test_TC_ILL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ILL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH reads MinMeasuredValue attribute from DUT\n"); - if (ShouldSkip("ILL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2aThReadsMinMeasuredValueAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads MaxMeasuredValue attribute from DUT\n"); - if (ShouldSkip("ILL.S.A0002")) { - NextTest(); - return; - } - err = TestStep2bThReadsMaxMeasuredValueAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Cover the sensor or darken the room\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep3CoverTheSensorOrDarkenTheRoom_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 1s\n"); - err = TestWait1s_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: Expose the sensor again to light\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep5ExposeTheSensorAgainToLight_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 1s\n"); - err = TestWait1s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.\n"); - if (ShouldSkip("ILL.S.A0000 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2aThReadsMinMeasuredValueAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads MinMeasuredValue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads MinMeasuredValue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16u", "int16u")); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep2bThReadsMaxMeasuredValueAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads MaxMeasuredValue attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads MaxMeasuredValue attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16u", "int16u")); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3CoverTheSensorOrDarkenTheRoom_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for Successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait1s_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value unsignedShortValue], 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ExposeTheSensorAgainToLight_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for Successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait1s_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.: Error: %@", err); - } else { - NSLog(@"Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_1_1() - : TestCommandBridge("Test_TC_LVL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: Read the global attribute: ClusterRevision\n"); - err = TestStep1ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: Read the global attribute: FeatureMap\n"); - if (ShouldSkip(" !LVL.S.F00 && !LVL.S.F01 && !LVL.S.F02 ")) { - NextTest(); - return; - } - err = TestStep2aReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LVL.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenLvlsf00ooEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenLvlsf01ltEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LVL.S.F02")) { - NextTest(); - return; - } - err = TestStep2dGivenLvlsf02fqEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aReadTheGlobalAttributeAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aReadTheGlobalAttributeAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: Read the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep3bReadTheOptionalAttributeStartUpCurrentLevelAndRemainingTimeInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: Read the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList\n"); - if (ShouldSkip("LVL.S.F02")) { - NextTest(); - return; - } - err = TestStep3cReadTheOptionalAttributeCurrentFrequencyMinFrequencyAndMinFrequencyInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3d: Read the optional attribute(MinLevel) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3dReadTheOptionalAttributeMinLevelInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3e: Read the optional attribute(MaxLevel) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep3eReadTheOptionalAttributeMaxLevelInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3f: Read the optional attribute(OnOffTransitionTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep3fReadTheOptionalAttributeOnOffTransitionTimeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3g: Read the optional attribute(OnTransitionTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep3gReadTheOptionalAttributeOnTransitionTimeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3h: Read the optional attribute(OffTransitionTime) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep3hReadTheOptionalAttributeOffTransitionTimeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3i: Read the optional attribute(DefaultMoveRate) in AttributeList\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep3iReadTheOptionalAttributeDefaultMoveRateInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AcceptedCommandList\n"); - err = TestStep4aReadTheGlobalAttributeAcceptedCommandList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a.1: Read the Feature-dependent(LVL.S.F02) command in AcceptedCommandList\n"); - if (ShouldSkip("LVL.S.F02")) { - NextTest(); - return; - } - err = TestStep4a1ReadTheFeatureDependentLVLSF02CommandInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: Read the global attribute: GeneratedCommandList\n"); - err = TestStep4bReadTheGlobalAttributeGeneratedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 1: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 2a: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenLvlsf00ooEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenLvlsf01ltEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dGivenLvlsf02fqEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bReadTheOptionalAttributeStartUpCurrentLevelAndRemainingTimeInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Read the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: Read the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cReadTheOptionalAttributeCurrentFrequencyMinFrequencyAndMinFrequencyInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Read the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: Read the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dReadTheOptionalAttributeMinLevelInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Read the optional attribute(MinLevel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3d: Read the optional attribute(MinLevel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eReadTheOptionalAttributeMaxLevelInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Read the optional attribute(MaxLevel) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3e: Read the optional attribute(MaxLevel) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fReadTheOptionalAttributeOnOffTransitionTimeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Read the optional attribute(OnOffTransitionTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3f: Read the optional attribute(OnOffTransitionTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gReadTheOptionalAttributeOnTransitionTimeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Read the optional attribute(OnTransitionTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3g: Read the optional attribute(OnTransitionTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hReadTheOptionalAttributeOffTransitionTimeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Read the optional attribute(OffTransitionTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3h: Read the optional attribute(OffTransitionTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iReadTheOptionalAttributeDefaultMoveRateInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Read the optional attribute(DefaultMoveRate) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3i: Read the optional attribute(DefaultMoveRate) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAcceptedCommandList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a1ReadTheFeatureDependentLVLSF02CommandInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a.1: Read the Feature-dependent(LVL.S.F02) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4a.1: Read the Feature-dependent(LVL.S.F02) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheGlobalAttributeGeneratedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_2_1() - : TestCommandBridge("Test_TC_LVL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the CurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentLevelAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the RemainingTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheRemainingTimeAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the MinLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0002 && LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheMinLevelAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads the MinLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0002 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheMinLevelAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003 && LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheMaxLevelAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheMaxLevelAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b & 4C TH reads the CurrentLevel attribute\n"); - if (ShouldSkip("LVL.S.F01 && LVL.S.A0002 && LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep4b4cThReadsTheCurrentLevelAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b & 4C TH reads the CurrentLevel attribute\n"); - if (ShouldSkip("LVL.S.A0002 && LVL.S.A0003 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep4b4cThReadsTheCurrentLevelAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the CurrentFrequency attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheCurrentFrequencyAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the MinFrequency attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0005")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheMinFrequencyAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads the MaxFrequency attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0006")) { - NextTest(); - return; - } - err = TestStep7ThReadsTheMaxFrequencyAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b & 7C TH reads the CurrentFrequency attribute\n"); - if (ShouldSkip("LVL.S.A0004 && LVL.S.A0005 && LVL.S.A0006")) { - NextTest(); - return; - } - err = TestStep7b7cThReadsTheCurrentFrequencyAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 8: TH reads the OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep8ThReadsTheOnOffTransitionTimeAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 9a: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.F01 && LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep9aThReadsTheOnLevelAttributeFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 9b: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0011 && !LVL.S.F01")) { - NextTest(); - return; - } - err = TestStep9bThReadsTheOnLevelAttributeFromTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 10: TH reads the OnTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep10ThReadsTheOnTransitionTimeAttributeFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 11: TH reads the OffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep11ThReadsTheOffTransitionTimeAttributeFromTheDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 12: TH reads the DefaultMoveRate attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep12ThReadsTheDefaultMoveRateAttributeFromTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 13: TH reads the Options attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep13ThReadsTheOptionsAttributeFromTheDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 14: TH reads the StartUpCurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep14ThReadsTheStartUpCurrentLevelAttributeFromTheDut_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable CurrentLevelValue; - - CHIP_ERROR TestStep1ThReadsTheCurrentLevelAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 254U)); - } - { - CurrentLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheRemainingTimeAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRemainingTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the RemainingTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the RemainingTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("remainingTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("remainingTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("remainingTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinLevelValue; - - CHIP_ERROR TestStep3aThReadsTheMinLevelAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the MinLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the MinLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("MinLevel", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); - { - MinLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinLevelFeatureMapNotSupportedValue; - - CHIP_ERROR TestStep3bThReadsTheMinLevelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the MinLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the MinLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("minLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minLevel", [value unsignedCharValue], 254U)); - { - MinLevelFeatureMapNotSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxLevelValue; - - CHIP_ERROR TestStep4ThReadsTheMaxLevelAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("MaxLevel", actualValue, 254U)); - } - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], MinLevelValue)); - { - MaxLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxLevelFeatureMapNotSupportedValue; - - CHIP_ERROR TestStep4aThReadsTheMaxLevelAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); - { - MaxLevelFeatureMapNotSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4b4cThReadsTheCurrentLevelAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], MinLevelValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], MaxLevelValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4b4cThReadsTheCurrentLevelAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], MaxLevelFeatureMapNotSupportedValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheCurrentFrequencyAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the CurrentFrequency attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the CurrentFrequency attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinFrequencyValue; - - CHIP_ERROR TestStep6ThReadsTheMinFrequencyAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the MinFrequency attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the MinFrequency attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minFrequency", [value unsignedShortValue], 65535U)); - { - MinFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxFrequencyValue; - - CHIP_ERROR TestStep7ThReadsTheMaxFrequencyAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the MaxFrequency attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the MaxFrequency attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxFrequency", [value unsignedShortValue], 65535U)); - { - MaxFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7b7cThReadsTheCurrentFrequencyAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b & 7C TH reads the CurrentFrequency attribute: Error: %@", err); - } else { - NSLog(@"Step 7b & 7C TH reads the CurrentFrequency attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], MinFrequencyValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], MaxFrequencyValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsTheOnOffTransitionTimeAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onOffTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onOffTransitionTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9aThReadsTheOnLevelAttributeFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9a: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 9a: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], MinLevelValue)); - VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], MaxLevelValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9bThReadsTheOnLevelAttributeFromTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9b: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 9b: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); - VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], MaxLevelFeatureMapNotSupportedValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsTheOnTransitionTimeAttributeFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the OnTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onTransitionTime", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsTheOffTransitionTimeAttributeFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads the OffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("offTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("offTransitionTime", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsTheDefaultMoveRateAttributeFromTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads the DefaultMoveRate attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("defaultMoveRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("defaultMoveRate", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsTheOptionsAttributeFromTheDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads the Options attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads the Options attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("options", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsTheStartUpCurrentLevelAttributeFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("startUpCurrentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpCurrentLevel", [value unsignedCharValue], 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_2_2() - : TestCommandBridge("Test_TC_LVL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("OnOffTransitionTimeConfigValue", 0, UINT16_MAX, &mOnOffTransitionTimeConfigValue); - AddArgument("OnLevelConfigValue", 0, UINT8_MAX, &mOnLevelConfigValue); - AddArgument("OnTransitionTimeConfigValue", 0, UINT16_MAX, &mOnTransitionTimeConfigValue); - AddArgument("OffTransitionTimeConfigValue", 0, UINT16_MAX, &mOffTransitionTimeConfigValue); - AddArgument("DefaultMoveRateConfigValue", 0, UINT8_MAX, &mDefaultMoveRateConfigValue); - AddArgument("StartUpCurrentLevelConfigValue", 0, UINT8_MAX, &mStartUpCurrentLevelConfigValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads the OnOffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep1aThReadsTheOnOffTransitionTimeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep1bThWritesTheOnOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn1a_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads the OnOffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestStep1cThReadsTheOnOffTransitionTimeAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheOnLevelAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep2bThWritesTheOnLevelAttributeOnTheDutWithADifferentValueThanThatReadIn2a_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: TH reads the OnLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep2cThReadsTheOnLevelAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH reads the OnTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheOnTransitionTimeAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep3bThWritesTheOnTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn3a_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: TH reads the OnTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0012")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOnTransitionTimeAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads the OffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheOffTransitionTimeAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep4bThWritesTheOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn4a_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: TH reads the OffTransitionTime attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0013")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOffTransitionTimeAttributeFromTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: TH reads the DefaultMoveRate attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep5aThReadsTheDefaultMoveRateAttributeFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep5bThWritesTheDefaultMoveRateAttributeOnTheDutWithADifferentValueThanThatReadIn5a_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5c: TH reads the DefaultMoveRate attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0014")) { - NextTest(); - return; - } - err = TestStep5cThReadsTheDefaultMoveRateAttributeFromTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep6aThReadsTheStartUpCurrentLevelAttributeFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep6bThWritesTheStartUpCurrentLevelAttributeOnTheDutWithADifferentValueThanThatReadIn6a_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A4000")) { - NextTest(); - return; - } - err = TestStep6cThReadsTheStartUpCurrentLevelAttributeFromTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : writes back default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestWritesBackDefaultValueOfOnOffTransitionTimeAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mOnOffTransitionTimeConfigValue; - chip::Optional mOnLevelConfigValue; - chip::Optional mOnTransitionTimeConfigValue; - chip::Optional mOffTransitionTimeConfigValue; - chip::Optional mDefaultMoveRateConfigValue; - chip::Optional mStartUpCurrentLevelConfigValue; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull OnOffTransitionTimeValue; - - CHIP_ERROR TestStep1aThReadsTheOnOffTransitionTimeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads the OnOffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads the OnOffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onOffTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onOffTransitionTime", [value unsignedShortValue], 65535U)); - { - OnOffTransitionTimeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWritesTheOnOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn1a_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = mOnOffTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOnOffTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:10U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a: Error: %@", err); - } else { - NSLog(@"Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsTheOnOffTransitionTimeAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads the OnOffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads the OnOffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOffTransitionTime", actualValue, mOnOffTransitionTimeConfigValue.HasValue() ? mOnOffTransitionTimeConfigValue.Value() : 10U)); - } - - VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintNotValue("onOffTransitionTime", value, OnOffTransitionTimeValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OnLevelValue; - - CHIP_ERROR TestStep2aThReadsTheOnLevelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], 254U)); - } - { - OnLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWritesTheOnLevelAttributeOnTheDutWithADifferentValueThanThatReadIn2a_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = mOnLevelConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mOnLevelConfigValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a: Error: %@", err); - } else { - NSLog(@"Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsTheOnLevelAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads the OnLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads the OnLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnLevel", actualValue)); - VerifyOrReturn(CheckValue("OnLevel", actualValue, mOnLevelConfigValue.HasValue() ? mOnLevelConfigValue.Value() : 5U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); - } - VerifyOrReturn(CheckConstraintNotValue("onLevel", value, OnLevelValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OnTransitionTimeValue; - - CHIP_ERROR TestStep3aThReadsTheOnTransitionTimeAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the OnTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onTransitionTime", [value unsignedShortValue], 65535U)); - } - { - OnTransitionTimeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThWritesTheOnTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn3a_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onTransitionTimeArgument; - onTransitionTimeArgument = mOnTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOnTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:5U]; - [cluster writeAttributeOnTransitionTimeWithValue:onTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a: Error: %@", err); - } else { - NSLog(@"Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOnTransitionTimeAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the OnTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnTransitionTime", actualValue)); - VerifyOrReturn(CheckValue("OnTransitionTime", actualValue, mOnTransitionTimeConfigValue.HasValue() ? mOnTransitionTimeConfigValue.Value() : 5U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); - } - VerifyOrReturn(CheckConstraintNotValue("onTransitionTime", value, OnTransitionTimeValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OffTransitionTimeValue; - - CHIP_ERROR TestStep4aThReadsTheOffTransitionTimeAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the OffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("offTransitionTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("offTransitionTime", [value unsignedShortValue], 65535U)); - } - { - OffTransitionTimeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWritesTheOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn4a_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id offTransitionTimeArgument; - offTransitionTimeArgument = mOffTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOffTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:10U]; - [cluster writeAttributeOffTransitionTimeWithValue:offTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a: Error: %@", err); - } else { - NSLog(@"Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOffTransitionTimeAttributeFromTheDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the OffTransitionTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OffTransitionTime", actualValue)); - VerifyOrReturn(CheckValue("OffTransitionTime", actualValue, mOffTransitionTimeConfigValue.HasValue() ? mOffTransitionTimeConfigValue.Value() : 10U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); - } - VerifyOrReturn(CheckConstraintNotValue("offTransitionTime", value, OffTransitionTimeValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable DefaultMoveRatevalue; - - CHIP_ERROR TestStep5aThReadsTheDefaultMoveRateAttributeFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH reads the DefaultMoveRate attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("defaultMoveRate", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("defaultMoveRate", [value unsignedCharValue], 255U)); - } - { - DefaultMoveRatevalue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThWritesTheDefaultMoveRateAttributeOnTheDutWithADifferentValueThanThatReadIn5a_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id defaultMoveRateArgument; - defaultMoveRateArgument = mDefaultMoveRateConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mDefaultMoveRateConfigValue.Value()] : [NSNumber numberWithUnsignedChar:111U]; - [cluster writeAttributeDefaultMoveRateWithValue:defaultMoveRateArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a: Error: %@", err); - } else { - NSLog(@"Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThReadsTheDefaultMoveRateAttributeFromTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH reads the DefaultMoveRate attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("DefaultMoveRate", actualValue)); - VerifyOrReturn(CheckValue("DefaultMoveRate", actualValue, mDefaultMoveRateConfigValue.HasValue() ? mDefaultMoveRateConfigValue.Value() : 111U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); - } - VerifyOrReturn(CheckConstraintNotValue("defaultMoveRate", value, DefaultMoveRatevalue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable StartUpCurrentLevelValue; - - CHIP_ERROR TestStep6aThReadsTheStartUpCurrentLevelAttributeFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("startUpCurrentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("startUpCurrentLevel", [value unsignedCharValue], 255U)); - } - { - StartUpCurrentLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThWritesTheStartUpCurrentLevelAttributeOnTheDutWithADifferentValueThanThatReadIn6a_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpCurrentLevelArgument; - startUpCurrentLevelArgument = mStartUpCurrentLevelConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mStartUpCurrentLevelConfigValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeStartUpCurrentLevelWithValue:startUpCurrentLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a: Error: %@", err); - } else { - NSLog(@"Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsTheStartUpCurrentLevelAttributeFromTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartUpCurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("StartUpCurrentLevel", actualValue, mStartUpCurrentLevelConfigValue.HasValue() ? mStartUpCurrentLevelConfigValue.Value() : 5U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); - } - VerifyOrReturn(CheckConstraintNotValue("startUpCurrentLevel", value, StartUpCurrentLevelValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWritesBackDefaultValueOfOnOffTransitionTimeAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"writes back default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"writes back default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_3_1() - : TestCommandBridge("Test_TC_LVL_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOnCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1ThWrites0ToTheOptionsAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1a: TH writes NULL to the OnLevel attribute\n"); - if (ShouldSkip("LVL.S.A0011")) { - NextTest(); - return; - } - err = TestStep1aThWritesNullToTheOnLevelAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("LVL.S.C04.Rsp && OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsAMoveToLevelWithOnOffCommandToDutWithLevel50AndTransitionTime0Immediate_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); - if (ShouldSkip("OO.S.A0000 && LVL.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C04.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentLevelAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("LVL.S.C04.Rsp && OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentLevelAttributeFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAMoveToLevelCommandToTheDutWithLevel200AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 10000ms\n"); - err = TestWait10000ms_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10000ms\n"); - err = TestWait10000ms_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10000ms\n"); - err = TestWait10000ms_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 5000ms\n"); - err = TestWait5000ms_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition)\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && !LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5a: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep5aThWrites0x00ToTheOptionsAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 5b: TH reads the Options attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep5bThReadsTheOptionsAttributeFromTheDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 5c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThSendsOnCommandToDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5e: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5eThReadsCurrentLevelAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5fThSendsOffCommandToDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5h: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5hThReadsCurrentLevelAttributeFromDut_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 5j: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5jThReadsCurrentLevelAttributeFromDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 5l: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep5lThReadsCurrentLevelAttributeFromDut_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 6a: TH writes 0x01 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep6aThWrites0x01ToTheOptionsAttribute_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 6b: TH reads the Options attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionsAttributeFromTheDut_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 6c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThSendsOnCommandToDut_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 6e: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6eThReadsCurrentLevelAttributeFromDut_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 6f: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6fThSendsOffCommandToDut_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 6h: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6hThReadsCurrentLevelAttributeFromDut_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 6j: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6jThReadsCurrentLevelAttributeFromDut_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 6l: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6lThReadsCurrentLevelAttributeFromDut_46(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 47; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionSendOnCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition Send On Command: Error: %@", err); - } else { - NSLog(@"Precondition Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThWrites0ToTheOptionsAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWritesNullToTheOnLevelAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = nil; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes NULL to the OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes NULL to the OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsAMoveToLevelWithOnOffCommandToDutWithLevel50AndTransitionTime0Immediate_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThReadsCurrentLevelAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentLevelAttributeFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAMoveToLevelCommandToTheDutWithLevel200AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10000ms_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrites0x00ToTheOptionsAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 5a: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsTheOptionsAttributeFromTheDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads the Options attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads the Options attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsOnCommandToDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5eThReadsCurrentLevelAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5e: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5e: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5fThSendsOffCommandToDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5hThReadsCurrentLevelAttributeFromDut_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5h: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5h: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:140U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5jThReadsCurrentLevelAttributeFromDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5j: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5j: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:160U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Error: %@", err); - } else { - NSLog(@"Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5lThReadsCurrentLevelAttributeFromDut_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5l: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5l: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWrites0x01ToTheOptionsAttribute_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH writes 0x01 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 6a: TH writes 0x01 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionsAttributeFromTheDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the Options attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the Options attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Options", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThSendsOnCommandToDut_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 6c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThReadsCurrentLevelAttributeFromDut_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6e: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThSendsOffCommandToDut_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 6f: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:120U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6hThReadsCurrentLevelAttributeFromDut_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6h: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6h: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 120U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:140U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Error: %@", err); - } else { - NSLog(@"Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6jThReadsCurrentLevelAttributeFromDut_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6j: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6j: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 120U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:160U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Error: %@", err); - } else { - NSLog(@"Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6lThReadsCurrentLevelAttributeFromDut_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6l: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6l: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 160U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_4_1() - : TestCommandBridge("Test_TC_LVL_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOnCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1a: TH writes 0 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0ToTheOptionsAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1b: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp && LVL.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s)\n"); - if (ShouldSkip("LVL.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsAMoveWithOnOffCommandToDutWithMoveMode0x00UpAndRate10UnitsS_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); - if (ShouldSkip("OO.S.A0000 && LVL.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C05.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsCurrentLevelAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5000ms\n"); - err = TestWait5000ms_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C05.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2eAfter5SecondsThReadsCurrentLevelAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3c: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3cThReadsCurrentLevelAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s)\n"); - if (ShouldSkip("LVL.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAMoveCommandToTheDutWithMoveMode0x00UpAndRate5UnitsS_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10s\n"); - err = TestWait10s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); - err = TestWait10s_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); - err = TestWait10s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 19s\n"); - err = TestWait19s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4eAfterAnother19SecondsThReadsCurrentLevelAttributeFromDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Precondition send Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOffCommand_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_25(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 26; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionSendOnCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition Send On Command: Error: %@", err); - } else { - NSLog(@"Precondition Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsAMoveWithOnOffCommandToDutWithMoveMode0x00UpAndRate10UnitsS_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveWithOnOffParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:10U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable CurrentLevelValue; - - CHIP_ERROR TestStep2dThReadsCurrentLevelAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); - } - { - CurrentLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eAfter5SecondsThReadsCurrentLevelAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsCurrentLevelAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAMoveCommandToTheDutWithMoveMode0x00UpAndRate5UnitsS_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s): Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 230U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait19s_22() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 19000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eAfterAnother19SecondsThReadsCurrentLevelAttributeFromDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionSendOffCommand_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition send Off Command: Error: %@", err); - } else { - NSLog(@"Precondition send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_5_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_5_1() - : TestCommandBridge("Test_TC_LVL_5_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_5_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_5_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_5_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOnCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1ThWrites0x00ToTheOptionsAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp && LVL.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsAStepWithOnOffCommandToDutWithStepMode0x00UpStepSize50AndTransitionTime0Immediate_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); - if (ShouldSkip("OO.S.A0000 && LVL.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3c: Reads current level attribute from DUT\n"); - if (ShouldSkip("LVL.S.A0000 && LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3cReadsCurrentLevelAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.\n"); - if (ShouldSkip("LVL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAStepCommandToTheDutWithStepMode0x00UpStepSize150AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 10s\n"); - err = TestWait10s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 10s\n"); - err = TestWait10s_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10s\n"); - err = TestWait10s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 5000ms\n"); - err = TestWait5000ms_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition)\n"); - if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && !LVL.S.M.VarRate")) { - NextTest(); - return; - } - err = TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Precondition send Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOffCommand_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionSendOnCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition Send On Command: Error: %@", err); - } else { - NSLog(@"Precondition Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThWrites0x00ToTheOptionsAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsAStepWithOnOffCommandToDutWithStepMode0x00UpStepSize50AndTransitionTime0Immediate_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStepWithOnOffParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:0U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cReadsCurrentLevelAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Reads current level attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: Reads current level attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAStepCommandToTheDutWithStepMode0x00UpStepSize150AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStepParams alloc] init]; - params.stepMode = - [NSNumber numberWithUnsignedChar:0U]; - params.stepSize = - [NSNumber numberWithUnsignedChar:150U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:300U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stepWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait10s_16() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionSendOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition send Off Command: Error: %@", err); - } else { - NSLog(@"Precondition send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_6_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_6_1() - : TestCommandBridge("Test_TC_LVL_6_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_6_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_6_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_6_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1a: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aThWrites0x00ToTheOptionsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1bThSendsOnCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.A0000 && LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsCurrentLevelAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s)\n"); - if (ShouldSkip("LVL.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2d: Wait 5000ms\n"); - err = TestStep2dWait5000ms_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3: After 5 seconds, TH sends a Stop command to the DUT\n"); - if (ShouldSkip("LVL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3After5SecondsThSendsAStopCommandToTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Physically verify that the device has stopped transitioning\n"); - if (ShouldSkip("PICS_USER_PROMPT && LVL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.C03.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsCurrentLevelAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s)\n"); - if (ShouldSkip("LVL.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5000ms\n"); - err = TestWait5000ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT\n"); - if (ShouldSkip("LVL.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep6After5SecondsThSendsAStopWithOnOffCommandToTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Physically verify that the device has stopped transitioning\n"); - if (ShouldSkip("PICS_USER_PROMPT && LVL.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.C07.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep7ThReadsCurrentLevelAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Precondition send Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionSendOffCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWrites0x00ToTheOptionsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsOnCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:50U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsCurrentLevelAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dWait5000ms_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3After5SecondsThSendsAStopCommandToTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStopParams alloc] init]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stopWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: After 5 seconds, TH sends a Stop command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: After 5 seconds, TH sends a Stop command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThReadsCurrentLevelAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 64U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 86U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; - params.moveMode = - [NSNumber numberWithUnsignedChar:0U]; - params.rate = - [NSNumber numberWithUnsignedChar:5U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5000ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6After5SecondsThSendsAStopWithOnOffCommandToTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterStopWithOnOffParams alloc] init]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster stopWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThReadsCurrentLevelAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); - VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionSendOffCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition send Off Command: Error: %@", err); - } else { - NSLog(@"Precondition send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LVL_7_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LVL_7_1() - : TestCommandBridge("Test_TC_LVL_7_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("RandomLevelValue", 0, UINT8_MAX, &mRandomLevelValue); - AddArgument("RandomFrequencyValue", 0, UINT16_MAX, &mRandomFrequencyValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LVL_7_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_7_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_7_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: write default value of OnOffTransitionTime attribute\n"); - if (ShouldSkip("LVL.S.A0010")) { - NextTest(); - return; - } - err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0a: TH writes 0x00 to the Options attribute\n"); - if (ShouldSkip("LVL.S.A000f")) { - NextTest(); - return; - } - err = TestStep0aThWrites0x00ToTheOptionsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0b: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep0bThSendsOnCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1a: TH reads the MinLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0002")) { - NextTest(); - return; - } - err = TestStep1aThReadsTheMinLevelAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1b: TH reads the MaxLevel attribute from the DUT\n"); - if (ShouldSkip("LVL.S.A0003")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).\n"); - if (ShouldSkip("LVL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1cThSendsAMoveToLevelCommandToDutWithTheLevelFieldSetToAValueBetweenTheMinLevelAndMaxLevelValuesIfPresentOtherwiseBetween0x01And0xFEAndTheTransitionTimeFieldSetTo0x0000MoveImmediately_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 100ms\n"); - err = TestWait100ms_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1d: TH reads CurrentLevel attribute from DUT\n"); - if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1dThReadsCurrentLevelAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheCurrentFrequencyAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH reads the MinFrequency attribute.\n"); - if (ShouldSkip("LVL.S.A0005")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheMinFrequencyAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.\n"); - if (ShouldSkip("LVL.S.A0006")) { - NextTest(); - return; - } - err = TestStep2cThReadsTheMaxFrequencyAttributeAndCheckIfFmaxFminFailTheTest_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test\n"); - if (ShouldSkip("LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep2dSanityCheckOnValuesReadInSteps2a2cIfFcFminFailTheTestAndFcFmaxFailTheTest_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax\n"); - if (ShouldSkip("LVL.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToARandomValueFrandChosenSuchThatFminFrandFmax_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 100ms\n"); - err = TestWait100ms_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheCurrentFrequencyAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to fmax + 1\n"); - if (ShouldSkip("LVL.S.C08.Rsp && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep4aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmax1_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004 && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheCurrentFrequencyAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to fmin - 1\n"); - if (ShouldSkip("LVL.S.C08.Rsp && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep5aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmin1_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5b: TH reads the CurrentFrequency attribute.\n"); - if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004 && PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep5bThReadsTheCurrentFrequencyAttribute_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mRandomLevelValue; - chip::Optional mRandomFrequencyValue; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0aThWrites0x00ToTheOptionsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id optionsArgument; - optionsArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH writes 0x00 to the Options attribute: Error: %@", err); - } else { - NSLog(@"Step 0a: TH writes 0x00 to the Options attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThSendsOnCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull minLevelValue; - - CHIP_ERROR TestStep1aThReadsTheMinLevelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads the MinLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads the MinLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("minLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minLevel", [value unsignedCharValue], 254U)); - { - minLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull maxLevelValue; - - CHIP_ERROR TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); - { - maxLevelValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThSendsAMoveToLevelCommandToDutWithTheLevelFieldSetToAValueBetweenTheMinLevelAndMaxLevelValuesIfPresentOtherwiseBetween0x01And0xFEAndTheTransitionTimeFieldSetTo0x0000MoveImmediately_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = mRandomLevelValue.HasValue() ? [NSNumber numberWithUnsignedChar:mRandomLevelValue.Value()] : [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1dThReadsCurrentLevelAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, mRandomLevelValue.HasValue() ? mRandomLevelValue.Value() : 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull CurrentFrequencyValue; - - CHIP_ERROR TestStep2aThReadsTheCurrentFrequencyAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], 65535U)); - { - CurrentFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MinFrequencyValue; - - CHIP_ERROR TestStep2bThReadsTheMinFrequencyAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the MinFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the MinFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minFrequency", [value unsignedShortValue], 65535U)); - { - MinFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxFrequencyValue; - - CHIP_ERROR TestStep2cThReadsTheMaxFrequencyAttributeAndCheckIfFmaxFminFailTheTest_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxFrequency", [value unsignedShortValue], MinFrequencyValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxFrequency", [value unsignedShortValue], 65535U)); - { - MaxFrequencyValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dSanityCheckOnValuesReadInSteps2a2cIfFcFminFailTheTestAndFcFmaxFailTheTest_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test: Error: %@", err); - } else { - NSLog(@"Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], MinFrequencyValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], MaxFrequencyValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToARandomValueFrandChosenSuchThatFminFrandFmax_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToClosestFrequencyParams alloc] init]; - params.frequency = mRandomFrequencyValue.HasValue() ? [NSNumber numberWithUnsignedShort:mRandomFrequencyValue.Value()] : [NSNumber numberWithUnsignedShort:30000U]; - [cluster moveToClosestFrequencyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100ms_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsTheCurrentFrequencyAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmax1_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4bThReadsTheCurrentFrequencyAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmin1_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5bThReadsTheCurrentFrequencyAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads the CurrentFrequency attribute.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads the CurrentFrequency attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LCFG_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LCFG_1_1() - : TestCommandBridge("Test_TC_LCFG_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LCFG_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LCFG_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LCFG_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LUNIT_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LUNIT_1_2() - : TestCommandBridge("Test_TC_LUNIT_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LUNIT_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LUNIT_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LUNIT_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !LUNIT.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("LUNIT.S.F00")) { - NextTest(); - return; - } - err = TestStep3GivenLunitsf00tempEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("LUNIT.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentLUNITSF00AttributeInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3GivenLunitsf00tempEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentLUNITSF00AttributeInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LUNIT_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LUNIT_3_1() - : TestCommandBridge("Test_TC_LUNIT_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LUNIT_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LUNIT_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LUNIT_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsFromTheDutTheTemperatureUnit_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes 0 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Fahrenheit")) { - NextTest(); - return; - } - err = TestStep2ThWrites0ToTemperatureUnit_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Fahrenheit")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTemperatureUnit_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes 1 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Celsius")) { - NextTest(); - return; - } - err = TestStep4ThWrites1ToTemperatureUnit_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Celsius")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheTemperatureUnit_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes 2 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Kelvin")) { - NextTest(); - return; - } - err = TestStep6ThWrites2ToTemperatureUnit_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Kelvin")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheTemperatureUnit_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH writes 5 to TemperatureUnit\n"); - if (ShouldSkip("LUNIT.S.A0000")) { - NextTest(); - return; - } - err = TestStep8ThWrites5ToTemperatureUnit_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsFromTheDutTheTemperatureUnit_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("temperatureUnit", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThWrites0ToTemperatureUnit_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes 0 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 2: TH writes 0 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTemperatureUnit_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWrites1ToTemperatureUnit_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes 1 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 4: TH writes 1 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheTemperatureUnit_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWrites2ToTemperatureUnit_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes 2 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 6: TH writes 2 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheTemperatureUnit_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThWrites5ToTemperatureUnit_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureUnitArgument; - temperatureUnitArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH writes 5 to TemperatureUnit: Error: %@", err); - } else { - NSLog(@"Step 8: TH writes 5 to TemperatureUnit: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LTIME_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LTIME_1_2() - : TestCommandBridge("Test_TC_LTIME_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LTIME_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LTIME_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LTIME_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT\n"); - if (ShouldSkip("LTIME.S.F00 && LTIME.S.A0001")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentAttributeActiveCalendarTypeInAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT\n"); - if (ShouldSkip("LTIME.S.F00 && LTIME.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentAttributeSupportedCalendarTypesInAttributeListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - VerifyOrReturn(CheckConstraintMinValue("featureMap", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("featureMap", [value unsignedIntValue], 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeActiveCalendarTypeInAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeSupportedCalendarTypesInAttributeListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LTIME_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LTIME_3_1() - : TestCommandBridge("Test_TC_LTIME_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LTIME_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LTIME_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LTIME_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads HourFormat attribute from DUT\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsHourFormatAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.M.12HR")) { - NextTest(); - return; - } - err = TestStep2IfLtimesa000012hrThWrites0ToHourFormatAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep3ThReadsHourFormatAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.M.24HR")) { - NextTest(); - return; - } - err = TestStep4IfLtimesa000024hrThWrites1ToHourFormatAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep5ThReadsHourFormatAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads ActiveCalendarType attribute from DUT\n"); - if (ShouldSkip("LTIME.S.A0001")) { - NextTest(); - return; - } - err = TestStep6ThReadsActiveCalendarTypeAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads SupportedCalendarTypes attribute from DUT\n"); - if (ShouldSkip("LTIME.S.A0002")) { - NextTest(); - return; - } - err = TestStep7ThReadsSupportedCalendarTypesAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH writes value in PIXIT.LTIME.SCT to ActiveCalendarType attribute, followed by reading the ActiveCalendarType attribute value\n"); - if (ShouldSkip("LTIME.S.A0001 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep8ThWritesValueInPixitltimesctToActiveCalendarTypeAttributeFollowedByReadingTheActiveCalendarTypeAttributeValue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: Repeat step 8 for all the values in PIXIT.LTIME.SCT\n"); - if (ShouldSkip("LTIME.S.A0001 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep9RepeatStep8ForAllTheValuesInPixitltimesct_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH writes 50 to ActiveCalendarType attribute\n"); - if (ShouldSkip("LTIME.S.A0001")) { - NextTest(); - return; - } - err = TestStep10ThWrites50ToActiveCalendarTypeAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH writes 5 to HourFormat attribute\n"); - if (ShouldSkip("LTIME.S.A0000")) { - NextTest(); - return; - } - err = TestStep11ThWrites5ToHourFormatAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsHourFormatAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads HourFormat attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads HourFormat attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("hourFormat", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2IfLtimesa000012hrThWrites0ToHourFormatAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id hourFormatArgument; - hourFormatArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsHourFormatAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("HourFormat", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4IfLtimesa000024hrThWrites1ToHourFormatAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id hourFormatArgument; - hourFormatArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsHourFormatAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("HourFormat", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsActiveCalendarTypeAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveCalendarTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads ActiveCalendarType attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads ActiveCalendarType attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("activeCalendarType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("activeCalendarType", [value unsignedCharValue], 11U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsSupportedCalendarTypesAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedCalendarTypesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads SupportedCalendarTypes attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads SupportedCalendarTypes attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxLength("supportedCalendarTypes", value, 12)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThWritesValueInPixitltimesctToActiveCalendarTypeAttributeFollowedByReadingTheActiveCalendarTypeAttributeValue_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep9RepeatStep8ForAllTheValuesInPixitltimesct_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThWrites50ToActiveCalendarTypeAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id activeCalendarTypeArgument; - activeCalendarTypeArgument = - [NSNumber numberWithUnsignedChar:50U]; - [cluster writeAttributeActiveCalendarTypeWithValue:activeCalendarTypeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH writes 50 to ActiveCalendarType attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH writes 50 to ActiveCalendarType attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThWrites5ToHourFormatAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id hourFormatArgument; - hourFormatArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH writes 5 to HourFormat attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH writes 5 to HourFormat attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LWM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LWM_1_1() - : TestCommandBridge("Test_TC_LWM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LWM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LWM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LWM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF)\n"); - if (ShouldSkip("LWM.S.F00")) { - NextTest(); - return; - } - err = TestStep3thReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfLwmsf00deponoff_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !LWM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList\n"); - if (ShouldSkip("LWM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList\n"); - if (ShouldSkip("LWM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentAttributeDEPONOFFInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3thReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfLwmsf00deponoff_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF): Error: %@", err); - } else { - NSLog(@"Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentAttributeDEPONOFFInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LWM_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LWM_2_1() - : TestCommandBridge("Test_TC_LWM_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("NewMode_CHANGE_OK", 0, UINT8_MAX, &mNewModeChangeOk); - AddArgument("NewMode_CHANGE_FAIL", 0, UINT8_MAX, &mNewModeChangeFail); - AddArgument("invalid_mode_th", 0, UINT8_MAX, &mInvalidModeTh); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LWM_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LWM_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LWM_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SupportedModes attribute.\n"); - if (ShouldSkip("LWM.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheSupportedModesAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheCurrentModeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th\n"); - if (ShouldSkip("LWM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsAChangeToModeCommandToTheDutWithNewModeSetToNewModeTh_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: Manually put the device in a state from which it will FAIL to transition to PIXIT.LWM.MODE_CHANGE_FAIL\n"); - if (ShouldSkip("LWM.S.M.CAN_TEST_MODE_FAILURE && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5ManuallyPutTheDeviceInAStateFromWhichItWillFailToTransitionToPixitlwmmodeChangeFail_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheCurrentModeAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_FAIL\n"); - if (ShouldSkip("LWM.S.M.CAN_TEST_MODE_FAILURE && LWM.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep7ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeFail_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheCurrentModeAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: Manually put the device in a state from which it will SUCCESSFULLY transition to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep9ManuallyPutTheDeviceInAStateFromWhichItWillSuccessfullyTransitionToPixitlwmmodeChangeOk_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the CurrentMode attribute.\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheCurrentModeAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("LWM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeOk_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th\n"); - if (ShouldSkip("LWM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsAChangeToModeCommandToTheDutWithNewModeSetToInvalidModeTh_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK\n"); - if (ShouldSkip("LWM.S.A0001")) { - NextTest(); - return; - } - err = TestStep14ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mNewModeChangeOk; - chip::Optional mNewModeChangeFail; - chip::Optional mInvalidModeTh; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheSupportedModesAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedModesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the SupportedModes attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the SupportedModes attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedModes", "list", "list")); - VerifyOrReturn(CheckConstraintMinLength("supportedModes", value, 2)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull old_current_mode_dut; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheCurrentModeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - { - old_current_mode_dut = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsAChangeToModeCommandToTheDutWithNewModeSetToNewModeTh_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; - params.newMode = - [old_current_mode_dut copy]; - [cluster changeToModeWithParams:params completion: - ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ManuallyPutTheDeviceInAStateFromWhichItWillFailToTransitionToPixitlwmmodeChangeFail_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull Step6_current_mode_dut; - - CHIP_ERROR TestStep6ThReadsFromTheDutTheCurrentModeAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - { - Step6_current_mode_dut = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeFail_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheCurrentModeAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, Step6_current_mode_dut)); - } - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ManuallyPutTheDeviceInAStateFromWhichItWillSuccessfullyTransitionToPixitlwmmodeChangeOk_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull Step10_current_mode_dut; - - CHIP_ERROR TestStep10ThReadsFromTheDutTheCurrentModeAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the CurrentMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); - { - Step10_current_mode_dut = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeOk_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; - params.newMode = mNewModeChangeOk.HasValue() ? [NSNumber numberWithUnsignedChar:mNewModeChangeOk.Value()] : [NSNumber numberWithUnsignedChar:2U]; - [cluster changeToModeWithParams:params completion: - ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, mNewModeChangeOk.HasValue() ? mNewModeChangeOk.Value() : 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsAChangeToModeCommandToTheDutWithNewModeSetToInvalidModeTh_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; - params.newMode = mInvalidModeTh.HasValue() ? [NSNumber numberWithUnsignedChar:mInvalidModeTh.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster changeToModeWithParams:params completion: - ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, mNewModeChangeOk.HasValue() ? mNewModeChangeOk.Value() : 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WASHERCTRL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WASHERCTRL_1_1() - : TestCommandBridge("Test_TC_WASHERCTRL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WASHERCTRL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH\n"); - err = TestCommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false\n"); - if (ShouldSkip("!WASHERCTRL.S.F00 && !WASHERCTRL.S.F01")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeIfWasherctrlsf00spinWasherctrlsf01rinseAreFalse_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true)\n"); - if (ShouldSkip("WASHERCTRL.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0SetTo1IfTheDutIsCapableOfControllingTheWasherUsingTheSpinAttributesWasherctrlsf00spinIsTrue_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true)\n"); - if (ShouldSkip("WASHERCTRL.S.F01")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit1SetTo1IfTheDutSupportsRinseAttributesWasherctrlsf01rinseIsTrue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.\n"); - if (ShouldSkip("WASHERCTRL.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentWASHERCTRLSF00AttributesInAttributeListFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.\n"); - if (ShouldSkip("WASHERCTRL.S.F01")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentWASHERCTRLSF01AttributesInAttributeListFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeIfWasherctrlsf00spinWasherctrlsf01rinseAreFalse_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0SetTo1IfTheDutIsCapableOfControllingTheWasherUsingTheSpinAttributesWasherctrlsf00spinIsTrue_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit1SetTo1IfTheDutSupportsRinseAttributesWasherctrlsf01rinseIsTrue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentWASHERCTRLSF00AttributesInAttributeListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentWASHERCTRLSF01AttributesInAttributeListFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WASHERCTRL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WASHERCTRL_2_1() - : TestCommandBridge("Test_TC_WASHERCTRL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("SpinSpeedCurrentValue", 0, UINT8_MAX, &mSpinSpeedCurrentValue); - AddArgument("unsupportedSpinSpeedCurrentValue", 0, UINT8_MAX, &mUnsupportedSpinSpeedCurrentValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WASHERCTRL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the SpinSpeeds attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheSpinSpeedsAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheSpinSpeedCurrentAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the DUT response contains a uint8 with value between 0 and numSpinSpeeds-1 inclusive.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyThatTheDutResponseContainsAUint8WithValueBetween0AndNumSpinSpeeds1Inclusive_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1)\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4ThWritesASupportedSpinSpeedCurrentAttributeThatIsAValidIndexIntoTheListOfSpinSpeeds0ToNumSpinSpeeds1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 2 seconds\n"); - err = TestWait2Seconds_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheSpinSpeedCurrentAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT\n"); - if (ShouldSkip("WASHERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep6ThWritesAnUnsupportedSpinSpeedCurrentAttributeThatIsOtherThan0ToDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mSpinSpeedCurrentValue; - chip::Optional mUnsupportedSpinSpeedCurrentValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheSpinSpeedsAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpinSpeedsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the SpinSpeeds attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the SpinSpeeds attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("spinSpeeds", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("spinSpeeds", value, 16)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSpinSpeedCurrentAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpinSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("spinSpeedCurrent", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("spinSpeedCurrent", [value unsignedCharValue], 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheDutResponseContainsAUint8WithValueBetween0AndNumSpinSpeeds1Inclusive_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThWritesASupportedSpinSpeedCurrentAttributeThatIsAValidIndexIntoTheListOfSpinSpeeds0ToNumSpinSpeeds1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id spinSpeedCurrentArgument; - spinSpeedCurrentArgument = mSpinSpeedCurrentValue.HasValue() ? [NSNumber numberWithUnsignedChar:mSpinSpeedCurrentValue.Value()] : [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeSpinSpeedCurrentWithValue:spinSpeedCurrentArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1): Error: %@", err); - } else { - NSLog(@"Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2Seconds_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheSpinSpeedCurrentAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpinSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpinSpeedCurrent", actualValue)); - VerifyOrReturn(CheckValue("SpinSpeedCurrent", actualValue, mSpinSpeedCurrentValue.HasValue() ? mSpinSpeedCurrentValue.Value() : 3U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("spinSpeedCurrent", "int8u", "int8u")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWritesAnUnsupportedSpinSpeedCurrentAttributeThatIsOtherThan0ToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id spinSpeedCurrentArgument; - spinSpeedCurrentArgument = mUnsupportedSpinSpeedCurrentValue.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedSpinSpeedCurrentValue.Value()] : [NSNumber numberWithUnsignedChar:17U]; - [cluster writeAttributeSpinSpeedCurrentWithValue:spinSpeedCurrentArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WASHERCTRL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WASHERCTRL_2_2() - : TestCommandBridge("Test_TC_WASHERCTRL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("NumberOfRinsesValue", 0, UINT8_MAX, &mNumberOfRinsesValue); - AddArgument("unsupportedNumberOfRinsesValue", 0, UINT8_MAX, &mUnsupportedNumberOfRinsesValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WASHERCTRL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the NumberOfRinses attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheTheNumberOfRinsesAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SupportedRinses attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0003")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheTheSupportedRinsesAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list\n"); - if (ShouldSkip("WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThWritesASupportedNumberOfRinsesAttributeToDutWithinTheRangeOfTheSupportedRinsesList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 2 seconds\n"); - err = TestWait2Seconds_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute\n"); - if (ShouldSkip("WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheNumberOfRinsesAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: Operate device to set the condition to read only\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && WASHERCTRL.S.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6OperateDeviceToSetTheConditionToReadOnly_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.\n"); - if (ShouldSkip("WASHERCTRL.S.M.ManuallyControlled && WASHERCTRL.S.A0002")) { - NextTest(); - return; - } - err = TestStep7ThWritesAnUnsupportedNumberOfRinsesAttributeToDutWhileDutIsNotInAValidState_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mNumberOfRinsesValue; - chip::Optional mUnsupportedNumberOfRinsesValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheTheNumberOfRinsesAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfRinsesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the the NumberOfRinses attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the the NumberOfRinses attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("numberOfRinses", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("numberOfRinses", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfRinses", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSupportedRinsesAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedRinsesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the the SupportedRinses attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the the SupportedRinses attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedRinses", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("supportedRinses", value, 4)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThWritesASupportedNumberOfRinsesAttributeToDutWithinTheRangeOfTheSupportedRinsesList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id numberOfRinsesArgument; - numberOfRinsesArgument = mNumberOfRinsesValue.HasValue() ? [NSNumber numberWithUnsignedChar:mNumberOfRinsesValue.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeNumberOfRinsesWithValue:numberOfRinsesArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list: Error: %@", err); - } else { - NSLog(@"Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2Seconds_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheNumberOfRinsesAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfRinsesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfRinses", actualValue, mNumberOfRinsesValue.HasValue() ? mNumberOfRinsesValue.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6OperateDeviceToSetTheConditionToReadOnly_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThWritesAnUnsupportedNumberOfRinsesAttributeToDutWhileDutIsNotInAValidState_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id numberOfRinsesArgument; - numberOfRinsesArgument = mUnsupportedNumberOfRinsesValue.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedNumberOfRinsesValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeNumberOfRinsesWithValue:numberOfRinsesArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.: Error: %@", err); - } else { - NSLog(@"Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRYERCTRL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRYERCTRL_1_1() - : TestCommandBridge("Test_TC_DRYERCTRL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRYERCTRL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRYERCTRL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRYERCTRL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRYERCTRL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRYERCTRL_2_1() - : TestCommandBridge("Test_TC_DRYERCTRL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("unsupportedSelectedDrynessLevel", 0, UINT8_MAX, &mUnsupportedSelectedDrynessLevel); - AddArgument("SupportedDrynessLevel", 0, UINT8_MAX, &mSupportedDrynessLevel); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRYERCTRL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRYERCTRL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRYERCTRL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels\n"); - if (ShouldSkip("DRYERCTRL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMandatoryAttributeSupportedDrynessLevels_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMandatoryAttributeSelectedDrynessLevel_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep4thWritesASupportedSelectedDrynessLevelAttributeThatIsWithinTheListOfSupportedDrynessLevels_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 2 seconds\n"); - err = TestWait2Seconds_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep5AfterAFewSecondsThReadsFromTheDutTheSelectedDrynessLevelAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT\n"); - if (ShouldSkip("DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep6ThWritesAnUnsupportedSelectedDrynessLevelAttributeThatIsNotInListOfSupportedDrynessLevelsToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: Operate device to set the condition to read only\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DRYERCTRL.S.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6OperateDeviceToSetTheConditionToReadOnly_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.\n"); - if (ShouldSkip("DRYERCTRL.S.M.ManuallyControlled && DRYERCTRL.S.A0001")) { - NextTest(); - return; - } - err = TestStep7ThWritesASupportedSelectedDrynessLevelAttributeToDutWhileDutIsNotInAValidState_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mUnsupportedSelectedDrynessLevel; - chip::Optional mSupportedDrynessLevel; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMandatoryAttributeSupportedDrynessLevels_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedDrynessLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedDrynessLevels", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("supportedDrynessLevels", value, 16)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMandatoryAttributeSelectedDrynessLevel_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedDrynessLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("selectedDrynessLevel", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("selectedDrynessLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("selectedDrynessLevel", [value unsignedCharValue], 15U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4thWritesASupportedSelectedDrynessLevelAttributeThatIsWithinTheListOfSupportedDrynessLevels_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id selectedDrynessLevelArgument; - selectedDrynessLevelArgument = mSupportedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mSupportedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels: Error: %@", err); - } else { - NSLog(@"Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait2Seconds_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheSelectedDrynessLevelAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedDrynessLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SelectedDrynessLevel", actualValue)); - VerifyOrReturn(CheckValue("SelectedDrynessLevel", actualValue, mSupportedDrynessLevel.HasValue() ? mSupportedDrynessLevel.Value() : 1U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("selectedDrynessLevel", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThWritesAnUnsupportedSelectedDrynessLevelAttributeThatIsNotInListOfSupportedDrynessLevelsToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id selectedDrynessLevelArgument; - selectedDrynessLevelArgument = mUnsupportedSelectedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedSelectedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6OperateDeviceToSetTheConditionToReadOnly_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThWritesASupportedSelectedDrynessLevelAttributeToDutWhileDutIsNotInAValidState_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id selectedDrynessLevelArgument; - selectedDrynessLevelArgument = mSupportedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mSupportedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.: Error: %@", err); - } else { - NSLog(@"Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LOWPOWER_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LOWPOWER_1_1() - : TestCommandBridge("Test_TC_LOWPOWER_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LOWPOWER_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LOWPOWER_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LOWPOWER_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(6))); - VerifyOrReturn(CheckValue("", actualValue[0], 65528UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 65529UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 65530UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 65531UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 65532UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 65533UL)); - } - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValue("", actualValue[0], 65528UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 65529UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 65531UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 65532UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 65533UL)); - } - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_KEYPADINPUT_1_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_KEYPADINPUT_1_2() - : TestCommandBridge("Test_TC_KEYPADINPUT_1_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_KEYPADINPUT_1_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_1_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_1_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !KEYPADINPUT.S.F00 && KEYPADINPUT.S.F01 && !KEYPADINPUT.S.F02 ")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not\n"); - if (ShouldSkip("KEYPADINPUT.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenKeypadinputsf00nvFeatureMapBitMaskIsSetOrNot_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not\n"); - if (ShouldSkip("KEYPADINPUT.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenKeypadinputsf01lkFeatureMapBitMaskIsSetOrNot_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not\n"); - if (ShouldSkip("KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep2dGivenKeypadinputsf02nkFeatureMapBitMaskIsSetOrNot_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenKeypadinputsf00nvFeatureMapBitMaskIsSetOrNot_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not: Error: %@", err); - } else { - NSLog(@"Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenKeypadinputsf01lkFeatureMapBitMaskIsSetOrNot_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not: Error: %@", err); - } else { - NSLog(@"Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dGivenKeypadinputsf02nkFeatureMapBitMaskIsSetOrNot_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not: Error: %@", err); - } else { - NSLog(@"Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APPLAUNCHER_1_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APPLAUNCHER_1_3() - : TestCommandBridge("Test_TC_APPLAUNCHER_1_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APPLAUNCHER_1_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_1_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_1_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip("APPLAUNCHER.S.F00")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !APPLAUNCHER.S.F00 ")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheFeatureMapAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3b: TH reads the optional attribute(CatalogList) in AttributeList\n"); - if (ShouldSkip("APPLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeCatalogListInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList\n"); - if (ShouldSkip("APPLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeCurrentAppInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsTheFeatureMapAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeCatalogListInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(CatalogList) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(CatalogList) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeCurrentAppInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_1_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_1_4() - : TestCommandBridge("Test_TC_MEDIAINPUT_1_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_1_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_1_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_1_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !MEDIAINPUT.S.F00 ")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("MEDIAINPUT.S.F00")) { - NextTest(); - return; - } - err = TestStep2GivenMediainputsf00nuEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3b: TH reads the optional attribute(InputList) in AttributeList\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeInputListInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList\n"); - if (ShouldSkip("MEDIAINPUT.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeCurrentInputInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2GivenMediainputsf00nuEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeInputListInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(InputList) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(InputList) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeCurrentInputInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WAKEONLAN_1_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WAKEONLAN_1_5() - : TestCommandBridge("Test_TC_WAKEONLAN_1_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WAKEONLAN_1_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WAKEONLAN_1_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WAKEONLAN_1_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(MACAddress) in AttributeList\n"); - if (ShouldSkip("WAKEONLAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeMACAddressInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the global attribute: AcceptedCommandList\n"); - err = TestStep4ThReadsTheGlobalAttributeAcceptedCommandList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the global attribute: GeneratedCommandList\n"); - err = TestStep5ThReadsTheGlobalAttributeGeneratedCommandList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeMACAddressInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(MACAddress) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(MACAddress) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheGlobalAttributeAcceptedCommandList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGlobalAttributeGeneratedCommandList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CHANNEL_1_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_1_6() - : TestCommandBridge("Test_TC_CHANNEL_1_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_1_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_1_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_1_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: read the global attribute: ClusterRevision\n"); - err = TestStep1ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: Read the global attribute: FeatureMap\n"); - if (ShouldSkip("( !CHANNEL.S.F00 && !CHANNEL.S.F01 )")) { - NextTest(); - return; - } - err = TestStep2aReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CHANNEL.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenCchannelsf00clEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CHANNEL.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenChannelsf01liEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aReadTheGlobalAttributeAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aReadTheGlobalAttributeAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: Read the optional attribute(ChannelList): AttributeList\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bReadTheOptionalAttributeChannelListAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: Reading optional attribute(Lineup) in AttributeList\n"); - if (ShouldSkip("CHANNEL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cReadingOptionalAttributeLineupInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: Read the optional attribute(CurrentChannel): AttributeList\n"); - if (ShouldSkip("CHANNEL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3dReadTheOptionalAttributeCurrentChannelAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList\n"); - if (ShouldSkip("CHANNEL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aReadTheOptionalCommandChangeChannelInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList\n"); - if (ShouldSkip("CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalCommandChangeChannelByNumberInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList\n"); - if (ShouldSkip("CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4cReadTheOptionalCommandSkipChannelInAcceptedCommandList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: Read the global attribute: GeneratedCommandList\n"); - if (ShouldSkip("( !CHANNEL.S.F00 && !CHANNEL.S.F01 )")) { - NextTest(); - return; - } - err = TestStep5aReadTheGlobalAttributeGeneratedCommandList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: Read the global attribute: GeneratedCommandList\n"); - if (ShouldSkip("CHANNEL.S.F00 || CHANNEL.S.F01")) { - NextTest(); - return; - } - err = TestStep5bReadTheGlobalAttributeGeneratedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 16; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 1: read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 2a: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenCchannelsf00clEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenChannelsf01liEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bReadTheOptionalAttributeChannelListAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Read the optional attribute(ChannelList): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: Read the optional attribute(ChannelList): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cReadingOptionalAttributeLineupInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Reading optional attribute(Lineup) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: Reading optional attribute(Lineup) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dReadTheOptionalAttributeCurrentChannelAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Read the optional attribute(CurrentChannel): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3d: Read the optional attribute(CurrentChannel): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheOptionalCommandChangeChannelInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalCommandChangeChannelByNumberInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheOptionalCommandSkipChannelInAcceptedCommandList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aReadTheGlobalAttributeGeneratedCommandList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5a: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bReadTheGlobalAttributeGeneratedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5b: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_1_7 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_1_7() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_1_7") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_1_7() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_1_7\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_1_7\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !MEDIAPLAYBACK.S.F00 && !MEDIAPLAYBACK.S.F01 ")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenMediaplaybacksf00asEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenMediaplaybacksf01vsEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads the optional attribute(StartTime) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeStartTimeInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: TH reads the optional attribute(Duration) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0002")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeDurationInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheOptionalAttributeSampledPositionInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004")) { - NextTest(); - return; - } - err = TestStep3eThReadsTheOptionalAttributePlaybackSpeedInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0005")) { - NextTest(); - return; - } - err = TestStep3fThReadsTheOptionalAttributeSeekRangeEndInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0006")) { - NextTest(); - return; - } - err = TestStep3gThReadsTheOptionalAttributeSeekRangeStartInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4aThReadsTheAcceptedCommandListAttributeFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalCommandStartOverInAcceptedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4c: TH reads the optional command(Previous) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalCommandPreviousInAcceptedCommandList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4d: TH reads the optional command(Next) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalCommandNextInAcceptedCommandList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalCommandRewindInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalCommandFastForwardInAcceptedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalCommandSkipForwardInAcceptedCommandList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep4hThReadsTheOptionalCommandSkipBackwardInAcceptedCommandList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4i: TH reads the optional command(Seek) in AcceptedCommandList\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep4iThReadsTheOptionalCommandSeekInAcceptedCommandList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenMediaplaybacksf00asEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenMediaplaybacksf01vsEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeStartTimeInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(StartTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(StartTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeDurationInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(Duration) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(Duration) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsTheOptionalAttributeSampledPositionInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThReadsTheOptionalAttributePlaybackSpeedInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsTheOptionalAttributeSeekRangeEndInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gThReadsTheOptionalAttributeSeekRangeStartInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAcceptedCommandListAttributeFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalCommandStartOverInAcceptedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalCommandPreviousInAcceptedCommandList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional command(Previous) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional command(Previous) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalCommandNextInAcceptedCommandList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional command(Next) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional command(Next) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalCommandRewindInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalCommandFastForwardInAcceptedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalCommandSkipForwardInAcceptedCommandList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsTheOptionalCommandSkipBackwardInAcceptedCommandList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsTheOptionalCommandSeekInAcceptedCommandList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads the optional command(Seek) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads the optional command(Seek) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_AUDIOOUTPUT_1_8 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AUDIOOUTPUT_1_8() - : TestCommandBridge("Test_TC_AUDIOOUTPUT_1_8") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AUDIOOUTPUT_1_8() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_1_8\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_1_8\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip("AUDIOOUTPUT.S.F00")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TTH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !AUDIOOUTPUT.S.F00 ")) { - NextTest(); - return; - } - err = TestStep2bTthReadsTheFeatureMapAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bTthReadsTheFeatureMapAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TTH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TTH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TGTNAV_1_9 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TGTNAV_1_9() - : TestCommandBridge("Test_TC_TGTNAV_1_9") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TGTNAV_1_9() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TGTNAV_1_9\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TGTNAV_1_9\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList\n"); - if (ShouldSkip("TGTNAV.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeCurrentTargetInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeCurrentTargetInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APBSC_1_10 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APBSC_1_10() - : TestCommandBridge("Test_TC_APBSC_1_10") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APBSC_1_10() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APBSC_1_10\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APBSC_1_10\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(VendorName) in AttributeList\n"); - if (ShouldSkip("APBSC.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeVendorNameInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3c: TH reads the optional attribute(VendorID) in AttributeList\n"); - if (ShouldSkip("APBSC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeVendorIDInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3d: TH reads the optional attribute(ProductID) in AttributeList\n"); - if (ShouldSkip("APBSC.S.A0003")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheOptionalAttributeProductIDInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeVendorNameInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(VendorName) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(VendorName) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeVendorIDInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(VendorID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(VendorID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsTheOptionalAttributeProductIDInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the optional attribute(ProductID) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the optional attribute(ProductID) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_1_11 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_1_11() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_1_11") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_1_11() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_1_11\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_1_11\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip("( !CONTENTLAUNCHER.S.F00 && !CONTENTLAUNCHER.S.F01 )")) { - NextTest(); - return; - } - err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenContentlaunchersf00CsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenContentlaunchersf01upEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheOptionalAttributeAcceptHeaderAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThReadsTheOptionalAttributeSupportedStreamingProtocolsAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute\n"); - if (ShouldSkip("CONTENTLAUNCHER.C.C00.Tx")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheOptionalCommandLaunchContentInAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute\n"); - if (ShouldSkip("CONTENTLAUNCHER.C.C01.Tx")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalCommandLaunchURLInAcceptedCommandListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenContentlaunchersf00CsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenContentlaunchersf01upEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsTheOptionalAttributeAcceptHeaderAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsTheOptionalAttributeSupportedStreamingProtocolsAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheOptionalCommandLaunchContentInAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalCommandLaunchURLInAcceptedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ALOGIN_1_12 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ALOGIN_1_12() - : TestCommandBridge("Test_TC_ALOGIN_1_12") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ALOGIN_1_12() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ALOGIN_1_12\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ALOGIN_1_12\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); - err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the EventList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_LOWPOWER_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_LOWPOWER_2_1() - : TestCommandBridge("Test_TC_LOWPOWER_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_LOWPOWER_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_LOWPOWER_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LOWPOWER_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends Sleep command to DUT\n"); - if (ShouldSkip("LOWPOWER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsSleepCommandToDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsSleepCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster sleepWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends Sleep command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends Sleep command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_KEYPADINPUT_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_KEYPADINPUT_3_2() - : TestCommandBridge("Test_TC_KEYPADINPUT_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_KEYPADINPUT_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends CEC Settings Keys(0x0A) to DUT\n"); - if (ShouldSkip("KEYPADINPUT.S.F01 && KEYPADINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsCecSettingsKeys0x0AToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends CEC Home Keys(0x09) to DUT\n"); - if (ShouldSkip("KEYPADINPUT.S.F01 && KEYPADINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsCecHomeKeys0x09ToDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsCecSettingsKeys0x0AToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:10U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends CEC Settings Keys(0x0A) to DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends CEC Settings Keys(0x0A) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsCecHomeKeys0x09ToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:9U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends CEC Home Keys(0x09) to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends CEC Home Keys(0x09) to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_KEYPADINPUT_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_KEYPADINPUT_3_3() - : TestCommandBridge("Test_TC_KEYPADINPUT_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_KEYPADINPUT_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends Numbers1\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1aThSendsNumbers1_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends Numbers2\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1bThSendsNumbers2_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH sends Numbers3\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1cThSendsNumbers3_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH sends Numbers4\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1dThSendsNumbers4_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH sends Numbers5\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1eThSendsNumbers5_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH sends Numbers6\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1fThSendsNumbers6_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1g: TH sends Numbers7\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1gThSendsNumbers7_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1h: TH sends Numbers8\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1hThSendsNumbers8_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 1i: TH sends Numbers9\n"); - if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { - NextTest(); - return; - } - err = TestStep1iThSendsNumbers9_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsNumbers1_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:33U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends Numbers1: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends Numbers1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThSendsNumbers2_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:34U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH sends Numbers2: Error: %@", err); - } else { - NSLog(@"Step 1b: TH sends Numbers2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThSendsNumbers3_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:35U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends Numbers3: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends Numbers3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThSendsNumbers4_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:36U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH sends Numbers4: Error: %@", err); - } else { - NSLog(@"Step 1d: TH sends Numbers4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThSendsNumbers5_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:37U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH sends Numbers5: Error: %@", err); - } else { - NSLog(@"Step 1e: TH sends Numbers5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fThSendsNumbers6_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:38U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: TH sends Numbers6: Error: %@", err); - } else { - NSLog(@"Step 1f: TH sends Numbers6: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1gThSendsNumbers7_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:39U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1g: TH sends Numbers7: Error: %@", err); - } else { - NSLog(@"Step 1g: TH sends Numbers7: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1hThSendsNumbers8_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:40U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1h: TH sends Numbers8: Error: %@", err); - } else { - NSLog(@"Step 1h: TH sends Numbers8: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1iThSendsNumbers9_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:41U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1i: TH sends Numbers9: Error: %@", err); - } else { - NSLog(@"Step 1i: TH sends Numbers9: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APPLAUNCHER_3_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APPLAUNCHER_3_5() - : TestCommandBridge("Test_TC_APPLAUNCHER_3_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APPLAUNCHER_3_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_3_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_3_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog\n"); - if (ShouldSkip("APPLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsCatalogListAttributeFromTheDutForTheListOfSupportedApplicationCatalogsAndWhereEachEntryInTheListIsACsaIssuedVendorIdOfTypeUnsigned16BitIntegerRangingBetween065536ForTheCatalog_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsCatalogListAttributeFromTheDutForTheListOfSupportedApplicationCatalogsAndWhereEachEntryInTheListIsACsaIssuedVendorIdOfTypeUnsigned16BitIntegerRangingBetween065536ForTheCatalog_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCatalogListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APPLAUNCHER_3_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APPLAUNCHER_3_6() - : TestCommandBridge("Test_TC_APPLAUNCHER_3_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APPLAUNCHER_3_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_3_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_3_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application\n"); - if (ShouldSkip("APPLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep1ThReadsCurrentAppAttributeFromTheDutAndVerifyTheInFocusApplicationAttributesWhichShouldIncludeTheDisplayApplicationIDtypeuint16CatalogVendorIDtypestringOrNullIfThereIsNoCurrentInFocusApplication_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsCurrentAppAttributeFromTheDutAndVerifyTheInFocusApplicationAttributesWhichShouldIncludeTheDisplayApplicationIDtypeuint16CatalogVendorIDtypestringOrNullIfThereIsNoCurrentInFocusApplication_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentAppWithCompletion:^(MTRApplicationLauncherClusterApplicationEPStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_10 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_10() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_10") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_10() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_10\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_10\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_11 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_11() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_11") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_11() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_11\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_11\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.\n"); - if (ShouldSkip("MEDIAINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsSelectInputCommandToDutToSelectAnInputByPassingTheIndexOfThePreferredInput_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.\n"); - if (ShouldSkip("MEDIAINPUT.S.A0001 && MEDIAINPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsCurrentInputAttributeFromTheDutToShowTheCurrentInputSelected_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsSelectInputCommandToDutToSelectAnInputByPassingTheIndexOfThePreferredInput_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterSelectInputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster selectInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsCurrentInputAttributeFromTheDutToShowTheCurrentInputSelected_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentInputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentInput", actualValue, mIndex.HasValue() ? mIndex.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_12 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_12() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_12") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_12() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_12\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_12\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list\n"); - if (ShouldSkip("MEDIAINPUT.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsShowInputStatusCommandToDutToShowActiveStatusOfTheInputList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list\n"); - if (ShouldSkip("MEDIAINPUT.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsHideInputStatusCommandToDutToHideActiveStatusOfTheInputList_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsShowInputStatusCommandToDutToShowActiveStatusOfTheInputList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster showInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsHideInputStatusCommandToDutToHideActiveStatusOfTheInputList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster hideInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAINPUT_3_13 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAINPUT_3_13() - : TestCommandBridge("Test_TC_MEDIAINPUT_3_13") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAINPUT_3_13() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_13\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_13\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available\n"); - if (ShouldSkip("MEDIAINPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1\n"); - if (ShouldSkip("MEDIAINPUT.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsARenameInputCommandToDutToRenameAnInputFromTheListReturnedInStep1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the InputList attribute from the DUT to show list of Inputs available\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAINPUT.S.A0000 && MEDIAINPUT.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("inputList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsARenameInputCommandToDutToRenameAnInputFromTheListReturnedInStep1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterRenameInputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - params.name = @"A1"; - [cluster renameInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_CHANNEL_5_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_5_1() - : TestCommandBridge("Test_TC_CHANNEL_5_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_5_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional)\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheChannelListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsAListOfTheKnownTvChannelsEachListElementShouldConsistOfTheFollowingMajorNumberUnsigned16BitIntegerMandatoryMinorNumberUnsigned16BitIntegerMandatoryNameStringOptionalCallSignStringOptionalAffiliateCallSignStringOptional_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheChannelListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsAListOfTheKnownTvChannelsEachListElementShouldConsistOfTheFollowingMajorNumberUnsigned16BitIntegerMandatoryMinorNumberUnsigned16BitIntegerMandatoryNameStringOptionalCallSignStringOptionalAffiliateCallSignStringOptional_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional): Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CHANNEL_5_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_5_2() - : TestCommandBridge("Test_TC_CHANNEL_5_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("majornumber", 0, UINT16_MAX, &mMajornumber); - AddArgument("minornumber", 0, UINT16_MAX, &mMinornumber); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_5_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ChannelList attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheChannelListAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1\n"); - if (ShouldSkip("CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsAChangeChannelByNumberCommandToTheDutWithChannelInformationMajorAndMinorNumbersFromTheListInStep1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: Verify that the channel has changed on the device\n"); - if (ShouldSkip("PICS_USER_PROMPT && CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2aVerifyThatTheChannelHasChangedOnTheDevice_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the CurrentChannel attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0002 && CHANNEL.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mMajornumber; - chip::Optional mMinornumber; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheChannelListAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("channelList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsAChangeChannelByNumberCommandToTheDutWithChannelInformationMajorAndMinorNumbersFromTheListInStep1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = mMajornumber.HasValue() ? [NSNumber numberWithUnsignedShort:mMajornumber.Value()] : [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = mMinornumber.HasValue() ? [NSNumber numberWithUnsignedShort:mMinornumber.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aVerifyThatTheChannelHasChangedOnTheDevice_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if channel has changed on the devicegarbage: not in length on purpose", 53); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber.HasValue() ? mMajornumber.Value() : 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber.HasValue() ? mMinornumber.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CHANNEL_5_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CHANNEL_5_3() - : TestCommandBridge("Test_TC_CHANNEL_5_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("majornumber", 0, UINT16_MAX, &mMajornumber); - AddArgument("minornumber", 0, UINT16_MAX, &mMinornumber); - AddArgument("majornumber2", 0, UINT16_MAX, &mMajornumber2); - AddArgument("minornumber2", 0, UINT16_MAX, &mMinornumber2); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CHANNEL_5_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object\n"); - if (ShouldSkip("CHANNEL.S.A0001")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheLineupAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsALineupInfoObject_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the ChannelList attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheChannelListAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the CurrentChannel attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends a SkipChannel command to the DUT with a value of 1\n"); - if (ShouldSkip("CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsASkipChannelCommandToTheDutWithAValueOf1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: Verify that the channel has changed on the device\n"); - if (ShouldSkip("PICS_USER_PROMPT && CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4aVerifyThatTheChannelHasChangedOnTheDevice_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the CurrentChannel attribute from the DUT\n"); - if (ShouldSkip("CHANNEL.S.A0002 && CHANNEL.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheCurrentChannelAttributeFromTheDut_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mMajornumber; - chip::Optional mMinornumber; - chip::Optional mMajornumber2; - chip::Optional mMinornumber2; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheLineupAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsALineupInfoObject_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLineupWithCompletion:^(MTRChannelClusterLineupInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheChannelListAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ChannelList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ChannelList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("channelList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber.HasValue() ? mMajornumber.Value() : 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber.HasValue() ? mMinornumber.Value() : 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsASkipChannelCommandToTheDutWithAValueOf1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:1]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a SkipChannel command to the DUT with a value of 1: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a SkipChannel command to the DUT with a value of 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aVerifyThatTheChannelHasChangedOnTheDevice_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if channel has changed on the devicegarbage: not in length on purpose", 53); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThReadsTheCurrentChannelAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the CurrentChannel attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber2.HasValue() ? mMajornumber2.Value() : 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber2.HasValue() ? mMinornumber2.Value() : 1U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentChannel", "ChannelInfoStruct", "ChannelInfoStruct")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_6_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_1() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Play command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsAPlayCommandToTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that the media state is playing\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaStateIsPlaying_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH sends a Pause command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsAPauseCommandToTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that the media is paused\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsPaused_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp && MEDIAPLAYBACK.S.A0000")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheCurrentStateAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH sends a Stop command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsAStopCommandToTheDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify that the media is stoped\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsStoped_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThReadsTheCurrentStateAttributeFromTheDut_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsAPlayCommandToTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Play command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Play command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsAPauseCommandToTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a Pause command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a Pause command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsPaused_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is pausedgarbage: not in length on purpose", 41); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThReadsTheCurrentStateAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsAStopCommandToTheDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a Stop command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a Stop command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsStoped_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is stopedgarbage: not in length on purpose", 41); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThReadsTheCurrentStateAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_6_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_2() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Play command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsAPlayCommandToTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that the media state is playing\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaStateIsPlaying_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH sends a StartOver command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsAStartOverCommandToTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that the media is started over\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsStartedOver_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH sends a Next command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsANextCommandToTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Verify that the next media item in the queue has been loaded\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheNextMediaItemInTheQueueHasBeenLoaded_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH sends a Previous command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsAPreviousCommandToTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Verify that the previous media item in the queue has been loaded\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatThePreviousMediaItemInTheQueueHasBeenLoaded_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsASkipForwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Verify that the media has skipped forward 10 seconds\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasSkippedForward10Seconds_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 8: TH reads the SampledPosition attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThReadsTheSampledPositionAttributeFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsASkipBackwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify that the media has skipped backward 10 seconds\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasSkippedBackward10Seconds_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 10: TH reads the SampledPosition attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C09.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThReadsTheSampledPositionAttributeFromTheDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsAPlayCommandToTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Play command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Play command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsAStartOverCommandToTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startOverWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a StartOver command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a StartOver command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsStartedOver_7() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media is started overgarbage: not in length on purpose", 41); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThSendsANextCommandToTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster nextWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a Next command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a Next command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheNextMediaItemInTheQueueHasBeenLoaded_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media item in the queue has been loadedgarbage: not in length on purpose", 59); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6ThSendsAPreviousCommandToTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster previousWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a Previous command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a Previous command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatThePreviousMediaItemInTheQueueHasBeenLoaded_11() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if previous media item in the queue has been loadedgarbage: not in length on purpose", 68); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThSendsASkipForwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipForwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:10000ULL]; - [cluster skipForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasSkippedForward10Seconds_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has skipped forward 10 secondsgarbage: not in length on purpose", 56); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsTheSampledPositionAttributeFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the SampledPosition attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the SampledPosition attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 10000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsASkipBackwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipBackwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:10000ULL]; - [cluster skipBackwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasSkippedBackward10Seconds_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has skipped backward 10 secondsgarbage: not in length on purpose", 57); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThReadsTheSampledPositionAttributeFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the SampledPosition attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the SampledPosition attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_MEDIAPLAYBACK_6_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_3() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("SeekPosition", 0, UINT64_MAX, &mSeekPosition); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends a Seek command to the DUT with a Position value of 10000\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsASeekCommandToTheDutWithAPositionValueOf10000_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the media has moved to 10 seconds from the starting point\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasMovedTo10SecondsFromTheStartingPoint_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads the SampledPosition attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheSampledPositionAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the StartTime attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheStartTimeAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the SeekRangeEnd attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0005")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheSeekRangeEndAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the SeekRangeStart attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0006")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheSeekRangeStartAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the Duration attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0002")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheDurationAttributeFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media)\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsASeekCommandToTheDutWithAPositionValueBeyondTheFurthestValidPositionExBeyondTheDurationOfTheMedia_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : verify that the media has not moved.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaHasNotMoved_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mSeekPosition; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThSendsASeekCommandToTheDutWithAPositionValueOf10000_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; - params.position = - [NSNumber numberWithUnsignedLongLong:10000ULL]; - [cluster seekWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a Seek command to the DUT with a Position value of 10000: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a Seek command to the DUT with a Position value of 10000: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasMovedTo10SecondsFromTheStartingPoint_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has moved to 10 seconds from the starting pointgarbage: not in length on purpose", 73); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheSampledPositionAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the SampledPosition attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the SampledPosition attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 10000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheStartTimeAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the StartTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the StartTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startTime", "epoch_us", "epoch_us")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheSeekRangeEndAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeEndWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the SeekRangeEnd attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the SeekRangeEnd attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("seekRangeEnd", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("seekRangeEnd", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("seekRangeEnd", [value unsignedLongLongValue], 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheSeekRangeStartAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeStartWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the SeekRangeStart attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the SeekRangeStart attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("seekRangeStart", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("seekRangeStart", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("seekRangeStart", [value unsignedLongLongValue], 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheDurationAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDurationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the Duration attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the Duration attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("duration", "int64u", "int64u")); - VerifyOrReturn(CheckConstraintMinValue("duration", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("duration", [value unsignedLongLongValue], 18446744073709551615ULL)); - } - VerifyOrReturn(CheckConstraintNotValue("duration", value, 0ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsASeekCommandToTheDutWithAPositionValueBeyondTheFurthestValidPositionExBeyondTheDurationOfTheMedia_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; - params.position = mSeekPosition.HasValue() ? [NSNumber numberWithUnsignedLongLong:mSeekPosition.Value()] : [NSNumber numberWithUnsignedLongLong:100000000ULL]; - [cluster seekWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media): Error: %@", err); - } else { - NSLog(@"Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaHasNotMoved_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media has not movedgarbage: not in length on purpose", 39); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_MEDIAPLAYBACK_6_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MEDIAPLAYBACK_6_4() - : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MEDIAPLAYBACK_6_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThReadsThePlaybackSpeedAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH sends a FastForward command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsAFastForwardCommandToTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : verify that the media state is playing\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaStateIsPlaying_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheCurrentStateAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThReadsThePlaybackSpeedAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH sends a FastForward command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsAFastForwardCommandToTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : verify that the media play speed has increased.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaPlaySpeedHasIncreased_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThReadsThePlaybackSpeedAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 8: TH sends a Rewind command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsARewindCommandToTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : verify that the media play has reversed direction.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaPlayHasReversedDirection_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 9: TH reads the CurrentState attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThReadsTheCurrentStateAttributeFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 10: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThReadsThePlaybackSpeedAttributeFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 11: TH sends a Rewind command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsARewindCommandToTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : verify that the media play speed has increased in the reverse direction.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaPlaySpeedHasIncreasedInTheReverseDirection_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 12: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep12ThReadsThePlaybackSpeedAttributeFromTheDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 13: TH sends a Play command to the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsAPlayCommandToTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : verify that the media is has resumed playing forward at the default speed.\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatTheMediaIsHasResumedPlayingForwardAtTheDefaultSpeed_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 14: TH reads the PlaybackSpeed attribute from the DUT\n"); - if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep14ThReadsThePlaybackSpeedAttributeFromTheDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 15: STH sends consecutive FastForward commands up to the manufacturer defined max speed\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { - NextTest(); - return; - } - err = TestStep15SthSendsConsecutiveFastForwardCommandsUpToTheManufacturerDefinedMaxSpeed_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 16: TH sends consecutive Rewind commands up to the manufacturer defined max speed\n"); - if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { - NextTest(); - return; - } - err = TestStep16ThSendsConsecutiveRewindCommandsUpToTheManufacturerDefinedMaxSpeed_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); - } else { - NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsThePlaybackSpeedAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsAFastForwardCommandToTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; - [cluster fastForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a FastForward command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a FastForward command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThReadsTheCurrentStateAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsThePlaybackSpeedAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 1.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsAFastForwardCommandToTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; - [cluster fastForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a FastForward command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a FastForward command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaPlaySpeedHasIncreased_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media play speed has increased.garbage: not in length on purpose", 51); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThReadsThePlaybackSpeedAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 2.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsARewindCommandToTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; - [cluster rewindWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends a Rewind command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends a Rewind command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaPlayHasReversedDirection_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media play has reversed directiongarbage: not in length on purpose", 53); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep9ThReadsTheCurrentStateAttributeFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads the CurrentState attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads the CurrentState attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsThePlaybackSpeedAttributeFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, -1.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsARewindCommandToTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; - [cluster rewindWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends a Rewind command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends a Rewind command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaPlaySpeedHasIncreasedInTheReverseDirection_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media play speed has increased in the reverse directiongarbage: not in length on purpose", 75); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep12ThReadsThePlaybackSpeedAttributeFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, -2.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsAPlayCommandToTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends a Play command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends a Play command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheMediaIsHasResumedPlayingForwardAtTheDefaultSpeed_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if media is has resumed playing forward at the default speedgarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep14ThReadsThePlaybackSpeedAttributeFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads the PlaybackSpeed attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 1.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15SthSendsConsecutiveFastForwardCommandsUpToTheManufacturerDefinedMaxSpeed_21() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep16ThSendsConsecutiveRewindCommandsUpToTheManufacturerDefinedMaxSpeed_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_AUDIOOUTPUT_7_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AUDIOOUTPUT_7_1() - : TestCommandBridge("Test_TC_AUDIOOUTPUT_7_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AUDIOOUTPUT_7_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_7_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_7_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the OutputList attribute\n"); - if (ShouldSkip("AUDIOOUTPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheOutputListAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1\n"); - if (ShouldSkip("AUDIOOUTPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsASelectAudioOutputCommandToTheDutWithAnIndexFromTheListInStep1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the CurrentOutput attribute from the DUT\n"); - if (ShouldSkip("AUDIOOUTPUT.S.A0001 && AUDIOOUTPUT.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheCurrentOutputAttributeFromTheDut_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheOutputListAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the OutputList attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the OutputList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("outputList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsASelectAudioOutputCommandToTheDutWithAnIndexFromTheListInStep1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterSelectOutputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster selectOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheCurrentOutputAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentOutputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the CurrentOutput attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the CurrentOutput attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentOutput", actualValue, mIndex.HasValue() ? mIndex.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_AUDIOOUTPUT_7_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_AUDIOOUTPUT_7_2() - : TestCommandBridge("Test_TC_AUDIOOUTPUT_7_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Index", 0, UINT8_MAX, &mIndex); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_AUDIOOUTPUT_7_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_7_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_7_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the OutputList attribute from the DUT\n"); - if (ShouldSkip("AUDIOOUTPUT.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheOutputListAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest'\n"); - if (ShouldSkip("AUDIOOUTPUT.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsARenameOutputCommandToTheDutWithAnIndexFromTheListInStep1AndTheNameCertTest_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the OutputList attribute from the DUT. Verify that the output at the index provided in step 2 has the name CertTest\n"); - if (ShouldSkip("PICS_USER_PROMPT && AUDIOOUTPUT.S.A0001 && AUDIOOUTPUT.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheOutputListAttributeFromTheDutVerifyThatTheOutputAtTheIndexProvidedInStep2HasTheNameCertTest_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mIndex; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSArray * _Nonnull audioOutputListValues; - - CHIP_ERROR TestStep1ThReadsTheOutputListAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the OutputList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the OutputList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("outputList", "list", "list")); - { - audioOutputListValues = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsARenameOutputCommandToTheDutWithAnIndexFromTheListInStep1AndTheNameCertTest_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterRenameOutputParams alloc] init]; - params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; - params.name = @"CertTest"; - [cluster renameOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest': Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheOutputListAttributeFromTheDutVerifyThatTheOutputAtTheIndexProvidedInStep2HasTheNameCertTest_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_TGTNAV_8_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TGTNAV_8_1() - : TestCommandBridge("Test_TC_TGTNAV_8_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("targetvalue", 0, UINT8_MAX, &mTargetvalue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TGTNAV_8_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TGTNAV_8_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TGTNAV_8_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads the CurrentTarget attribute\n"); - if (ShouldSkip("TGTNAV.S.A0001")) { - NextTest(); - return; - } - err = TestStep1aThReadsTheCurrentTargetAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads the TargetList attribute\n"); - if (ShouldSkip("TGTNAV.S.A0000")) { - NextTest(); - return; - } - err = TestStep1bThReadsTheTargetListAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH Sends a NavigateTarget command\n"); - if (ShouldSkip("TGTNAV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsANavigateTargetCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH reads the CurrentTarget attribute\n"); - if (ShouldSkip("TGTNAV.S.A0001 && TGTNAV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheCurrentTargetAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTargetvalue; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThReadsTheCurrentTargetAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads the CurrentTarget attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads the CurrentTarget attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentTarget", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentTarget", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentTarget", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSArray * _Nonnull TargetListValues; - - CHIP_ERROR TestStep1bThReadsTheTargetListAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads the TargetList attribute: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads the TargetList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("targetList", "list", "list")); - { - TargetListValues = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsANavigateTargetCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTargetNavigatorClusterNavigateTargetParams alloc] init]; - params.target = mTargetvalue.HasValue() ? [NSNumber numberWithUnsignedChar:mTargetvalue.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster navigateTargetWithParams:params completion: - ^(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH Sends a NavigateTarget command: Error: %@", err); - } else { - NSLog(@"Step 2a: TH Sends a NavigateTarget command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsTheCurrentTargetAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the CurrentTarget attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the CurrentTarget attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentTarget", actualValue, mTargetvalue.HasValue() ? mTargetvalue.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_APBSC_9_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_APBSC_9_1() - : TestCommandBridge("Test_TC_APBSC_9_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_APBSC_9_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_APBSC_9_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APBSC_9_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the VendorName attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheVendorNameAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the VendorID attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheVendorIDAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the ApplicationName attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheApplicationNameAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads the ProductID attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0003")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheProductIDAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads the Application attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0004")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheApplicationAttributeFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads the Status attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0005")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheStatusAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads the ApplicationVersion attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0006")) { - NextTest(); - return; - } - err = TestStep7ThReadsTheApplicationVersionAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH reads the AllowedVendorList attribute from the DUT\n"); - if (ShouldSkip("APBSC.S.A0007")) { - NextTest(); - return; - } - err = TestStep8ThReadsTheAllowedVendorListAttributeFromTheDut_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheVendorNameAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the VendorName attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the VendorName attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("vendorName", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("vendorName", value, 32)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheVendorIDAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the VendorID attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the VendorID attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("vendorID", "vendor_id", "vendor_id")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheApplicationNameAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the ApplicationName attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the ApplicationName attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("applicationName", "long_char_string", "long_char_string")); - VerifyOrReturn(CheckConstraintMaxLength("applicationName", value, 256)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheProductIDAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeProductIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the ProductID attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the ProductID attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("productID", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("productID", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("productID", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheApplicationAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationWithCompletion:^(MTRApplicationBasicClusterApplicationStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the Application attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the Application attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("application", "ApplicationStruct", "ApplicationStruct")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheStatusAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the Status attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the Status attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("status", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("status", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsTheApplicationVersionAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationVersionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads the ApplicationVersion attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads the ApplicationVersion attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("applicationVersion", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("applicationVersion", value, 32)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsTheAllowedVendorListAttributeFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAllowedVendorListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads the AllowedVendorList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads the AllowedVendorList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("allowedVendorList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_10_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_1() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the AcceptHeader attribute from the DUT\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheAcceptHeaderAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheSupportedStreamingProtocolsAttributeFromTheDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheAcceptHeaderAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptHeaderWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the AcceptHeader attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the AcceptHeader attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptHeader", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsTheSupportedStreamingProtocolsAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedStreamingProtocolsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedStreamingProtocols", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WAKEONLAN_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WAKEONLAN_4_1() - : TestCommandBridge("Test_TC_WAKEONLAN_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WAKEONLAN_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WAKEONLAN_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WAKEONLAN_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the MACAddress attribute from the DUT\n"); - if (ShouldSkip("WAKEONLAN.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsTheMACAddressAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a Sleep command to DUT\n"); - if (ShouldSkip("LOWPOWER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsASleepCommandToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends a Wake-On LAN magic packet containing the MAC address from step 1\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep3ThSendsAWakeOnLanMagicPacketContainingTheMacAddressFromStep1_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsTheMACAddressAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMACAddressWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads the MACAddress attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads the MACAddress attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("MACAddress", value, 12)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsASleepCommandToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster sleepWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Sleep command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Sleep command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsAWakeOnLanMagicPacketContainingTheMacAddressFromStep1_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_ALOGIN_12_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ALOGIN_12_1() - : TestCommandBridge("Test_TC_ALOGIN_12_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("TempAccountIdentifier", &mTempAccountIdentifier); - AddArgument("catalogVendorId", 0, UINT16_MAX, &mCatalogVendorId); - AddArgument("applicationId", &mApplicationId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ALOGIN_12_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ALOGIN_12_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ALOGIN_12_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Launch an app with the provided a application ID\n"); - if (ShouldSkip("APPLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestLaunchAnAppWithTheProvidedAApplicationId_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.\n"); - if (ShouldSkip("ALOGIN.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep1ThSendsAGetSetupPINCommandToTheDutWithTestValuesProvidedByTheProductMaker_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Login command to the DUT with test values provided by the product maker.\n"); - if (ShouldSkip("ALOGIN.S.C02.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep2ThSendsALoginCommandToTheDutWithTestValuesProvidedByTheProductMaker_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.\n"); - if (ShouldSkip("ALOGIN.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep3ThSendsALogoutCommandToTheDutWithTestValuesProvidedByTheProductMaker_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTempAccountIdentifier; - chip::Optional mCatalogVendorId; - chip::Optional mApplicationId; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestLaunchAnAppWithTheProvidedAApplicationId_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterLaunchAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = mCatalogVendorId.HasValue() ? [NSNumber numberWithUnsignedShort:mCatalogVendorId.Value()] : [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = mApplicationId.HasValue() ? [[NSString alloc] initWithBytes:mApplicationId.Value().data() length:mApplicationId.Value().size() encoding:NSUTF8StringEncoding] : @"exampleid"; - - params.data = - [[NSData alloc] initWithBytes:"Hello World" length:11]; - [cluster launchAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch an app with the provided a application ID: Error: %@", err); - } else { - NSLog(@"Launch an app with the provided a application ID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull setupPIN; - - CHIP_ERROR TestStep1ThSendsAGetSetupPINCommandToTheDutWithTestValuesProvidedByTheProductMaker_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterGetSetupPINParams alloc] init]; - params.tempAccountIdentifier = mTempAccountIdentifier.HasValue() ? [[NSString alloc] initWithBytes:mTempAccountIdentifier.Value().data() length:mTempAccountIdentifier.Value().size() encoding:NSUTF8StringEncoding] : @"1111"; - [cluster getSetupPINWithParams:params completion: - ^(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("setupPIN", values.setupPIN, 8)); - { - setupPIN = values.setupPIN; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsALoginCommandToTheDutWithTestValuesProvidedByTheProductMaker_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLoginParams alloc] init]; - params.tempAccountIdentifier = mTempAccountIdentifier.HasValue() ? [[NSString alloc] initWithBytes:mTempAccountIdentifier.Value().data() length:mTempAccountIdentifier.Value().size() encoding:NSUTF8StringEncoding] : @"1111"; - params.setupPIN = - [setupPIN copy]; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster loginWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a Login command to the DUT with test values provided by the product maker.: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a Login command to the DUT with test values provided by the product maker.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsALogoutCommandToTheDutWithTestValuesProvidedByTheProductMaker_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLogoutParams alloc] init]; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster logoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_10_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_3() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("data", &mData); - AddArgument("SearchValue", &mSearchValue); - AddArgument("ExternalIdName", &mExternalIdName); - AddArgument("ExternalIdValue", &mExternalIdValue); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToFalse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT present via its user interface a list of matches based on the provided search criteria.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutPresentViaItsUserInterfaceAListOfMatchesBasedOnTheProvidedSearchCriteria_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToTrue_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT should also begin playing content that best matched the given search criteria\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldAlsoBeginPlayingContentThatBestMatchedTheGivenSearchCriteria_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mData; - chip::Optional mSearchValue; - chip::Optional mExternalIdName; - chip::Optional mExternalIdValue; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToFalse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mSearchValue.HasValue() ? [[NSString alloc] initWithBytes:mSearchValue.Value().data() length:mSearchValue.Value().size() encoding:NSUTF8StringEncoding] : @"exampleValue"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = mExternalIdName.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdName.Value().data() length:mExternalIdName.Value().size() encoding:NSUTF8StringEncoding] : @"name"; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = mExternalIdValue.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdValue.Value().data() length:mExternalIdValue.Value().size() encoding:NSUTF8StringEncoding] : @"value"; - - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; - } - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:false]; - params.data = mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - params.useCurrentContext = - [NSNumber numberWithBool:false]; - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutPresentViaItsUserInterfaceAListOfMatchesBasedOnTheProvidedSearchCriteria_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT present via its user interface a list of matches based on the provided search criteria.garbage: not in length on purpose", 111); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToTrue_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mSearchValue.HasValue() ? [[NSString alloc] initWithBytes:mSearchValue.Value().data() length:mSearchValue.Value().size() encoding:NSUTF8StringEncoding] : @"exampleValue"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = mExternalIdName.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdName.Value().data() length:mExternalIdName.Value().size() encoding:NSUTF8StringEncoding] : @"name"; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = mExternalIdValue.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdValue.Value().data() length:mExternalIdValue.Value().size() encoding:NSUTF8StringEncoding] : @"value"; - - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; - } - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.data = mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - params.useCurrentContext = - [NSNumber numberWithBool:false]; - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldAlsoBeginPlayingContentThatBestMatchedTheGivenSearchCriteria_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT begin playing content that best matched the given search criteriagarbage: not in length on purpose", 89); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_CONTENTLAUNCHER_10_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_5() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("GoodURL", &mGoodURL); - AddArgument("BadURL", &mBadURL); - AddArgument("UnauthorizedURL", &mUnauthorizedURL); - AddArgument("DisplayContent", &mDisplayContent); - AddArgument("providerNameString", &mProviderNameString); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlString_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT launched the content at the given URL\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrl_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndADisplayString_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT launched the content at the given URL with the given display string in the application-specific description area\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithTheGivenDisplayStringInTheApplicationSpecificDescriptionArea_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndABrandInformationObject_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Verify that DUT launched the content at the given URL with the player interface updated as per the provided branding information\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithThePlayerInterfaceUpdatedAsPerTheProvidedBrandingInformation_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsALaunchURLCommandToTheDutWithAKnownUnreachableContentUrlString_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsALaunchURLCommandToTheDutWithAKnownUnAuthorizedContentUrlString_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mGoodURL; - chip::Optional mBadURL; - chip::Optional mUnauthorizedURL; - chip::Optional mDisplayContent; - chip::Optional mProviderNameString; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlString_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrl_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URLgarbage: not in length on purpose", 61); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndADisplayString_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; - params.displayString = mDisplayContent.HasValue() ? [[NSString alloc] initWithBytes:mDisplayContent.Value().data() length:mDisplayContent.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, mDisplayContent.HasValue() ? [[NSString alloc] initWithBytes:mDisplayContent.Value().data() length:mDisplayContent.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithTheGivenDisplayStringInTheApplicationSpecificDescriptionArea_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URL with the given display string in the application-specific description areagarbage: not in length on purpose", 136); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndABrandInformationObject_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithThePlayerInterfaceUpdatedAsPerTheProvidedBrandingInformation_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URL with the player interface updated as per the provided branding informationgarbage: not in length on purpose", 136); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThSendsALaunchURLCommandToTheDutWithAKnownUnreachableContentUrlString_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mBadURL.HasValue() ? [[NSString alloc] initWithBytes:mBadURL.Value().data() length:mBadURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://badurl"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsALaunchURLCommandToTheDutWithAKnownUnAuthorizedContentUrlString_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = mUnauthorizedURL.HasValue() ? [[NSString alloc] initWithBytes:mUnauthorizedURL.Value().data() length:mUnauthorizedURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/badauth"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_CONTENTLAUNCHER_10_7 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_CONTENTLAUNCHER_10_7() - : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_7") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("PopularityName", &mPopularityName); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_CONTENTLAUNCHER_10_7() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_7\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_7\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsActorAndValueAsAnActorsNameForExampleGabySHoffman_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsChannelAndValueAsChannelNameNameForExamplePbs_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsCharacterAndValueAsCharactersNameforExampleSnowWhite_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsDirectorAndValueAsDirectorsNameForExampleSpikeLee_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsEventAndValueAsAnEventsNameForExampleFootballGames_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsFranchiseAndValueAsFranchisesNameforExampleStarWars_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsGenreAndValueAsGenresNameForExampleHorror_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsLeagueAndValueAsLeaguesNameForExampleNcaa_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsPopularityAndValueAsPopularitysName_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsProviderAndValueAsProvidersNameForExampleNetflix_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep11ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportAndValueAsSportsNameForExampleFootball_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep12ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportsTeamAndValueAsSportTeamsNameForExampleArsenel_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries\n"); - if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsTypeAndValueAsTypesNameForExampleTVSeries_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Verify that DUT should play or display the search result.\n"); - if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_26(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 27; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPopularityName; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsActorAndValueAsAnActorsNameForExampleGabySHoffman_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Gaby sHoffman"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsChannelAndValueAsChannelNameNameForExamplePbs_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"PBS"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsCharacterAndValueAsCharactersNameforExampleSnowWhite_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Snow White"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:false]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsDirectorAndValueAsDirectorsNameForExampleSpikeLee_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Spike Lee"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsEventAndValueAsAnEventsNameForExampleFootballGames_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Football games"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsFranchiseAndValueAsFranchisesNameforExampleStarWars_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Star Wars"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_12() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsGenreAndValueAsGenresNameForExampleHorror_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:6U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Horror"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep8ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsLeagueAndValueAsLeaguesNameForExampleNcaa_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:7U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"NCAA"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep9ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsPopularityAndValueAsPopularitysName_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:8U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mPopularityName.HasValue() ? [[NSString alloc] initWithBytes:mPopularityName.Value().data() length:mPopularityName.Value().size() encoding:NSUTF8StringEncoding] : @"popular content"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsProviderAndValueAsProvidersNameForExampleNetflix_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:9U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Netflix"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_20() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep11ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportAndValueAsSportsNameForExampleFootball_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:10U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"football"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep12ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportsTeamAndValueAsSportTeamsNameForExampleArsenel_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:11U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Arsenel"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel: Error: %@", err); - } else { - NSLog(@"Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_24() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep13ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsTypeAndValueAsTypesNameForExampleTVSeries_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:12U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"TVSeries"; - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_26() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_MOD_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_MOD_1_1() - : TestCommandBridge("Test_TC_MOD_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_MOD_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_MOD_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MOD_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("MOD.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !MOD.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT\n"); - if (ShouldSkip("MOD.S.A0004")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT\n"); - if (ShouldSkip("MOD.S.F00 && MOD.S.A0005")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentAttributeOnModeInAttributeListFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentAttributeOnModeInAttributeListFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class OTA_SuccessfulTransfer : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - OTA_SuccessfulTransfer() - : TestCommandBridge("OTA_SuccessfulTransfer") - , mTestIndex(0) - { - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("requestorNodeId", 0, UINT64_MAX, &mRequestorNodeId); - AddArgument("providerNodeId", 0, UINT64_MAX, &mProviderNodeId); - AddArgument("providerPayload", &mProviderPayload); - AddArgument("providerDiscriminator", 0, UINT16_MAX, &mProviderDiscriminator); - AddArgument("providerPort", 0, UINT16_MAX, &mProviderPort); - AddArgument("providerKvs", &mProviderKvs); - AddArgument("otaImageFilePath", &mOtaImageFilePath); - AddArgument("rawImageFilePath", &mRawImageFilePath); - AddArgument("rawImageContent", &mRawImageContent); - AddArgument("downloadImageFilePath", &mDownloadImageFilePath); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~OTA_SuccessfulTransfer() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: OTA_SuccessfulTransfer\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: OTA_SuccessfulTransfer\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Create OTA image\n"); - err = TestCreateOtaImage_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Start the provider with an image\n"); - err = TestStartTheProviderWithAnImage_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Commission the provider from alpha\n"); - err = TestCommissionTheProviderFromAlpha_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Wait for the commissioned provider to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedProviderToBeRetrievedForAlpha_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Install ACL for QueryImage\n"); - err = TestInstallAclForQueryImage_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Stop the requestor\n"); - err = TestStopTheRequestor_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Start the requestor with an OTA download path\n"); - err = TestStartTheRequestorWithAnOtaDownloadPath_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait for the commissioned requestor to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedRequestorToBeRetrievedForAlpha_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Send an announce OTA provider command to the requestor\n"); - err = TestSendAnAnnounceOtaProviderCommandToTheRequestor_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Wait for transfer complete message\n"); - err = TestWaitForTransferCompleteMessage_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Compare original file to downloaded file\n"); - err = TestCompareOriginalFileToDownloadedFile_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mEndpoint; - chip::Optional mRequestorNodeId; - chip::Optional mProviderNodeId; - chip::Optional mProviderPayload; - chip::Optional mProviderDiscriminator; - chip::Optional mProviderPort; - chip::Optional mProviderKvs; - chip::Optional mOtaImageFilePath; - chip::Optional mRawImageFilePath; - chip::Optional mRawImageContent; - chip::Optional mDownloadImageFilePath; - chip::Optional mTimeout; - - CHIP_ERROR TestCreateOtaImage_0() - { - - chip::app::Clusters::SystemCommands::Commands::CreateOtaImage::Type value; - value.otaImageFilePath = mOtaImageFilePath.HasValue() ? mOtaImageFilePath.Value() : chip::Span("/tmp/otaImage", 13); - value.rawImageFilePath = mRawImageFilePath.HasValue() ? mRawImageFilePath.Value() : chip::Span("/tmp/rawImage", 13); - value.rawImageContent = mRawImageContent.HasValue() ? mRawImageContent.Value() : chip::Span("Have a hootenanny!", 18); - return CreateOtaImage("alpha", value); - } - - CHIP_ERROR TestStartTheProviderWithAnImage_1() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-ota-provider-appgarbage: not in length on purpose", 21); - value.discriminator.Emplace(); - value.discriminator.Value() = mProviderDiscriminator.HasValue() ? mProviderDiscriminator.Value() : 50U; - value.port.Emplace(); - value.port.Value() = mProviderPort.HasValue() ? mProviderPort.Value() : 5560U; - value.kvs.Emplace(); - value.kvs.Value() = mProviderKvs.HasValue() ? mProviderKvs.Value() : chip::Span("/tmp/chip_kvs_provider", 22); - value.filepath.Emplace(); - value.filepath.Value() = mOtaImageFilePath.HasValue() ? mOtaImageFilePath.Value() : chip::Span("/tmp/otaImage", 13); - return Start("alpha", value); - } - - CHIP_ERROR TestCommissionTheProviderFromAlpha_2() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mProviderNodeId.HasValue() ? mProviderNodeId.Value() : 12648430ULL; - value.payload = mProviderPayload.HasValue() ? mProviderPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedProviderToBeRetrievedForAlpha_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mProviderNodeId.HasValue() ? mProviderNodeId.Value() : 12648430ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestInstallAclForQueryImage_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = - [NSNumber numberWithUnsignedInt:41UL]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Install ACL for QueryImage: Error: %@", err); - } else { - NSLog(@"Install ACL for QueryImage: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStopTheRequestor_5() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheRequestorWithAnOtaDownloadPath_6() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.otaDownloadPath.Emplace(); - value.otaDownloadPath.Value() = mDownloadImageFilePath.HasValue() ? mDownloadImageFilePath.Value() : chip::Span("/tmp/downloadedImage", 20); - return Start("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedRequestorToBeRetrievedForAlpha_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mRequestorNodeId.HasValue() ? mRequestorNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendAnAnnounceOtaProviderCommandToTheRequestor_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOTASoftwareUpdateRequestor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROTASoftwareUpdateRequestorClusterAnnounceOTAProviderParams alloc] init]; - params.providerNodeID = mProviderNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mProviderNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:12648430ULL]; - params.vendorID = - [NSNumber numberWithUnsignedShort:0U]; - params.announcementReason = - [NSNumber numberWithUnsignedChar:0U]; - params.endpoint = mEndpoint.HasValue() ? [NSNumber numberWithUnsignedShort:mEndpoint.Value()] : [NSNumber numberWithUnsignedShort:0U]; - [cluster announceOTAProviderWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send an announce OTA provider command to the requestor: Error: %@", err); - } else { - NSLog(@"Send an announce OTA provider command to the requestor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitForTransferCompleteMessage_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMessage::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - value.message = chip::Span("OTA image downloadedgarbage: not in length on purpose", 20); - return WaitForMessage("alpha", value); - } - - CHIP_ERROR TestCompareOriginalFileToDownloadedFile_10() - { - - chip::app::Clusters::SystemCommands::Commands::CompareFiles::Type value; - value.file1 = mRawImageFilePath.HasValue() ? mRawImageFilePath.Value() : chip::Span("/tmp/rawImage", 13); - value.file2 = mDownloadImageFilePath.HasValue() ? mDownloadImageFilePath.Value() : chip::Span("/tmp/downloadedImage", 20); - return CompareFiles("alpha", value); - } -}; - -class Test_TC_OCC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OCC_1_1() - : TestCommandBridge("Test_TC_OCC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OCC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributePIROccupiedToUnoccupiedDelayInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributePIRUnoccupiedToOccupiedDelayInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributePIRUnoccupiedToOccupiedThresholdInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeUltrasonicOccupiedToUnoccupiedDelayInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedDelayInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0022")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedThresholdInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0030")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributePhysicalContactOccupiedToUnoccupiedDelayInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0031")) { - NextTest(); - return; - } - err = TestStep4iThReadsTheOptionalAttributePhysicalContactUnoccupiedToOccupiedDelayInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList\n"); - if (ShouldSkip("OCC.S.A0032")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributePhysicalContactUnoccupiedToOccupiedThresholdInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute\n"); - err = TestStep6ThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributePIROccupiedToUnoccupiedDelayInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributePIRUnoccupiedToOccupiedDelayInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributePIRUnoccupiedToOccupiedThresholdInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeUltrasonicOccupiedToUnoccupiedDelayInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedDelayInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedThresholdInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributePhysicalContactOccupiedToUnoccupiedDelayInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsTheOptionalAttributePhysicalContactUnoccupiedToOccupiedDelayInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributePhysicalContactUnoccupiedToOccupiedThresholdInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OCC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OCC_2_1() - : TestCommandBridge("Test_TC_OCC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OCC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0x0000) Occupancy attribute\n"); - if (ShouldSkip("OCC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutThe0x0000OccupancyAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute\n"); - if (ShouldSkip("OCC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutThe0x0001OccupancySensorTypeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute\n"); - if (ShouldSkip("OCC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4thReadsFromTheDutThe0x0002OccupancySensorTypeBitmapAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor\n"); - if (ShouldSkip("OCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutThe0x0010PIROccupiedToUnoccupiedDelayOptionalAttributeIfPirSensor_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor\n"); - if (ShouldSkip("OCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutThe0x0011PIRUnoccupiedToOccupiedDelayOptionalAttributeIfPirSensor_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor\n"); - if (ShouldSkip("OCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutThe0x0012PIRUnoccupiedToOccupiedThresholdOptionalAttributeIfPirSensor_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor\n"); - if (ShouldSkip("OCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutThe0x0020UltrasonicOccupiedToUnoccupiedDelayOptionalAttributeIfUltrasonicSensor_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor\n"); - if (ShouldSkip("OCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutThe0x0021UltrasonicUnoccupiedToOccupiedDelayOptionalAttributeIfUltrasonicSensor_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor\n"); - if (ShouldSkip("OCC.S.A0022")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutThe0x0022UltrasonicUnoccupiedToOccupiedThresholdOptionalAttributeIfUltrasonicSensor_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor\n"); - if (ShouldSkip("OCC.S.A0030")) { - NextTest(); - return; - } - err = TestStep11thReadsFromTheDutThe0x0030PhysicalContactOccupiedToUnoccupiedDelayOptionalAttributeIfPhysicalContactSensor_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor\n"); - if (ShouldSkip("OCC.S.A0031")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutThe0x0031PhysicalContactUnoccupiedToOccupiedDelayOptionalAttributeIfPhysicalContactSensor_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor\n"); - if (ShouldSkip("OCC.S.A0032")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutThe0x0032PhysicalContactUnoccupiedToOccupiedThresholdOptionalAttributeIfPhysicalContactSensor_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0x0000OccupancyAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) Occupancy attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0x0000) Occupancy attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancy", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("occupancy", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancy", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutThe0x0001OccupancySensorTypeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorType", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4thReadsFromTheDutThe0x0002OccupancySensorTypeBitmapAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeBitmapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute: Error: %@", err); - } else { - NSLog(@"Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorTypeBitmap", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorTypeBitmap", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorTypeBitmap", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutThe0x0010PIROccupiedToUnoccupiedDelayOptionalAttributeIfPirSensor_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePIROccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("PIROccupiedToUnoccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("PIROccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PIROccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutThe0x0011PIRUnoccupiedToOccupiedDelayOptionalAttributeIfPirSensor_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePIRUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("PIRUnoccupiedToOccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("PIRUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("PIRUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0x0012PIRUnoccupiedToOccupiedThresholdOptionalAttributeIfPirSensor_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePIRUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("PIRUnoccupiedToOccupiedThreshold", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("PIRUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("PIRUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutThe0x0020UltrasonicOccupiedToUnoccupiedDelayOptionalAttributeIfUltrasonicSensor_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUltrasonicOccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("ultrasonicOccupiedToUnoccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("ultrasonicOccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("ultrasonicOccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutThe0x0021UltrasonicUnoccupiedToOccupiedDelayOptionalAttributeIfUltrasonicSensor_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUltrasonicUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("ultrasonicUnoccupiedToOccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("ultrasonicUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("ultrasonicUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutThe0x0022UltrasonicUnoccupiedToOccupiedThresholdOptionalAttributeIfUltrasonicSensor_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUltrasonicUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("ultrasonicUnoccupiedToOccupiedThreshold", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("ultrasonicUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("ultrasonicUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11thReadsFromTheDutThe0x0030PhysicalContactOccupiedToUnoccupiedDelayOptionalAttributeIfPhysicalContactSensor_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalContactOccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor: Error: %@", err); - } else { - NSLog(@"Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalContactOccupiedToUnoccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalContactOccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalContactOccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutThe0x0031PhysicalContactUnoccupiedToOccupiedDelayOptionalAttributeIfPhysicalContactSensor_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalContactUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalContactUnoccupiedToOccupiedDelay", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalContactUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalContactUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutThe0x0032PhysicalContactUnoccupiedToOccupiedThresholdOptionalAttributeIfPhysicalContactSensor_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalContactUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalContactUnoccupiedToOccupiedThreshold", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("physicalContactUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalContactUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OCC_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OCC_2_3() - : TestCommandBridge("Test_TC_OCC_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OCC_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads OccupancySensorType attribute from DUT\n"); - if (ShouldSkip("OCC.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsOccupancySensorTypeAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT\n"); - if (ShouldSkip("OCC.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsOccupancySensorTypeBitmapAttributeFromDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsOccupancySensorTypeAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads OccupancySensorType attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads OccupancySensorType attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorType", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsOccupancySensorTypeBitmapAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOccupancySensorTypeBitmapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("occupancySensorTypeBitmap", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("occupancySensorTypeBitmap", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("occupancySensorTypeBitmap", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_1_1() - : TestCommandBridge("Test_TC_OO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("( !OO.S.F00 && !OO.S.F01 )")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OO.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenOosf00ltEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("OO.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenOosf01dfEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("OO.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentOOSF00AttributeInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList\n"); - if (ShouldSkip("OO.S.F00")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheFeatureDependentOOSF00CommandsInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("clusterRevision", [value unsignedShortValue], 5U)); - VerifyOrReturn(CheckConstraintMaxValue("clusterRevision", [value unsignedShortValue], 6U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenOosf00ltEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenOosf01dfEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentOOSF00AttributeInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16386UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16387UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheFeatureDependentOOSF00CommandsInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 65UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 66UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_2_1() - : TestCommandBridge("Test_TC_OO_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheOnOffAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the GlobalSceneControl attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4000")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheGlobalSceneControlAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the OnTime attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4001")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheOnTimeAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the OffWaitTime attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4002")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheOffWaitTimeAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads the StartUpOnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheStartUpOnOffAttributeFromTheDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheOnOffAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onOff", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheGlobalSceneControlAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGlobalSceneControlWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the GlobalSceneControl attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the GlobalSceneControl attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("globalSceneControl", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheOnTimeAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the OnTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the OnTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("onTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("onTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("onTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheOffWaitTimeAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOffWaitTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the OffWaitTime attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the OffWaitTime attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("offWaitTime", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("offWaitTime", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("offWaitTime", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheStartUpOnOffAttributeFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the StartUpOnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the StartUpOnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("startUpOnOff", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_2_2() - : TestCommandBridge("Test_TC_OO_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsOffCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep2bAfterAFewSecondsThReadsOnOffAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsOnCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep3bAfterAFewSecondsThReadsOnOffAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3c: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3cThSendsOnCommandToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dAfterAFewSecondsThReadsOnOffAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsOffCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bAfterAFewSecondsThReadsOnOffAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4cThSendsOffCommandToDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep4dAfterAFewSecondsThReadsOnOffAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5c: TH sends Toggle command to DUT\n"); - if (ShouldSkip("OO.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep5cThSendsToggleCommandToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 1000ms\n"); - err = TestWait1000ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep5dAfterAFewSecondsThReadsOnOffAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : TH sends Toggle command to DUT\n"); - if (ShouldSkip("OO.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestThSendsToggleCommandToDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 1000ms\n"); - err = TestWait1000ms_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Check on/off attribute value is false after toggle command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterToggleCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6a: Operate on device to set OnOff attribute manually to on\n"); - if (ShouldSkip("PICS_USER_PROMPT && OO.M.ManuallyControlled && OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6aOperateOnDeviceToSetOnOffAttributeManuallyToOn_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6b: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && OO.S.A0000 && OO.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6bAfterAFewSecondsThReadsOnOffAttributeFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6c: Operate on device to set OnOff attribute manually to off\n"); - if (ShouldSkip("PICS_USER_PROMPT && OO.M.ManuallyControlled && OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6cOperateOnDeviceToSetOnOffAttributeManuallyToOff_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 6d: after a few seconds, TH reads OnOff attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && OO.S.A0000 && OO.M.ManuallyControlled")) { - NextTest(); - return; - } - err = TestStep6dAfterAFewSecondsThReadsOnOffAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Reset Off Command\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestResetOffCommand_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Check on/off attribute value is false after off command\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsOffCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bAfterAFewSecondsThReadsOnOffAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsOnCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bAfterAFewSecondsThReadsOnOffAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThSendsOnCommandToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dAfterAFewSecondsThReadsOnOffAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsOffCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bAfterAFewSecondsThReadsOnOffAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThSendsOffCommandToDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dAfterAFewSecondsThReadsOnOffAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsToggleCommandToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster toggleWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends Toggle command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends Toggle command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5dAfterAFewSecondsThReadsOnOffAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestThSendsToggleCommandToDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster toggleWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH sends Toggle command to DUT: Error: %@", err); - } else { - NSLog(@"TH sends Toggle command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1000ms_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterToggleCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after toggle command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after toggle command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aOperateOnDeviceToSetOnOffAttributeManuallyToOn_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6bAfterAFewSecondsThReadsOnOffAttributeFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cOperateOnDeviceToSetOnOffAttributeManuallyToOff_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6dAfterAFewSecondsThReadsOnOffAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 6d: after a few seconds, TH reads OnOff attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResetOffCommand_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reset Off Command: Error: %@", err); - } else { - NSLog(@"Reset Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OO_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OO_2_4() - : TestCommandBridge("Test_TC_OO_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OO_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH sends On command to DUT\n"); - if (ShouldSkip("OO.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsOnCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep3aThWritesAValueOf0ToStartUpOnOffAttributeOfDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3bRebootTargetDevice_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep3cRebootTargetDeviceDUT_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheOnOffAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep4aThWritesAValueOf1ToStartUpOnOffAttributeOfDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4bRebootTargetDevice_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4cRebootTargetDeviceDUT_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOnOffAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep5aThWritesAValueOf2ToStartUpOnOffAttributeOfDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep5bRebootTargetDevice_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5cRebootTargetDeviceDUT_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep5dThReadsTheOnOffAttributeFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5e: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep5eRebootTargetDevice_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5f: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5fRebootTargetDeviceDUT_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5g: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep5gThReadsTheOnOffAttributeFromTheDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 6a: TH writes NULL to StartUpOnOff attribute of DUT\n"); - if (ShouldSkip("OO.S.A4003")) { - NextTest(); - return; - } - err = TestStep6aThWritesNullToStartUpOnOffAttributeOfDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 6b: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6bRebootTargetDevice_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6c: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6cRebootTargetDeviceDUT_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 6d: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6dThReadsTheOnOffAttributeFromTheDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 6e: TH sends Off command to DUT\n"); - if (ShouldSkip("OO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6eThSendsOffCommandToDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 6f: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6fThReadsTheOnOffAttributeFromTheDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6g: Reboot target device\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6gRebootTargetDevice_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 6h: Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep6hRebootTargetDeviceDUT_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 6i: TH reads the OnOff attribute from the DUT\n"); - if (ShouldSkip("OO.S.A0000")) { - NextTest(); - return; - } - err = TestStep6iThReadsTheOnOffAttributeFromTheDut_31(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 32; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsOnCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends On command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends On command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWritesAValueOf0ToStartUpOnOffAttributeOfDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bRebootTargetDevice_3() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep3cRebootTargetDeviceDUT_4() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsTheOnOffAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWritesAValueOf1ToStartUpOnOffAttributeOfDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bRebootTargetDevice_8() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep4cRebootTargetDeviceDUT_9() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep4dThReadsTheOnOffAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWritesAValueOf2ToStartUpOnOffAttributeOfDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bRebootTargetDevice_13() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep5cRebootTargetDeviceDUT_14() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep5dThReadsTheOnOffAttributeFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5eRebootTargetDevice_17() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep5fRebootTargetDeviceDUT_18() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_19() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep5gThReadsTheOnOffAttributeFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5g: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5g: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWritesNullToStartUpOnOffAttributeOfDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = nil; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH writes NULL to StartUpOnOff attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH writes NULL to StartUpOnOff attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bRebootTargetDevice_22() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep6cRebootTargetDeviceDUT_23() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_24() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep6dThReadsTheOnOffAttributeFromTheDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThSendsOffCommandToDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH sends Off command to DUT: Error: %@", err); - } else { - NSLog(@"Step 6e: TH sends Off command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThReadsTheOnOffAttributeFromTheDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6f: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gRebootTargetDevice_28() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStep6hRebootTargetDeviceDUT_29() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep6iThReadsTheOnOffAttributeFromTheDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6i: TH reads the OnOff attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6i: TH reads the OnOff attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OPSTATE_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OPSTATE_1_1() - : TestCommandBridge("Test_TC_OPSTATE_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OPSTATE_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OPSTATE_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OPSTATE_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT\n"); - if (ShouldSkip("OPSTATE.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5a: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5b: TH reads from the DUT the optional event(OperationCompletion) in EventList.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && OPSTATE.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: TH reads the optional command(Start) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsTheOptionalCommandStartInAcceptedCommandList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6b: TH reads the optional command(Stop) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6c: TH reads the optional command(Pause) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsTheOptionalCommandPauseInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6d: TH reads the optional command(Resume) in AcceptedCommandList\n"); - if (ShouldSkip("OPSTATE.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("!OPSTATE.S.C00.Rsp && !OPSTATE.S.C01.Rsp && !OPSTATE.S.C02.Rsp && !OPSTATE.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheAcceptedCommandListAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip("(OPSTATE.S.C00.Rsp || OPSTATE.S.C01.Rsp || OPSTATE.S.C02.Rsp || OPSTATE.S.C03.Rsp)")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsTheOptionalCommandStartInAcceptedCommandList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads the optional command(Start) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads the optional command(Start) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsTheOptionalCommandPauseInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads the optional command(Pause) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads the optional command(Pause) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheAcceptedCommandListAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OVENOPSTATE_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OVENOPSTATE_1_1() - : TestCommandBridge("Test_TC_OVENOPSTATE_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OVENOPSTATE_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap attribute from the DUT\n"); - err = TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT\n"); - if (ShouldSkip("OVENOPSTATE.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5a: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5b: TH reads from the DUT the optional event(OperationCompletion) in EventList.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && OVENOPSTATE.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: Read the optional command(Start) in AcceptedCommandList\n"); - if (ShouldSkip("OVENOPSTATE.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6aReadTheOptionalCommandStartInAcceptedCommandList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6b: Read the optional command(Stop) in AcceptedCommandList\n"); - if (ShouldSkip("OVENOPSTATE.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep6bReadTheOptionalCommandStopInAcceptedCommandList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6c: Read the optional command(Pause) in AcceptedCommandList\n"); - if (ShouldSkip("OVENOPSTATE.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6cReadTheOptionalCommandPauseInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6d: Read the optional command(Resume) in AcceptedCommandList\n"); - if (ShouldSkip("OVENOPSTATE.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6dReadTheOptionalCommandResumeInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: Read the global attribute: GeneratedCommandList\n"); - if (ShouldSkip("!OVENOPSTATE.S.C00.Rsp && !OVENOPSTATE.S.C01.Rsp && !OVENOPSTATE.S.C02.Rsp && !OVENOPSTATE.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: Read the global attribute: GeneratedCommandList\n"); - if (ShouldSkip("(OVENOPSTATE.S.C00.Rsp || OVENOPSTATE.S.C01.Rsp || OVENOPSTATE.S.C02.Rsp || OVENOPSTATE.S.C03.Rsp)")) { - NextTest(); - return; - } - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aReadTheOptionalCommandStartInAcceptedCommandList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: Read the optional command(Start) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: Read the optional command(Start) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bReadTheOptionalCommandStopInAcceptedCommandList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: Read the optional command(Stop) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: Read the optional command(Stop) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cReadTheOptionalCommandPauseInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: Read the optional command(Pause) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: Read the optional command(Pause) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dReadTheOptionalCommandResumeInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: Read the optional command(Resume) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: Read the optional command(Resume) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_OVENOPSTATE_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OVENOPSTATE_2_4() - : TestCommandBridge("Test_TC_OVENOPSTATE_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OVENOPSTATE_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Set up a subscription to the OperationalError event\n"); - if (ShouldSkip("OVENOPSTATE.S.E00")) { - NextTest(); - return; - } - err = TestStep2SetUpASubscriptionToTheOperationalErrorEvent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: At the DUT take the vendor defined action to generate an OperationalError event\n"); - if (ShouldSkip("OVENOPSTATE.S.E00 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep3AtTheDutTakeTheVendorDefinedActionToGenerateAnOperationalErrorEvent_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the OperationalState attribute\n"); - if (ShouldSkip("OVENOPSTATE.S.A0004 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheOperationalStateAttribute_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2SetUpASubscriptionToTheOperationalErrorEvent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - if (err != nil) { - NSLog(@"Step 2: Set up a subscription to the OperationalError event: Error: %@", err); - } else { - NSLog(@"Step 2: Set up a subscription to the OperationalError event: Success"); - } - }]; - - return CHIP_NO_ERROR; -} - -CHIP_ERROR -TestStep3AtTheDutTakeTheVendorDefinedActionToGenerateAnOperationalErrorEvent_2() -{ - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); -} - -CHIP_ERROR TestStep4ThReadsFromTheDutTheOperationalStateAttribute_3() -{ - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the OperationalState attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the OperationalState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("operationalState", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; -} -} -; - -class Test_TC_PS_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PS_1_1() - : TestCommandBridge("Test_TC_PS_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PS_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PS_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PS_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap\n"); - if (ShouldSkip(" !PS.S.F00 && !PS.S.F01 && !PS.S.F02 && !PS.S.F03 ")) { - NextTest(); - return; - } - err = TestStep3aReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPssf00wiredEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenPssf01batEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F02")) { - NextTest(); - return; - } - err = TestStep3cGivenPssf02rechgEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PS.S.F03")) { - NextTest(); - return; - } - err = TestStep3dGivenPssf03replcEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ReadTheGlobalAttributeAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ReadTheGlobalAttributeAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: Read the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F00")) { - NextTest(); - return; - } - err = TestStep4aReadTheFeatureDependentPSSF00WiredAttributeInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: Read the Feature dependent(PS.S.F01-BAT) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F01")) { - NextTest(); - return; - } - err = TestStep4bReadTheFeatureDependentPSSF01BatAttributeInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: Read the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F02")) { - NextTest(); - return; - } - err = TestStep4cReadTheFeatureDependentPSSF02RechgAttributeInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: Read the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList\n"); - if (ShouldSkip("PS.S.F03")) { - NextTest(); - return; - } - err = TestStep4dReadTheFeatureDependentPSSF03ReplcAttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5: Read the global attribute: AcceptedCommandList\n"); - err = TestStep5ReadTheGlobalAttributeAcceptedCommandList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6: Read the global attribute: GeneratedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeGeneratedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7a: Read the global attribute: EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !PS.S.E00 && !PS.S.E01 && !PS.S.E02 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7b: Read PS.S.E00(WiredFaultChange) event in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E00")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 7c: Read PS.S.E01(BatFaultChange) event in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7d: Read PS.S.E02(BatChargeFaultChange) event in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E02")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 19; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPssf00wiredEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPssf01batEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPssf02rechgEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPssf03replcEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheFeatureDependentPSSF00WiredAttributeInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheFeatureDependentPSSF01BatAttributeInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the Feature dependent(PS.S.F01-BAT) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the Feature dependent(PS.S.F01-BAT) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheFeatureDependentPSSF02RechgAttributeInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheFeatureDependentPSSF03ReplcAttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ReadTheGlobalAttributeAcceptedCommandList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeGeneratedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PS_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PS_2_1() - : TestCommandBridge("Test_TC_PS_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PS_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PS_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PS_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Test Harness Client reads Status from server DUT\n"); - if (ShouldSkip("PS.S.A0000")) { - NextTest(); - return; - } - err = TestStep2TestHarnessClientReadsStatusFromServerDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Test Harness Client reads Order from server DUT\n"); - if (ShouldSkip("PS.S.A0001")) { - NextTest(); - return; - } - err = TestStep3TestHarnessClientReadsOrderFromServerDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Test Harness Client reads Order from server DUT\n"); - if (ShouldSkip("PS.S.A0002")) { - NextTest(); - return; - } - err = TestStep4TestHarnessClientReadsOrderFromServerDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT\n"); - if (ShouldSkip("PS.S.A0003")) { - NextTest(); - return; - } - err = TestStep5TestHarnessClientReadsWiredAssessedInputVoltageFromServerDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT\n"); - if (ShouldSkip("PS.S.A0004")) { - NextTest(); - return; - } - err = TestStep6TestHarnessClientReadsWiredAssessedInputFrequencyfromServerDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: Test Harness Client reads WiredCurrentType from server DUT\n"); - if (ShouldSkip("PS.S.A0005")) { - NextTest(); - return; - } - err = TestStep7TestHarnessClientReadsWiredCurrentTypeFromServerDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT\n"); - if (ShouldSkip("PS.S.A0006")) { - NextTest(); - return; - } - err = TestStep8TestHarnessClientReadsWiredAssessedCurrentFromServerDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: Test Harness Client reads WiredNominalVoltage from server DUT\n"); - if (ShouldSkip("PS.S.A0007")) { - NextTest(); - return; - } - err = TestStep9TestHarnessClientReadsWiredNominalVoltageFromServerDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT\n"); - if (ShouldSkip("PS.S.A0008")) { - NextTest(); - return; - } - err = TestStep10TestHarnessClientReadsWiredMaximumCurrentFromServerDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: Test Harness Client reads WiredPresent from Server DUT\n"); - if (ShouldSkip("PS.S.A0009")) { - NextTest(); - return; - } - err = TestStep11TestHarnessClientReadsWiredPresentFromServerDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT\n"); - if (ShouldSkip("PS.S.A000a")) { - NextTest(); - return; - } - err = TestStep12TestHarnessClientReadsActiveWiredFaultsFromServerDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: Test Harness Client reads BatVoltage from Server DUT\n"); - if (ShouldSkip("PS.S.A000b")) { - NextTest(); - return; - } - err = TestStep13TestHarnessClientReadsBatVoltageFromServerDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: Test Harness Client reads BatPercentRemaining from Server DUT\n"); - if (ShouldSkip("PS.S.A000c")) { - NextTest(); - return; - } - err = TestStep14TestHarnessClientReadsBatPercentRemainingFromServerDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: Test Harness Client reads BatTimeRemaining from Server DUT\n"); - if (ShouldSkip("PS.S.A000d")) { - NextTest(); - return; - } - err = TestStep15TestHarnessClientReadsBatTimeRemainingFromServerDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: Test Harness Client reads BatChargeLevel from Server DUT\n"); - if (ShouldSkip("PS.S.A000e")) { - NextTest(); - return; - } - err = TestStep16TestHarnessClientReadsBatChargeLevelFromServerDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT\n"); - if (ShouldSkip("PS.S.A000f")) { - NextTest(); - return; - } - err = TestStep17TestHarnessClientReadsBatReplacementNeededFromServerDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: Test Harness Client reads BatReplaceability from Server DUT\n"); - if (ShouldSkip("PS.S.A0010")) { - NextTest(); - return; - } - err = TestStep18TestHarnessClientReadsBatReplaceabilityFromServerDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: Test Harness Client reads BatPresent from Server DUT\n"); - if (ShouldSkip("PS.S.A0011")) { - NextTest(); - return; - } - err = TestStep19TestHarnessClientReadsBatPresentFromServerDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: Test Harness Client readsActiveBatFaults from Server DUT\n"); - if (ShouldSkip("PS.S.A0012")) { - NextTest(); - return; - } - err = TestStep20TestHarnessClientReadsActiveBatFaultsFromServerDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 21: Test Harness Client reads BatReplacementDescription from Server DUT\n"); - if (ShouldSkip("PS.S.A0013")) { - NextTest(); - return; - } - err = TestStep21TestHarnessClientReadsBatReplacementDescriptionFromServerDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 22: Test Harness Client reads BatCommonDesignation from Server DUT\n"); - if (ShouldSkip("PS.S.A0014")) { - NextTest(); - return; - } - err = TestStep22TestHarnessClientReadsBatCommonDesignationFromServerDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 23: Test Harness Client reads BatANSIDesignation from Server DUT\n"); - if (ShouldSkip("PS.S.A0015")) { - NextTest(); - return; - } - err = TestStep23TestHarnessClientReadsBatANSIDesignationFromServerDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 24: Test Harness Client reads BatIECDesignation from Server DUT\n"); - if (ShouldSkip("PS.S.A0016")) { - NextTest(); - return; - } - err = TestStep24TestHarnessClientReadsBatIECDesignationFromServerDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT\n"); - if (ShouldSkip("PS.S.A0017")) { - NextTest(); - return; - } - err = TestStep25TestHarnessClientReadsBatApprovedChemistryFromServerDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 26: Test Harness Client reads BatCapacity from Server DUT\n"); - if (ShouldSkip("PS.S.A0018")) { - NextTest(); - return; - } - err = TestStep26TestHarnessClientReadsBatCapacityFromServerDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 27: Test Harness Client reads BatQuantity from Server DUT\n"); - if (ShouldSkip("PS.S.A0019")) { - NextTest(); - return; - } - err = TestStep27TestHarnessClientReadsBatQuantityFromServerDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 28: Test Harness Client reads BatChargeState from Server DUT\n"); - if (ShouldSkip("PS.S.A001a")) { - NextTest(); - return; - } - err = TestStep28TestHarnessClientReadsBatChargeStateFromServerDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT\n"); - if (ShouldSkip("PS.S.A001b")) { - NextTest(); - return; - } - err = TestStep29TestHarnessClientReadsBatTimeToFullChargeFromServerDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT\n"); - if (ShouldSkip("PS.S.A001c")) { - NextTest(); - return; - } - err = TestStep30TestHarnessClientReadsBatFunctionalWhileChargingFromServerDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 31: Test Harness Client reads BatChargingCurrent from Server DUT\n"); - if (ShouldSkip("PS.S.A001d")) { - NextTest(); - return; - } - err = TestStep31TestHarnessClientReadsBatChargingCurrentFromServerDut_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT\n"); - if (ShouldSkip("PS.S.A001e")) { - NextTest(); - return; - } - err = TestStep32TestHarnessClientReadsActiveBatChargeFaultsFromServerDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 33: Test Harness Client reads EndpointList from Server DUT\n"); - if (ShouldSkip("PS.S.A001f")) { - NextTest(); - return; - } - err = TestStep33TestHarnessClientReadsEndpointListFromServerDut_32(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 33; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2TestHarnessClientReadsStatusFromServerDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Test Harness Client reads Status from server DUT: Error: %@", err); - } else { - NSLog(@"Step 2: Test Harness Client reads Status from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("status", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("status", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("status", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3TestHarnessClientReadsOrderFromServerDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOrderWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Test Harness Client reads Order from server DUT: Error: %@", err); - } else { - NSLog(@"Step 3: Test Harness Client reads Order from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("order", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("order", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("order", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4TestHarnessClientReadsOrderFromServerDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: Test Harness Client reads Order from server DUT: Error: %@", err); - } else { - NSLog(@"Step 4: Test Harness Client reads Order from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("description", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("description", value, 60)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5TestHarnessClientReadsWiredAssessedInputVoltageFromServerDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredAssessedInputVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT: Error: %@", err); - } else { - NSLog(@"Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiredAssessedInputVoltage", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredAssessedInputVoltage", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedInputVoltage", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6TestHarnessClientReadsWiredAssessedInputFrequencyfromServerDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredAssessedInputFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT: Error: %@", err); - } else { - NSLog(@"Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiredAssessedInputFrequency", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("wiredAssessedInputFrequency", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedInputFrequency", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7TestHarnessClientReadsWiredCurrentTypeFromServerDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredCurrentTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Test Harness Client reads WiredCurrentType from server DUT: Error: %@", err); - } else { - NSLog(@"Step 7: Test Harness Client reads WiredCurrentType from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredCurrentType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("wiredCurrentType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("wiredCurrentType", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8TestHarnessClientReadsWiredAssessedCurrentFromServerDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredAssessedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT: Error: %@", err); - } else { - NSLog(@"Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiredAssessedCurrent", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredAssessedCurrent", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedCurrent", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9TestHarnessClientReadsWiredNominalVoltageFromServerDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredNominalVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: Test Harness Client reads WiredNominalVoltage from server DUT: Error: %@", err); - } else { - NSLog(@"Step 9: Test Harness Client reads WiredNominalVoltage from server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredNominalVoltage", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredNominalVoltage", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredNominalVoltage", [value unsignedIntValue], 4294967295UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10TestHarnessClientReadsWiredMaximumCurrentFromServerDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredMaximumCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredMaximumCurrent", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("wiredMaximumCurrent", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("wiredMaximumCurrent", [value unsignedIntValue], 4294967295UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11TestHarnessClientReadsWiredPresentFromServerDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiredPresentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: Test Harness Client reads WiredPresent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 11: Test Harness Client reads WiredPresent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("wiredPresent", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12TestHarnessClientReadsActiveWiredFaultsFromServerDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveWiredFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("activeWiredFaults", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("activeWiredFaults", value, 8)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13TestHarnessClientReadsBatVoltageFromServerDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: Test Harness Client reads BatVoltage from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 13: Test Harness Client reads BatVoltage from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batVoltage", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batVoltage", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batVoltage", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14TestHarnessClientReadsBatPercentRemainingFromServerDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatPercentRemainingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: Test Harness Client reads BatPercentRemaining from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 14: Test Harness Client reads BatPercentRemaining from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batPercentRemaining", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("batPercentRemaining", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batPercentRemaining", [value unsignedCharValue], 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15TestHarnessClientReadsBatTimeRemainingFromServerDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatTimeRemainingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: Test Harness Client reads BatTimeRemaining from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 15: Test Harness Client reads BatTimeRemaining from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batTimeRemaining", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batTimeRemaining", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batTimeRemaining", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16TestHarnessClientReadsBatChargeLevelFromServerDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatChargeLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: Test Harness Client reads BatChargeLevel from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 16: Test Harness Client reads BatChargeLevel from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batChargeLevel", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batChargeLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batChargeLevel", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17TestHarnessClientReadsBatReplacementNeededFromServerDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatReplacementNeededWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batReplacementNeeded", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18TestHarnessClientReadsBatReplaceabilityFromServerDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatReplaceabilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: Test Harness Client reads BatReplaceability from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 18: Test Harness Client reads BatReplaceability from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batReplaceability", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batReplaceability", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batReplaceability", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19TestHarnessClientReadsBatPresentFromServerDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatPresentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: Test Harness Client reads BatPresent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 19: Test Harness Client reads BatPresent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batPresent", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20TestHarnessClientReadsActiveBatFaultsFromServerDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveBatFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: Test Harness Client readsActiveBatFaults from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 20: Test Harness Client readsActiveBatFaults from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("activeBatFaults", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("activeBatFaults", value, 8)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21TestHarnessClientReadsBatReplacementDescriptionFromServerDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatReplacementDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21: Test Harness Client reads BatReplacementDescription from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 21: Test Harness Client reads BatReplacementDescription from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batReplacementDescription", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("batReplacementDescription", value, 60)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22TestHarnessClientReadsBatCommonDesignationFromServerDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatCommonDesignationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: Test Harness Client reads BatCommonDesignation from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 22: Test Harness Client reads BatCommonDesignation from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batCommonDesignation", "enum16", "enum16")); - VerifyOrReturn(CheckConstraintMinValue("batCommonDesignation", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batCommonDesignation", [value unsignedShortValue], 80U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23TestHarnessClientReadsBatANSIDesignationFromServerDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatANSIDesignationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: Test Harness Client reads BatANSIDesignation from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 23: Test Harness Client reads BatANSIDesignation from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batANSIDesignation", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("batANSIDesignation", value, 20)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24TestHarnessClientReadsBatIECDesignationFromServerDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatIECDesignationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: Test Harness Client reads BatIECDesignation from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 24: Test Harness Client reads BatIECDesignation from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batIECDesignation", "char_string", "char_string")); - VerifyOrReturn(CheckConstraintMaxLength("batIECDesignation", value, 20)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep25TestHarnessClientReadsBatApprovedChemistryFromServerDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatApprovedChemistryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batApprovedChemistry", "enum16", "enum16")); - VerifyOrReturn(CheckConstraintMinValue("batApprovedChemistry", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batApprovedChemistry", [value unsignedShortValue], 32U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep26TestHarnessClientReadsBatCapacityFromServerDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatCapacityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 26: Test Harness Client reads BatCapacity from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 26: Test Harness Client reads BatCapacity from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batCapacity", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batCapacity", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batCapacity", [value unsignedIntValue], 4294967295UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep27TestHarnessClientReadsBatQuantityFromServerDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatQuantityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 27: Test Harness Client reads BatQuantity from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 27: Test Harness Client reads BatQuantity from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batQuantity", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("batQuantity", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batQuantity", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep28TestHarnessClientReadsBatChargeStateFromServerDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatChargeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 28: Test Harness Client reads BatChargeState from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 28: Test Harness Client reads BatChargeState from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batChargeState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batChargeState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batChargeState", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep29TestHarnessClientReadsBatTimeToFullChargeFromServerDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatTimeToFullChargeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batTimeToFullCharge", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batTimeToFullCharge", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batTimeToFullCharge", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep30TestHarnessClientReadsBatFunctionalWhileChargingFromServerDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatFunctionalWhileChargingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batFunctionalWhileCharging", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep31TestHarnessClientReadsBatChargingCurrentFromServerDut_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatChargingCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 31: Test Harness Client reads BatChargingCurrent from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 31: Test Harness Client reads BatChargingCurrent from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("batChargingCurrent", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("batChargingCurrent", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("batChargingCurrent", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep32TestHarnessClientReadsActiveBatChargeFaultsFromServerDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeActiveBatChargeFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("activeBatChargeFaults", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("activeBatChargeFaults", value, 16)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep33TestHarnessClientReadsEndpointListFromServerDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndpointListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 33: Test Harness Client reads EndpointList from Server DUT: Error: %@", err); - } else { - NSLog(@"Step 33: Test Harness Client reads EndpointList from Server DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endpointList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PRS_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PRS_1_1() - : TestCommandBridge("Test_TC_PRS_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PRS_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !PRS.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PRS.S.F00")) { - NextTest(); - return; - } - err = TestStep3GivenPrssf00extEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0010")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeScaledValueInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0011")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeMinScaledValueInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0012")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeMaxScaledValueInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4e: TH reads the optional attribute(Scale) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0014")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeScaleInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4f: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0003")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalAttributeToleranceInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList\n"); - if (ShouldSkip("PRS.S.A0013")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeScaledToleranceInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3GivenPrssf00extEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeScaledValueInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeMinScaledValueInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeMaxScaledValueInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeScaleInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute(Scale) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute(Scale) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalAttributeToleranceInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeScaledToleranceInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PRS_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PRS_2_1() - : TestCommandBridge("Test_TC_PRS_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PRS_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); - if (ShouldSkip("PRS.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); - if (ShouldSkip("PRS.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); - if (ShouldSkip("PRS.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the Tolerance attribute.\n"); - if (ShouldSkip("PRS.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheToleranceAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the MinScaledValue attribute.\n"); - if (ShouldSkip("PRS.S.A0011")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheMinScaledValueAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the MaxScaledValue attribute.\n"); - if (ShouldSkip("PRS.S.A0012")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheMaxScaledValueAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the ScaledValue attribute.\n"); - if (ShouldSkip("PRS.S.A0010")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheScaledValueAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the ScaledTolerance attribute.\n"); - if (ShouldSkip("PRS.S.A0013")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheScaledToleranceAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the Scale attribute.\n"); - if (ShouldSkip("PRS.S.A0014")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheScaleAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable MinMeasuredValueValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value shortValue], 32766)); - } - { - MinMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxMeasuredValueValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value shortValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value shortValue], 32767)); - } - { - MaxMeasuredValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value shortValue], MinMeasuredValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value shortValue], MaxMeasuredValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheToleranceAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the Tolerance attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the Tolerance attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MinScaledValueValue; - - CHIP_ERROR TestStep6ThReadsFromTheDutTheMinScaledValueAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the MinScaledValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the MinScaledValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minScaledValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minScaledValue", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("minScaledValue", [value shortValue], 32766)); - } - { - MinScaledValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable MaxScaledValueValue; - - CHIP_ERROR TestStep7ThReadsFromTheDutTheMaxScaledValueAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the MaxScaledValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the MaxScaledValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxScaledValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxScaledValue", [value shortValue], MinScaledValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("maxScaledValue", [value shortValue], 32767)); - } - { - MaxScaledValueValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheScaledValueAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the ScaledValue attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the ScaledValue attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("scaledValue", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("scaledValue", [value shortValue], MinScaledValueValue)); - VerifyOrReturn(CheckConstraintMaxValue("scaledValue", [value shortValue], MaxScaledValueValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheScaledToleranceAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScaledToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the ScaledTolerance attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the ScaledTolerance attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("scaledTolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("scaledTolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("scaledTolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheScaleAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScaleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the Scale attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the Scale attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("scale", "int8s", "int8s")); - VerifyOrReturn(CheckConstraintMinValue("scale", [value charValue], -127)); - VerifyOrReturn(CheckConstraintMaxValue("scale", [value charValue], 127)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PRS_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PRS_2_2() - : TestCommandBridge("Test_TC_PRS_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PRS_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MeasuredValue attribute\n"); - if (ShouldSkip("PRS.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMeasuredValueAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Operate on device to change the pressure significantly\n"); - if (ShouldSkip("PICS_USER_PROMPT && PRS.M.PressureChange")) { - NextTest(); - return; - } - err = TestStep3OperateOnDeviceToChangeThePressureSignificantly_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Wait 2s\n"); - err = TestWait2s_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute\n"); - if (ShouldSkip("PRS.S.A0000 && PRS.M.PressureChange")) { - NextTest(); - return; - } - err = TestStep4AfterAFewSecondsThReadsFromTheDutTheMeasuredValueAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable ValueBeforeChange; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMeasuredValueAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MeasuredValue attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MeasuredValue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ValueBeforeChange = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3OperateOnDeviceToChangeThePressureSignificantly_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestWait2s_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4AfterAFewSecondsThReadsFromTheDutTheMeasuredValueAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute: Error: %@", err); - } else { - NSLog(@"Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("measuredValue", value, ValueBeforeChange)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_1_1() - : TestCommandBridge("Test_TC_PCC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap attribute from the DUT\n"); - if (ShouldSkip(" !PCC.S.F00 && !PCC.S.F01 && !PCC.S.F02 && !PCC.S.F03 && !PCC.S.F04 && !PCC.S.F05 && !PCC.S.F06 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenPccsf00prsconstEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenPccsf01prscompEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenPccsf02flwEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenPccsf03spdEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenPccsf04tempEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F05")) { - NextTest(); - return; - } - err = TestStep3gGivenPccsf05autoEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("PCC.S.F06")) { - NextTest(); - return; - } - err = TestStep3hGivenPccsf06localEnsureFeaturemapHasTheCorrectBitSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeMinConstPressureAttributeInAttributeListFromTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0004")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeMaxConstPressureAttributeInAttributeListFromTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0005")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeMinCompPressureAttributeInAttributeListFromTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0006")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeMaxCompPressureAttributeInAttributeListFromTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0007")) { - NextTest(); - return; - } - err = TestStep4fThReadsOptionalAttributeMinConstSpeedAttributeInAttributeListFromTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0008")) { - NextTest(); - return; - } - err = TestStep4gThReadsOptionalAttributeMaxConstSpeedAttributeInAttributeListFromTheDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0009")) { - NextTest(); - return; - } - err = TestStep4hThReadsOptionalAttributeMinConstFlowAttributeInAttributeListFromTheDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A000a")) { - NextTest(); - return; - } - err = TestStep4iThReadsOptionalAttributeMaxConstFlowAttributeInAttributeListFromTheDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A000b")) { - NextTest(); - return; - } - err = TestStep4jThReadsOptionalAttributeMinConstTempAttributeInAttributeListFromTheDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A000c")) { - NextTest(); - return; - } - err = TestStep4kThReadsOptionalAttributeMaxConstTempAttributeInAttributeListFromTheDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep4lThReadsOptionalAttributePumpStatusAttributeInAttributeListFromTheDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0014")) { - NextTest(); - return; - } - err = TestStep4mThReadsOptionalAttributeSpeedAttributeInAttributeListFromTheDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4nThReadsOptionalAttributeLifetimeRunningHoursAttributeInAttributeListFromTheDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0016")) { - NextTest(); - return; - } - err = TestStep4oThReadsOptionalAttributePowerAttributeInAttributeListFromTheDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep4pThReadsOptionalAttributeLifetimeEnergyConsumedAttributeInAttributeListFromTheDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT\n"); - if (ShouldSkip("PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4qThReadsOptionalAttributeControlModeAttributeInAttributeListFromTheDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !PCC.S.E00 && !PCC.S.E01 && !PCC.S.E02 && !PCC.S.E03 && !PCC.S.E04 && !PCC.S.E05 && !PCC.S.E06 && !PCC.S.E07 && !PCC.S.E08 && !PCC.S.E09 && !PCC.S.E0a && !PCC.S.E0b && !PCC.S.E0c && !PCC.S.E0d && !PCC.S.E0e && !PCC.S.E0f && !PCC.S.E10 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 5b: TH reads from the DUT the EventList optional (SupplyVoltageLow)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E00")) { - NextTest(); - return; - } - NextTest(); - return; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5c: TH reads from the DUT the EventList optional (SupplyVoltageHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5d: TH reads from the DUT the EventList optional (PowerMissingPhase)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E02")) { - NextTest(); - return; - } - NextTest(); - return; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 5e: TH reads from the DUT the EventList optional (SystemPressureLow)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E03")) { - NextTest(); - return; - } - NextTest(); - return; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 5f: TH reads from the DUT the EventList optional (SystemPressureHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E04")) { - NextTest(); - return; - } - NextTest(); - return; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 5g: TH reads from the DUT the EventList optional (DryRunning)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E05")) { - NextTest(); - return; - } - NextTest(); - return; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 5h: TH reads from the DUT the EventList optional (MotorTemperatureHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E06")) { - NextTest(); - return; - } - NextTest(); - return; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 5i: TH reads from the DUT the EventList optional (PumpMotorFatalFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E07")) { - NextTest(); - return; - } - NextTest(); - return; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5j: TH reads from the DUT the EventList optional (ElectronicTemperatureHigh)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E08")) { - NextTest(); - return; - } - NextTest(); - return; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 5k: TH reads from the DUT the EventList optional (PumpBlocked)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E09")) { - NextTest(); - return; - } - NextTest(); - return; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 5l: TH reads from the DUT the EventList optional (SensorFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0a")) { - NextTest(); - return; - } - NextTest(); - return; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 5m: TH reads from the DUT the EventList optional (ElectronicNonFatalFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0b")) { - NextTest(); - return; - } - NextTest(); - return; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 5n: TH reads from the DUT the EventList optional (ElectronicFatalFailure)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0c")) { - NextTest(); - return; - } - NextTest(); - return; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 5o: TH reads from the DUT the EventList optional (GeneralFault)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0d")) { - NextTest(); - return; - } - NextTest(); - return; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 5p: TH reads from the DUT the EventList optional (Leakage)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0e")) { - NextTest(); - return; - } - NextTest(); - return; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 5q: TH reads from the DUT the EventList optional (AirDetection)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0f")) { - NextTest(); - return; - } - NextTest(); - return; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 5r: TH reads from the DUT the EventList optional (TurbineOperation)attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E10")) { - NextTest(); - return; - } - NextTest(); - return; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_47(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 48; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenPccsf00prsconstEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenPccsf01prscompEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenPccsf02flwEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenPccsf03spdEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenPccsf04tempEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenPccsf05autoEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenPccsf06localEnsureFeaturemapHasTheCorrectBitSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeMinConstPressureAttributeInAttributeListFromTheDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeMaxConstPressureAttributeInAttributeListFromTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeMinCompPressureAttributeInAttributeListFromTheDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeMaxCompPressureAttributeInAttributeListFromTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsOptionalAttributeMinConstSpeedAttributeInAttributeListFromTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsOptionalAttributeMaxConstSpeedAttributeInAttributeListFromTheDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsOptionalAttributeMinConstFlowAttributeInAttributeListFromTheDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsOptionalAttributeMaxConstFlowAttributeInAttributeListFromTheDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsOptionalAttributeMinConstTempAttributeInAttributeListFromTheDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsOptionalAttributeMaxConstTempAttributeInAttributeListFromTheDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsOptionalAttributePumpStatusAttributeInAttributeListFromTheDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsOptionalAttributeSpeedAttributeInAttributeListFromTheDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsOptionalAttributeLifetimeRunningHoursAttributeInAttributeListFromTheDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsOptionalAttributePowerAttributeInAttributeListFromTheDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsOptionalAttributeLifetimeEnergyConsumedAttributeInAttributeListFromTheDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsOptionalAttributeControlModeAttributeInAttributeListFromTheDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_1() - : TestCommandBridge("Test_TC_PCC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MaxPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMaxPressureAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxSpeed attribute.\n"); - if (ShouldSkip("PCC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxSpeedAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MaxFlow attribute.\n"); - if (ShouldSkip("PCC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMaxFlowAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the MinConstPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheMinConstPressureAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the MaxConstPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheMaxConstPressureAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the MinCompPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheMinCompPressureAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the MaxCompPressure attribute.\n"); - if (ShouldSkip("PCC.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheMaxCompPressureAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MinConstSpeed attribute.\n"); - if (ShouldSkip("PCC.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheMinConstSpeedAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MaxConstSpeed attribute.\n"); - if (ShouldSkip("PCC.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheMaxConstSpeedAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the MinConstFlow attribute.\n"); - if (ShouldSkip("PCC.S.A0009")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheMinConstFlowAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the MaxConstFlow attribute.\n"); - if (ShouldSkip("PCC.S.A000a")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheMaxConstFlowAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the MinConstTemp attribute.\n"); - if (ShouldSkip("PCC.S.A000b")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutTheMinConstTempAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the MaxConstTemp attribute.\n"); - if (ShouldSkip("PCC.S.A000c")) { - NextTest(); - return; - } - err = TestStep14ThReadsFromTheDutTheMaxConstTempAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH reads from the DUT the PumpStatus attribute.\n"); - if (ShouldSkip("PCC.S.A0010")) { - NextTest(); - return; - } - err = TestStep15ThReadsFromTheDutThePumpStatusAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH reads from the DUT the EffectiveOperationMode attribute.\n"); - if (ShouldSkip("PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep16ThReadsFromTheDutTheEffectiveOperationModeAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep17ThReadsFromTheDutTheEffectiveControlModeAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH reads from the DUT the Capacity attribute.\n"); - if (ShouldSkip("PCC.S.A0013")) { - NextTest(); - return; - } - err = TestStep18ThReadsFromTheDutTheCapacityAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: TH reads from the DUT the Speed attribute.\n"); - if (ShouldSkip("PCC.S.A0014")) { - NextTest(); - return; - } - err = TestStep19ThReadsFromTheDutTheSpeedAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep20ThReadsFromTheDutTheLifetimeRunningHoursAttribute_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 21: TH reads from the DUT the Power attribute.\n"); - if (ShouldSkip("PCC.S.A0016")) { - NextTest(); - return; - } - err = TestStep21ThReadsFromTheDutThePowerAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep22ThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 23: TH reads from the DUT the OperationMode attribute.\n"); - if (ShouldSkip("PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep23ThReadsFromTheDutTheOperationModeAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 24: TH reads from the DUT the ControlMode attribute.\n"); - if (ShouldSkip("PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep24ThReadsFromTheDutTheControlModeAttribute_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMaxPressureAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MaxPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MaxPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxSpeedAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxSpeed attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxSpeed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxSpeed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxSpeed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxSpeed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMaxFlowAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MaxFlow attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MaxFlow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxFlow", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxFlow", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxFlow", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheMinConstPressureAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the MinConstPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the MinConstPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minConstPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("minConstPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheMaxConstPressureAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the MaxConstPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the MaxConstPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxConstPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheMinCompPressureAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinCompPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the MinCompPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the MinCompPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minCompPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minCompPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("minCompPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheMaxCompPressureAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxCompPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the MaxCompPressure attribute.: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the MaxCompPressure attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxCompPressure", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxCompPressure", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxCompPressure", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheMinConstSpeedAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the MinConstSpeed attribute.: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the MinConstSpeed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstSpeed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minConstSpeed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minConstSpeed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheMaxConstSpeedAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the MaxConstSpeed attribute.: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the MaxConstSpeed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstSpeed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxConstSpeed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstSpeed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheMinConstFlowAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the MinConstFlow attribute.: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the MinConstFlow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstFlow", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("minConstFlow", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minConstFlow", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheMaxConstFlowAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the MaxConstFlow attribute.: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the MaxConstFlow attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstFlow", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("maxConstFlow", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstFlow", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutTheMinConstTempAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinConstTempWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the MinConstTemp attribute.: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the MinConstTemp attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minConstTemp", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minConstTemp", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("minConstTemp", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsFromTheDutTheMaxConstTempAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxConstTempWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads from the DUT the MaxConstTemp attribute.: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads from the DUT the MaxConstTemp attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxConstTemp", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxConstTemp", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("maxConstTemp", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep15ThReadsFromTheDutThePumpStatusAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePumpStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 15: TH reads from the DUT the PumpStatus attribute.: Error: %@", err); - } else { - NSLog(@"Step 15: TH reads from the DUT the PumpStatus attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("pumpStatus", "bitmap16", "bitmap16")); - VerifyOrReturn(CheckConstraintMinValue("pumpStatus", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("pumpStatus", [value unsignedShortValue], 8U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ThReadsFromTheDutTheEffectiveOperationModeAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 16: TH reads from the DUT the EffectiveOperationMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 16: TH reads from the DUT the EffectiveOperationMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("effectiveOperationMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("effectiveOperationMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("effectiveOperationMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep17ThReadsFromTheDutTheEffectiveControlModeAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 17: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 17: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("effectiveControlMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("effectiveControlMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("effectiveControlMode", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep18ThReadsFromTheDutTheCapacityAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCapacityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 18: TH reads from the DUT the Capacity attribute.: Error: %@", err); - } else { - NSLog(@"Step 18: TH reads from the DUT the Capacity attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("capacity", "int16s", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("capacity", [value shortValue], -32768)); - VerifyOrReturn(CheckConstraintMaxValue("capacity", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep19ThReadsFromTheDutTheSpeedAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 19: TH reads from the DUT the Speed attribute.: Error: %@", err); - } else { - NSLog(@"Step 19: TH reads from the DUT the Speed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("speed", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("speed", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("speed", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep20ThReadsFromTheDutTheLifetimeRunningHoursAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 20: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 20: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lifetimeRunningHours", "int24u", "int24u")); - VerifyOrReturn(CheckConstraintMinValue("lifetimeRunningHours", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("lifetimeRunningHours", [value unsignedIntValue], 16777215UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep21ThReadsFromTheDutThePowerAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePowerWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 21: TH reads from the DUT the Power attribute.: Error: %@", err); - } else { - NSLog(@"Step 21: TH reads from the DUT the Power attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("power", "int24u", "int24u")); - VerifyOrReturn(CheckConstraintMinValue("power", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("power", [value unsignedIntValue], 16777215UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep22ThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lifetimeEnergyConsumed", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("lifetimeEnergyConsumed", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("lifetimeEnergyConsumed", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep23ThReadsFromTheDutTheOperationModeAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 23: TH reads from the DUT the OperationMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 23: TH reads from the DUT the OperationMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("operationMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("operationMode", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep24ThReadsFromTheDutTheControlModeAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 24: TH reads from the DUT the ControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 24: TH reads from the DUT the ControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("controlMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("controlMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("controlMode", [value unsignedCharValue], 7U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_2() - : TestCommandBridge("Test_TC_PCC_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT\n"); - if (ShouldSkip("PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep3aThWrite1MinimumToTheOperationModeAttributeToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheEffectiveOperationModeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep4aThWrite2MaximumToTheOperationModeAttributeToDutOneAtATime_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheEffectiveOperationModeAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT\n"); - if (ShouldSkip("PCC.S.F06 && PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep5aThWrite3LocalToTheOperationModeAttributeToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.F06 && PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep5bThReadsFromTheDutTheEffectiveOperationModeAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWrite1MinimumToTheOperationModeAttributeToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheEffectiveOperationModeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrite2MaximumToTheOperationModeAttributeToDutOneAtATime_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheEffectiveOperationModeAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrite3LocalToTheOperationModeAttributeToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsFromTheDutTheEffectiveOperationModeAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_3() - : TestCommandBridge("Test_TC_PCC_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.\n"); - if (ShouldSkip("PCC.S.A0020")) { - NextTest(); - return; - } - err = TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the EffectiveOperationMode attribute\n"); - if (ShouldSkip("PCC.S.A0011")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep3aThWrite0ConstantSpeedToTheControlModeAttributeToDutOneAtATime_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F03 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheEffectiveControlModeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F00 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep4aThWrite1ConstantPressureToTheControlModeAttributeToDutOneAtATime_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F00 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheEffectiveControlModeAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F01 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep5aThWrite2ProportionalPressureToTheControlModeAttributeToDutOneAtATime_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F01 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep5bThReadsFromTheDutTheEffectiveControlModeAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F02 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep6aThWrite3ConstantFlowToTheControlModeAttributeToDutOneAtATime_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F02 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep6bThReadsFromTheDutTheEffectiveControlModeAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F04 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep7aThWrite5ConstantTemperatureToTheControlModeAttributeToDutOneAtATime_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F04 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep7bThReadsFromTheDutTheEffectiveControlModeAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.\n"); - if (ShouldSkip("PCC.S.F05 && PCC.S.A0021")) { - NextTest(); - return; - } - err = TestStep8aThWrite7AutomaticToTheControlModeAttributeToDutOneAtATime_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 8b: TH reads from the DUT the EffectiveControlMode attribute.\n"); - if (ShouldSkip("PCC.S.F05 && PCC.S.A0012")) { - NextTest(); - return; - } - err = TestStep8bThReadsFromTheDutTheEffectiveControlModeAttribute_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id operationModeArgument; - operationModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.: Error: %@", err); - } else { - NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWrite0ConstantSpeedToTheControlModeAttributeToDutOneAtATime_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheEffectiveControlModeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrite1ConstantPressureToTheControlModeAttributeToDutOneAtATime_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheEffectiveControlModeAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrite2ProportionalPressureToTheControlModeAttributeToDutOneAtATime_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsFromTheDutTheEffectiveControlModeAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWrite3ConstantFlowToTheControlModeAttributeToDutOneAtATime_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFromTheDutTheEffectiveControlModeAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThWrite5ConstantTemperatureToTheControlModeAttributeToDutOneAtATime_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsFromTheDutTheEffectiveControlModeAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8aThWrite7AutomaticToTheControlModeAttributeToDutOneAtATime_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id controlModeArgument; - controlModeArgument = - [NSNumber numberWithUnsignedChar:7U]; - [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.: Error: %@", err); - } else { - NSLog(@"Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8bThReadsFromTheDutTheEffectiveControlModeAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); - } else { - NSLog(@"Step 8b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_PCC_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_PCC_2_4() - : TestCommandBridge("Test_TC_PCC_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_PCC_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep2aThWrite1ToTheLifetimeRunningHoursAttributeToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutTheLifetimeRunningHoursAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep3aThWrite2ToTheLifetimeRunningHoursAttributeOfDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheLifetimeRunningHoursAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4aThWrite3ToTheLifetimeRunningHoursAttributeToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); - if (ShouldSkip("PCC.S.A0015")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheLifetimeRunningHoursAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep5aThWrite1ToTheLifetimeEnergyConsumedAttributeOfDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep5bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep6aThWrite2ToTheLifetimeEnergyConsumedAttributeOfDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep6bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep7aThWrite3ToTheLifetimeEnergyConsumedAttributeOfDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); - if (ShouldSkip("PCC.S.A0017")) { - NextTest(); - return; - } - err = TestStep7bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWrite1ToTheLifetimeRunningHoursAttributeToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeRunningHoursArgument; - lifetimeRunningHoursArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutTheLifetimeRunningHoursAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); - VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWrite2ToTheLifetimeRunningHoursAttributeOfDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeRunningHoursArgument; - lifetimeRunningHoursArgument = - [NSNumber numberWithUnsignedInt:2UL]; - [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheLifetimeRunningHoursAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); - VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 2UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWrite3ToTheLifetimeRunningHoursAttributeToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeRunningHoursArgument; - lifetimeRunningHoursArgument = - [NSNumber numberWithUnsignedInt:3UL]; - [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheLifetimeRunningHoursAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); - VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWrite1ToTheLifetimeEnergyConsumedAttributeOfDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeEnergyConsumedArgument; - lifetimeEnergyConsumedArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); - VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThWrite2ToTheLifetimeEnergyConsumedAttributeOfDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeEnergyConsumedArgument; - lifetimeEnergyConsumedArgument = - [NSNumber numberWithUnsignedInt:2UL]; - [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); - VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 2UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThWrite3ToTheLifetimeEnergyConsumedAttributeOfDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id lifetimeEnergyConsumedArgument; - lifetimeEnergyConsumedArgument = - [NSNumber numberWithUnsignedInt:3UL]; - [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); - } else { - NSLog(@"Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); - VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_REFALM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_REFALM_1_1() - : TestCommandBridge("Test_TC_REFALM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_REFALM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_REFALM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_REFALM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_REFALM_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_REFALM_2_1() - : TestCommandBridge("Test_TC_REFALM_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_REFALM_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_REFALM_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_REFALM_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Ensure that the door alarm is not locally suppressed and the door is closed\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep2EnsureThatTheDoorAlarmIsNotLocallySuppressedAndTheDoorIsClosed_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3:TH reads from the DUT the Mask attribute\n"); - if (ShouldSkip("REFALM.S.A0000")) { - NextTest(); - return; - } - err = TestStep3thReadsFromTheDutTheMaskAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH reads from the DUT the State attribute\n"); - if (ShouldSkip("REFALM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4thReadsFromTheDutTheStateAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5:TH reads from the DUT the Supportedask attribute\n"); - if (ShouldSkip("REFALM.S.A0003")) { - NextTest(); - return; - } - err = TestStep5thReadsFromTheDutTheSupportedaskAttribute_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2EnsureThatTheDoorAlarmIsNotLocallySuppressedAndTheDoorIsClosed_1() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3thReadsFromTheDutTheMaskAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3:TH reads from the DUT the Mask attribute: Error: %@", err); - } else { - NSLog(@"Step 3:TH reads from the DUT the Mask attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("mask", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4thReadsFromTheDutTheStateAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4:TH reads from the DUT the State attribute: Error: %@", err); - } else { - NSLog(@"Step 4:TH reads from the DUT the State attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("state", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5thReadsFromTheDutTheSupportedaskAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5:TH reads from the DUT the Supportedask attribute: Error: %@", err); - } else { - NSLog(@"Step 5:TH reads from the DUT the Supportedask attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supported", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RH_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RH_1_1() - : TestCommandBridge("Test_TC_RH_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RH_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RH_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RH_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT.\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap attribute from the DUT.\n"); - err = TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("RH.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the AcceptedCommandList attribute from the DUT.\n"); - err = TestStep5ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the GeneratedCommandList attribute from the DUT.\n"); - err = TestStep6ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads the EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the AcceptedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the AcceptedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the GeneratedCommandList attribute from the DUT.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the GeneratedCommandList attribute from the DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RVCCLEANM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RVCCLEANM_1_1() - : TestCommandBridge("Test_TC_RVCCLEANM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RVCCLEANM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCCLEANM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCCLEANM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !RVCCLEANM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Given RVCCLEANM.S.F00(DEPONOFF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RVCCLEANM.S.F00")) { - NextTest(); - return; - } - err = TestStep3GivenRvccleanmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT\n"); - if (ShouldSkip("RVCCLEANM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT\n"); - if (ShouldSkip("RVCCLEANM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT\n"); - if (ShouldSkip(" !RVCCLEANM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode)\n"); - if (ShouldSkip("RVCCLEANM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse)\n"); - if (ShouldSkip("RVCCLEANM.S.C01.Tx")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3GivenRvccleanmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Given RVCCLEANM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3: Given RVCCLEANM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RVCRUNM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RVCRUNM_1_1() - : TestCommandBridge("Test_TC_RVCRUNM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RVCRUNM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCRUNM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCRUNM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !RVCRUNM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given RVCRUNM.S.F00(DEPONOFF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("RVCRUNM.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenRvcrunmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT\n"); - if (ShouldSkip("RVCRUNM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT\n"); - if (ShouldSkip("RVCRUNM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT\n"); - if (ShouldSkip(" !RVCRUNM.S.F00 ")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode)\n"); - if (ShouldSkip("RVCRUNM.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse)\n"); - if (ShouldSkip("RVCRUNM.S.C01.Tx")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_11(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 12; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenRvcrunmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given RVCRUNM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given RVCRUNM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_RVCOPSTATE_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_RVCOPSTATE_1_1() - : TestCommandBridge("Test_TC_RVCOPSTATE_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_RVCOPSTATE_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCOPSTATE_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCOPSTATE_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT\n"); - if (ShouldSkip("RVCOPSTATE.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5a: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5b: TH reads from the DUT the optional event(OperationCompletion) in EventList.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && RVCOPSTATE.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: TH reads the optional command(Pause) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C00.Rsp || RVCOPSTATE.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsTheOptionalCommandPauseInAcceptedCommandList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6b: TH reads the optional command(Stop) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C01.Rsp || RVCOPSTATE.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6c: TH reads the optional command(Start) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsTheOptionalCommandStartInAcceptedCommandList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6d: TH reads the optional command(Resume) in AcceptedCommandList\n"); - if (ShouldSkip("RVCOPSTATE.S.C03.Rsp || RVCOPSTATE.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip(" !RVCOPSTATE.S.C00.Rsp && !RVCOPSTATE.S.C01.Rsp && !RVCOPSTATE.S.C02.Rsp && !RVCOPSTATE.S.C03.Rsp ")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip(" RVCOPSTATE.S.C00.Rsp || RVCOPSTATE.S.C01.Rsp || RVCOPSTATE.S.C02.Rsp || RVCOPSTATE.S.C03.Rsp ")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsTheOptionalCommandPauseInAcceptedCommandList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads the optional command(Pause) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads the optional command(Pause) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsTheOptionalCommandStartInAcceptedCommandList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads the optional command(Start) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads the optional command(Start) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_SMOKECO_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_SMOKECO_1_1() - : TestCommandBridge("Test_TC_SMOKECO_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_SMOKECO_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_SMOKECO_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SMOKECO_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT\n"); - err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute\n"); - if (ShouldSkip("!SMOKECO.S.F00 && !SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm)\n"); - if (ShouldSkip("SMOKECO.S.F00 && !SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheFeatureMapAttributeSmokeAlarm_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm)\n"); - if (ShouldSkip("SMOKECO.S.F01 && !SMOKECO.S.F00")) { - NextTest(); - return; - } - err = TestStep3cThReadsFromTheDutTheFeatureMapAttributeCOAlarm_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm)\n"); - if (ShouldSkip("SMOKECO.S.F00 && SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep3dThReadsFromTheDutTheFeatureMapAttributeSmokeAlarmCoAlarm_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState)\n"); - if (ShouldSkip("SMOKECO.S.A0001 && SMOKECO.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttributeSmokeState_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads from the DUT the AttributeList attribute(COState)\n"); - if (ShouldSkip("SMOKECO.S.A0002 && SMOKECO.S.F01")) { - NextTest(); - return; - } - err = TestStep4cThReadsFromTheDutTheAttributeListAttributeCOState_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted)\n"); - if (ShouldSkip("SMOKECO.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dThReadsFromTheDutTheAttributeListAttributeDeviceMuted_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm)\n"); - if (ShouldSkip("SMOKECO.S.A0008")) { - NextTest(); - return; - } - err = TestStep4eThReadsFromTheDutTheAttributeListAttributeInterconnectSmokeAlarm_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm)\n"); - if (ShouldSkip("SMOKECO.S.A0009")) { - NextTest(); - return; - } - err = TestStep4fThReadsFromTheDutTheAttributeListAttributeInterconnectCOAlarm_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState)\n"); - if (ShouldSkip("SMOKECO.S.A000a")) { - NextTest(); - return; - } - err = TestStep4gThReadsFromTheDutTheAttributeListAttributeContaminationState_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel)\n"); - if (ShouldSkip("SMOKECO.S.A000b")) { - NextTest(); - return; - } - err = TestStep4hThReadsFromTheDutTheAttributeListAttributeSmokeSensitivityLevel_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate)\n"); - if (ShouldSkip("SMOKECO.S.A000c")) { - NextTest(); - return; - } - err = TestStep4iThReadsFromTheDutTheAttributeListAttributeExpiryDate_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads from the DUT the EventList attribute(SmokeAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E00")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5c: TH reads from the DUT the EventList attribute(COAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E01")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5d: TH reads from the DUT the EventList attribute(AlarmMuted)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E06")) { - NextTest(); - return; - } - NextTest(); - return; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5e: TH reads from the DUT the EventList attribute(MuteEnded)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E07")) { - NextTest(); - return; - } - NextTest(); - return; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5f: TH reads from the DUT the EventList attribute(InterconnectSmokeAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E08")) { - NextTest(); - return; - } - NextTest(); - return; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5g: TH reads from the DUT the EventList attribute(InterconnectCOAlarm)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E09")) { - NextTest(); - return; - } - NextTest(); - return; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("!SMOKECO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6b: TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("SMOKECO.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsFromTheDutTheAcceptedCommandListAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_24(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 25; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheFeatureMapAttributeSmokeAlarm_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm): Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFromTheDutTheFeatureMapAttributeCOAlarm_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm): Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 2UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsFromTheDutTheFeatureMapAttributeSmokeAlarmCoAlarm_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm): Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 3UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttributeSmokeState_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState): Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttributeCOState_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute(COState): Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute(COState): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFromTheDutTheAttributeListAttributeDeviceMuted_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted): Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFromTheDutTheAttributeListAttributeInterconnectSmokeAlarm_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm): Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsFromTheDutTheAttributeListAttributeInterconnectCOAlarm_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm): Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsFromTheDutTheAttributeListAttributeContaminationState_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState): Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsFromTheDutTheAttributeListAttributeSmokeSensitivityLevel_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel): Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsFromTheDutTheAttributeListAttributeExpiryDate_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate): Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFromTheDutTheAcceptedCommandListAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_SMOKECO_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_SMOKECO_2_1() - : TestCommandBridge("Test_TC_SMOKECO_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_SMOKECO_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_SMOKECO_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SMOKECO_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ExpressedState attribute\n"); - if (ShouldSkip("SMOKECO.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheExpressedStateAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SmokeState attribute\n"); - if (ShouldSkip("SMOKECO.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheSmokeStateAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the COState attribute\n"); - if (ShouldSkip("SMOKECO.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheCOStateAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the BatteryAlert attribute\n"); - if (ShouldSkip("SMOKECO.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheBatteryAlertAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the DeviceMuted attribute\n"); - if (ShouldSkip("SMOKECO.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheDeviceMutedAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the TestInProgress attribute\n"); - if (ShouldSkip("SMOKECO.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheTestInProgressAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the HardwareFaultAlert attribute\n"); - if (ShouldSkip("SMOKECO.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheHardwareFaultAlertAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the EndOfServiceAlert attribute\n"); - if (ShouldSkip("SMOKECO.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheEndOfServiceAlertAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute\n"); - if (ShouldSkip("SMOKECO.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsFromTheDutTheInterconnectSmokeAlarmAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the InterconnectCOAlarm attribute\n"); - if (ShouldSkip("SMOKECO.S.A0009")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheInterconnectCOAlarmAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the ContaminationState attribute\n"); - if (ShouldSkip("SMOKECO.S.A000a")) { - NextTest(); - return; - } - err = TestStep12ThReadsFromTheDutTheContaminationStateAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute\n"); - if (ShouldSkip("SMOKECO.S.A000b")) { - NextTest(); - return; - } - err = TestStep13ThReadsFromTheDutTheSmokeSensitivityLevelAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the ExpiryDate attribute\n"); - if (ShouldSkip("SMOKECO.S.A000c")) { - NextTest(); - return; - } - err = TestStep14ThReadsFromTheDutTheExpiryDateAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheExpressedStateAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeExpressedStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ExpressedState attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ExpressedState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("expressedState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("expressedState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("expressedState", [value unsignedCharValue], 8U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheSmokeStateAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSmokeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the SmokeState attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the SmokeState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("smokeState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("smokeState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("smokeState", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheCOStateAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCOStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the COState attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the COState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("COState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("COState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("COState", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheBatteryAlertAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBatteryAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the BatteryAlert attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the BatteryAlert attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("batteryAlert", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("batteryAlert", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("batteryAlert", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheDeviceMutedAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceMutedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the DeviceMuted attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the DeviceMuted attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("deviceMuted", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("deviceMuted", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("deviceMuted", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheTestInProgressAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTestInProgressWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the TestInProgress attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the TestInProgress attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("testInProgress", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheHardwareFaultAlertAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeHardwareFaultAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the HardwareFaultAlert attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the HardwareFaultAlert attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("hardwareFaultAlert", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheEndOfServiceAlertAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndOfServiceAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the EndOfServiceAlert attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the EndOfServiceAlert attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endOfServiceAlert", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("endOfServiceAlert", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("endOfServiceAlert", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsFromTheDutTheInterconnectSmokeAlarmAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInterconnectSmokeAlarmWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("interconnectSmokeAlarm", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("interconnectSmokeAlarm", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("interconnectSmokeAlarm", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheInterconnectCOAlarmAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInterconnectCOAlarmWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the InterconnectCOAlarm attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the InterconnectCOAlarm attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("interconnectCOAlarm", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("interconnectCOAlarm", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("interconnectCOAlarm", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsFromTheDutTheContaminationStateAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeContaminationStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads from the DUT the ContaminationState attribute: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads from the DUT the ContaminationState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("contaminationState", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("contaminationState", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("contaminationState", [value unsignedCharValue], 3U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsFromTheDutTheSmokeSensitivityLevelAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSmokeSensitivityLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("smokeSensitivityLevel", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("smokeSensitivityLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("smokeSensitivityLevel", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsFromTheDutTheExpiryDateAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeExpiryDateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads from the DUT the ExpiryDate attribute: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads from the DUT the ExpiryDate attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("expiryDate", "epoch_s", "epoch_s")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_SWTCH_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_SWTCH_1_1() - : TestCommandBridge("Test_TC_SWTCH_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_SWTCH_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_SWTCH_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SWTCH_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 3: Read the global attribute: ClusterRevision\n"); - err = TestStep3ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: Read FeatureMap attribute and Check values of flags in this FeatureMap\n"); - if (ShouldSkip("!SWTCH.S.F00 && !SWTCH.S.F01 && !SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep2aReadFeatureMapAttributeAndCheckValuesOfFlagsInThisFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F00")) { - NextTest(); - return; - } - err = TestStep2bGivenSwtchsf00lsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F01")) { - NextTest(); - return; - } - err = TestStep2cGivenSwtchsf01msEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F02")) { - NextTest(); - return; - } - err = TestStep2dGivenSwtchsf02msrEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F03")) { - NextTest(); - return; - } - err = TestStep2eGivenSwtchsf03mslEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep2fGivenSwtchsf04msmEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep4bReadTheGlobalAttributeAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED && !SWTCH.S.F04")) { - NextTest(); - return; - } - err = TestStep4bReadTheGlobalAttributeAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5a: Read the global attribute: EventList \n"); - if (ShouldSkip("!SWTCH.S.F00 && !SWTCH.S.F01 && !SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5b: Read EventList if SWTCH.S.F00(LS)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SWTCH.S.F00")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5c: Read EventList if SWTCH.S.F01(MS) & !SWTCH.S.F02(MSR)\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && !SWTCH.S.F02")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5d: Read EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & !SWTCH.S.F03(MSL) & !SWTCH.S.F04(MSM)\n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5e: Read EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & SWTCH.S.F03(MSL) & !SWTCH.S.F04(MSM)\n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && SWTCH.S.F03 && !SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5f: Read EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & !SWTCH.S.F03(MSL) & SWTCH.S.F04(MSM) \n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && !SWTCH.S.F03 && SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5g: Read EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & SWTCH.S.F03(MSL) & SWTCH.S.F04(MSM) \n"); - if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && SWTCH.S.F03 && SWTCH.S.F04 ")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: Read the global attribute: AcceptedCommandList\n"); - err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: Read the global attribute: GeneratedCommandList\n"); - err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep3ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 3: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aReadFeatureMapAttributeAndCheckValuesOfFlagsInThisFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: Read FeatureMap attribute and Check values of flags in this FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 2a: Read FeatureMap attribute and Check values of flags in this FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bGivenSwtchsf00lsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cGivenSwtchsf01msEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dGivenSwtchsf02msrEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eGivenSwtchsf03mslEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fGivenSwtchsf04msmEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheGlobalAttributeAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheGlobalAttributeAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCCM_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCCM_1_1() - : TestCommandBridge("Test_TC_TCCM_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCCM_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCCM_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCCM_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!TCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF)\n"); - if (ShouldSkip("TCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTccmsf00deponoff_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode)\n"); - if (ShouldSkip("TCCM.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0002ShallBeIncludedIfAndOnlyIfTCCMSA0002StartUpMode_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF)\n"); - if (ShouldSkip("TCCM.S.F00")) { - NextTest(); - return; - } - err = TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTccmsf00deponoff_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTccmsf00deponoff_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF): Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0002ShallBeIncludedIfAndOnlyIfTCCMSA0002StartUpMode_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode): Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTccmsf00deponoff_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF): Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_1_1() - : TestCommandBridge("Test_TC_TCTL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute\n"); - if (ShouldSkip("!TCTL.S.F00 && !TCTL.S.F01 && !TCTL.S.F02")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL)\n"); - if (ShouldSkip("TCTL.S.F00 && !TCTL.S.F01")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTctlsf00tntctlsf01tl_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN)\n"); - if (ShouldSkip("TCTL.S.F01 && !TCTL.S.F00")) { - NextTest(); - return; - } - err = TestStep3cThReadsFromTheDutTheFeatureMapAttributeBit1ShallBe1IfAndOnlyIfTctlsf01tltctlsf00tn_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN)\n"); - if (ShouldSkip("TCTL.S.F02 && TCTL.S.F00")) { - NextTest(); - return; - } - err = TestStep3dThReadsFromTheDutTheFeatureMapAttributeBit2ShallBe1IfAndOnlyIfTctlsf02aStepTctlsf00tn_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN)\n"); - if (ShouldSkip("TCTL.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x00000x00010x0002ShallBeIncludedIfAndOnlyIfTctlsf00tn_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP)\n"); - if (ShouldSkip("TCTL.S.F02")) { - NextTest(); - return; - } - err = TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTctlsf02aStep_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL)\n"); - if (ShouldSkip("TCTL.S.F01")) { - NextTest(); - return; - } - err = TestStep4dThReadsFromTheDutTheAttributeListAttribute0x00040x0005ShallBeIncludedIfAndOnlyIfTctlsf01tl_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTctlsf00tntctlsf01tl_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL): Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFromTheDutTheFeatureMapAttributeBit1ShallBe1IfAndOnlyIfTctlsf01tltctlsf00tn_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN): Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsFromTheDutTheFeatureMapAttributeBit2ShallBe1IfAndOnlyIfTctlsf02aStepTctlsf00tn_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN): Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x00000x00010x0002ShallBeIncludedIfAndOnlyIfTctlsf00tn_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN): Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTctlsf02aStep_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP): Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFromTheDutTheAttributeListAttribute0x00040x0005ShallBeIncludedIfAndOnlyIfTctlsf01tl_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL): Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_2_2() - : TestCommandBridge("Test_TC_TCTL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheMinTemperatureAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMaxTemperatureAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheTemperatureSetpointAttribute_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull MinTemperatureValue; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheMinTemperatureAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the MinTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the MinTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minTemperature", "temperature", "temperature")); - { - MinTemperatureValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull MaxTemperatureValue; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxTemperatureAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MaxTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MaxTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxTemperature", "temperature", "temperature")); - VerifyOrReturn(CheckConstraintMinValue("maxTemperature", [value shortValue], MinTemperatureValue)); - { - MaxTemperatureValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull temperatureValue; - - CHIP_ERROR TestStep4ThReadsFromTheDutTheTemperatureSetpointAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("temperatureSetpoint", [value shortValue], MinTemperatureValue)); - VerifyOrReturn(CheckConstraintMaxValue("temperatureSetpoint", [value shortValue], MaxTemperatureValue)); - { - temperatureValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_2_3() - : TestCommandBridge("Test_TC_TCTL_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); - if (ShouldSkip("TCTL.S.A0004")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute\n"); - if (ShouldSkip("TCTL.S.A0005")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the DUT response contains a list of strings with each string length not exceeding 16 characters.\n"); - if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.A0005")) { - NextTest(); - return; - } - err = TestVerifyThatTheDutResponseContainsAListOfStringsWithEachStringLengthNotExceeding16Characters_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("selectedTemperatureLevel", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("selectedTemperatureLevel", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("selectedTemperatureLevel", [value unsignedCharValue], 31U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedTemperatureLevels", "list", "list")); - VerifyOrReturn(CheckConstraintMaxLength("supportedTemperatureLevels", value, 32)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatTheDutResponseContainsAListOfStringsWithEachStringLengthNotExceeding16Characters_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_TCTL_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_3_2() - : TestCommandBridge("Test_TC_TCTL_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step_5_setTemp", INT16_MIN, INT16_MAX, &mStep5SetTemp); - AddArgument("InvalidTemp", INT16_MIN, INT16_MAX, &mInvalidTemp); - AddArgument("Step_10_setTemp", INT16_MIN, INT16_MAX, &mStep10SetTemp); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Operate device such that a temperature number can be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep2OperateDeviceSuchThatATemperatureNumberCanBeAccepted_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MinTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheMinTemperatureAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MaxTemperature attribute\n"); - if (ShouldSkip("TCTL.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheMaxTemperatureAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for 5s\n"); - err = TestWaitFor5s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheTemperatureSetpointAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends command SetTemperatureCommand with an invalid value\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait for 5s\n"); - err = TestWaitFor5s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheTemperatureSetpointAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 9: Operate device such that a temperature number cannot be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep9OperateDeviceSuchThatATemperatureNumberCannotBeAccepted_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp\n"); - if (ShouldSkip("TCTL.S.C00.Rsp && PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep10ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for 5s\n"); - err = TestWaitFor5s_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 11: TH reads from the DUT the TemperatureSetpoint attribute\n"); - if (ShouldSkip("TCTL.S.A0000 && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep11ThReadsFromTheDutTheTemperatureSetpointAttribute_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep5SetTemp; - chip::Optional mInvalidTemp; - chip::Optional mStep10SetTemp; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2OperateDeviceSuchThatATemperatureNumberCanBeAccepted_1() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSNumber * _Nonnull minTemp; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheMinTemperatureAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the MinTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the MinTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("minTemperature", "temperature", "temperature")); - { - minTemp = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull maxTemp; - - CHIP_ERROR TestStep4ThReadsFromTheDutTheMaxTemperatureAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the MaxTemperature attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the MaxTemperature attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("maxTemperature", "temperature", "temperature")); - { - maxTemp = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperature = mStep5SetTemp.HasValue() ? [NSNumber numberWithShort:mStep5SetTemp.Value()] : [NSNumber numberWithShort:5]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheTemperatureSetpointAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperature = mInvalidTemp.HasValue() ? [NSNumber numberWithShort:mInvalidTemp.Value()] : [NSNumber numberWithShort:100]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheTemperatureSetpointAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9OperateDeviceSuchThatATemperatureNumberCannotBeAccepted_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep10ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperature = mStep10SetTemp.HasValue() ? [NSNumber numberWithShort:mStep10SetTemp.Value()] : [NSNumber numberWithShort:50]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep11ThReadsFromTheDutTheTemperatureSetpointAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads from the DUT the TemperatureSetpoint attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TCTL_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TCTL_3_3() - : TestCommandBridge("Test_TC_TCTL_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step_4_setLevel", 0, UINT8_MAX, &mStep4SetLevel); - AddArgument("Step_7_setLevel", 0, UINT8_MAX, &mStep7SetLevel); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TCTL_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Operate device such that a temperature level can be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep2OperateDeviceSuchThatATemperatureLevelCanBeAccepted_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute\n"); - if (ShouldSkip("TCTL.S.A0005")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsCommandSetTemperatureCommandWithAValueFromSupportedLevelsSavedAsSetLevel_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 5s\n"); - if (ShouldSkip("TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestWaitFor5s_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); - if (ShouldSkip("TCTL.S.A0004 && TCTL.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6:Operate device such that a temperature level cannot be accepted\n"); - if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep6OperateDeviceSuchThatATemperatureLevelCannotBeAccepted_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends command SetTemperatureCommand with an invalid value\n"); - if (ShouldSkip("TCTL.S.C00.Rsp && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait for 5s\n"); - if (ShouldSkip("TCTL.S.C00.Rsp && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestWaitFor5s_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); - if (ShouldSkip("TCTL.S.A0004 && TCTL.S.M.SupportsInvalidInMode")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep4SetLevel; - chip::Optional mStep7SetLevel; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2OperateDeviceSuchThatATemperatureLevelCanBeAccepted_1() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - NSArray * _Nonnull supportedLevels; - - CHIP_ERROR TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedTemperatureLevels", "list", "list")); - { - supportedLevels = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsCommandSetTemperatureCommandWithAValueFromSupportedLevelsSavedAsSetLevel_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = mStep4SetLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mStep4SetLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, mStep4SetLevel.HasValue() ? mStep4SetLevel.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6OperateDeviceSuchThatATemperatureLevelCannotBeAccepted_6() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = mStep7SetLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mStep7SetLevel.Value()] : [NSNumber numberWithUnsignedChar:3U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitFor5s_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, mStep4SetLevel.HasValue() ? mStep4SetLevel.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TMP_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TMP_1_1() - : TestCommandBridge("Test_TC_TMP_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TMP_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TMP_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TMP_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from the DUT\n"); - err = TestStep2ThReadsClusterRevisionAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from the DUT\n"); - err = TestStep3ThReadsFeatureMapAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheGlobalAttributeAttributeList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsTheGlobalAttributeAttributeList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); - if (ShouldSkip("TMP.S.A0003")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads AcceptedCommandList attribute from the DUT\n"); - err = TestStep5ThReadsAcceptedCommandListAttributeFromTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads GeneratedCommandList attribute from the DUT\n"); - err = TestStep6ThReadsGeneratedCommandListAttributeFromTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads ClusterRevision attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads ClusterRevision attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads FeatureMap attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads FeatureMap attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheGlobalAttributeAttributeList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsTheGlobalAttributeAttributeList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsAcceptedCommandListAttributeFromTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads AcceptedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads AcceptedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsGeneratedCommandListAttributeFromTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads GeneratedCommandList attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads GeneratedCommandList attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TMP_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TMP_2_1() - : TestCommandBridge("Test_TC_TMP_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TMP_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TMP_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TMP_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the MinMeasuredValue attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0001")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheMinMeasuredValueAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the MaxMeasuredValue attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0002")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheMaxMeasuredValueAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the MeasuredValue attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheMeasuredValueAttributeFromTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the Tolerance attribute from the DUT\n"); - if (ShouldSkip("TMP.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsTheToleranceAttributeFromTheDut_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable CurrentMinMeasured; - - CHIP_ERROR TestStep2ThReadsTheMinMeasuredValueAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the MinMeasuredValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the MinMeasuredValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("minMeasuredValue", "temperature", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value shortValue], -27315)); - VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value shortValue], 32766)); - } - { - CurrentMinMeasured = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable CurrentMaxMeasured; - - CHIP_ERROR TestStep3ThReadsTheMaxMeasuredValueAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the MaxMeasuredValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the MaxMeasuredValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "temperature", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value shortValue], CurrentMinMeasured)); - VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value shortValue], 32767)); - } - { - CurrentMaxMeasured = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheMeasuredValueAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the MeasuredValue attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the MeasuredValue attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("measuredValue", "temperature", "int16s")); - VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value shortValue], CurrentMinMeasured)); - VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value shortValue], CurrentMaxMeasured)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsTheToleranceAttributeFromTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSTAT_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSTAT_1_1() - : TestCommandBridge("Test_TC_TSTAT_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSTAT_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSTAT_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSTAT_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); - err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap\n"); - if (ShouldSkip("!TSTAT.S.F00 && !TSTAT.S.F01 && !TSTAT.S.F02 && !TSTAT.S.F03 && !TSTAT.S.F04 && !TSTAT.S.F05")) { - NextTest(); - return; - } - err = TestStep3aReadTheGlobalAttributeFeatureMap_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenTstatsf00heatEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenTstatsf01coolEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenTstatsf02occEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenTstatsf03schEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenTstatsf04sbEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F05")) { - NextTest(); - return; - } - err = TestStep3gGivenTstatsf05autoEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TSTAT.S.F06")) { - NextTest(); - return; - } - err = TestStep3hGivenTstatsf06ltneEnsureFeaturemapHasTheCorrectBitSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: Read the global attribute: AttributeList\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aReadTheGlobalAttributeAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: Read the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00")) { - NextTest(); - return; - } - err = TestStep4bReadTheFeatureDependentTSTATSF00HEATAttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: Read the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01")) { - NextTest(); - return; - } - err = TestStep4cReadTheFeatureDependentTSTATSF01COOLAttributeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4d: Read the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4dReadTheFeatureDependentTSTATSF02OCCAttributeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4e: Read the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4eReadTheFeatureDependentTSTATSF00HEATTstatsf02occAttributeInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4f: Read the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4fReadTheFeatureDependentTSTATSF01COOLTstatsf02occAttributeInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4g: Read the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F05")) { - NextTest(); - return; - } - err = TestStep4gReadTheFeatureDependentTSTATSF05AUTOAttributeInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4h: Read the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep4hReadTheFeatureDependentTSTATSF03SCHAttributeInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4i: Read the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F04")) { - NextTest(); - return; - } - err = TestStep4iReadTheFeatureDependentTSTATSF04SBAttributeInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4j: Read the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F04 && TSTAT.S.F02")) { - NextTest(); - return; - } - err = TestStep4jReadTheFeatureDependentTSTATSF04SBTstatsf02occAttributeInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4k: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0001")) { - NextTest(); - return; - } - err = TestStep4kReadTheOptionalAttributeInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4l: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0009")) { - NextTest(); - return; - } - err = TestStep4lReadTheOptionalAttributeInAttributeList_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4m: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0010")) { - NextTest(); - return; - } - err = TestStep4mReadTheOptionalAttributeInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4n: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A001a")) { - NextTest(); - return; - } - err = TestStep4nReadTheOptionalAttributeInAttributeList_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4o: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A001d")) { - NextTest(); - return; - } - err = TestStep4oReadTheOptionalAttributeInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4p: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0023")) { - NextTest(); - return; - } - err = TestStep4pReadTheOptionalAttributeInAttributeList_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4q: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0024")) { - NextTest(); - return; - } - err = TestStep4qReadTheOptionalAttributeInAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4r: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0025")) { - NextTest(); - return; - } - err = TestStep4rReadTheOptionalAttributeInAttributeList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4s: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0029")) { - NextTest(); - return; - } - err = TestStep4sReadTheOptionalAttributeInAttributeList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4t: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0030")) { - NextTest(); - return; - } - err = TestStep4tReadTheOptionalAttributeInAttributeList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4u: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0031")) { - NextTest(); - return; - } - err = TestStep4uReadTheOptionalAttributeInAttributeList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4x: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0032")) { - NextTest(); - return; - } - err = TestStep4xReadTheOptionalAttributeInAttributeList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 5y: Read the optional attribute: AttributeList\n"); - if (ShouldSkip("TSTAT.S.A003a")) { - NextTest(); - return; - } - err = TestStep5yReadTheOptionalAttributeAttributeList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4z: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0040")) { - NextTest(); - return; - } - err = TestStep4zReadTheOptionalAttributeInAttributeList_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4A: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0041")) { - NextTest(); - return; - } - err = TestStep4aReadTheOptionalAttributeInAttributeList_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4B: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0042")) { - NextTest(); - return; - } - err = TestStep4bReadTheOptionalAttributeInAttributeList_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 4C: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0043")) { - NextTest(); - return; - } - err = TestStep4cReadTheOptionalAttributeInAttributeList_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 5D: Read the optional attribute: AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0044")) { - NextTest(); - return; - } - err = TestStep5dReadTheOptionalAttributeAttributeList_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 4E: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0045")) { - NextTest(); - return; - } - err = TestStep4eReadTheOptionalAttributeInAttributeList_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 4F: Read the optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0046")) { - NextTest(); - return; - } - err = TestStep4fReadTheOptionalAttributeInAttributeList_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 5G: Read the optional attribute: AttributeList\n"); - if (ShouldSkip("TSTAT.S.A0047")) { - NextTest(); - return; - } - err = TestStep5gReadTheOptionalAttributeAttributeList_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 4H: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0003")) { - NextTest(); - return; - } - err = TestStep4hReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 4I: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0004")) { - NextTest(); - return; - } - err = TestStep4iReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 4J: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0008")) { - NextTest(); - return; - } - err = TestStep4jReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 4K: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0015")) { - NextTest(); - return; - } - err = TestStep4kReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 4L: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0016")) { - NextTest(); - return; - } - err = TestStep4lReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 4M: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0005")) { - NextTest(); - return; - } - err = TestStep4mReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 4N: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0007")) { - NextTest(); - return; - } - err = TestStep4nReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Step 4O: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0007")) { - NextTest(); - return; - } - err = TestStep4oReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Step 4P: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0017")) { - NextTest(); - return; - } - err = TestStep4pReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Step 4Q: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0018")) { - NextTest(); - return; - } - err = TestStep4qReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Step 4R: Read the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList\n"); - if (ShouldSkip("TSTAT.S.F05 && TSTAT.S.A001e")) { - NextTest(); - return; - } - err = TestStep4rReadTheFeatureDependentTSTATSF05AUTOOptionalAttributeInAttributeList_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Step 5a: Read the mandatory commands in AcceptedCommandList\n"); - err = TestStep5aReadTheMandatoryCommandsInAcceptedCommandList_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Step 5b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep5bReadFeatureDependentTSTATSF03SCHCommandsInAcceptedCommandList_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Step 5c: Read the optional (GetRelayStatusLog) command in AcceptedCommandList\n"); - if (ShouldSkip("TSTAT.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep5cReadTheOptionalGetRelayStatusLogCommandInAcceptedCommandList_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Step 6a: Read the global attribute: GeneratedCommandList\n"); - if (ShouldSkip(" !TSTAT.S.C04.Rsp && !TSTAT.S.C02.Rsp ")) { - NextTest(); - return; - } - err = TestStep6aReadTheGlobalAttributeGeneratedCommandList_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Step 6b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList\n"); - if (ShouldSkip("TSTAT.S.F03")) { - NextTest(); - return; - } - err = TestStep6bReadFeatureDependentTSTATSF03SCHCommandsInGeneratedCommandList_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Step 6c: Read optional command (GetRelayStatusLogResponse) in GeneratedCommandList\n"); - if (ShouldSkip("TSTAT.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep6cReadOptionalCommandGetRelayStatusLogResponseInGeneratedCommandList_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Step 7: Read EventList attribute from the DUT.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 60; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); - } else { - NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 6U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMap_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: Read the global attribute: FeatureMap: Error: %@", err); - } else { - NSLog(@"Step 3a: Read the global attribute: FeatureMap: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenTstatsf00heatEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenTstatsf01coolEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenTstatsf02occEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenTstatsf03schEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenTstatsf04sbEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenTstatsf05autoEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenTstatsf06ltneEnsureFeaturemapHasTheCorrectBitSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheFeatureDependentTSTATSF00HEATAttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: Read the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: Read the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheFeatureDependentTSTATSF01COOLAttributeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Read the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Read the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dReadTheFeatureDependentTSTATSF02OCCAttributeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Read the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Read the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eReadTheFeatureDependentTSTATSF00HEATTstatsf02occAttributeInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Read the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: Read the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheFeatureDependentTSTATSF01COOLTstatsf02occAttributeInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Read the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Read the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gReadTheFeatureDependentTSTATSF05AUTOAttributeInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Read the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: Read the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheFeatureDependentTSTATSF03SCHAttributeInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Read the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Read the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iReadTheFeatureDependentTSTATSF04SBAttributeInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Read the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: Read the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 53UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheFeatureDependentTSTATSF04SBTstatsf02occAttributeInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Read the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Read the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 57UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kReadTheOptionalAttributeInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lReadTheOptionalAttributeInAttributeList_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mReadTheOptionalAttributeInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nReadTheOptionalAttributeInAttributeList_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oReadTheOptionalAttributeInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 29UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pReadTheOptionalAttributeInAttributeList_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4p: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qReadTheOptionalAttributeInAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4q: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rReadTheOptionalAttributeInAttributeList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4r: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4r: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4sReadTheOptionalAttributeInAttributeList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4s: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4s: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4tReadTheOptionalAttributeInAttributeList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4t: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4t: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4uReadTheOptionalAttributeInAttributeList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4u: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4u: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4xReadTheOptionalAttributeInAttributeList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4x: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4x: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5yReadTheOptionalAttributeAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5y: Read the optional attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 5y: Read the optional attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4zReadTheOptionalAttributeInAttributeList_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4z: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4z: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aReadTheOptionalAttributeInAttributeList_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4A: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4A: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bReadTheOptionalAttributeInAttributeList_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4B: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4B: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 66UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cReadTheOptionalAttributeInAttributeList_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4C: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4C: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 67UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dReadTheOptionalAttributeAttributeList_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5D: Read the optional attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 5D: Read the optional attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 68UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eReadTheOptionalAttributeInAttributeList_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4E: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4E: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 69UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fReadTheOptionalAttributeInAttributeList_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4F: Read the optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4F: Read the optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 70UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5gReadTheOptionalAttributeAttributeList_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5G: Read the optional attribute: AttributeList: Error: %@", err); - } else { - NSLog(@"Step 5G: Read the optional attribute: AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 71UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4H: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4H: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4I: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4I: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4J: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4J: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4K: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4K: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4L: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4L: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4M: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4M: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4N: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4N: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4O: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4O: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4P: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4P: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4Q: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4Q: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rReadTheFeatureDependentTSTATSF05AUTOOptionalAttributeInAttributeList_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4R: Read the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4R: Read the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 30UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aReadTheMandatoryCommandsInAcceptedCommandList_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: Read the mandatory commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5a: Read the mandatory commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bReadFeatureDependentTSTATSF03SCHCommandsInAcceptedCommandList_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cReadTheOptionalGetRelayStatusLogCommandInAcceptedCommandList_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: Read the optional (GetRelayStatusLog) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 5c: Read the optional (GetRelayStatusLog) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aReadTheGlobalAttributeGeneratedCommandList_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: Read the global attribute: GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6a: Read the global attribute: GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bReadFeatureDependentTSTATSF03SCHCommandsInGeneratedCommandList_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cReadOptionalCommandGetRelayStatusLogResponseInGeneratedCommandList_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: Read optional command (GetRelayStatusLogResponse) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: Read optional command (GetRelayStatusLogResponse) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSUIC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSUIC_1_1() - : TestCommandBridge("Test_TC_TSUIC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSUIC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeScheduleProgrammingVisibilityInAttributeList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeScheduleProgrammingVisibilityInAttributeList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSUIC_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSUIC_2_1() - : TestCommandBridge("Test_TC_TSUIC_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSUIC_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the TemperatureDisplayMode attribute from the DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsTheTemperatureDisplayModeAttributeFromTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the KeypadLockout attribute from the DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsTheKeypadLockoutAttributeFromTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsTheScheduleProgrammingVisibilityAttributeFromTheDut_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheTemperatureDisplayModeAttributeFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the TemperatureDisplayMode attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the TemperatureDisplayMode attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("temperatureDisplayMode", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("temperatureDisplayMode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("temperatureDisplayMode", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsTheKeypadLockoutAttributeFromTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads the KeypadLockout attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads the KeypadLockout attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("keypadLockout", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("keypadLockout", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("keypadLockout", [value unsignedCharValue], 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsTheScheduleProgrammingVisibilityAttributeFromTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("scheduleProgrammingVisibility", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("scheduleProgrammingVisibility", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("scheduleProgrammingVisibility", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TSUIC_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TSUIC_2_2() - : TestCommandBridge("Test_TC_TSUIC_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TSUIC_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2aThWritesAValueOf0ToTemperatureDisplayModeAttributeOfDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify device temperature displayed in °C\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestVerifyDeviceTemperatureDisplayedInc_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads the TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2bThReadsTheTemperatureDisplayModeAttributeOfDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2cThWritesAValueOf1ToTemperatureDisplayModeAttributeOfDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Verify device temperature displayed in °F\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestVerifyDeviceTemperatureDisplayedInf_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2d: TH reads the TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2dThReadsTheTemperatureDisplayModeAttributeOfDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2eThWritesAValueOfGreaterThan1ToTemperatureDisplayModeAttributeOfDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2f: TH reads the TemperatureDisplayMode attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0000")) { - NextTest(); - return; - } - err = TestStep2fThReadsTheTemperatureDisplayModeAttributeOfDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3aThWritesAValueOf0ToKeypadLockoutAttributeOfDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Verify all device functionality available to the user\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyAllDeviceFunctionalityAvailableToTheUser_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsTheKeypadLockoutAttributeOfDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3cThWritesAValueOf1ToKeypadLockoutAttributeOfDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Verify device operates at Level 1 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel1ReducedFunctionality_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheKeypadLockoutAttributeOfDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3eThWritesAValueOf2ToKeypadLockoutAttributeOfDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Verify device operates at Level 2 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel2ReducedFunctionality_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3f: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3fThReadsTheKeypadLockoutAttributeOfDut_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3gThWritesAValueOf3ToKeypadLockoutAttributeOfDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Verify device operates at Level 3 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel3ReducedFunctionality_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3h: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3hThReadsTheKeypadLockoutAttributeOfDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3iThWritesAValueOf4ToKeypadLockoutAttributeOfDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Verify device operates at Level 4 reduced functionality\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLevel4ReducedFunctionality_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3j: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3jThReadsTheKeypadLockoutAttributeOfDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3kThWritesAValueOf5ToKeypadLockoutAttributeOfDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Verify device operates at least functionality level\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestVerifyDeviceOperatesAtLeastFunctionalityLevel_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3l: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3lThReadsTheKeypadLockoutAttributeOfDut_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3mWritesAValueOfGreaterThan5ToKeypadLockoutAttributeOfDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 3n: TH reads the KeypadLockout attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0001")) { - NextTest(); - return; - } - err = TestStep3nThReadsTheKeypadLockoutAttributeOfDut_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4aThWritesAValueOf0ToScheduleProgrammingVisibilityAttributeOfDut_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Verify local schedule programming functionality is enabled at the thermostat\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestVerifyLocalScheduleProgrammingFunctionalityIsEnabledAtTheThermostat_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheScheduleProgrammingVisibilityAttributeOfDut_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cThWritesAValueOf1ToScheduleProgrammingVisibilityAttributeOfDut_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Verify local schedule programming functionality is disabled at the thermostat\n"); - if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestVerifyLocalScheduleProgrammingFunctionalityIsDisabledAtTheThermostat_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheScheduleProgrammingVisibilityAttributeOfDut_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4eThWritesAValueOfGreaterThan1ToScheduleProgrammingVisibilityAttributeOfDut_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); - if (ShouldSkip("TSUIC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheScheduleProgrammingVisibilityAttributeOfDut_36(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 37; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2aThWritesAValueOf0ToTemperatureDisplayModeAttributeOfDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureDisplayModeArgument; - temperatureDisplayModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceTemperatureDisplayedInc_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2bThReadsTheTemperatureDisplayModeAttributeOfDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads the TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThWritesAValueOf1ToTemperatureDisplayModeAttributeOfDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureDisplayModeArgument; - temperatureDisplayModeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceTemperatureDisplayedInf_5() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep2dThReadsTheTemperatureDisplayModeAttributeOfDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads the TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThWritesAValueOfGreaterThan1ToTemperatureDisplayModeAttributeOfDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id temperatureDisplayModeArgument; - temperatureDisplayModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsTheTemperatureDisplayModeAttributeOfDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads the TemperatureDisplayMode attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWritesAValueOf0ToKeypadLockoutAttributeOfDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyAllDeviceFunctionalityAvailableToTheUser_10() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3bThReadsTheKeypadLockoutAttributeOfDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThWritesAValueOf1ToKeypadLockoutAttributeOfDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel1ReducedFunctionality_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3dThReadsTheKeypadLockoutAttributeOfDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThWritesAValueOf2ToKeypadLockoutAttributeOfDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel2ReducedFunctionality_16() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3fThReadsTheKeypadLockoutAttributeOfDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gThWritesAValueOf3ToKeypadLockoutAttributeOfDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel3ReducedFunctionality_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3hThReadsTheKeypadLockoutAttributeOfDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3h: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iThWritesAValueOf4ToKeypadLockoutAttributeOfDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLevel4ReducedFunctionality_22() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3jThReadsTheKeypadLockoutAttributeOfDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3j: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kThWritesAValueOf5ToKeypadLockoutAttributeOfDut_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyDeviceOperatesAtLeastFunctionalityLevel_25() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3lThReadsTheKeypadLockoutAttributeOfDut_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3l: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3mWritesAValueOfGreaterThan5ToKeypadLockoutAttributeOfDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id keypadLockoutArgument; - keypadLockoutArgument = - [NSNumber numberWithUnsignedChar:6U]; - [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3nThReadsTheKeypadLockoutAttributeOfDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3n: TH reads the KeypadLockout attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 3n: TH reads the KeypadLockout attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThWritesAValueOf0ToScheduleProgrammingVisibilityAttributeOfDut_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id scheduleProgrammingVisibilityArgument; - scheduleProgrammingVisibilityArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyLocalScheduleProgrammingFunctionalityIsEnabledAtTheThermostat_30() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4bThReadsTheScheduleProgrammingVisibilityAttributeOfDut_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThWritesAValueOf1ToScheduleProgrammingVisibilityAttributeOfDut_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id scheduleProgrammingVisibilityArgument; - scheduleProgrammingVisibilityArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyLocalScheduleProgrammingFunctionalityIsDisabledAtTheThermostat_33() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4dThReadsTheScheduleProgrammingVisibilityAttributeOfDut_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThWritesAValueOfGreaterThan1ToScheduleProgrammingVisibilityAttributeOfDut_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id scheduleProgrammingVisibilityArgument; - scheduleProgrammingVisibilityArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheScheduleProgrammingVisibilityAttributeOfDut_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGTHREAD_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGTHREAD_1_1() - : TestCommandBridge("Test_TC_DGTHREAD_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGTHREAD_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGTHREAD_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGTHREAD_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DGTHREAD.S.F00 && !DGTHREAD.S.F01 && !DGTHREAD.S.F02 && !DGTHREAD.S.F03 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDgthreadsf00pktcntEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDgthreadsf01errcntEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenDgthreadsf02mlecntEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGTHREAD.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenDgthreadsf03maccntEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads mandatory attributes in AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads mandatory attributes in AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList\n"); - if (ShouldSkip("DGTHREAD.S.A0006 && DGTHREAD.S.F01")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentAttributeDGTHREADSF01ERRCNTInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList\n"); - if (ShouldSkip("DGTHREAD.S.F02")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentAttributeDgthreadsf02mlecntInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList\n"); - if (ShouldSkip("DGTHREAD.S.F03")) { - NextTest(); - return; - } - err = TestStep4dThReadsFeatureDependentAttributeDgthreadsf03maccntInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList\n"); - if (ShouldSkip("DGTHREAD.S.A0038")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeActiveTimestampInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList\n"); - if (ShouldSkip("DGTHREAD.S.A0039")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheOptionalAttributePendingTimestampInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4g: TH reads the optional attribute (Delay) in AttributeList\n"); - if (ShouldSkip("DGTHREAD.S.A003a")) { - NextTest(); - return; - } - err = TestStep4gThReadsTheOptionalAttributeDelayInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip(" !DGTHREAD.S.E00 && !DGTHREAD.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads DGTHREAD.S.E00(ConnectionStatus) event in EventList\n"); - if (ShouldSkip("DGTHREAD.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5c: TH reads DGTHREAD.S.E01(NetworkFaultChange) event in EventList\n"); - if (ShouldSkip("DGTHREAD.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGTHREAD.S.F01 ")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip("DGTHREAD.S.F01")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDgthreadsf00pktcntEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDgthreadsf01errcntEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenDgthreadsf02mlecntEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenDgthreadsf03maccntEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 61UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 62UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 61UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 62UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeDGTHREADSF01ERRCNTInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeDgthreadsf02mlecntInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFeatureDependentAttributeDgthreadsf03maccntInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 29UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 30UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 39UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 43UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 44UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 45UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 46UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 47UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 53UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeActiveTimestampInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheOptionalAttributePendingTimestampInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 57UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsTheOptionalAttributeDelayInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads the optional attribute (Delay) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads the optional attribute (Delay) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TIMESYNC_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TIMESYNC_1_1() - : TestCommandBridge("Test_TC_TIMESYNC_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TIMESYNC_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TIMESYNC_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TIMESYNC_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGiventimesyncsf00tzEnsureFeaturemapHasTheCorrectBitClear_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenTimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep3dGiventimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitClear_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep3eGivenTimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep3fGiventimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitClear_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep3gGivenTimesyncsf03tscEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear\n"); - if (ShouldSkip("!TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep3hGiventimesyncsf03tscEnsureFeaturemapHasTheCorrectBitClear_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4bThReadsFromTheDutTheAttributeListAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: Check for optional attribute TimeSource in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4cCheckForOptionalAttributeTimeSourceInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4d: Check for optional attribute TimeSource not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dCheckForOptionalAttributeTimeSourceNotInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4e: Check for TZ feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep4eCheckForTzFeatureBasedAttributesInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4f: Check for TZ feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep4fCheckForTzFeatureBasedAttributesNotInAttributeList_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4g: Check for NTPC feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep4gCheckForNtpcFeatureBasedAttributesInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4h: Check for NTPC feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep4hCheckForNtpcFeatureBasedAttributesNotInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4i: Check for NTPS feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep4iCheckForNtpsFeatureBasedAttributesInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4j: Check for NTPS feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F02")) { - NextTest(); - return; - } - err = TestStep4jCheckForNtpsFeatureBasedAttributesNotInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4k: Check for TSC feature-based attributes in AttributeList\n"); - if (ShouldSkip("TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep4kCheckForTscFeatureBasedAttributesInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4l: Check for TSC feature-based attributes not in AttributeList\n"); - if (ShouldSkip("!TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep4lCheckForTscFeatureBasedAttributesNotInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5a: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5b: Check for TZ feature-based events in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && TIMESYNC.S.F00")) { - NextTest(); - return; - } - NextTest(); - return; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 5c: Check for TZ feature-based events not in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !TIMESYNC.S.F00")) { - NextTest(); - return; - } - NextTest(); - return; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 5d: Check for TSC feature-based events in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && TIMESYNC.S.F03")) { - NextTest(); - return; - } - NextTest(); - return; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5e: Check for TSC feature-based events not in EventList\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !TIMESYNC.S.F03")) { - NextTest(); - return; - } - NextTest(); - return; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6b: Check for TZ feature-based commands in AcceptedCommandList\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep6bCheckForTzFeatureBasedCommandsInAcceptedCommandList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 6c: Check for TZ feature-based commands in not AcceptedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep6cCheckForTzFeatureBasedCommandsInNotAcceptedCommandList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 6d: Check for NTPC feature-based commands in AcceptedCommandList\n"); - if (ShouldSkip("TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep6dCheckForNtpcFeatureBasedCommandsInAcceptedCommandList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F01")) { - NextTest(); - return; - } - err = TestStep6eCheckForNtpcFeatureBasedCommandsInNotAcceptedCommandList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 6f: Check for TSC feature-based commands in AcceptedCommandList\n"); - if (ShouldSkip("TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep6fCheckForTscFeatureBasedCommandsInAcceptedCommandList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 6g: Check for TSC feature-based commands in not AcceptedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F03")) { - NextTest(); - return; - } - err = TestStep6gCheckForTscFeatureBasedCommandsInNotAcceptedCommandList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 7a: TH reads from the DUT the GeneratedCommandList attribute\n"); - if (ShouldSkip("TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 7b: Check for TZ feature-based commands in not GeneratedCommandList\n"); - if (ShouldSkip("!TIMESYNC.S.F00")) { - NextTest(); - return; - } - err = TestStep7bCheckForTzFeatureBasedCommandsInNotGeneratedCommandList_35(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 36; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGiventimesyncsf00tzEnsureFeaturemapHasTheCorrectBitClear_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenTimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGiventimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitClear_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenTimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGiventimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitClear_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenTimesyncsf03tscEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGiventimesyncsf03tscEnsureFeaturemapHasTheCorrectBitClear_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear: Error: %@", err); - } else { - NSLog(@"Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cCheckForOptionalAttributeTimeSourceInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: Check for optional attribute TimeSource in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: Check for optional attribute TimeSource in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dCheckForOptionalAttributeTimeSourceNotInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: Check for optional attribute TimeSource not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: Check for optional attribute TimeSource not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eCheckForTzFeatureBasedAttributesInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: Check for TZ feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: Check for TZ feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fCheckForTzFeatureBasedAttributesNotInAttributeList_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: Check for TZ feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: Check for TZ feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gCheckForNtpcFeatureBasedAttributesInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: Check for NTPC feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: Check for NTPC feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hCheckForNtpcFeatureBasedAttributesNotInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: Check for NTPC feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: Check for NTPC feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iCheckForNtpsFeatureBasedAttributesInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: Check for NTPS feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: Check for NTPS feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jCheckForNtpsFeatureBasedAttributesNotInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: Check for NTPS feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: Check for NTPS feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 9UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kCheckForTscFeatureBasedAttributesInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: Check for TSC feature-based attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: Check for TSC feature-based attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lCheckForTscFeatureBasedAttributesNotInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: Check for TSC feature-based attributes not in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: Check for TSC feature-based attributes not in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bCheckForTzFeatureBasedCommandsInAcceptedCommandList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: Check for TZ feature-based commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: Check for TZ feature-based commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cCheckForTzFeatureBasedCommandsInNotAcceptedCommandList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: Check for TZ feature-based commands in not AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: Check for TZ feature-based commands in not AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dCheckForNtpcFeatureBasedCommandsInAcceptedCommandList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: Check for NTPC feature-based commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: Check for NTPC feature-based commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eCheckForNtpcFeatureBasedCommandsInNotAcceptedCommandList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fCheckForTscFeatureBasedCommandsInAcceptedCommandList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: Check for TSC feature-based commands in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6f: Check for TSC feature-based commands in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gCheckForTscFeatureBasedCommandsInNotAcceptedCommandList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: Check for TSC feature-based commands in not AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6g: Check for TSC feature-based commands in not AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bCheckForTzFeatureBasedCommandsInNotGeneratedCommandList_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: Check for TZ feature-based commands in not GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7b: Check for TZ feature-based commands in not GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_TIMESYNC_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_TIMESYNC_2_3() - : TestCommandBridge("Test_TC_TIMESYNC_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_TIMESYNC_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_TIMESYNC_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TIMESYNC_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read commissioner nodeID and saves as th_node_id\n"); - err = TestReadCommissionerNodeIDAndSavesAsThNodeId_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0\n"); - err = TestStep1ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceFieldsSetAsFollowsNodeIDThNodeIdEndpoint0_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx\n"); - err = TestStep2ThReadsFromTheDutTheCurrentFabricIndexAttributeFromTheNodeOperationalCredentialsClusterAndSavesAsThFabricIdx_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads from the DUT the TrustedTimeSource attribute.\n"); - err = TestStep3ThReadsFromTheDutTheTrustedTimeSourceAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.\n"); - err = TestStep4ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceSetToNull_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the TrustedTimeSource attribute.\n"); - err = TestStep5ThReadsFromTheDutTheTrustedTimeSourceAttribute_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull th_node_id; - - CHIP_ERROR TestReadCommissionerNodeIDAndSavesAsThNodeId_1() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - th_node_id = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestStep1ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceFieldsSetAsFollowsNodeIDThNodeIdEndpoint0_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTrustedTimeSourceParams alloc] init]; - params.trustedTimeSource = [[MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct alloc] init]; - ((MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct *) params.trustedTimeSource).nodeID = - [th_node_id copy]; - ((MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct *) params.trustedTimeSource).endpoint = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster setTrustedTimeSourceWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0: Error: %@", err); - } else { - NSLog(@"Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull th_fabric_idx; - - CHIP_ERROR TestStep2ThReadsFromTheDutTheCurrentFabricIndexAttributeFromTheNodeOperationalCredentialsClusterAndSavesAsThFabricIdx_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th_fabric_idx = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheTrustedTimeSourceAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTrustedTimeSourceWithCompletion:^(MTRTimeSynchronizationClusterTrustedTimeSourceStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the TrustedTimeSource attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the TrustedTimeSource attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TrustedTimeSource", actualValue)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).fabricIndex, th_fabric_idx)); - VerifyOrReturn(CheckValue("NodeID", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).nodeID, th_node_id)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).endpoint, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceSetToNull_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTrustedTimeSourceParams alloc] init]; - params.trustedTimeSource = nil; - [cluster setTrustedTimeSourceWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheTrustedTimeSourceAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTrustedTimeSourceWithCompletion:^(MTRTimeSynchronizationClusterTrustedTimeSourceStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the TrustedTimeSource attribute.: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the TrustedTimeSource attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("TrustedTimeSource", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_1_1() - : TestCommandBridge("Test_TC_ULABEL_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); - err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_1() - : TestCommandBridge("Test_TC_ULABEL_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads LabelList from the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThReadsLabelListFromTheDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsLabelListFromTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads LabelList from the DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads LabelList from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("labelList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_2() - : TestCommandBridge("Test_TC_ULABEL_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom'\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThWritesLabelListAttributeOnTheDutWithFollowingEntryroomNamemasterBedroom1orientationeastfloor2roomTypebedroom_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads LabelList attribute of the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsLabelListAttributeOfTheDut_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThWritesLabelListAttributeOnTheDutWithFollowingEntryroomNamemasterBedroom1orientationeastfloor2roomTypebedroom_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"roomName"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"master bedroom 1"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"Orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"east"; - - temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"2"; - - temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"roomType"; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"bedroom"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom': Error: %@", err); - } else { - NSLog(@"Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsLabelListAttributeOfTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"roomName")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"master bedroom 1")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"Orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"east")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"2")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"roomType")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"bedroom")); - } - - VerifyOrReturn(CheckConstraintType("labelList", "list", "list")); - VerifyOrReturn(CheckConstraintMinLength("labelList", value, 4)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_3() - : TestCommandBridge("Test_TC_ULABEL_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong'\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThWritesLabelListAttributeOfTheDutBySettingroom17BytesIsTooLong_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar'\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThWritesLabelListAttributeOfTheDutBySetting17BytesIsTooLongfoobar_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThWritesLabelListAttributeOfTheDutBySettingroom17BytesIsTooLong_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"17_bytesIsTooLongforuserlabelnotexpected"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong': Error: %@", err); - } else { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThWritesLabelListAttributeOfTheDutBySetting17BytesIsTooLongfoobar_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"17_bytesIsTooLongforuserlabelnotexpected"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"foobar"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar': Error: %@", err); - } else { - NSLog(@"Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar': Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ULABEL_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ULABEL_2_4() - : TestCommandBridge("Test_TC_ULABEL_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ULABEL_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' \n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep1ThWritesLabelListAttributeOfTheDutWithEntryAsFollowingroombedroom1orientationeast_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads LabelList attribute of the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsLabelListAttributeOfTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep3ThWritesLabelListAttributeOfTheDutWithAnEntryAsEmptyValuesInTheList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads LabelList attribute of the DUT\n"); - if (ShouldSkip("ULABEL.S.A0000")) { - NextTest(); - return; - } - err = TestStep4ThReadsLabelListAttributeOfTheDut_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThWritesLabelListAttributeOfTheDutWithEntryAsFollowingroombedroom1orientationeast_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 1"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"Orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"east"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' : Error: %@", err); - } else { - NSLog(@"Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' : Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThReadsLabelListAttributeOfTheDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 1")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"Orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"east")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThWritesLabelListAttributeOfTheDutWithAnEntryAsEmptyValuesInTheList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @""; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @""; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list: Error: %@", err); - } else { - NSLog(@"Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsLabelListAttributeOfTheDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads LabelList attribute of the DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads LabelList attribute of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGWIFI_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGWIFI_1_1() - : TestCommandBridge("Test_TC_DGWIFI_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGWIFI_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip("( !DGWIFI.S.F00 && !DGWIFI.S.F01 )")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGWIFI.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDGWIFISF00PacketCountsEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGWIFI.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDGWIFISF01ErrorCountsEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT\n"); - if (ShouldSkip("DGWIFI.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentDGWIFISF00AttributesInAttributeListFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT\n"); - if (ShouldSkip("DGWIFI.S.F01")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentDGWIFISF01AttributesInAttributeListFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT\n"); - if (ShouldSkip("DGWIFI.S.A000b")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeCurrentMaxRateInAttributeListFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip(" !DGWIFI.S.E00 && !DGWIFI.S.E01 && !DGWIFI.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5b: TH reads optional attribute (Disconnection) in EventList from DUT\n"); - if (ShouldSkip("DGWIFI.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5c: TH reads optional attribute (AssociationFailure) in EventList from DUT\n"); - if (ShouldSkip("DGWIFI.S.E01 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5d: TH reads optional attribute (ConnectionStatus) in EventList from DUT\n"); - if (ShouldSkip("DGWIFI.S.E02 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6a: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGWIFI.S.F01 ")) { - NextTest(); - return; - } - err = TestStep6aThReadsAcceptedCommandListFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT\n"); - if (ShouldSkip("DGWIFI.S.F01")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentDGWIFISF01CommandInAcceptedCommandListFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDGWIFISF00PacketCountsEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDGWIFISF01ErrorCountsEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentDGWIFISF00AttributesInAttributeListFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentDGWIFISF01AttributesInAttributeListFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeCurrentMaxRateInAttributeListFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsAcceptedCommandListFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentDGWIFISF01CommandInAcceptedCommandListFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGWIFI_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGWIFI_2_1() - : TestCommandBridge("Test_TC_DGWIFI_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGWIFI_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads BSSID attribute from DUT\n"); - if (ShouldSkip("DGWIFI.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsBssidAttributeFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads SecurityType attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsSecurityTypeAttributeConstraints_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads WiFiVersion attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsWiFiVersionAttributeConstraints_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads ChannelNumber attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsChannelNumberAttributeConstraints_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads RSSI attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsRssiAttributeConstraints_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads BeaconLostCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsBeaconLostCountAttributeConstraints_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads BeaconRxCount attribute constraints\n"); - if (ShouldSkip("DGWIFI.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsBeaconRxCountAttributeConstraints_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads PacketMulticastRxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsPacketMulticastRxCountAttributeConstraints_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads PacketMulticastTxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0008")) { - NextTest(); - return; - } - err = TestStep10ThReadsPacketMulticastTxCountAttributeConstraints_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads PacketUnicastRxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0009")) { - NextTest(); - return; - } - err = TestStep11ThReadsPacketUnicastRxCountAttributeConstraints_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads PacketUnicastTxCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000a")) { - NextTest(); - return; - } - err = TestStep12ThReadsPacketUnicastTxCountAttributeConstraints_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads CurrentMaxRate attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000b")) { - NextTest(); - return; - } - err = TestStep13ThReadsCurrentMaxRateAttributeConstraints_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads OverrunCount attribute constraints\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000c")) { - NextTest(); - return; - } - err = TestStep14ThReadsOverrunCountAttributeConstraints_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsBssidAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBSSIDWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads BSSID attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads BSSID attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("bssid", "octet_string", "octet_string")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsSecurityTypeAttributeConstraints_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSecurityTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads SecurityType attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads SecurityType attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("securityType", "enum8", "enum8")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsWiFiVersionAttributeConstraints_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWiFiVersionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads WiFiVersion attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads WiFiVersion attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("wiFiVersion", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("wiFiVersion", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("wiFiVersion", [value unsignedCharValue], 6U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsChannelNumberAttributeConstraints_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelNumberWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads ChannelNumber attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads ChannelNumber attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("channelNumber", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("channelNumber", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("channelNumber", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsRssiAttributeConstraints_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRSSIWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads RSSI attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads RSSI attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("rssi", "int8s", "int8s")); - VerifyOrReturn(CheckConstraintMinValue("rssi", [value charValue], -120)); - VerifyOrReturn(CheckConstraintMaxValue("rssi", [value charValue], 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsBeaconLostCountAttributeConstraints_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconLostCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads BeaconLostCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads BeaconLostCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconLostCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconLostCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconLostCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsBeaconRxCountAttributeConstraints_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads BeaconRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads BeaconRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsPacketMulticastRxCountAttributeConstraints_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads PacketMulticastRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads PacketMulticastRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThReadsPacketMulticastTxCountAttributeConstraints_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH reads PacketMulticastTxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 10: TH reads PacketMulticastTxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThReadsPacketUnicastRxCountAttributeConstraints_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH reads PacketUnicastRxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 11: TH reads PacketUnicastRxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThReadsPacketUnicastTxCountAttributeConstraints_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH reads PacketUnicastTxCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 12: TH reads PacketUnicastTxCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThReadsCurrentMaxRateAttributeConstraints_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentMaxRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH reads CurrentMaxRate attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 13: TH reads CurrentMaxRate attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentMaxRate", "int64u", "int64u")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep14ThReadsOverrunCountAttributeConstraints_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 14: TH reads OverrunCount attribute constraints: Error: %@", err); - } else { - NSLog(@"Step 14: TH reads OverrunCount attribute constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("overrunCount", "int64u", "int64u")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGWIFI_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGWIFI_2_3() - : TestCommandBridge("Test_TC_DGWIFI_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGWIFI_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TWait for the commissioned device to be retrieved\n"); - err = TestStep1TWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH sends ResetCounts command to DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsResetCountsCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads BeaconLostCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0005")) { - NextTest(); - return; - } - err = TestStep2aThReadsBeaconLostCountAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads BeaconRxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0006")) { - NextTest(); - return; - } - err = TestStep2bThReadsBeaconRxCountAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: TH reads PacketMulticastRxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0007")) { - NextTest(); - return; - } - err = TestStep2cThReadsPacketMulticastRxCountAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: TH reads PacketMulticastTxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0008")) { - NextTest(); - return; - } - err = TestStep2dThReadsPacketMulticastTxCountAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2e: TH reads PacketUnicastRxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0009")) { - NextTest(); - return; - } - err = TestStep2eThReadsPacketUnicastRxCountAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2f: TH reads PacketUnicastTxCount attribute from DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A000a")) { - NextTest(); - return; - } - err = TestStep2fThReadsPacketUnicastTxCountAttributeFromDut_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1TWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThSendsResetCountsCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resetCountsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends ResetCounts command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends ResetCounts command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsBeaconLostCountAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconLostCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads BeaconLostCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads BeaconLostCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconLostCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconLostCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconLostCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsBeaconRxCountAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBeaconRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads BeaconRxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads BeaconRxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("beaconRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("beaconRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("beaconRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsPacketMulticastRxCountAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads PacketMulticastRxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads PacketMulticastRxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThReadsPacketMulticastTxCountAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketMulticastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads PacketMulticastTxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads PacketMulticastTxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetMulticastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetMulticastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetMulticastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThReadsPacketUnicastRxCountAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads PacketUnicastRxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads PacketUnicastRxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastRxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastRxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastRxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsPacketUnicastTxCountAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePacketUnicastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads PacketUnicastTxCount attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads PacketUnicastTxCount attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("packetUnicastTxCount", "int32u", "int32u")); - VerifyOrReturn(CheckConstraintMinValue("packetUnicastTxCount", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("packetUnicastTxCount", [value unsignedIntValue], 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_1_1() - : TestCommandBridge("Test_TC_WNCV_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); - if (ShouldSkip("!WNCV.S.F00 && !WNCV.S.F01 && !WNCV.S.F02 && !WNCV.S.F03 && !WNCV.S.F04 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenWncvsf00lfEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenWncvsf01tlEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenWncvsf02paLfEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep3eGivenWncvsf03absEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep3fGivenWncvsf04paTlEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList\n"); - if (ShouldSkip("WNCV.S.A001a")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeSafetyStatusInAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheFeatureDependentWNCVSF00Wncvsf02Wncvsf03AttributeInAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheFeatureDependentWNCVSF00Wncvsf02AttributeInAttributeList_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheFeatureDependentWNCVSF01Wncvsf04Wncvsf03AttributeInAttributeList_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsTheFeatureDependentWNCVSF01Wncvsf04AttributeInAttributeList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute\n"); - err = TestStep6aThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentWNCVSF00Wncvsf02CommandInAcceptedCommandList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F03")) { - NextTest(); - return; - } - err = TestStep6cThReadsFeatureDependentWNCVSF01Wncvsf03CommandInAcceptedCommandList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep6dThReadsFeatureDependentWNCVSF01Wncvsf04CommandInAcceptedCommandList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); - err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("clusterRevision", [value unsignedShortValue], 5U)); - VerifyOrReturn(CheckConstraintMaxValue("clusterRevision", [value unsignedShortValue], 200U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenWncvsf00lfEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenWncvsf01tlEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenWncvsf02paLfEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenWncvsf03absEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenWncvsf04paTlEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeSafetyStatusInAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheFeatureDependentWNCVSF00Wncvsf02Wncvsf03AttributeInAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheFeatureDependentWNCVSF00Wncvsf02AttributeInAttributeList_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheFeatureDependentWNCVSF01Wncvsf04Wncvsf03AttributeInAttributeList_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsTheFeatureDependentWNCVSF01Wncvsf04AttributeInAttributeList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentWNCVSF00Wncvsf02CommandInAcceptedCommandList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsFeatureDependentWNCVSF01Wncvsf03CommandInAcceptedCommandList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsFeatureDependentWNCVSF01Wncvsf04CommandInAcceptedCommandList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_1() - : TestCommandBridge("Test_TC_WNCV_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads from the DUT the ( 0) Type attribute\n"); - if (ShouldSkip("WNCV.S.A0000")) { - NextTest(); - return; - } - err = TestStep1aThReadsFromTheDutThe0TypeAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute\n"); - if (ShouldSkip("WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1bThReadsFromTheDutThe7ConfigStatusAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep1cThReadsFromTheDutThe10OperationalStatusAttributeOperationalStatus_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads from the DUT the (13) EndProductType attribute\n"); - if (ShouldSkip("WNCV.S.A000d")) { - NextTest(); - return; - } - err = TestStep1dThReadsFromTheDutThe13EndProductTypeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads from the DUT the (23) Mode attribute\n"); - if (ShouldSkip("WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1eThReadsFromTheDutThe23ModeAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH writes to (23) Mode attribute the value 0\n"); - if (ShouldSkip("WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1fThWritesTo23ModeAttributeTheValue0_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2aThReadsFromTheDutThe11TargetPositionLiftPercent100thsAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2bThReadsFromTheDutThe12TargetPositionTiltPercent100thsAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep2cThReadsFromTheDutThe14CurrentPositionLiftPercent100thsAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute\n"); - if (ShouldSkip("WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep2dThReadsFromTheDutThe15CurrentPositionTiltPercent100thsAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute\n"); - if (ShouldSkip("WNCV.S.A0010")) { - NextTest(); - return; - } - err = TestStep2eThReadsFromTheDutThe16InstalledOpenLimitLiftAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute\n"); - if (ShouldSkip("WNCV.S.A0011")) { - NextTest(); - return; - } - err = TestStep2fThReadsFromTheDutThe17InstalledClosedLimitLiftAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0012")) { - NextTest(); - return; - } - err = TestStep2gThReadsFromTheDutThe18InstalledOpenLimitTiltAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0013")) { - NextTest(); - return; - } - err = TestStep2hThReadsFromTheDutThe19InstalledClosedLimitTiltAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH reads from the DUT the (26) SafetyStatus attribute\n"); - if (ShouldSkip("WNCV.S.A001a")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutThe26SafetyStatusAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute\n"); - if (ShouldSkip("WNCV.S.A0001")) { - NextTest(); - return; - } - err = TestStep3bThReadsFromTheDutThe1PhysicalClosedLimitLiftAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0002")) { - NextTest(); - return; - } - err = TestStep3cThReadsFromTheDutThe2PhysicalClosedLimitTiltAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute\n"); - if (ShouldSkip("WNCV.S.A0003 && !WNCV.S.A0010 && !WNCV.S.A0011")) { - NextTest(); - return; - } - err = TestStep3dThReadsFromTheDutThe3CurrentPositionLiftAttribute_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3d: TH reads the RO optional attribute default: CurrentPositionLift\n"); - if (ShouldSkip("WNCV.S.A0003 && WNCV.S.A0010 && WNCV.S.A0011")) { - NextTest(); - return; - } - err = TestStep3dThReadsTheRoOptionalAttributeDefaultCurrentPositionLift_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0004 && !WNCV.S.A0012 && !WNCV.S.A0013")) { - NextTest(); - return; - } - err = TestStep3eThReadsFromTheDutThe4CurrentPositionTiltAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt\n"); - if (ShouldSkip("WNCV.S.A0004 && WNCV.S.A0012 && WNCV.S.A0013")) { - NextTest(); - return; - } - err = TestStep3eThReadsTheRoOptionalAttributeDefaultCurrentPositionTilt_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute\n"); - if (ShouldSkip("WNCV.S.A0005")) { - NextTest(); - return; - } - err = TestStep3fThReadsFromTheDutThe5NumberOfActuationsLiftAttribute_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute\n"); - if (ShouldSkip("WNCV.S.A0006")) { - NextTest(); - return; - } - err = TestStep3gThReadsFromTheDutThe6NumberOfActuationsTiltAttribute_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute\n"); - if (ShouldSkip("WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3hThReadsFromTheDutThe8CurrentPositionLiftPercentageAttribute_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute\n"); - if (ShouldSkip("WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3iThReadsFromTheDutThe9CurrentPositionTiltPercentageAttribute_25(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 26; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThReadsFromTheDutThe0TypeAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads from the DUT the ( 0) Type attribute: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads from the DUT the ( 0) Type attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("type", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("type", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("type", [value unsignedCharValue], 9U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsFromTheDutThe7ConfigStatusAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsFromTheDutThe10OperationalStatusAttributeOperationalStatus_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("operationalStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("operationalStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsFromTheDutThe13EndProductTypeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndProductTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads from the DUT the (13) EndProductType attribute: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads from the DUT the (13) EndProductType attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endProductType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("endProductType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("endProductType", [value unsignedCharValue], 23U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThReadsFromTheDutThe23ModeAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads from the DUT the (23) Mode attribute: Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads from the DUT the (23) Mode attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("mode", "bitmap8", "bitmap8")); - VerifyOrReturn(CheckConstraintMinValue("mode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("mode", [value unsignedCharValue], 15U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fThWritesTo23ModeAttributeTheValue0_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: TH writes to (23) Mode attribute the value 0: Error: %@", err); - } else { - NSLog(@"Step 1f: TH writes to (23) Mode attribute the value 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThReadsFromTheDutThe11TargetPositionLiftPercent100thsAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThReadsFromTheDutThe12TargetPositionTiltPercent100thsAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThReadsFromTheDutThe14CurrentPositionLiftPercent100thsAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThReadsFromTheDutThe15CurrentPositionTiltPercent100thsAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute: Error: %@", err); - } else { - NSLog(@"Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledOpenLimitLiftValue; - - CHIP_ERROR TestStep2eThReadsFromTheDutThe16InstalledOpenLimitLiftAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledOpenLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedOpenLimitLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedOpenLimitLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedOpenLimitLift", [value unsignedShortValue], 65535U)); - { - InstalledOpenLimitLiftValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledClosedLimitLiftValue; - - CHIP_ERROR TestStep2fThReadsFromTheDutThe17InstalledClosedLimitLiftAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledClosedLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedClosedLimitLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedClosedLimitLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedClosedLimitLift", [value unsignedShortValue], 65535U)); - { - InstalledClosedLimitLiftValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledOpenLimitTiltValue; - - CHIP_ERROR TestStep2gThReadsFromTheDutThe18InstalledOpenLimitTiltAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledOpenLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedOpenLimitTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedOpenLimitTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedOpenLimitTilt", [value unsignedShortValue], 65535U)); - { - InstalledOpenLimitTiltValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull InstalledClosedLimitTiltValue; - - CHIP_ERROR TestStep2hThReadsFromTheDutThe19InstalledClosedLimitTiltAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInstalledClosedLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("installedClosedLimitTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("installedClosedLimitTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("installedClosedLimitTilt", [value unsignedShortValue], 65535U)); - { - InstalledClosedLimitTiltValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutThe26SafetyStatusAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSafetyStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the (26) SafetyStatus attribute: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the (26) SafetyStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("safetyStatus", "bitmap16", "bitmap16")); - VerifyOrReturn(CheckConstraintMinValue("safetyStatus", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("safetyStatus", [value unsignedShortValue], 2047U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFromTheDutThe1PhysicalClosedLimitLiftAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalClosedLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalClosedLimitLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalClosedLimitLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalClosedLimitLift", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFromTheDutThe2PhysicalClosedLimitTiltAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhysicalClosedLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("physicalClosedLimitTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("physicalClosedLimitTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("physicalClosedLimitTilt", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsFromTheDutThe3CurrentPositionLiftAttribute_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLift", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsTheRoOptionalAttributeDefaultCurrentPositionLift_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads the RO optional attribute default: CurrentPositionLift: Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads the RO optional attribute default: CurrentPositionLift: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLift", [value unsignedShortValue], InstalledOpenLimitLiftValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLift", [value unsignedShortValue], InstalledClosedLimitLiftValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThReadsFromTheDutThe4CurrentPositionTiltAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTilt", [value unsignedShortValue], 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThReadsTheRoOptionalAttributeDefaultCurrentPositionTilt_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTilt", [value unsignedShortValue], InstalledOpenLimitTiltValue)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTilt", [value unsignedShortValue], InstalledClosedLimitTiltValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsFromTheDutThe5NumberOfActuationsLiftAttribute_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfActuationsLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("numberOfActuationsLift", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("numberOfActuationsLift", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfActuationsLift", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gThReadsFromTheDutThe6NumberOfActuationsTiltAttribute_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfActuationsTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute: Error: %@", err); - } else { - NSLog(@"Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("numberOfActuationsTilt", "int16u", "int16u")); - VerifyOrReturn(CheckConstraintMinValue("numberOfActuationsTilt", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfActuationsTilt", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hThReadsFromTheDutThe8CurrentPositionLiftPercentageAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute: Error: %@", err); - } else { - NSLog(@"Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iThReadsFromTheDutThe9CurrentPositionTiltPercentageAttribute_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute: Error: %@", err); - } else { - NSLog(@"Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_2() - : TestCommandBridge("Test_TC_WNCV_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b\n"); - if (ShouldSkip("WNCV.S.A0007 && WNCV.S.F00 && WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep1aThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b\n"); - if (ShouldSkip("WNCV.S.A0007 && !WNCV.S.F00 && !WNCV.S.F02")) { - NextTest(); - return; - } - err = TestStep1bThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,\n"); - if (ShouldSkip("WNCV.S.A0007 && WNCV.S.F01 && WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep1cThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,\n"); - if (ShouldSkip("WNCV.S.A0007 && !WNCV.S.F01 && !WNCV.S.F04")) { - NextTest(); - return; - } - err = TestStep1dThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational)\n"); - if (ShouldSkip("WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1eThReadsConfigStatusAttributeFromDutValueOfBit0MustBe1bOperational_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThReadsConfigStatusAttributeFromDutValueOfBit0MustBe1bOperational_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational): Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_3() - : TestCommandBridge("Test_TC_WNCV_2_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step Wait for the commissioned device to be retrieved\n"); - err = TestStepWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH set the Mode Attribute bit0 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1aThSetTheModeAttributeBit0OfTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1bThReadsConfigStatusAttributeFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH clear the Mode Attribute bit0 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep1cThClearTheModeAttributeBit0OfTheDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep1dThReadsConfigStatusAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH set the Mode Attribute bit1 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep2aThSetTheModeAttributeBit1OfTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep2bThReadsConfigStatusAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2cIfConfigStatusBit00ThSendDownOrCloseCommandToTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2d: TH clear the Mode Attribute bit1 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep2dThClearTheModeAttributeBit1OfTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2e: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep2eThReadsConfigStatusAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2f: TH reads the Mode Attribute from the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep2fThReadsTheModeAttributeFromTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2g: TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2gThSendDownOrCloseCommandToTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH set the Mode Attribute bit2 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep3aThSetTheModeAttributeBit2OfTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3b: TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3bThSendDownOrCloseCommandToTheDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3c: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep3cThReadsConfigStatusAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH clear the Mode Attribute bit2 of the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0017")) { - NextTest(); - return; - } - err = TestStep3dThClearTheModeAttributeBit2OfTheDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3e: TH send DownOrClose command to the DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep3eThSendDownOrCloseCommandToTheDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3f: TH reads ConfigStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0007")) { - NextTest(); - return; - } - err = TestStep3fThReadsConfigStatusAttributeFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_BUSY)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStepWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSetTheModeAttributeBit0OfTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH set the Mode Attribute bit0 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH set the Mode Attribute bit0 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsConfigStatusAttributeFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 4U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThClearTheModeAttributeBit0OfTheDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH clear the Mode Attribute bit0 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH clear the Mode Attribute bit0 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsConfigStatusAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSetTheModeAttributeBit1OfTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH set the Mode Attribute bit1 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH set the Mode Attribute bit1 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull configStatusValA; - - CHIP_ERROR TestStep2bThReadsConfigStatusAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - { - configStatusValA = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cIfConfigStatusBit00ThSendDownOrCloseCommandToTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThClearTheModeAttributeBit1OfTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: TH clear the Mode Attribute bit1 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: TH clear the Mode Attribute bit1 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThReadsConfigStatusAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2fThReadsTheModeAttributeFromTheDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2f: TH reads the Mode Attribute from the DUT: Error: %@", err); - } else { - NSLog(@"Step 2f: TH reads the Mode Attribute from the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("mode", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("mode", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2gThSendDownOrCloseCommandToTheDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2g: TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 2g: TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSetTheModeAttributeBit2OfTheDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH set the Mode Attribute bit2 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH set the Mode Attribute bit2 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendDownOrCloseCommandToTheDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_BUSY)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull configStatusValB; - - CHIP_ERROR TestStep3cThReadsConfigStatusAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - { - configStatusValB = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThClearTheModeAttributeBit2OfTheDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id modeArgument; - modeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH clear the Mode Attribute bit2 of the DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: TH clear the Mode Attribute bit2 of the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eThSendDownOrCloseCommandToTheDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH send DownOrClose command to the DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH send DownOrClose command to the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsConfigStatusAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads ConfigStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads ConfigStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_2_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_2_5() - : TestCommandBridge("Test_TC_WNCV_2_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_2_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads EndProductType attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000d")) { - NextTest(); - return; - } - err = TestStep1ThReadsEndProductTypeAttributeFromDut_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1ThReadsEndProductTypeAttributeFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEndProductTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads EndProductType attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads EndProductType attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("endProductType", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("endProductType", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("endProductType", [value unsignedCharValue], 23U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_1() - : TestCommandBridge("Test_TC_WNCV_3_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step1bWaitTime", 0, UINT16_MAX, &mStep1bWaitTime); - AddArgument("Step2bWaitTime", 0, UINT16_MAX, &mStep2bWaitTime); - AddArgument("Step2eWaitTime", 0, UINT16_MAX, &mStep2eWaitTime); - AddArgument("Step4bWaitTime", 0, UINT16_MAX, &mStep4bWaitTime); - AddArgument("Step5aWaitTime", 0, UINT16_MAX, &mStep5aWaitTime); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH Waits for 5 - 15 seconds movement(s) on the device\n"); - err = TestStep1bThWaitsFor515SecondsMovementsOnTheDevice_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH sends UpOrOpen command to DUT\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsUpOrOpenCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH waits for 1-5 seconds movement(s) on the DUT\n"); - err = TestStep2eThWaitsFor15SecondsMovementsOnTheDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a1: TH reads OperationalStatus attribute's bit 0..1\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3a1ThReadsOperationalStatusAttributesBit01_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3a2WriteAttributeBitmap8WithOperationalStatusValueToDoTheBitsChecksInUpcomingOperationalStatusReadSteps_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF))\n"); - if (ShouldSkip("WNCV.S.A000a && WNCV.S.F00")) { - NextTest(); - return; - } - err = TestStep3a3ThChecksOperationalStatusValueBit23Wncvsf00lf_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a4: TH check OperationalStatus value bit 2..3 (WNCV.S.F00(LF))\n"); - if (ShouldSkip("WNCV.S.A000a && !WNCV.S.F00")) { - NextTest(); - return; - } - err = TestStep3a4ThCheckOperationalStatusValueBit23Wncvsf00lf_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL))\n"); - if (ShouldSkip("WNCV.S.A000a && WNCV.S.F01")) { - NextTest(); - return; - } - err = TestStep3a5ThChecksOperationalStatusValueBit45Wncvsf01tl_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a6: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL))\n"); - if (ShouldSkip("WNCV.S.A000a && !WNCV.S.F01")) { - NextTest(); - return; - } - err = TestStep3a6ThChecksOperationalStatusValueBit45Wncvsf01tl_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3a7: DUT updates its attributes\n"); - err = TestStep3a7DutUpdatesItsAttributes_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4a: TH sends a StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAStopMotionCommandToDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); - err = TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4c: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep4cThReadsOperationalStatusAttributeFromDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5a: TH waits for 100-1000 ms\n"); - err = TestStep5aThWaitsFor1001000Ms_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_28(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 29; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep1bWaitTime; - chip::Optional mStep2bWaitTime; - chip::Optional mStep2eWaitTime; - chip::Optional mStep4bWaitTime; - chip::Optional mStep5aWaitTime; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDevice_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep1bWaitTime.HasValue() ? mStep1bWaitTime.Value() : 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsUpOrOpenCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2bWaitTime.HasValue() ? mStep2bWaitTime.Value() : 500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThWaitsFor15SecondsMovementsOnTheDut_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2eWaitTime.HasValue() ? mStep2eWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull OperationalStatusValue; - - CHIP_ERROR TestStep3a1ThReadsOperationalStatusAttributesBit01_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a1: TH reads OperationalStatus attribute's bit 0..1: Error: %@", err); - } else { - NSLog(@"Step 3a1: TH reads OperationalStatus attribute's bit 0..1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - { - OperationalStatusValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a2WriteAttributeBitmap8WithOperationalStatusValueToDoTheBitsChecksInUpcomingOperationalStatusReadSteps_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [OperationalStatusValue copy]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.: Error: %@", err); - } else { - NSLog(@"Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a3ThChecksOperationalStatusValueBit23Wncvsf00lf_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Error: %@", err); - } else { - NSLog(@"Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); - } - - VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a4ThCheckOperationalStatusValueBit23Wncvsf00lf_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a4: TH check OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Error: %@", err); - } else { - NSLog(@"Step 3a4: TH check OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); - } - - VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a5ThChecksOperationalStatusValueBit45Wncvsf01tl_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Error: %@", err); - } else { - NSLog(@"Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); - } - - VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a6ThChecksOperationalStatusValueBit45Wncvsf01tl_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a6: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Error: %@", err); - } else { - NSLog(@"Step 3a6: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); - } - - VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a7DutUpdatesItsAttributes_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 3000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAStopMotionCommandToDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_24() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep4bWaitTime.HasValue() ? mStep4bWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cThReadsOperationalStatusAttributeFromDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsFor1001000Ms_26() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep5aWaitTime.HasValue() ? mStep5aWaitTime.Value() : 500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_2() - : TestCommandBridge("Test_TC_WNCV_3_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("Step1bWaitTime", 0, UINT16_MAX, &mStep1bWaitTime); - AddArgument("Step2bWaitTime", 0, UINT16_MAX, &mStep2bWaitTime); - AddArgument("Step2eWaitTime", 0, UINT16_MAX, &mStep2eWaitTime); - AddArgument("Step4bWaitTime", 0, UINT16_MAX, &mStep4bWaitTime); - AddArgument("Step5aWaitTime", 0, UINT16_MAX, &mStep5aWaitTime); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH Waits for 10 seconds movement(s) on the device\n"); - err = TestStep1bThWaitsFor10SecondsMovementsOnTheDevice_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH sends DownOrClose command to DUT\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsDownOrCloseCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH leave the device moving for 2 seconds\n"); - err = TestStep2eThLeaveTheDeviceMovingFor2Seconds_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a1: TH reads OperationalStatus attribute's bit 0..1\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3a1ThReadsOperationalStatusAttributesBit01_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3a2WriteAttributeBitmap8WithOperationalStatusValueToDoTheBitsChecksInUpcomingOperationalStatusReadSteps_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF))\n"); - if (ShouldSkip("WNCV.S.A000a && WNCV.S.F00")) { - NextTest(); - return; - } - err = TestStep3a3ThChecksOperationalStatusValueBit23Wncvsf00lf_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a4: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF))\n"); - if (ShouldSkip("WNCV.S.A000a && !WNCV.S.F00")) { - NextTest(); - return; - } - err = TestStep3a4ThChecksOperationalStatusValueBit23Wncvsf00lf_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL))\n"); - if (ShouldSkip("WNCV.S.A000a && WNCV.S.F01")) { - NextTest(); - return; - } - err = TestStep3a5ThChecksOperationalStatusValueBit45Wncvsf01tl_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a6: TH chesks OperationalStatus value bit 4..5 (WNCV.S.F01(TL))\n"); - if (ShouldSkip("WNCV.S.A000a && !WNCV.S.F01")) { - NextTest(); - return; - } - err = TestStep3a6ThChesksOperationalStatusValueBit45Wncvsf01tl_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3a7: DUT updates its attributes\n"); - err = TestStep3a7DutUpdatesItsAttributes_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4a: TH sends a StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsAStopMotionCommandToDut_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); - err = TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4c: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep4cThReadsOperationalStatusAttributeFromDut_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5a: TH waits for 100-1000 ms\n"); - err = TestStep5aThWaitsFor1001000Ms_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_28(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 29; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mStep1bWaitTime; - chip::Optional mStep2bWaitTime; - chip::Optional mStep2eWaitTime; - chip::Optional mStep4bWaitTime; - chip::Optional mStep5aWaitTime; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor10SecondsMovementsOnTheDevice_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep1bWaitTime.HasValue() ? mStep1bWaitTime.Value() : 10000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 99U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsDownOrCloseCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2bWaitTime.HasValue() ? mStep2bWaitTime.Value() : 500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2eThLeaveTheDeviceMovingFor2Seconds_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep2eWaitTime.HasValue() ? mStep2eWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nonnull OperationalStatusValue; - - CHIP_ERROR TestStep3a1ThReadsOperationalStatusAttributesBit01_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a1: TH reads OperationalStatus attribute's bit 0..1: Error: %@", err); - } else { - NSLog(@"Step 3a1: TH reads OperationalStatus attribute's bit 0..1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - { - OperationalStatusValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a2WriteAttributeBitmap8WithOperationalStatusValueToDoTheBitsChecksInUpcomingOperationalStatusReadSteps_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [OperationalStatusValue copy]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.: Error: %@", err); - } else { - NSLog(@"Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a3ThChecksOperationalStatusValueBit23Wncvsf00lf_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Error: %@", err); - } else { - NSLog(@"Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); - } - - VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a4ThChecksOperationalStatusValueBit23Wncvsf00lf_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a4: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Error: %@", err); - } else { - NSLog(@"Step 3a4: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); - } - - VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a5ThChecksOperationalStatusValueBit45Wncvsf01tl_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Error: %@", err); - } else { - NSLog(@"Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); - } - - VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a6ThChesksOperationalStatusValueBit45Wncvsf01tl_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a6: TH chesks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Error: %@", err); - } else { - NSLog(@"Step 3a6: TH chesks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); - } - - VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3a7DutUpdatesItsAttributes_18() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 3000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsAStopMotionCommandToDut_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_24() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep4bWaitTime.HasValue() ? mStep4bWaitTime.Value() : 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cThReadsOperationalStatusAttributeFromDut_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsFor1001000Ms_26() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mStep5aWaitTime.HasValue() ? mStep5aWaitTime.Value() : 500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); - VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 1U)); - VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_3() - : TestCommandBridge("Test_TC_WNCV_3_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 6-8 seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsFor68SecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH waits for 1-5 seconds revert motion(s) on the DUT\n"); - err = TestStep1dThWaitsFor15SecondsRevertMotionsOnTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep1eThReadsOperationalStatusAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH waits for 2 seconds\n"); - err = TestStep1fThWaitsFor2Seconds_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute\n"); - err = TestReportStep2SubscribeToDutReportsOnOperationalStatusAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2: Subscribe to DUT reports on OperationalStatus attribute\n"); - err = TestStep2SubscribeToDutReportsOnOperationalStatusAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH sends a StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsAStopMotionCommandToDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); - err = TestStep2bThWaitsFor15SecondsEndOfMotionsOnTheDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2cThReadsOperationalStatusAttributeFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: TH waits for 100ms - 3s attributes update on the device\n"); - err = TestStep2dThWaitsFor100ms3sAttributesUpdateOnTheDevice_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2e: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2eThReadsOperationalStatusAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000c && WNCV.S.A000f && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor68SecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThWaitsFor15SecondsRevertMotionsOnTheDut_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1eThReadsOperationalStatusAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("operationalStatus", value, 0U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1fThWaitsFor2Seconds_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - bool testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_Test_TC_WNCV_3_3_OperationalStatus_Reported - = nil; - - CHIP_ERROR TestReportStep2SubscribeToDutReportsOnOperationalStatusAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_Test_TC_WNCV_3_3_OperationalStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute: Error: %@", err); - } else { - NSLog(@"Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); - testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2SubscribeToDutReportsOnOperationalStatusAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 4U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeOperationalStatusWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: Subscribe to DUT reports on OperationalStatus attribute: Error: %@", err); - } else { - NSLog(@"Step 2: Subscribe to DUT reports on OperationalStatus attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_Test_TC_WNCV_3_3_OperationalStatus_Reported - != nil) { - ResponseHandler callback = test_Test_TC_WNCV_3_3_OperationalStatus_Reported; - test_Test_TC_WNCV_3_3_OperationalStatus_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsAStopMotionCommandToDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends a StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends a StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor15SecondsEndOfMotionsOnTheDut_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 3000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsOperationalStatusAttributeFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThWaitsFor100ms3sAttributesUpdateOnTheDevice_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 2000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2eThReadsOperationalStatusAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2e: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2e: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable attrCurrentPositionLift; - - CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionLift = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionLift == nil) { - VerifyOrReturn(CheckValueNull("TargetPositionLiftPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, attrCurrentPositionLift)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable attrCurrentPositionTilt; - - CHIP_ERROR TestStep4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionTilt = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionTilt == nil) { - VerifyOrReturn(CheckValueNull("TargetPositionTiltPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, attrCurrentPositionTilt)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_4() - : TestCommandBridge("Test_TC_WNCV_3_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fastMotionDuration", 0, UINT16_MAX, &mFastMotionDuration); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 5-15 seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends UpOrOpen command to DUT\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsUpOrOpenCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2cThChecksOperationalStatusAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFastMotionDuration; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFastMotionDuration.HasValue() ? mFastMotionDuration.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsUpOrOpenCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThChecksOperationalStatusAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_3_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_3_5() - : TestCommandBridge("Test_TC_WNCV_3_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fastMotionDuration", 0, UINT16_MAX, &mFastMotionDuration); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_3_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends UpOrOpen command to DUT\n"); - if (ShouldSkip("WNCV.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsUpOrOpenCommandToDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 5-15 seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends DownOrClose command to DUT\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsDownOrCloseCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep2cThChecksOperationalStatusAttributeFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFastMotionDuration; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsUpOrOpenCommandToDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends UpOrOpen command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends UpOrOpen command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFastMotionDuration.HasValue() ? mFastMotionDuration.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aThSendsDownOrCloseCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThChecksOperationalStatusAttributeFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 10000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_1() - : TestCommandBridge("Test_TC_WNCV_4_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for x seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsForXSecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsGoToLiftPercentageCommandWith25PercentToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3bThChecksOperationalStatusAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep3dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToLiftPercentageCommandWith7520PercentToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH waits for 100-1000 ms\n"); - err = TestStep4bThWaitsFor1001000Ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { - NextTest(); - return; - } - err = TestStep4cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5b: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep5bThChecksOperationalStatusAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep5cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { - NextTest(); - return; - } - err = TestStep5dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsForXSecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionLiftPercent100ths", value, 0U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsGoToLiftPercentageCommandWith25PercentToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:2500U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 2500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThChecksOperationalStatusAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 2500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 25U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToLiftPercentageCommandWith7520PercentToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:7520U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor1001000Ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 7520U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bThChecksOperationalStatusAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 7520U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 75U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_2() - : TestCommandBridge("Test_TC_WNCV_4_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); - if (ShouldSkip("WNCV.S.C01.Rsp")) { - NextTest(); - return; - } - err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for x seconds movement(s) on the DUT\n"); - err = TestStep1bThWaitsForXSecondsMovementsOnTheDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsGoToTiltPercentageCommandWith30PercentToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH waits for 100-1000 ms\n"); - err = TestStep2bThWaitsFor1001000Ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep2cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH checks OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep3bThChecksOperationalStatusAttributeFromDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToTiltPercentageCommandWith6005PercentToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH waits for 100-1000 ms\n"); - err = TestStep4bThWaitsFor1001000Ms_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { - NextTest(); - return; - } - err = TestStep4cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); - err = TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5b: TH reads OperationalStatus attribute from DUT\n"); - if (ShouldSkip("WNCV.S.A000a")) { - NextTest(); - return; - } - err = TestStep5bThReadsOperationalStatusAttributeFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep5cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep5dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mFullMotionDuration; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster downOrCloseWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); - } else { - NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsForXSecondsMovementsOnTheDut_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionTiltPercent100ths", value, 0U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsGoToTiltPercentageCommandWith30PercentToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:3000U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor1001000Ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 3000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep3bThChecksOperationalStatusAttributeFromDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 3000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 30U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToTiltPercentageCommandWith6005PercentToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:6005U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThWaitsFor1001000Ms_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep4cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 6005U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep5bThReadsOperationalStatusAttributeFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH reads OperationalStatus attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5b: TH reads OperationalStatus attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 6005U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); - } else { - NSLog(@"Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 60U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_3 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_3() - : TestCommandBridge("Test_TC_WNCV_4_3") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_3() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_3\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_3\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1aIfPaLfLfThReadsCurrentPositionLiftPercent100thsFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep1b1cIfPaLfLfThReadsCurrentPositionLiftPercentageFromDutAssertCurrentPositionLiftPercent100ths100EqualsCurrentPositionLiftPercentage_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsGoToLiftPercentageCommandWithBadParamToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsGoToLiftPercentageCommandWith10001ToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable attrCurrentPositionLiftPercent100ths; - - CHIP_ERROR TestStep1aIfPaLfLfThReadsCurrentPositionLiftPercent100thsFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionLiftPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1b1cIfPaLfLfThReadsCurrentPositionLiftPercentageFromDutAssertCurrentPositionLiftPercent100ths100EqualsCurrentPositionLiftPercentage_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage: Error: %@", err); - } else { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, [attrCurrentPositionLiftPercent100ths unsignedShortValue] / 100U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsGoToLiftPercentageCommandWithBadParamToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:12288U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGoToLiftPercentageCommandWith10001ToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:10001U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_4() - : TestCommandBridge("Test_TC_WNCV_4_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); - err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep1aIfPaTlTlThReadsCurrentPositionTiltPercent100thsFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f && WNCV.S.A0009")) { - NextTest(); - return; - } - err = TestStep1b1cIfPaLfLfThReadsCurrentPositionTiltPercentageFromDutAssertCurrentPositionTiltPercent100ths100EqualsCurrentPositionTiltPercentage_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsGoToTiltPercentageCommandWithBadParamToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep3aThSendsGoToTiltPercentageCommandWith10001ToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsGoToTiltPercentageCommandWith0xFFFFToDut_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nullable attrCurrentPositionTiltPercent100ths; - - CHIP_ERROR TestStep1aIfPaTlTlThReadsCurrentPositionTiltPercent100thsFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); - } - { - attrCurrentPositionTiltPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1b1cIfPaLfLfThReadsCurrentPositionTiltPercentageFromDutAssertCurrentPositionTiltPercent100ths100EqualsCurrentPositionTiltPercentage_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage: Error: %@", err); - } else { - NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, [attrCurrentPositionTiltPercent100ths unsignedShortValue] / 100U)); - } - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsGoToTiltPercentageCommandWithBadParamToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:12288U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGoToTiltPercentageCommandWith10001ToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:10001U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsGoToTiltPercentageCommandWith0xFFFFToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_WNCV_4_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_WNCV_4_5() - : TestCommandBridge("Test_TC_WNCV_4_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_WNCV_4_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0a: Wait for the commissioned device to be retrieved\n"); - err = TestStep0aWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0b: TH sends UpOrOpen command to preposition the DUT\n"); - err = TestStep0bThSendsUpOrOpenCommandToPrepositionTheDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep1aIfPaLfLfThSendsGoToLiftPercentageCommandWith90ToDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1b: TH Waits for 100ms-1s\n"); - err = TestStep1bThWaitsFor100ms1s_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1c: TH sends StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep1cThSendsStopMotionCommandToDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1d: TH Waits for 100ms-1s\n"); - err = TestStep1dThWaitsFor100ms1s_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.C08.Rsp")) { - NextTest(); - return; - } - err = TestStep2aIfPaTlTlThSendsGoToTiltPercentageCommandWith90ToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH Waits for 100ms-1s\n"); - err = TestStep2bThWaitsFor100ms1s_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH sends StopMotion command to DUT\n"); - if (ShouldSkip("WNCV.S.C02.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThSendsStopMotionCommandToDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH Waits for 100ms-1s\n"); - err = TestStep2dThWaitsFor100ms1s_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3aThReadsCurrentPositionLiftPercent100thsFromDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3bThReadsCurrentPositionTiltPercent100thsFromDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: reboot/restart the DUT\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep3cRebootRestartTheDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step Reboot target device(DUT)\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStepRebootTargetDeviceDUT_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: Wait for the commissioned device to be retrieved\n"); - err = TestStep3dWaitForTheCommissionedDeviceToBeRetrieved_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { - NextTest(); - return; - } - err = TestStep3eThReadsCurrentPositionLiftPercent100thsFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT\n"); - if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { - NextTest(); - return; - } - err = TestStep3fThReadsCurrentPositionTiltPercent100thsFromDut_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep0aWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0bThSendsUpOrOpenCommandToPrepositionTheDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster upOrOpenWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH sends UpOrOpen command to preposition the DUT: Error: %@", err); - } else { - NSLog(@"Step 0b: TH sends UpOrOpen command to preposition the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aIfPaLfLfThSendsGoToLiftPercentageCommandWith90ToDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; - params.liftPercent100thsValue = - [NSNumber numberWithUnsignedShort:9000U]; - [cluster goToLiftPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWaitsFor100ms1s_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep1cThSendsStopMotionCommandToDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH sends StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH sends StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThWaitsFor100ms1s_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2aIfPaTlTlThSendsGoToTiltPercentageCommandWith90ToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; - params.tiltPercent100thsValue = - [NSNumber numberWithUnsignedShort:9000U]; - [cluster goToTiltPercentageWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT: Error: %@", err); - } else { - NSLog(@"Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThWaitsFor100ms1s_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThSendsStopMotionCommandToDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopMotionWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends StopMotion command to DUT: Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends StopMotion command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2dThWaitsFor100ms1s_9() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 500UL; - return WaitForMs("alpha", value); - } - NSNumber * _Nullable attrCurrentPositionLiftPercent100ths; - - CHIP_ERROR TestStep3aThReadsCurrentPositionLiftPercent100thsFromDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionLiftPercent100ths", value, 0U)); - { - attrCurrentPositionLiftPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable attrCurrentPositionTiltPercent100ths; - - CHIP_ERROR TestStep3bThReadsCurrentPositionTiltPercent100thsFromDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("currentPositionTiltPercent100ths", value, 0U)); - { - attrCurrentPositionTiltPercent100ths = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cRebootRestartTheDut_12() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestStepRebootTargetDeviceDUT_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3dWaitForTheCommissionedDeviceToBeRetrieved_14() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep3eThReadsCurrentPositionLiftPercent100thsFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionLiftPercent100ths == nil) { - VerifyOrReturn(CheckValueNull("CurrentPositionLiftPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, attrCurrentPositionLiftPercent100ths)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fThReadsCurrentPositionTiltPercent100thsFromDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); - } else { - NSLog(@"Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (attrCurrentPositionTiltPercent100ths == nil) { - VerifyOrReturn(CheckValueNull("CurrentPositionTiltPercent100ths", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); - VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, attrCurrentPositionTiltPercent100ths)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_TargetNavigatorCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_TargetNavigatorCluster() - : TestCommandBridge("TV_TargetNavigatorCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_TargetNavigatorCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_TargetNavigatorCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_TargetNavigatorCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Target Navigator list\n"); - err = TestReadAttributeTargetNavigatorList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute current navigator target\n"); - err = TestReadAttributeCurrentNavigatorTarget_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Navigate Target Request Command\n"); - err = TestNavigateTargetRequestCommand_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeTargetNavigatorList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTargetListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Target Navigator list: Error: %@", err); - } else { - NSLog(@"Read attribute Target Navigator list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TargetList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Identifier", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[0]).identifier, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[0]).name, @"exampleName")); - VerifyOrReturn(CheckValue("Identifier", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[1]).identifier, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[1]).name, @"exampleName")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCurrentNavigatorTarget_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute current navigator target: Error: %@", err); - } else { - NSLog(@"Read attribute current navigator target: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentTarget", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestNavigateTargetRequestCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTargetNavigatorClusterNavigateTargetParams alloc] init]; - params.target = - [NSNumber numberWithUnsignedChar:1U]; - params.data = @"1"; - [cluster navigateTargetWithParams:params completion: - ^(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Navigate Target Request Command: Error: %@", err); - } else { - NSLog(@"Navigate Target Request Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_AudioOutputCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_AudioOutputCluster() - : TestCommandBridge("TV_AudioOutputCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_AudioOutputCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_AudioOutputCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_AudioOutputCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Audio Output list\n"); - err = TestReadAttributeAudioOutputList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute current audio output\n"); - err = TestReadAttributeCurrentAudioOutput_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Select Output Command\n"); - err = TestSelectOutputCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Rename Output Command\n"); - err = TestRenameOutputCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute Audio Output list\n"); - err = TestReadAttributeAudioOutputList_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeAudioOutputList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Audio Output list: Error: %@", err); - } else { - NSLog(@"Read attribute Audio Output list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OutputList", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).name, @"HDMI")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).index, 3U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).name, @"HDMI")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCurrentAudioOutput_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentOutputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute current audio output: Error: %@", err); - } else { - NSLog(@"Read attribute current audio output: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentOutput", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSelectOutputCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterSelectOutputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - [cluster selectOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Select Output Command: Error: %@", err); - } else { - NSLog(@"Select Output Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRenameOutputCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAudioOutputClusterRenameOutputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - params.name = @"HDMI Test"; - [cluster renameOutputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Rename Output Command: Error: %@", err); - } else { - NSLog(@"Rename Output Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeAudioOutputList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Audio Output list: Error: %@", err); - } else { - NSLog(@"Read attribute Audio Output list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OutputList", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).name, @"HDMI Test")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).index, 3U)); - VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).outputType, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).name, @"HDMI")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ApplicationLauncherCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ApplicationLauncherCluster() - : TestCommandBridge("TV_ApplicationLauncherCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ApplicationLauncherCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ApplicationLauncherCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ApplicationLauncherCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Application Launcher list\n"); - err = TestReadAttributeApplicationLauncherList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute application launcher app\n"); - err = TestReadAttributeApplicationLauncherApp_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Launch App Command\n"); - err = TestLaunchAppCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Stop App Command\n"); - err = TestStopAppCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Hide App Command\n"); - err = TestHideAppCommand_5(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 6; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeApplicationLauncherList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCatalogListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Application Launcher list: Error: %@", err); - } else { - NSLog(@"Read attribute Application Launcher list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CatalogList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 123U)); - VerifyOrReturn(CheckValue("", actualValue[1], 456U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationLauncherApp_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentAppWithCompletion:^(MTRApplicationLauncherClusterApplicationEPStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application launcher app: Error: %@", err); - } else { - NSLog(@"Read attribute application launcher app: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CurrentApp", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLaunchAppCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterLaunchAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = - [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; - - params.data = - [[NSData alloc] initWithBytes:"data" length:4]; - [cluster launchAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch App Command: Error: %@", err); - } else { - NSLog(@"Launch App Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStopAppCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterStopAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = - [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; - - [cluster stopAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Stop App Command: Error: %@", err); - } else { - NSLog(@"Stop App Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestHideAppCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRApplicationLauncherClusterHideAppParams alloc] init]; - params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = - [NSNumber numberWithUnsignedShort:123U]; - ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; - - [cluster hideAppWithParams:params completion: - ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Hide App Command: Error: %@", err); - } else { - NSLog(@"Hide App Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_KeypadInputCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_KeypadInputCluster() - : TestCommandBridge("TV_KeypadInputCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_KeypadInputCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_KeypadInputCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_KeypadInputCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Key Command\n"); - err = TestSendKeyCommand_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendKeyCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; - params.keyCode = - [NSNumber numberWithUnsignedChar:3U]; - [cluster sendKeyWithParams:params completion: - ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Key Command: Error: %@", err); - } else { - NSLog(@"Send Key Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_AccountLoginCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_AccountLoginCluster() - : TestCommandBridge("TV_AccountLoginCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_AccountLoginCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_AccountLoginCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_AccountLoginCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Get Setup PIN Command\n"); - err = TestGetSetupPinCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Login Command\n"); - err = TestLoginCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Logout Command\n"); - err = TestLogoutCommand_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestGetSetupPinCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterGetSetupPINParams alloc] init]; - params.tempAccountIdentifier = @"asdf"; - [cluster getSetupPINWithParams:params completion: - ^(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Setup PIN Command: Error: %@", err); - } else { - NSLog(@"Get Setup PIN Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.setupPIN; - VerifyOrReturn(CheckValueAsString("SetupPIN", actualValue, @"tempPin123")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLoginCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLoginParams alloc] init]; - params.tempAccountIdentifier = @"asdf"; - params.setupPIN = @"tempPin123"; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster loginWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Login Command: Error: %@", err); - } else { - NSLog(@"Login Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLogoutCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAccountLoginClusterLogoutParams alloc] init]; - params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; - [cluster logoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Logout Command: Error: %@", err); - } else { - NSLog(@"Logout Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_WakeOnLanCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_WakeOnLanCluster() - : TestCommandBridge("TV_WakeOnLanCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_WakeOnLanCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_WakeOnLanCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_WakeOnLanCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read mac address\n"); - err = TestReadMacAddress_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadMacAddress_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMACAddressWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read mac address: Error: %@", err); - } else { - NSLog(@"Read mac address: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("MACAddress", value, 3)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ApplicationBasicCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ApplicationBasicCluster() - : TestCommandBridge("TV_ApplicationBasicCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ApplicationBasicCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ApplicationBasicCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ApplicationBasicCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute vendor name\n"); - err = TestReadAttributeVendorName_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute vendor id\n"); - err = TestReadAttributeVendorId_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute application name\n"); - err = TestReadAttributeApplicationName_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute product id\n"); - err = TestReadAttributeProductId_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute application status\n"); - err = TestReadAttributeApplicationStatus_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute application status\n"); - err = TestReadAttributeApplicationStatus_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute application version\n"); - err = TestReadAttributeApplicationVersion_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute application allowed vendor list\n"); - err = TestReadAttributeApplicationAllowedVendorList_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeVendorName_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor name: Error: %@", err); - } else { - NSLog(@"Read attribute vendor name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("VendorName", actualValue, @"exampleVendorName1")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorId_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor id: Error: %@", err); - } else { - NSLog(@"Read attribute vendor id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("VendorID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationName_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application name: Error: %@", err); - } else { - NSLog(@"Read attribute application name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("ApplicationName", actualValue, @"exampleName1")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeProductId_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeProductIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute product id: Error: %@", err); - } else { - NSLog(@"Read attribute product id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ProductID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationStatus_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application status: Error: %@", err); - } else { - NSLog(@"Read attribute application status: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationStatus_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationWithCompletion:^(MTRApplicationBasicClusterApplicationStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application status: Error: %@", err); - } else { - NSLog(@"Read attribute application status: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CatalogVendorID", ((MTRApplicationBasicClusterApplicationStruct *) actualValue).catalogVendorID, 123U)); - VerifyOrReturn(CheckValueAsString("ApplicationID", ((MTRApplicationBasicClusterApplicationStruct *) actualValue).applicationID, @"applicationId")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationVersion_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeApplicationVersionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application version: Error: %@", err); - } else { - NSLog(@"Read attribute application version: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("ApplicationVersion", actualValue, @"exampleVersion")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeApplicationAllowedVendorList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAllowedVendorListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute application allowed vendor list: Error: %@", err); - } else { - NSLog(@"Read attribute application allowed vendor list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AllowedVendorList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 456U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_MediaPlaybackCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_MediaPlaybackCluster() - : TestCommandBridge("TV_MediaPlaybackCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_MediaPlaybackCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_MediaPlaybackCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_MediaPlaybackCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute playback state\n"); - err = TestReadAttributePlaybackState_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute start time\n"); - err = TestReadAttributeStartTime_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute duration\n"); - err = TestReadAttributeDuration_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute position\n"); - err = TestReadAttributePosition_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute playback speed\n"); - err = TestReadAttributePlaybackSpeed_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute seek range end\n"); - err = TestReadAttributeSeekRangeEnd_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute seek range start\n"); - err = TestReadAttributeSeekRangeStart_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Media Playback Play Command\n"); - err = TestMediaPlaybackPlayCommand_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Media Playback Pause Command\n"); - err = TestMediaPlaybackPauseCommand_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Media Playback Stop Command\n"); - err = TestMediaPlaybackStopCommand_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Media Playback Start Over Command\n"); - err = TestMediaPlaybackStartOverCommand_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Media Playback Previous Command\n"); - err = TestMediaPlaybackPreviousCommand_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Media Playback Next Command\n"); - err = TestMediaPlaybackNextCommand_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Media Playback Rewind Command\n"); - err = TestMediaPlaybackRewindCommand_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Media Playback Fast Forward Command\n"); - err = TestMediaPlaybackFastForwardCommand_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Media Playback Skip Forward Command\n"); - err = TestMediaPlaybackSkipForwardCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read attribute position after skip forward\n"); - err = TestReadAttributePositionAfterSkipForward_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Media Playback Skip Backward Command\n"); - err = TestMediaPlaybackSkipBackwardCommand_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read attribute position after skip backward\n"); - err = TestReadAttributePositionAfterSkipBackward_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Media Playback Seek Command\n"); - err = TestMediaPlaybackSeekCommand_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute position after seek\n"); - err = TestReadAttributePositionAfterSeek_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributePlaybackState_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute playback state: Error: %@", err); - } else { - NSLog(@"Read attribute playback state: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeStartTime_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute start time: Error: %@", err); - } else { - NSLog(@"Read attribute start time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartTime", actualValue)); - VerifyOrReturn(CheckValue("StartTime", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDuration_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDurationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute duration: Error: %@", err); - } else { - NSLog(@"Read attribute duration: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("Duration", actualValue)); - VerifyOrReturn(CheckValue("Duration", actualValue, 80000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePosition_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position: Error: %@", err); - } else { - NSLog(@"Read attribute position: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePlaybackSpeed_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute playback speed: Error: %@", err); - } else { - NSLog(@"Read attribute playback speed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSeekRangeEnd_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeEndWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute seek range end: Error: %@", err); - } else { - NSLog(@"Read attribute seek range end: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SeekRangeEnd", actualValue)); - VerifyOrReturn(CheckValue("SeekRangeEnd", actualValue, 80000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSeekRangeStart_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSeekRangeStartWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute seek range start: Error: %@", err); - } else { - NSLog(@"Read attribute seek range start: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SeekRangeStart", actualValue)); - VerifyOrReturn(CheckValue("SeekRangeStart", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackPlayCommand_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster playWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Play Command: Error: %@", err); - } else { - NSLog(@"Media Playback Play Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackPauseCommand_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Pause Command: Error: %@", err); - } else { - NSLog(@"Media Playback Pause Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackStopCommand_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Stop Command: Error: %@", err); - } else { - NSLog(@"Media Playback Stop Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackStartOverCommand_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startOverWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Start Over Command: Error: %@", err); - } else { - NSLog(@"Media Playback Start Over Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackPreviousCommand_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster previousWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Previous Command: Error: %@", err); - } else { - NSLog(@"Media Playback Previous Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackNextCommand_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster nextWithCompletion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Next Command: Error: %@", err); - } else { - NSLog(@"Media Playback Next Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackRewindCommand_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; - [cluster rewindWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Rewind Command: Error: %@", err); - } else { - NSLog(@"Media Playback Rewind Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackFastForwardCommand_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; - [cluster fastForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Fast Forward Command: Error: %@", err); - } else { - NSLog(@"Media Playback Fast Forward Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackSkipForwardCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipForwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:500ULL]; - [cluster skipForwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Skip Forward Command: Error: %@", err); - } else { - NSLog(@"Media Playback Skip Forward Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePositionAfterSkipForward_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position after skip forward: Error: %@", err); - } else { - NSLog(@"Read attribute position after skip forward: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 500ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackSkipBackwardCommand_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSkipBackwardParams alloc] init]; - params.deltaPositionMilliseconds = - [NSNumber numberWithUnsignedLongLong:100ULL]; - [cluster skipBackwardWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Skip Backward Command: Error: %@", err); - } else { - NSLog(@"Media Playback Skip Backward Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePositionAfterSkipBackward_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position after skip backward: Error: %@", err); - } else { - NSLog(@"Read attribute position after skip backward: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 400ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMediaPlaybackSeekCommand_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; - params.position = - [NSNumber numberWithUnsignedLongLong:1000ULL]; - [cluster seekWithParams:params completion: - ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Media Playback Seek Command: Error: %@", err); - } else { - NSLog(@"Media Playback Seek Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePositionAfterSeek_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute position after seek: Error: %@", err); - } else { - NSLog(@"Read attribute position after seek: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); - VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); - VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); - VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 1000ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ChannelCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ChannelCluster() - : TestCommandBridge("TV_ChannelCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ChannelCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ChannelCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ChannelCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Channel list\n"); - err = TestReadAttributeChannelList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute channel lineup\n"); - err = TestReadAttributeChannelLineup_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute current channel\n"); - err = TestReadAttributeCurrentChannel_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Change Channel Command\n"); - err = TestChangeChannelCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Change Channel By Number Command\n"); - err = TestChangeChannelByNumberCommand_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Skip Channel Command\n"); - err = TestSkipChannelCommand_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that Skip Channel Command set correct current channel\n"); - err = TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Skip Channel Command\n"); - err = TestSkipChannelCommand_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Verify that Skip Channel Command set correct current channel\n"); - err = TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Test 1.1 - Start from Channel 3\n"); - err = TestTest11StartFromChannel3_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Test 1.2 - Skip Up By 1\n"); - err = TestTest12SkipUpBy1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Test 2.1 - Start from Channel 3\n"); - err = TestTest21StartFromChannel3_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Test 2.2 - Skip Up By 2\n"); - err = TestTest22SkipUpBy2_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Test 2.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Test 3.1 - Start from Channel 3\n"); - err = TestTest31StartFromChannel3_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Test 3.2 - Skip Up By 3\n"); - err = TestTest32SkipUpBy3_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Test 3.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Test 4.1 - Start from Channel 3\n"); - err = TestTest41StartFromChannel3_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Test 4.2 - Skip Up By 4\n"); - err = TestTest42SkipUpBy4_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Test 4.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Test 5.2 - Skip Up By 5\n"); - err = TestTest52SkipUpBy5_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Test 5.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Test 6.1 - Start from Channel 3\n"); - err = TestTest61StartFromChannel3_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Test 6.2 - Skip Up By 6\n"); - err = TestTest62SkipUpBy6_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Test 6.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Test 7.1 - Start from Channel 3\n"); - err = TestTest71StartFromChannel3_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Test 7.2 - Skip Up By 7\n"); - err = TestTest72SkipUpBy7_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Test 7.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Test 8.1 - Start from Channel 3\n"); - err = TestTest81StartFromChannel3_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Test 8.2 - Skip Up By 8\n"); - err = TestTest82SkipUpBy8_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Test 8.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Test 1.2 - Skip Down By 1\n"); - err = TestTest12SkipDownBy1_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Test 2.1 - Start from Channel 3\n"); - err = TestTest21StartFromChannel3_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Test 2.2 - Skip Down By 2\n"); - err = TestTest22SkipDownBy2_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Test 2.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Test 3.1 - Start from Channel 3\n"); - err = TestTest31StartFromChannel3_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Test 3.2 - Skip Down By 3\n"); - err = TestTest32SkipDownBy3_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Test 3.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Test 4.1 - Start from Channel 3\n"); - err = TestTest41StartFromChannel3_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Test 4.2 - Skip Down By 4\n"); - err = TestTest42SkipDownBy4_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Test 4.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Test 5.2 - Skip Down By 5\n"); - err = TestTest52SkipDownBy5_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Test 5.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Test 6.1 - Start from Channel 3\n"); - err = TestTest61StartFromChannel3_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Test 6.2 - Skip Down By 6\n"); - err = TestTest62SkipDownBy6_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Test 6.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Test 7.1 - Start from Channel 3\n"); - err = TestTest71StartFromChannel3_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Test 7.2 - Skip Down By 7\n"); - err = TestTest72SkipDownBy7_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Test 7.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Test 8.1 - Start from Channel 3\n"); - err = TestTest81StartFromChannel3_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Test 8.2 - Skip Down By 8\n"); - err = TestTest82SkipDownBy8_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Test 8.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Test 1.2 - Skip Up By 32,767\n"); - err = TestTest12SkipUpBy32767_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Test 1.1 - Start from Channel 3\n"); - err = TestTest11StartFromChannel3_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Test 1.2 - Skip Down By 32,768\n"); - err = TestTest12SkipDownBy32768_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); - err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_59(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 60; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeChannelList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Channel list: Error: %@", err); - } else { - NSLog(@"Read attribute Channel list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ChannelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).affiliateCallSign, @"KAAL")); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).affiliateCallSign, @"KCTS")); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).affiliateCallSign, @"KCTS")); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeChannelLineup_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLineupWithCompletion:^(MTRChannelClusterLineupInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute channel lineup: Error: %@", err); - } else { - NSLog(@"Read attribute channel lineup: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("Lineup", actualValue)); - VerifyOrReturn(CheckValueAsString("OperatorName", ((MTRChannelClusterLineupInfoStruct *) actualValue).operatorName, @"Comcast")); - VerifyOrReturn(CheckValueAsString("LineupName", ((MTRChannelClusterLineupInfoStruct *) actualValue).lineupName, @"Comcast King County")); - VerifyOrReturn(CheckValueAsString("PostalCode", ((MTRChannelClusterLineupInfoStruct *) actualValue).postalCode, @"98052")); - VerifyOrReturn(CheckValue("LineupInfoType", ((MTRChannelClusterLineupInfoStruct *) actualValue).lineupInfoType, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCurrentChannel_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute current channel: Error: %@", err); - } else { - NSLog(@"Read attribute current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeChannelCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelParams alloc] init]; - params.match = @"PBS"; - [cluster changeChannelWithParams:params completion: - ^(MTRChannelClusterChangeChannelResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change Channel Command: Error: %@", err); - } else { - NSLog(@"Change Channel Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeChannelByNumberCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:6U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:0U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change Channel By Number Command: Error: %@", err); - } else { - NSLog(@"Change Channel By Number Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSkipChannelCommand_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:2]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Skip Channel Command: Error: %@", err); - } else { - NSLog(@"Skip Channel Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSkipChannelCommand_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:123]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Skip Channel Command: Error: %@", err); - } else { - NSLog(@"Skip Channel Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest11StartFromChannel3_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 1.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipUpBy1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:1]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Up By 1: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Up By 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest21StartFromChannel3_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 2.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest22SkipUpBy2_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:2]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.2 - Skip Up By 2: Error: %@", err); - } else { - NSLog(@"Test 2.2 - Skip Up By 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest31StartFromChannel3_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 3.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest32SkipUpBy3_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:3]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.2 - Skip Up By 3: Error: %@", err); - } else { - NSLog(@"Test 3.2 - Skip Up By 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest41StartFromChannel3_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 4.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest42SkipUpBy4_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:4]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.2 - Skip Up By 4: Error: %@", err); - } else { - NSLog(@"Test 4.2 - Skip Up By 4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest52SkipUpBy5_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:5]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.2 - Skip Up By 5: Error: %@", err); - } else { - NSLog(@"Test 5.2 - Skip Up By 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest61StartFromChannel3_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 6.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest62SkipUpBy6_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:6]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.2 - Skip Up By 6: Error: %@", err); - } else { - NSLog(@"Test 6.2 - Skip Up By 6: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest71StartFromChannel3_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 7.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest72SkipUpBy7_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:7]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.2 - Skip Up By 7: Error: %@", err); - } else { - NSLog(@"Test 7.2 - Skip Up By 7: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest81StartFromChannel3_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 8.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest82SkipUpBy8_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:8]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.2 - Skip Up By 8: Error: %@", err); - } else { - NSLog(@"Test 8.2 - Skip Up By 8: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipDownBy1_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-1]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Down By 1: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Down By 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest21StartFromChannel3_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 2.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest22SkipDownBy2_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-2]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.2 - Skip Down By 2: Error: %@", err); - } else { - NSLog(@"Test 2.2 - Skip Down By 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest31StartFromChannel3_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 3.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest32SkipDownBy3_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-3]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.2 - Skip Down By 3: Error: %@", err); - } else { - NSLog(@"Test 3.2 - Skip Down By 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest41StartFromChannel3_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 4.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest42SkipDownBy4_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-4]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.2 - Skip Down By 4: Error: %@", err); - } else { - NSLog(@"Test 4.2 - Skip Down By 4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest52SkipDownBy5_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-5]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.2 - Skip Down By 5: Error: %@", err); - } else { - NSLog(@"Test 5.2 - Skip Down By 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest61StartFromChannel3_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 6.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest62SkipDownBy6_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-6]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.2 - Skip Down By 6: Error: %@", err); - } else { - NSLog(@"Test 6.2 - Skip Down By 6: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest71StartFromChannel3_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 7.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest72SkipDownBy7_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-7]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.2 - Skip Down By 7: Error: %@", err); - } else { - NSLog(@"Test 7.2 - Skip Down By 7: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest81StartFromChannel3_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 8.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest82SkipDownBy8_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-8]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.2 - Skip Down By 8: Error: %@", err); - } else { - NSLog(@"Test 8.2 - Skip Down By 8: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipUpBy32767_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:32767]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Up By 32,767: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Up By 32,767: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest11StartFromChannel3_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; - params.majorNumber = - [NSNumber numberWithUnsignedShort:9U]; - params.minorNumber = - [NSNumber numberWithUnsignedShort:2U]; - [cluster changeChannelByNumberWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.1 - Start from Channel 3: Error: %@", err); - } else { - NSLog(@"Test 1.1 - Start from Channel 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest12SkipDownBy32768_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; - params.count = - [NSNumber numberWithShort:-32768]; - [cluster skipChannelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.2 - Skip Down By 32,768: Error: %@", err); - } else { - NSLog(@"Test 1.2 - Skip Down By 32,768: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); - } else { - NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); - VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); - VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); - VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); - VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_LowPowerCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_LowPowerCluster() - : TestCommandBridge("TV_LowPowerCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_LowPowerCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_LowPowerCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_LowPowerCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Sleep Input Status Command\n"); - err = TestSleepInputStatusCommand_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSleepInputStatusCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster sleepWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Sleep Input Status Command: Error: %@", err); - } else { - NSLog(@"Sleep Input Status Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_ContentLauncherCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_ContentLauncherCluster() - : TestCommandBridge("TV_ContentLauncherCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_ContentLauncherCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_ContentLauncherCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_ContentLauncherCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute accept header list\n"); - err = TestReadAttributeAcceptHeaderList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute supported streaming protocols\n"); - err = TestReadAttributeSupportedStreamingProtocols_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Launch Content Command\n"); - err = TestLaunchContentCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Launch URL Command\n"); - err = TestLaunchUrlCommand_4(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 5; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeAcceptHeaderList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptHeaderWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute accept header list: Error: %@", err); - } else { - NSLog(@"Read attribute accept header list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptHeader", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], @"example")); - VerifyOrReturn(CheckValueAsString("", actualValue[1], @"example")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSupportedStreamingProtocols_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedStreamingProtocolsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute supported streaming protocols: Error: %@", err); - } else { - NSLog(@"Read attribute supported streaming protocols: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SupportedStreamingProtocols", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLaunchContentCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; - params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"exampleValue"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = @"name"; - ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = @"value"; - - ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; - } - - ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; - } - - params.autoPlay = - [NSNumber numberWithBool:true]; - params.data = @"exampleData"; - params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; - temp_4[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; - { - NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; - temp_6[0] = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; - } - ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; - } - - params.useCurrentContext = - [NSNumber numberWithBool:true]; - [cluster launchContentWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch Content Command: Error: %@", err); - } else { - NSLog(@"Launch Content Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestLaunchUrlCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; - params.contentURL = @"exampleUrl"; - params.displayString = @"exampleDisplayString"; - params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = @"exampleName"; - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).imageURL = @"exampleUrl"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).color = @"exampleColor"; - ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).width = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).height = - [NSNumber numberWithDouble:0]; - ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).metric = - [NSNumber numberWithUnsignedChar:0U]; - - [cluster launchURLWithParams:params completion: - ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Launch URL Command: Error: %@", err); - } else { - NSLog(@"Launch URL Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.data; - VerifyOrReturn(CheckValueAsString("Data", actualValue, @"exampleData")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TV_MediaInputCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TV_MediaInputCluster() - : TestCommandBridge("TV_MediaInputCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TV_MediaInputCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TV_MediaInputCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TV_MediaInputCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute media input list\n"); - err = TestReadAttributeMediaInputList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current media input\n"); - err = TestReadCurrentMediaInput_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Select Input Command\n"); - err = TestSelectInputCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Hide Input Status Command\n"); - err = TestHideInputStatusCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Show Input Status Command\n"); - err = TestShowInputStatusCommand_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Rename Input Command\n"); - err = TestRenameInputCommand_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute media input list\n"); - err = TestReadAttributeMediaInputList_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeMediaInputList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute media input list: Error: %@", err); - } else { - NSLog(@"Read attribute media input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("InputList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).name, @"HDMI")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).descriptionString, @"High-Definition Multimedia Interface")); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).descriptionString, @"High-Definition Multimedia Interface")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentMediaInput_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentInputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current media input: Error: %@", err); - } else { - NSLog(@"Read current media input: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentInput", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSelectInputCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterSelectInputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - [cluster selectInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Select Input Command: Error: %@", err); - } else { - NSLog(@"Select Input Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestHideInputStatusCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster hideInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Hide Input Status Command: Error: %@", err); - } else { - NSLog(@"Hide Input Status Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestShowInputStatusCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster showInputStatusWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Show Input Status Command: Error: %@", err); - } else { - NSLog(@"Show Input Status Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRenameInputCommand_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRMediaInputClusterRenameInputParams alloc] init]; - params.index = - [NSNumber numberWithUnsignedChar:1U]; - params.name = @"HDMI Test"; - [cluster renameInputWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Rename Input Command: Error: %@", err); - } else { - NSLog(@"Rename Input Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeMediaInputList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute media input list: Error: %@", err); - } else { - NSLog(@"Read attribute media input list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("InputList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).index, 1U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).name, @"HDMI Test")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).descriptionString, @"High-Definition Multimedia Interface")); - VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).index, 2U)); - VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).inputType, 4U)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).name, @"HDMI")); - VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).descriptionString, @"High-Definition Multimedia Interface")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCASERecovery : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCASERecovery() - : TestCommandBridge("TestCASERecovery") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCASERecovery() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCASERecovery\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCASERecovery\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read an attribute\n"); - err = TestReadAnAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Reboot the server\n"); - err = TestRebootTheServer_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Re-get our session, but without expiring sesssions\n"); - err = TestReGetOurSessionButWithoutExpiringSesssions_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read an attribute again\n"); - err = TestReadAnAttributeAgain_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Re-get our session, but without expiring sesssions\n"); - err = TestReGetOurSessionButWithoutExpiringSesssions_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read an attribute a third time\n"); - err = TestReadAnAttributeAThirdTime_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAnAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read an attribute: Error: %@", err); - } else { - NSLog(@"Read an attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DataModelRevision", actualValue, 17U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTheServer_2() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestReGetOurSessionButWithoutExpiringSesssions_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.expireExistingSession.Emplace(); - value.expireExistingSession.Value() = false; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAnAttributeAgain_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read an attribute again: Error: %@", err); - } else { - NSLog(@"Read an attribute again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReGetOurSessionButWithoutExpiringSesssions_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.expireExistingSession.Emplace(); - value.expireExistingSession.Value() = false; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAnAttributeAThirdTime_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read an attribute a third time: Error: %@", err); - } else { - NSLog(@"Read an attribute a third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DataModelRevision", actualValue, 17U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCluster() - : TestCommandBridge("TestCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Command\n"); - err = TestSendTestCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Not Handled Command\n"); - err = TestSendTestNotHandledCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Send Test Specific Command\n"); - err = TestSendTestSpecificCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Send failing Test Add Arguments Command\n"); - err = TestSendFailingTestAddArgumentsCommand_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute BOOLEAN Default Value\n"); - err = TestReadAttributeBooleanDefaultValue_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write attribute BOOLEAN True\n"); - err = TestWriteAttributeBooleanTrue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BOOLEAN True\n"); - err = TestReadAttributeBooleanTrue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write attribute BOOLEAN False\n"); - err = TestWriteAttributeBooleanFalse_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read attribute BOOLEAN False\n"); - err = TestReadAttributeBooleanFalse_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read attribute BITMAP8 Default Value\n"); - err = TestReadAttributeBitmap8DefaultValue_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Write attribute BITMAP8 Max Value\n"); - err = TestWriteAttributeBitmap8MaxValue_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read attribute BITMAP8 Max Value\n"); - err = TestReadAttributeBitmap8MaxValue_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Write attribute BITMAP8 Min Value\n"); - err = TestWriteAttributeBitmap8MinValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read attribute BITMAP8 Min Value\n"); - err = TestReadAttributeBitmap8MinValue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute BITMAP16 Default Value\n"); - err = TestReadAttributeBitmap16DefaultValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write attribute BITMAP16 Max Value\n"); - err = TestWriteAttributeBitmap16MaxValue_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read attribute BITMAP16 Max Value\n"); - err = TestReadAttributeBitmap16MaxValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Write attribute BITMAP16 Min Value\n"); - err = TestWriteAttributeBitmap16MinValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read attribute BITMAP16 Min Value\n"); - err = TestReadAttributeBitmap16MinValue_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Write attribute BITMAP32 Max Value\n"); - err = TestWriteAttributeBitmap32MaxValue_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute BITMAP32 Max Value\n"); - err = TestReadAttributeBitmap32MaxValue_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Write attribute BITMAP32 Min Value\n"); - err = TestWriteAttributeBitmap32MinValue_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Read attribute BITMAP32 Min Value\n"); - err = TestReadAttributeBitmap32MinValue_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Write attribute BITMAP64 Max Value\n"); - err = TestWriteAttributeBitmap64MaxValue_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read attribute BITMAP64 Max Value\n"); - err = TestReadAttributeBitmap64MaxValue_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Write attribute BITMAP64 Min Value\n"); - err = TestWriteAttributeBitmap64MinValue_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Read attribute BITMAP64 Min Value\n"); - err = TestReadAttributeBitmap64MinValue_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute INT8U Default Value\n"); - err = TestReadAttributeInt8uDefaultValue_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute INT8U Max Value\n"); - err = TestWriteAttributeInt8uMaxValue_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute INT8U Max Value\n"); - err = TestReadAttributeInt8uMaxValue_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Write attribute INT8U Min Value\n"); - err = TestWriteAttributeInt8uMinValue_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Read attribute INT8U Min Value\n"); - err = TestReadAttributeInt8uMinValue_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read attribute INT16U Default Value\n"); - err = TestReadAttributeInt16uDefaultValue_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Write attribute INT16U Max Value\n"); - err = TestWriteAttributeInt16uMaxValue_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read attribute INT16U Max Value\n"); - err = TestReadAttributeInt16uMaxValue_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Write attribute INT16U Min Value\n"); - err = TestWriteAttributeInt16uMinValue_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Read attribute INT16U Min Value\n"); - err = TestReadAttributeInt16uMinValue_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute INT32U Default Value\n"); - err = TestReadAttributeInt32uDefaultValue_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute INT32U Max Value\n"); - err = TestWriteAttributeInt32uMaxValue_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute INT32U Max Value\n"); - err = TestReadAttributeInt32uMaxValue_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Write attribute INT32U Min Value\n"); - err = TestWriteAttributeInt32uMinValue_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Read attribute INT32U Min Value\n"); - err = TestReadAttributeInt32uMinValue_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute INT64U Default Value\n"); - err = TestReadAttributeInt64uDefaultValue_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Write attribute INT64U Max Value\n"); - err = TestWriteAttributeInt64uMaxValue_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Read attribute INT64U Max Value\n"); - err = TestReadAttributeInt64uMaxValue_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Write attribute INT64U Min Value\n"); - err = TestWriteAttributeInt64uMinValue_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Read attribute INT64U Min Value\n"); - err = TestReadAttributeInt64uMinValue_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute INT8S Max Value\n"); - err = TestWriteAttributeInt8sMaxValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute INT8S Max Value\n"); - err = TestReadAttributeInt8sMaxValue_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Write attribute INT8S Min Value\n"); - err = TestWriteAttributeInt8sMinValue_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Read attribute INT8S Min Value\n"); - err = TestReadAttributeInt8sMinValue_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Write attribute INT8S Default Value\n"); - err = TestWriteAttributeInt8sDefaultValue_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Write attribute INT16S Max Value\n"); - err = TestWriteAttributeInt16sMaxValue_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Read attribute INT16S Max Value\n"); - err = TestReadAttributeInt16sMaxValue_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Write attribute INT16S Min Value\n"); - err = TestWriteAttributeInt16sMinValue_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Read attribute INT16S Min Value\n"); - err = TestReadAttributeInt16sMinValue_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Write attribute INT16S Default Value\n"); - err = TestWriteAttributeInt16sDefaultValue_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Write attribute INT32S Max Value\n"); - err = TestWriteAttributeInt32sMaxValue_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Read attribute INT32S Max Value\n"); - err = TestReadAttributeInt32sMaxValue_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Write attribute INT32S Min Value\n"); - err = TestWriteAttributeInt32sMinValue_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Read attribute INT32S Min Value\n"); - err = TestReadAttributeInt32sMinValue_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Write attribute INT32S Default Value\n"); - err = TestWriteAttributeInt32sDefaultValue_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Write attribute INT64S Max Value\n"); - err = TestWriteAttributeInt64sMaxValue_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Read attribute INT64S Max Value\n"); - err = TestReadAttributeInt64sMaxValue_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Write attribute INT64S Min Value\n"); - err = TestWriteAttributeInt64sMinValue_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Read attribute INT64S Min Value\n"); - err = TestReadAttributeInt64sMinValue_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Write attribute INT64S Default Value\n"); - err = TestWriteAttributeInt64sDefaultValue_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Read attribute SINGLE Default Value\n"); - err = TestReadAttributeSingleDefaultValue_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Write attribute SINGLE medium Value\n"); - err = TestWriteAttributeSingleMediumValue_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Read attribute SINGLE medium Value\n"); - err = TestReadAttributeSingleMediumValue_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Write attribute SINGLE large Value\n"); - err = TestWriteAttributeSingleLargeValue_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Read attribute SINGLE large Value\n"); - err = TestReadAttributeSingleLargeValue_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Write attribute SINGLE small Value\n"); - err = TestWriteAttributeSingleSmallValue_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Read attribute SINGLE small Value\n"); - err = TestReadAttributeSingleSmallValue_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Write attribute SINGLE Default Value\n"); - err = TestWriteAttributeSingleDefaultValue_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Read attribute SINGLE Default Value\n"); - err = TestReadAttributeSingleDefaultValue_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Read attribute DOUBLE Default Value\n"); - err = TestReadAttributeDoubleDefaultValue_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Write attribute DOUBLE medium Value\n"); - err = TestWriteAttributeDoubleMediumValue_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Read attribute DOUBLE medium Value\n"); - err = TestReadAttributeDoubleMediumValue_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Write attribute DOUBLE large Value\n"); - err = TestWriteAttributeDoubleLargeValue_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Read attribute DOUBLE large Value\n"); - err = TestReadAttributeDoubleLargeValue_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Write attribute DOUBLE small Value\n"); - err = TestWriteAttributeDoubleSmallValue_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Read attribute DOUBLE small Value\n"); - err = TestReadAttributeDoubleSmallValue_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Write attribute DOUBLE Default Value\n"); - err = TestWriteAttributeDoubleDefaultValue_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Read attribute DOUBLE Default Value\n"); - err = TestReadAttributeDoubleDefaultValue_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Read attribute ENUM8 Default Value\n"); - err = TestReadAttributeEnum8DefaultValue_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Write attribute ENUM8 Max Value\n"); - err = TestWriteAttributeEnum8MaxValue_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Read attribute ENUM8 Max Value\n"); - err = TestReadAttributeEnum8MaxValue_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Write attribute ENUM8 Min Value\n"); - err = TestWriteAttributeEnum8MinValue_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Read attribute ENUM8 Min Value\n"); - err = TestReadAttributeEnum8MinValue_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Read attribute ENUM16 Default Value\n"); - err = TestReadAttributeEnum16DefaultValue_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Write attribute ENUM16 Max Value\n"); - err = TestWriteAttributeEnum16MaxValue_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Read attribute ENUM16 Max Value\n"); - err = TestReadAttributeEnum16MaxValue_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Write attribute ENUM16 Min Value\n"); - err = TestWriteAttributeEnum16MinValue_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Read attribute ENUM16 Min Value\n"); - err = TestReadAttributeEnum16MinValue_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Read attribute OCTET_STRING Default Value\n"); - err = TestReadAttributeOctetStringDefaultValue_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Write attribute OCTET_STRING with embedded null\n"); - err = TestWriteAttributeOctetStringWithEmbeddedNull_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Read attribute OCTET_STRING with embedded null\n"); - err = TestReadAttributeOctetStringWithEmbeddedNull_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Write attribute OCTET_STRING with hex: format\n"); - err = TestWriteAttributeOctetStringWithHexFormat_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Read attribute OCTET_STRING with hex: format\n"); - err = TestReadAttributeOctetStringWithHexFormat_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Write attribute OCTET_STRING with weird chars\n"); - err = TestWriteAttributeOctetStringWithWeirdChars_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Read attribute OCTET_STRING with weird chars\n"); - err = TestReadAttributeOctetStringWithWeirdChars_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Write attribute OCTET_STRING\n"); - err = TestWriteAttributeOctetString_114(); - break; - case 115: - ChipLogProgress(chipTool, " ***** Test Step 115 : Read attribute OCTET_STRING\n"); - err = TestReadAttributeOctetString_115(); - break; - case 116: - ChipLogProgress(chipTool, " ***** Test Step 116 : Write attribute OCTET_STRING\n"); - err = TestWriteAttributeOctetString_116(); - break; - case 117: - ChipLogProgress(chipTool, " ***** Test Step 117 : Read attribute OCTET_STRING\n"); - err = TestReadAttributeOctetString_117(); - break; - case 118: - ChipLogProgress(chipTool, " ***** Test Step 118 : Write attribute OCTET_STRING\n"); - err = TestWriteAttributeOctetString_118(); - break; - case 119: - ChipLogProgress(chipTool, " ***** Test Step 119 : Read attribute LONG_OCTET_STRING Default Value\n"); - err = TestReadAttributeLongOctetStringDefaultValue_119(); - break; - case 120: - ChipLogProgress(chipTool, " ***** Test Step 120 : Write attribute LONG_OCTET_STRING\n"); - err = TestWriteAttributeLongOctetString_120(); - break; - case 121: - ChipLogProgress(chipTool, " ***** Test Step 121 : Read attribute LONG_OCTET_STRING\n"); - err = TestReadAttributeLongOctetString_121(); - break; - case 122: - ChipLogProgress(chipTool, " ***** Test Step 122 : Write attribute LONG_OCTET_STRING\n"); - err = TestWriteAttributeLongOctetString_122(); - break; - case 123: - ChipLogProgress(chipTool, " ***** Test Step 123 : Read attribute CHAR_STRING Default Value\n"); - err = TestReadAttributeCharStringDefaultValue_123(); - break; - case 124: - ChipLogProgress(chipTool, " ***** Test Step 124 : Write attribute CHAR_STRING\n"); - err = TestWriteAttributeCharString_124(); - break; - case 125: - ChipLogProgress(chipTool, " ***** Test Step 125 : Read attribute CHAR_STRING\n"); - err = TestReadAttributeCharString_125(); - break; - case 126: - ChipLogProgress(chipTool, " ***** Test Step 126 : Write attribute CHAR_STRING - Value too long\n"); - err = TestWriteAttributeCharStringValueTooLong_126(); - break; - case 127: - ChipLogProgress(chipTool, " ***** Test Step 127 : Read attribute CHAR_STRING\n"); - err = TestReadAttributeCharString_127(); - break; - case 128: - ChipLogProgress(chipTool, " ***** Test Step 128 : Write attribute CHAR_STRING - Empty\n"); - err = TestWriteAttributeCharStringEmpty_128(); - break; - case 129: - ChipLogProgress(chipTool, " ***** Test Step 129 : Read attribute LONG_CHAR_STRING Default Value\n"); - err = TestReadAttributeLongCharStringDefaultValue_129(); - break; - case 130: - ChipLogProgress(chipTool, " ***** Test Step 130 : Write attribute LONG_CHAR_STRING\n"); - err = TestWriteAttributeLongCharString_130(); - break; - case 131: - ChipLogProgress(chipTool, " ***** Test Step 131 : Read attribute LONG_CHAR_STRING\n"); - err = TestReadAttributeLongCharString_131(); - break; - case 132: - ChipLogProgress(chipTool, " ***** Test Step 132 : Write attribute LONG_CHAR_STRING\n"); - err = TestWriteAttributeLongCharString_132(); - break; - case 133: - ChipLogProgress(chipTool, " ***** Test Step 133 : Read attribute LIST_LONG_OCTET_STRING (for chunked read)\n"); - err = TestReadAttributeListLongOctetStringForChunkedRead_133(); - break; - case 134: - ChipLogProgress(chipTool, " ***** Test Step 134 : Write attribute LIST_LONG_OCTET_STRING (for chunked write)\n"); - err = TestWriteAttributeListLongOctetStringForChunkedWrite_134(); - break; - case 135: - ChipLogProgress(chipTool, " ***** Test Step 135 : Read attribute LIST_LONG_OCTET_STRING (for chunked read)\n"); - err = TestReadAttributeListLongOctetStringForChunkedRead_135(); - break; - case 136: - ChipLogProgress(chipTool, " ***** Test Step 136 : Write attribute LIST_LONG_OCTET_STRING (for chunked write)\n"); - err = TestWriteAttributeListLongOctetStringForChunkedWrite_136(); - break; - case 137: - ChipLogProgress(chipTool, " ***** Test Step 137 : Read attribute EPOCH_US Default Value\n"); - err = TestReadAttributeEpochUsDefaultValue_137(); - break; - case 138: - ChipLogProgress(chipTool, " ***** Test Step 138 : Write attribute EPOCH_US Max Value\n"); - err = TestWriteAttributeEpochUsMaxValue_138(); - break; - case 139: - ChipLogProgress(chipTool, " ***** Test Step 139 : Read attribute EPOCH_US Max Value\n"); - err = TestReadAttributeEpochUsMaxValue_139(); - break; - case 140: - ChipLogProgress(chipTool, " ***** Test Step 140 : Write attribute EPOCH_US Min Value\n"); - err = TestWriteAttributeEpochUsMinValue_140(); - break; - case 141: - ChipLogProgress(chipTool, " ***** Test Step 141 : Read attribute EPOCH_US Min Value\n"); - err = TestReadAttributeEpochUsMinValue_141(); - break; - case 142: - ChipLogProgress(chipTool, " ***** Test Step 142 : Read attribute EPOCH_S Default Value\n"); - err = TestReadAttributeEpochSDefaultValue_142(); - break; - case 143: - ChipLogProgress(chipTool, " ***** Test Step 143 : Write attribute EPOCH_S Max Value\n"); - err = TestWriteAttributeEpochSMaxValue_143(); - break; - case 144: - ChipLogProgress(chipTool, " ***** Test Step 144 : Read attribute EPOCH_S Max Value\n"); - err = TestReadAttributeEpochSMaxValue_144(); - break; - case 145: - ChipLogProgress(chipTool, " ***** Test Step 145 : Write attribute EPOCH_S Min Value\n"); - err = TestWriteAttributeEpochSMinValue_145(); - break; - case 146: - ChipLogProgress(chipTool, " ***** Test Step 146 : Read attribute EPOCH_S Min Value\n"); - err = TestReadAttributeEpochSMinValue_146(); - break; - case 147: - ChipLogProgress(chipTool, " ***** Test Step 147 : Read attribute UNSUPPORTED\n"); - err = TestReadAttributeUnsupported_147(); - break; - case 148: - ChipLogProgress(chipTool, " ***** Test Step 148 : Writeattribute UNSUPPORTED\n"); - err = TestWriteattributeUnsupported_148(); - break; - case 149: - ChipLogProgress(chipTool, " ***** Test Step 149 : Send Test Command to unsupported endpoint\n"); - err = TestSendTestCommandToUnsupportedEndpoint_149(); - break; - case 150: - ChipLogProgress(chipTool, " ***** Test Step 150 : Send Test Command to unsupported cluster\n"); - err = TestSendTestCommandToUnsupportedCluster_150(); - break; - case 151: - ChipLogProgress(chipTool, " ***** Test Step 151 : Read attribute vendor_id Default Value\n"); - err = TestReadAttributeVendorIdDefaultValue_151(); - break; - case 152: - ChipLogProgress(chipTool, " ***** Test Step 152 : Write attribute vendor_id\n"); - err = TestWriteAttributeVendorId_152(); - break; - case 153: - ChipLogProgress(chipTool, " ***** Test Step 153 : Read attribute vendor_id\n"); - err = TestReadAttributeVendorId_153(); - break; - case 154: - ChipLogProgress(chipTool, " ***** Test Step 154 : Restore attribute vendor_id\n"); - err = TestRestoreAttributeVendorId_154(); - break; - case 155: - ChipLogProgress(chipTool, " ***** Test Step 155 : Send a command with a vendor_id and enum\n"); - err = TestSendACommandWithAVendorIdAndEnum_155(); - break; - case 156: - ChipLogProgress(chipTool, " ***** Test Step 156 : Send a command with a vendor_id and invalid enum\n"); - err = TestSendACommandWithAVendorIdAndInvalidEnum_156(); - break; - case 157: - ChipLogProgress(chipTool, " ***** Test Step 157 : Send Test Command With Struct Argument and arg1.b is true\n"); - err = TestSendTestCommandWithStructArgumentAndArg1bIsTrue_157(); - break; - case 158: - ChipLogProgress(chipTool, " ***** Test Step 158 : Send Test Command With Struct Argument and arg1.b is false\n"); - err = TestSendTestCommandWithStructArgumentAndArg1bIsFalse_158(); - break; - case 159: - ChipLogProgress(chipTool, " ***** Test Step 159 : Send Test Command With Nested Struct Argument and arg1.c.b is true\n"); - err = TestSendTestCommandWithNestedStructArgumentAndArg1cbIsTrue_159(); - break; - case 160: - ChipLogProgress(chipTool, " ***** Test Step 160 : Send Test Command With Nested Struct Argument arg1.c.b is false\n"); - err = TestSendTestCommandWithNestedStructArgumentArg1cbIsFalse_160(); - break; - case 161: - ChipLogProgress(chipTool, " ***** Test Step 161 : Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true\n"); - err = TestSendTestCommandWithNestedStructListArgumentAndAllFieldsBOfArg1dAreTrue_161(); - break; - case 162: - ChipLogProgress(chipTool, " ***** Test Step 162 : Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false\n"); - err = TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfArg1dAreFalse_162(); - break; - case 163: - ChipLogProgress(chipTool, " ***** Test Step 163 : Send Test Command With Struct Argument and see what we get back\n"); - err = TestSendTestCommandWithStructArgumentAndSeeWhatWeGetBack_163(); - break; - case 164: - ChipLogProgress(chipTool, " ***** Test Step 164 : Send Test Command With List of INT8U and none of them is set to 0\n"); - err = TestSendTestCommandWithListOfInt8uAndNoneOfThemIsSetTo0_164(); - break; - case 165: - ChipLogProgress(chipTool, " ***** Test Step 165 : Send Test Command With List of INT8U and one of them is set to 0\n"); - err = TestSendTestCommandWithListOfInt8uAndOneOfThemIsSetTo0_165(); - break; - case 166: - ChipLogProgress(chipTool, " ***** Test Step 166 : Send Test Command With List of INT8U and get it reversed\n"); - err = TestSendTestCommandWithListOfInt8uAndGetItReversed_166(); - break; - case 167: - ChipLogProgress(chipTool, " ***** Test Step 167 : Send Test Command With empty List of INT8U and get an empty list back\n"); - err = TestSendTestCommandWithEmptyListOfInt8uAndGetAnEmptyListBack_167(); - break; - case 168: - ChipLogProgress(chipTool, " ***** Test Step 168 : Send Test Command With List of Struct Argument and arg1.b of first item is true\n"); - err = TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsTrue_168(); - break; - case 169: - ChipLogProgress(chipTool, " ***** Test Step 169 : Send Test Command With List of Struct Argument and arg1.b of first item is false\n"); - err = TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsFalse_169(); - break; - case 170: - ChipLogProgress(chipTool, " ***** Test Step 170 : Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true\n"); - err = TestSendTestCommandWithListOfNestedStructListArgumentAndAllFieldsBOfElementsOfArg1dAreTrue_170(); - break; - case 171: - ChipLogProgress(chipTool, " ***** Test Step 171 : Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false\n"); - err = TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfElementsOfArg1dAreFalse_171(); - break; - case 172: - ChipLogProgress(chipTool, " ***** Test Step 172 : Write attribute LIST With List of INT8U and none of them is set to 0\n"); - err = TestWriteAttributeListWithListOfInt8uAndNoneOfThemIsSetTo0_172(); - break; - case 173: - ChipLogProgress(chipTool, " ***** Test Step 173 : Read attribute LIST With List of INT8U\n"); - err = TestReadAttributeListWithListOfInt8u_173(); - break; - case 174: - ChipLogProgress(chipTool, " ***** Test Step 174 : Write attribute LIST With List of OCTET_STRING\n"); - err = TestWriteAttributeListWithListOfOctetString_174(); - break; - case 175: - ChipLogProgress(chipTool, " ***** Test Step 175 : Read attribute LIST With List of OCTET_STRING\n"); - err = TestReadAttributeListWithListOfOctetString_175(); - break; - case 176: - ChipLogProgress(chipTool, " ***** Test Step 176 : Write attribute LIST With List of LIST_STRUCT_OCTET_STRING\n"); - err = TestWriteAttributeListWithListOfListStructOctetString_176(); - break; - case 177: - ChipLogProgress(chipTool, " ***** Test Step 177 : Read attribute LIST With List of LIST_STRUCT_OCTET_STRING\n"); - err = TestReadAttributeListWithListOfListStructOctetString_177(); - break; - case 178: - ChipLogProgress(chipTool, " ***** Test Step 178 : Send Test Command with optional arg set.\n"); - err = TestSendTestCommandWithOptionalArgSet_178(); - break; - case 179: - ChipLogProgress(chipTool, " ***** Test Step 179 : Send Test Command without its optional arg.\n"); - err = TestSendTestCommandWithoutItsOptionalArg_179(); - break; - case 180: - ChipLogProgress(chipTool, " ***** Test Step 180 : Read list of structs containing nullables and optionals\n"); - err = TestReadListOfStructsContainingNullablesAndOptionals_180(); - break; - case 181: - ChipLogProgress(chipTool, " ***** Test Step 181 : Write list of structs containing nullables and optionals\n"); - err = TestWriteListOfStructsContainingNullablesAndOptionals_181(); - break; - case 182: - ChipLogProgress(chipTool, " ***** Test Step 182 : Read list of structs containing nullables and optionals after writing\n"); - err = TestReadListOfStructsContainingNullablesAndOptionalsAfterWriting_182(); - break; - case 183: - ChipLogProgress(chipTool, " ***** Test Step 183 : Write attribute NULLABLE_BOOLEAN null\n"); - err = TestWriteAttributeNullableBooleanNull_183(); - break; - case 184: - ChipLogProgress(chipTool, " ***** Test Step 184 : Read attribute NULLABLE_BOOLEAN null\n"); - err = TestReadAttributeNullableBooleanNull_184(); - break; - case 185: - ChipLogProgress(chipTool, " ***** Test Step 185 : Write attribute NULLABLE_BOOLEAN True\n"); - err = TestWriteAttributeNullableBooleanTrue_185(); - break; - case 186: - ChipLogProgress(chipTool, " ***** Test Step 186 : Read attribute NULLABLE_BOOLEAN True\n"); - err = TestReadAttributeNullableBooleanTrue_186(); - break; - case 187: - ChipLogProgress(chipTool, " ***** Test Step 187 : Read attribute NULLABLE_BOOLEAN not null\n"); - err = TestReadAttributeNullableBooleanNotNull_187(); - break; - case 188: - ChipLogProgress(chipTool, " ***** Test Step 188 : Write attribute NULLABLE_BITMAP8 Max Value\n"); - err = TestWriteAttributeNullableBitmap8MaxValue_188(); - break; - case 189: - ChipLogProgress(chipTool, " ***** Test Step 189 : Read attribute NULLABLE_BITMAP8 Max Value\n"); - err = TestReadAttributeNullableBitmap8MaxValue_189(); - break; - case 190: - ChipLogProgress(chipTool, " ***** Test Step 190 : Write attribute NULLABLE_BITMAP8 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap8InvalidValue_190(); - break; - case 191: - ChipLogProgress(chipTool, " ***** Test Step 191 : Read attribute NULLABLE_BITMAP8 unchanged Value\n"); - err = TestReadAttributeNullableBitmap8UnchangedValue_191(); - break; - case 192: - ChipLogProgress(chipTool, " ***** Test Step 192 : Write attribute NULLABLE_BITMAP8 null Value\n"); - err = TestWriteAttributeNullableBitmap8NullValue_192(); - break; - case 193: - ChipLogProgress(chipTool, " ***** Test Step 193 : Read attribute NULLABLE_BITMAP8 null Value\n"); - err = TestReadAttributeNullableBitmap8NullValue_193(); - break; - case 194: - ChipLogProgress(chipTool, " ***** Test Step 194 : Read attribute NULLABLE_BITMAP8 not 254 Value\n"); - err = TestReadAttributeNullableBitmap8Not254Value_194(); - break; - case 195: - ChipLogProgress(chipTool, " ***** Test Step 195 : Write attribute NULLABLE_BITMAP16 Max Value\n"); - err = TestWriteAttributeNullableBitmap16MaxValue_195(); - break; - case 196: - ChipLogProgress(chipTool, " ***** Test Step 196 : Read attribute NULLABLE_BITMAP16 Max Value\n"); - err = TestReadAttributeNullableBitmap16MaxValue_196(); - break; - case 197: - ChipLogProgress(chipTool, " ***** Test Step 197 : Write attribute NULLABLE_BITMAP16 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap16InvalidValue_197(); - break; - case 198: - ChipLogProgress(chipTool, " ***** Test Step 198 : Read attribute NULLABLE_BITMAP16 unchanged Value\n"); - err = TestReadAttributeNullableBitmap16UnchangedValue_198(); - break; - case 199: - ChipLogProgress(chipTool, " ***** Test Step 199 : Write attribute NULLABLE_BITMAP16 null Value\n"); - err = TestWriteAttributeNullableBitmap16NullValue_199(); - break; - case 200: - ChipLogProgress(chipTool, " ***** Test Step 200 : Read attribute NULLABLE_BITMAP16 null Value\n"); - err = TestReadAttributeNullableBitmap16NullValue_200(); - break; - case 201: - ChipLogProgress(chipTool, " ***** Test Step 201 : Write attribute NULLABLE_BITMAP32 Max Value\n"); - err = TestWriteAttributeNullableBitmap32MaxValue_201(); - break; - case 202: - ChipLogProgress(chipTool, " ***** Test Step 202 : Read attribute NULLABLE_BITMAP32 Max Value\n"); - err = TestReadAttributeNullableBitmap32MaxValue_202(); - break; - case 203: - ChipLogProgress(chipTool, " ***** Test Step 203 : Write attribute NULLABLE_BITMAP32 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap32InvalidValue_203(); - break; - case 204: - ChipLogProgress(chipTool, " ***** Test Step 204 : Read attribute NULLABLE_BITMAP32 unchanged Value\n"); - err = TestReadAttributeNullableBitmap32UnchangedValue_204(); - break; - case 205: - ChipLogProgress(chipTool, " ***** Test Step 205 : Write attribute NULLABLE_BITMAP32 null Value\n"); - err = TestWriteAttributeNullableBitmap32NullValue_205(); - break; - case 206: - ChipLogProgress(chipTool, " ***** Test Step 206 : Read attribute NULLABLE_BITMAP32 null Value\n"); - err = TestReadAttributeNullableBitmap32NullValue_206(); - break; - case 207: - ChipLogProgress(chipTool, " ***** Test Step 207 : Write attribute NULLABLE_BITMAP64 Max Value\n"); - err = TestWriteAttributeNullableBitmap64MaxValue_207(); - break; - case 208: - ChipLogProgress(chipTool, " ***** Test Step 208 : Read attribute NULLABLE_BITMAP64 Max Value\n"); - err = TestReadAttributeNullableBitmap64MaxValue_208(); - break; - case 209: - ChipLogProgress(chipTool, " ***** Test Step 209 : Write attribute NULLABLE_BITMAP64 Invalid Value\n"); - err = TestWriteAttributeNullableBitmap64InvalidValue_209(); - break; - case 210: - ChipLogProgress(chipTool, " ***** Test Step 210 : Read attribute NULLABLE_BITMAP64 unchanged Value\n"); - err = TestReadAttributeNullableBitmap64UnchangedValue_210(); - break; - case 211: - ChipLogProgress(chipTool, " ***** Test Step 211 : Write attribute NULLABLE_BITMAP64 null Value\n"); - err = TestWriteAttributeNullableBitmap64NullValue_211(); - break; - case 212: - ChipLogProgress(chipTool, " ***** Test Step 212 : Read attribute NULLABLE_BITMAP64 null Value\n"); - err = TestReadAttributeNullableBitmap64NullValue_212(); - break; - case 213: - ChipLogProgress(chipTool, " ***** Test Step 213 : Write attribute NULLABLE_INT8U Min Value\n"); - err = TestWriteAttributeNullableInt8uMinValue_213(); - break; - case 214: - ChipLogProgress(chipTool, " ***** Test Step 214 : Read attribute NULLABLE_INT8U Min Value\n"); - err = TestReadAttributeNullableInt8uMinValue_214(); - break; - case 215: - ChipLogProgress(chipTool, " ***** Test Step 215 : Write attribute NULLABLE_INT8U Max Value\n"); - err = TestWriteAttributeNullableInt8uMaxValue_215(); - break; - case 216: - ChipLogProgress(chipTool, " ***** Test Step 216 : Read attribute NULLABLE_INT8U Max Value\n"); - err = TestReadAttributeNullableInt8uMaxValue_216(); - break; - case 217: - ChipLogProgress(chipTool, " ***** Test Step 217 : Write attribute NULLABLE_INT8U Invalid Value\n"); - err = TestWriteAttributeNullableInt8uInvalidValue_217(); - break; - case 218: - ChipLogProgress(chipTool, " ***** Test Step 218 : Read attribute NULLABLE_INT8U unchanged Value\n"); - err = TestReadAttributeNullableInt8uUnchangedValue_218(); - break; - case 219: - ChipLogProgress(chipTool, " ***** Test Step 219 : Read attribute NULLABLE_INT8U unchanged Value with constraint\n"); - err = TestReadAttributeNullableInt8uUnchangedValueWithConstraint_219(); - break; - case 220: - ChipLogProgress(chipTool, " ***** Test Step 220 : Write attribute NULLABLE_INT8U null Value\n"); - err = TestWriteAttributeNullableInt8uNullValue_220(); - break; - case 221: - ChipLogProgress(chipTool, " ***** Test Step 221 : Read attribute NULLABLE_INT8U null Value\n"); - err = TestReadAttributeNullableInt8uNullValue_221(); - break; - case 222: - ChipLogProgress(chipTool, " ***** Test Step 222 : Read attribute NULLABLE_INT8U null Value & range\n"); - err = TestReadAttributeNullableInt8uNullValueRange_222(); - break; - case 223: - ChipLogProgress(chipTool, " ***** Test Step 223 : Read attribute NULLABLE_INT8U null Value & not\n"); - err = TestReadAttributeNullableInt8uNullValueNot_223(); - break; - case 224: - ChipLogProgress(chipTool, " ***** Test Step 224 : Write attribute NULLABLE_INT8U Value\n"); - err = TestWriteAttributeNullableInt8uValue_224(); - break; - case 225: - ChipLogProgress(chipTool, " ***** Test Step 225 : Read attribute NULLABLE_INT8U Value in range\n"); - err = TestReadAttributeNullableInt8uValueInRange_225(); - break; - case 226: - ChipLogProgress(chipTool, " ***** Test Step 226 : Read attribute NULLABLE_INT8U notValue OK\n"); - err = TestReadAttributeNullableInt8uNotValueOk_226(); - break; - case 227: - ChipLogProgress(chipTool, " ***** Test Step 227 : Write attribute NULLABLE_INT16U Min Value\n"); - err = TestWriteAttributeNullableInt16uMinValue_227(); - break; - case 228: - ChipLogProgress(chipTool, " ***** Test Step 228 : Read attribute NULLABLE_INT16U Min Value\n"); - err = TestReadAttributeNullableInt16uMinValue_228(); - break; - case 229: - ChipLogProgress(chipTool, " ***** Test Step 229 : Write attribute NULLABLE_INT16U Max Value\n"); - err = TestWriteAttributeNullableInt16uMaxValue_229(); - break; - case 230: - ChipLogProgress(chipTool, " ***** Test Step 230 : Read attribute NULLABLE_INT16U Max Value\n"); - err = TestReadAttributeNullableInt16uMaxValue_230(); - break; - case 231: - ChipLogProgress(chipTool, " ***** Test Step 231 : Write attribute NULLABLE_INT16U Invalid Value\n"); - err = TestWriteAttributeNullableInt16uInvalidValue_231(); - break; - case 232: - ChipLogProgress(chipTool, " ***** Test Step 232 : Read attribute NULLABLE_INT16U unchanged Value\n"); - err = TestReadAttributeNullableInt16uUnchangedValue_232(); - break; - case 233: - ChipLogProgress(chipTool, " ***** Test Step 233 : Write attribute NULLABLE_INT16U null Value\n"); - err = TestWriteAttributeNullableInt16uNullValue_233(); - break; - case 234: - ChipLogProgress(chipTool, " ***** Test Step 234 : Read attribute NULLABLE_INT16U null Value\n"); - err = TestReadAttributeNullableInt16uNullValue_234(); - break; - case 235: - ChipLogProgress(chipTool, " ***** Test Step 235 : Read attribute NULLABLE_INT16U null Value & range\n"); - err = TestReadAttributeNullableInt16uNullValueRange_235(); - break; - case 236: - ChipLogProgress(chipTool, " ***** Test Step 236 : Read attribute NULLABLE_INT16U null Value & not\n"); - err = TestReadAttributeNullableInt16uNullValueNot_236(); - break; - case 237: - ChipLogProgress(chipTool, " ***** Test Step 237 : Write attribute NULLABLE_INT16U Value\n"); - err = TestWriteAttributeNullableInt16uValue_237(); - break; - case 238: - ChipLogProgress(chipTool, " ***** Test Step 238 : Read attribute NULLABLE_INT16U Value in range\n"); - err = TestReadAttributeNullableInt16uValueInRange_238(); - break; - case 239: - ChipLogProgress(chipTool, " ***** Test Step 239 : Read attribute NULLABLE_INT16U notValue OK\n"); - err = TestReadAttributeNullableInt16uNotValueOk_239(); - break; - case 240: - ChipLogProgress(chipTool, " ***** Test Step 240 : Write attribute NULLABLE_INT32U Min Value\n"); - err = TestWriteAttributeNullableInt32uMinValue_240(); - break; - case 241: - ChipLogProgress(chipTool, " ***** Test Step 241 : Read attribute NULLABLE_INT32U Min Value\n"); - err = TestReadAttributeNullableInt32uMinValue_241(); - break; - case 242: - ChipLogProgress(chipTool, " ***** Test Step 242 : Write attribute NULLABLE_INT32U Max Value\n"); - err = TestWriteAttributeNullableInt32uMaxValue_242(); - break; - case 243: - ChipLogProgress(chipTool, " ***** Test Step 243 : Read attribute NULLABLE_INT32U Max Value\n"); - err = TestReadAttributeNullableInt32uMaxValue_243(); - break; - case 244: - ChipLogProgress(chipTool, " ***** Test Step 244 : Write attribute NULLABLE_INT32U Invalid Value\n"); - err = TestWriteAttributeNullableInt32uInvalidValue_244(); - break; - case 245: - ChipLogProgress(chipTool, " ***** Test Step 245 : Read attribute NULLABLE_INT32U unchanged Value\n"); - err = TestReadAttributeNullableInt32uUnchangedValue_245(); - break; - case 246: - ChipLogProgress(chipTool, " ***** Test Step 246 : Write attribute NULLABLE_INT32U null Value\n"); - err = TestWriteAttributeNullableInt32uNullValue_246(); - break; - case 247: - ChipLogProgress(chipTool, " ***** Test Step 247 : Read attribute NULLABLE_INT32U null Value\n"); - err = TestReadAttributeNullableInt32uNullValue_247(); - break; - case 248: - ChipLogProgress(chipTool, " ***** Test Step 248 : Read attribute NULLABLE_INT32U null Value & range\n"); - err = TestReadAttributeNullableInt32uNullValueRange_248(); - break; - case 249: - ChipLogProgress(chipTool, " ***** Test Step 249 : Read attribute NULLABLE_INT32U null Value & not\n"); - err = TestReadAttributeNullableInt32uNullValueNot_249(); - break; - case 250: - ChipLogProgress(chipTool, " ***** Test Step 250 : Write attribute NULLABLE_INT32U Value\n"); - err = TestWriteAttributeNullableInt32uValue_250(); - break; - case 251: - ChipLogProgress(chipTool, " ***** Test Step 251 : Read attribute NULLABLE_INT32U Value in range\n"); - err = TestReadAttributeNullableInt32uValueInRange_251(); - break; - case 252: - ChipLogProgress(chipTool, " ***** Test Step 252 : Read attribute NULLABLE_INT32U notValue OK\n"); - err = TestReadAttributeNullableInt32uNotValueOk_252(); - break; - case 253: - ChipLogProgress(chipTool, " ***** Test Step 253 : Write attribute NULLABLE_INT64U Min Value\n"); - err = TestWriteAttributeNullableInt64uMinValue_253(); - break; - case 254: - ChipLogProgress(chipTool, " ***** Test Step 254 : Read attribute NULLABLE_INT64U Min Value\n"); - err = TestReadAttributeNullableInt64uMinValue_254(); - break; - case 255: - ChipLogProgress(chipTool, " ***** Test Step 255 : Write attribute NULLABLE_INT64U Max Value\n"); - err = TestWriteAttributeNullableInt64uMaxValue_255(); - break; - case 256: - ChipLogProgress(chipTool, " ***** Test Step 256 : Read attribute NULLABLE_INT64U Max Value\n"); - err = TestReadAttributeNullableInt64uMaxValue_256(); - break; - case 257: - ChipLogProgress(chipTool, " ***** Test Step 257 : Write attribute NULLABLE_INT64U Invalid Value\n"); - err = TestWriteAttributeNullableInt64uInvalidValue_257(); - break; - case 258: - ChipLogProgress(chipTool, " ***** Test Step 258 : Read attribute NULLABLE_INT64U unchanged Value\n"); - err = TestReadAttributeNullableInt64uUnchangedValue_258(); - break; - case 259: - ChipLogProgress(chipTool, " ***** Test Step 259 : Write attribute NULLABLE_INT64U null Value\n"); - err = TestWriteAttributeNullableInt64uNullValue_259(); - break; - case 260: - ChipLogProgress(chipTool, " ***** Test Step 260 : Read attribute NULLABLE_INT64U null Value\n"); - err = TestReadAttributeNullableInt64uNullValue_260(); - break; - case 261: - ChipLogProgress(chipTool, " ***** Test Step 261 : Read attribute NULLABLE_INT64U null Value & range\n"); - err = TestReadAttributeNullableInt64uNullValueRange_261(); - break; - case 262: - ChipLogProgress(chipTool, " ***** Test Step 262 : Read attribute NULLABLE_INT64U null Value & not\n"); - err = TestReadAttributeNullableInt64uNullValueNot_262(); - break; - case 263: - ChipLogProgress(chipTool, " ***** Test Step 263 : Write attribute NULLABLE_INT64U Value\n"); - err = TestWriteAttributeNullableInt64uValue_263(); - break; - case 264: - ChipLogProgress(chipTool, " ***** Test Step 264 : Read attribute NULLABLE_INT64U Value in range\n"); - err = TestReadAttributeNullableInt64uValueInRange_264(); - break; - case 265: - ChipLogProgress(chipTool, " ***** Test Step 265 : Read attribute NULLABLE_INT64U notValue OK\n"); - err = TestReadAttributeNullableInt64uNotValueOk_265(); - break; - case 266: - ChipLogProgress(chipTool, " ***** Test Step 266 : Write attribute NULLABLE_INT8S Min Value\n"); - err = TestWriteAttributeNullableInt8sMinValue_266(); - break; - case 267: - ChipLogProgress(chipTool, " ***** Test Step 267 : Read attribute NULLABLE_INT8S Min Value\n"); - err = TestReadAttributeNullableInt8sMinValue_267(); - break; - case 268: - ChipLogProgress(chipTool, " ***** Test Step 268 : Write attribute NULLABLE_INT8S Invalid Value\n"); - err = TestWriteAttributeNullableInt8sInvalidValue_268(); - break; - case 269: - ChipLogProgress(chipTool, " ***** Test Step 269 : Read attribute NULLABLE_INT8S unchanged Value\n"); - err = TestReadAttributeNullableInt8sUnchangedValue_269(); - break; - case 270: - ChipLogProgress(chipTool, " ***** Test Step 270 : Write attribute NULLABLE_INT8S null Value\n"); - err = TestWriteAttributeNullableInt8sNullValue_270(); - break; - case 271: - ChipLogProgress(chipTool, " ***** Test Step 271 : Read attribute NULLABLE_INT8S null Value\n"); - err = TestReadAttributeNullableInt8sNullValue_271(); - break; - case 272: - ChipLogProgress(chipTool, " ***** Test Step 272 : Read attribute NULLABLE_INT8S null Value & range\n"); - err = TestReadAttributeNullableInt8sNullValueRange_272(); - break; - case 273: - ChipLogProgress(chipTool, " ***** Test Step 273 : Read attribute NULLABLE_INT8S null Value & not\n"); - err = TestReadAttributeNullableInt8sNullValueNot_273(); - break; - case 274: - ChipLogProgress(chipTool, " ***** Test Step 274 : Write attribute NULLABLE_INT8S Value\n"); - err = TestWriteAttributeNullableInt8sValue_274(); - break; - case 275: - ChipLogProgress(chipTool, " ***** Test Step 275 : Read attribute NULLABLE_INT8S Value in range\n"); - err = TestReadAttributeNullableInt8sValueInRange_275(); - break; - case 276: - ChipLogProgress(chipTool, " ***** Test Step 276 : Read attribute NULLABLE_INT8S notValue OK\n"); - err = TestReadAttributeNullableInt8sNotValueOk_276(); - break; - case 277: - ChipLogProgress(chipTool, " ***** Test Step 277 : Write attribute NULLABLE_INT16S Min Value\n"); - err = TestWriteAttributeNullableInt16sMinValue_277(); - break; - case 278: - ChipLogProgress(chipTool, " ***** Test Step 278 : Read attribute NULLABLE_INT16S Min Value\n"); - err = TestReadAttributeNullableInt16sMinValue_278(); - break; - case 279: - ChipLogProgress(chipTool, " ***** Test Step 279 : Write attribute NULLABLE_INT16S Invalid Value\n"); - err = TestWriteAttributeNullableInt16sInvalidValue_279(); - break; - case 280: - ChipLogProgress(chipTool, " ***** Test Step 280 : Read attribute NULLABLE_INT16S unchanged Value\n"); - err = TestReadAttributeNullableInt16sUnchangedValue_280(); - break; - case 281: - ChipLogProgress(chipTool, " ***** Test Step 281 : Write attribute NULLABLE_INT16S null Value\n"); - err = TestWriteAttributeNullableInt16sNullValue_281(); - break; - case 282: - ChipLogProgress(chipTool, " ***** Test Step 282 : Read attribute NULLABLE_INT16S null Value\n"); - err = TestReadAttributeNullableInt16sNullValue_282(); - break; - case 283: - ChipLogProgress(chipTool, " ***** Test Step 283 : Read attribute NULLABLE_INT16S null Value & range\n"); - err = TestReadAttributeNullableInt16sNullValueRange_283(); - break; - case 284: - ChipLogProgress(chipTool, " ***** Test Step 284 : Read attribute NULLABLE_INT16S null Value & not\n"); - err = TestReadAttributeNullableInt16sNullValueNot_284(); - break; - case 285: - ChipLogProgress(chipTool, " ***** Test Step 285 : Write attribute NULLABLE_INT16S Value\n"); - err = TestWriteAttributeNullableInt16sValue_285(); - break; - case 286: - ChipLogProgress(chipTool, " ***** Test Step 286 : Read attribute NULLABLE_INT16S Value in range\n"); - err = TestReadAttributeNullableInt16sValueInRange_286(); - break; - case 287: - ChipLogProgress(chipTool, " ***** Test Step 287 : Read attribute NULLABLE_INT16S notValue OK\n"); - err = TestReadAttributeNullableInt16sNotValueOk_287(); - break; - case 288: - ChipLogProgress(chipTool, " ***** Test Step 288 : Write attribute NULLABLE_INT32S Min Value\n"); - err = TestWriteAttributeNullableInt32sMinValue_288(); - break; - case 289: - ChipLogProgress(chipTool, " ***** Test Step 289 : Read attribute NULLABLE_INT32S Min Value\n"); - err = TestReadAttributeNullableInt32sMinValue_289(); - break; - case 290: - ChipLogProgress(chipTool, " ***** Test Step 290 : Write attribute NULLABLE_INT32S Invalid Value\n"); - err = TestWriteAttributeNullableInt32sInvalidValue_290(); - break; - case 291: - ChipLogProgress(chipTool, " ***** Test Step 291 : Read attribute NULLABLE_INT32S unchanged Value\n"); - err = TestReadAttributeNullableInt32sUnchangedValue_291(); - break; - case 292: - ChipLogProgress(chipTool, " ***** Test Step 292 : Write attribute NULLABLE_INT32S null Value\n"); - err = TestWriteAttributeNullableInt32sNullValue_292(); - break; - case 293: - ChipLogProgress(chipTool, " ***** Test Step 293 : Read attribute NULLABLE_INT32S null Value\n"); - err = TestReadAttributeNullableInt32sNullValue_293(); - break; - case 294: - ChipLogProgress(chipTool, " ***** Test Step 294 : Read attribute NULLABLE_INT32S null Value & range\n"); - err = TestReadAttributeNullableInt32sNullValueRange_294(); - break; - case 295: - ChipLogProgress(chipTool, " ***** Test Step 295 : Read attribute NULLABLE_INT32S null Value & not\n"); - err = TestReadAttributeNullableInt32sNullValueNot_295(); - break; - case 296: - ChipLogProgress(chipTool, " ***** Test Step 296 : Write attribute NULLABLE_INT32S Value\n"); - err = TestWriteAttributeNullableInt32sValue_296(); - break; - case 297: - ChipLogProgress(chipTool, " ***** Test Step 297 : Read attribute NULLABLE_INT32S Value in range\n"); - err = TestReadAttributeNullableInt32sValueInRange_297(); - break; - case 298: - ChipLogProgress(chipTool, " ***** Test Step 298 : Read attribute NULLABLE_INT32S notValue OK\n"); - err = TestReadAttributeNullableInt32sNotValueOk_298(); - break; - case 299: - ChipLogProgress(chipTool, " ***** Test Step 299 : Write attribute NULLABLE_INT64S Min Value\n"); - err = TestWriteAttributeNullableInt64sMinValue_299(); - break; - case 300: - ChipLogProgress(chipTool, " ***** Test Step 300 : Read attribute NULLABLE_INT64S Min Value\n"); - err = TestReadAttributeNullableInt64sMinValue_300(); - break; - case 301: - ChipLogProgress(chipTool, " ***** Test Step 301 : Write attribute NULLABLE_INT64S Invalid Value\n"); - err = TestWriteAttributeNullableInt64sInvalidValue_301(); - break; - case 302: - ChipLogProgress(chipTool, " ***** Test Step 302 : Read attribute NULLABLE_INT64S unchanged Value\n"); - err = TestReadAttributeNullableInt64sUnchangedValue_302(); - break; - case 303: - ChipLogProgress(chipTool, " ***** Test Step 303 : Write attribute NULLABLE_INT64S null Value\n"); - err = TestWriteAttributeNullableInt64sNullValue_303(); - break; - case 304: - ChipLogProgress(chipTool, " ***** Test Step 304 : Read attribute NULLABLE_INT64S null Value\n"); - err = TestReadAttributeNullableInt64sNullValue_304(); - break; - case 305: - ChipLogProgress(chipTool, " ***** Test Step 305 : Read attribute NULLABLE_INT64S null Value & range\n"); - err = TestReadAttributeNullableInt64sNullValueRange_305(); - break; - case 306: - ChipLogProgress(chipTool, " ***** Test Step 306 : Read attribute NULLABLE_INT64S null Value & not\n"); - err = TestReadAttributeNullableInt64sNullValueNot_306(); - break; - case 307: - ChipLogProgress(chipTool, " ***** Test Step 307 : Write attribute NULLABLE_INT64S Value\n"); - err = TestWriteAttributeNullableInt64sValue_307(); - break; - case 308: - ChipLogProgress(chipTool, " ***** Test Step 308 : Read attribute NULLABLE_INT64S Value in range\n"); - err = TestReadAttributeNullableInt64sValueInRange_308(); - break; - case 309: - ChipLogProgress(chipTool, " ***** Test Step 309 : Read attribute NULLABLE_INT64S notValue OK\n"); - err = TestReadAttributeNullableInt64sNotValueOk_309(); - break; - case 310: - ChipLogProgress(chipTool, " ***** Test Step 310 : Write attribute NULLABLE_SINGLE medium Value\n"); - err = TestWriteAttributeNullableSingleMediumValue_310(); - break; - case 311: - ChipLogProgress(chipTool, " ***** Test Step 311 : Read attribute NULLABLE_SINGLE medium Value\n"); - err = TestReadAttributeNullableSingleMediumValue_311(); - break; - case 312: - ChipLogProgress(chipTool, " ***** Test Step 312 : Write attribute NULLABLE_SINGLE largest Value\n"); - err = TestWriteAttributeNullableSingleLargestValue_312(); - break; - case 313: - ChipLogProgress(chipTool, " ***** Test Step 313 : Read attribute NULLABLE_SINGLE largest Value\n"); - err = TestReadAttributeNullableSingleLargestValue_313(); - break; - case 314: - ChipLogProgress(chipTool, " ***** Test Step 314 : Write attribute NULLABLE_SINGLE smallest Value\n"); - err = TestWriteAttributeNullableSingleSmallestValue_314(); - break; - case 315: - ChipLogProgress(chipTool, " ***** Test Step 315 : Read attribute NULLABLE_SINGLE smallest Value\n"); - err = TestReadAttributeNullableSingleSmallestValue_315(); - break; - case 316: - ChipLogProgress(chipTool, " ***** Test Step 316 : Write attribute NULLABLE_SINGLE null Value\n"); - err = TestWriteAttributeNullableSingleNullValue_316(); - break; - case 317: - ChipLogProgress(chipTool, " ***** Test Step 317 : Read attribute NULLABLE_SINGLE null Value\n"); - err = TestReadAttributeNullableSingleNullValue_317(); - break; - case 318: - ChipLogProgress(chipTool, " ***** Test Step 318 : Write attribute NULLABLE_SINGLE 0 Value\n"); - err = TestWriteAttributeNullableSingle0Value_318(); - break; - case 319: - ChipLogProgress(chipTool, " ***** Test Step 319 : Read attribute NULLABLE_SINGLE 0 Value\n"); - err = TestReadAttributeNullableSingle0Value_319(); - break; - case 320: - ChipLogProgress(chipTool, " ***** Test Step 320 : Write attribute NULLABLE_DOUBLE medium Value\n"); - err = TestWriteAttributeNullableDoubleMediumValue_320(); - break; - case 321: - ChipLogProgress(chipTool, " ***** Test Step 321 : Read attribute NULLABLE_DOUBLE medium Value\n"); - err = TestReadAttributeNullableDoubleMediumValue_321(); - break; - case 322: - ChipLogProgress(chipTool, " ***** Test Step 322 : Write attribute NULLABLE_DOUBLE largest Value\n"); - err = TestWriteAttributeNullableDoubleLargestValue_322(); - break; - case 323: - ChipLogProgress(chipTool, " ***** Test Step 323 : Read attribute NULLABLE_DOUBLE largest Value\n"); - err = TestReadAttributeNullableDoubleLargestValue_323(); - break; - case 324: - ChipLogProgress(chipTool, " ***** Test Step 324 : Write attribute NULLABLE_DOUBLE smallest Value\n"); - err = TestWriteAttributeNullableDoubleSmallestValue_324(); - break; - case 325: - ChipLogProgress(chipTool, " ***** Test Step 325 : Read attribute NULLABLE_DOUBLE smallest Value\n"); - err = TestReadAttributeNullableDoubleSmallestValue_325(); - break; - case 326: - ChipLogProgress(chipTool, " ***** Test Step 326 : Write attribute NULLABLE_DOUBLE null Value\n"); - err = TestWriteAttributeNullableDoubleNullValue_326(); - break; - case 327: - ChipLogProgress(chipTool, " ***** Test Step 327 : Read attribute NULLABLE_DOUBLE null Value\n"); - err = TestReadAttributeNullableDoubleNullValue_327(); - break; - case 328: - ChipLogProgress(chipTool, " ***** Test Step 328 : Write attribute NULLABLE_DOUBLE 0 Value\n"); - err = TestWriteAttributeNullableDouble0Value_328(); - break; - case 329: - ChipLogProgress(chipTool, " ***** Test Step 329 : Read attribute NULLABLE_DOUBLE 0 Value\n"); - err = TestReadAttributeNullableDouble0Value_329(); - break; - case 330: - ChipLogProgress(chipTool, " ***** Test Step 330 : Write attribute NULLABLE_ENUM8 Min Value\n"); - err = TestWriteAttributeNullableEnum8MinValue_330(); - break; - case 331: - ChipLogProgress(chipTool, " ***** Test Step 331 : Read attribute NULLABLE_ENUM8 Min Value\n"); - err = TestReadAttributeNullableEnum8MinValue_331(); - break; - case 332: - ChipLogProgress(chipTool, " ***** Test Step 332 : Write attribute NULLABLE_ENUM8 Max Value\n"); - err = TestWriteAttributeNullableEnum8MaxValue_332(); - break; - case 333: - ChipLogProgress(chipTool, " ***** Test Step 333 : Read attribute NULLABLE_ENUM8 Max Value\n"); - err = TestReadAttributeNullableEnum8MaxValue_333(); - break; - case 334: - ChipLogProgress(chipTool, " ***** Test Step 334 : Write attribute NULLABLE_ENUM8 Invalid Value\n"); - err = TestWriteAttributeNullableEnum8InvalidValue_334(); - break; - case 335: - ChipLogProgress(chipTool, " ***** Test Step 335 : Read attribute NULLABLE_ENUM8 unchanged Value\n"); - err = TestReadAttributeNullableEnum8UnchangedValue_335(); - break; - case 336: - ChipLogProgress(chipTool, " ***** Test Step 336 : Write attribute NULLABLE_ENUM8 null Value\n"); - err = TestWriteAttributeNullableEnum8NullValue_336(); - break; - case 337: - ChipLogProgress(chipTool, " ***** Test Step 337 : Read attribute NULLABLE_ENUM8 null Value\n"); - err = TestReadAttributeNullableEnum8NullValue_337(); - break; - case 338: - ChipLogProgress(chipTool, " ***** Test Step 338 : Write attribute NULLABLE_ENUM16 Min Value\n"); - err = TestWriteAttributeNullableEnum16MinValue_338(); - break; - case 339: - ChipLogProgress(chipTool, " ***** Test Step 339 : Read attribute NULLABLE_ENUM16 Min Value\n"); - err = TestReadAttributeNullableEnum16MinValue_339(); - break; - case 340: - ChipLogProgress(chipTool, " ***** Test Step 340 : Write attribute NULLABLE_ENUM16 Max Value\n"); - err = TestWriteAttributeNullableEnum16MaxValue_340(); - break; - case 341: - ChipLogProgress(chipTool, " ***** Test Step 341 : Read attribute NULLABLE_ENUM16 Max Value\n"); - err = TestReadAttributeNullableEnum16MaxValue_341(); - break; - case 342: - ChipLogProgress(chipTool, " ***** Test Step 342 : Write attribute NULLABLE_ENUM16 Invalid Value\n"); - err = TestWriteAttributeNullableEnum16InvalidValue_342(); - break; - case 343: - ChipLogProgress(chipTool, " ***** Test Step 343 : Read attribute NULLABLE_ENUM16 unchanged Value\n"); - err = TestReadAttributeNullableEnum16UnchangedValue_343(); - break; - case 344: - ChipLogProgress(chipTool, " ***** Test Step 344 : Write attribute NULLABLE_ENUM16 null Value\n"); - err = TestWriteAttributeNullableEnum16NullValue_344(); - break; - case 345: - ChipLogProgress(chipTool, " ***** Test Step 345 : Read attribute NULLABLE_ENUM16 null Value\n"); - err = TestReadAttributeNullableEnum16NullValue_345(); - break; - case 346: - ChipLogProgress(chipTool, " ***** Test Step 346 : Write attribute NULLABLE_SIMPLE_ENUM Min Value\n"); - err = TestWriteAttributeNullableSimpleEnumMinValue_346(); - break; - case 347: - ChipLogProgress(chipTool, " ***** Test Step 347 : Read attribute NULLABLE_SIMPLE_ENUM Min Value\n"); - err = TestReadAttributeNullableSimpleEnumMinValue_347(); - break; - case 348: - ChipLogProgress(chipTool, " ***** Test Step 348 : Write attribute NULLABLE_SIMPLE_ENUM Max Value\n"); - err = TestWriteAttributeNullableSimpleEnumMaxValue_348(); - break; - case 349: - ChipLogProgress(chipTool, " ***** Test Step 349 : Read attribute NULLABLE_SIMPLE_ENUM Max Value\n"); - err = TestReadAttributeNullableSimpleEnumMaxValue_349(); - break; - case 350: - ChipLogProgress(chipTool, " ***** Test Step 350 : Write attribute NULLABLE_SIMPLE_ENUM Invalid Value\n"); - err = TestWriteAttributeNullableSimpleEnumInvalidValue_350(); - break; - case 351: - ChipLogProgress(chipTool, " ***** Test Step 351 : Read attribute NULLABLE_SIMPLE_ENUM unchanged Value\n"); - err = TestReadAttributeNullableSimpleEnumUnchangedValue_351(); - break; - case 352: - ChipLogProgress(chipTool, " ***** Test Step 352 : Write attribute NULLABLE_SIMPLE_ENUM null Value\n"); - err = TestWriteAttributeNullableSimpleEnumNullValue_352(); - break; - case 353: - ChipLogProgress(chipTool, " ***** Test Step 353 : Read attribute NULLABLE_SIMPLE_ENUM null Value\n"); - err = TestReadAttributeNullableSimpleEnumNullValue_353(); - break; - case 354: - ChipLogProgress(chipTool, " ***** Test Step 354 : Read attribute NULLABLE_SIMPLE_ENUM not 3 Value\n"); - err = TestReadAttributeNullableSimpleEnumNot3Value_354(); - break; - case 355: - ChipLogProgress(chipTool, " ***** Test Step 355 : Read attribute NULLABLE_OCTET_STRING Default Value\n"); - err = TestReadAttributeNullableOctetStringDefaultValue_355(); - break; - case 356: - ChipLogProgress(chipTool, " ***** Test Step 356 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_356(); - break; - case 357: - ChipLogProgress(chipTool, " ***** Test Step 357 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_357(); - break; - case 358: - ChipLogProgress(chipTool, " ***** Test Step 358 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_358(); - break; - case 359: - ChipLogProgress(chipTool, " ***** Test Step 359 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_359(); - break; - case 360: - ChipLogProgress(chipTool, " ***** Test Step 360 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_360(); - break; - case 361: - ChipLogProgress(chipTool, " ***** Test Step 361 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_361(); - break; - case 362: - ChipLogProgress(chipTool, " ***** Test Step 362 : Read attribute NULLABLE_OCTET_STRING not TestValue\n"); - err = TestReadAttributeNullableOctetStringNotTestValue_362(); - break; - case 363: - ChipLogProgress(chipTool, " ***** Test Step 363 : Read attribute NULLABLE_CHAR_STRING Default Value\n"); - err = TestReadAttributeNullableCharStringDefaultValue_363(); - break; - case 364: - ChipLogProgress(chipTool, " ***** Test Step 364 : Write attribute NULLABLE_CHAR_STRING\n"); - err = TestWriteAttributeNullableCharString_364(); - break; - case 365: - ChipLogProgress(chipTool, " ***** Test Step 365 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_365(); - break; - case 366: - ChipLogProgress(chipTool, " ***** Test Step 366 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_366(); - break; - case 367: - ChipLogProgress(chipTool, " ***** Test Step 367 : Write attribute NULLABLE_CHAR_STRING - Value too long\n"); - err = TestWriteAttributeNullableCharStringValueTooLong_367(); - break; - case 368: - ChipLogProgress(chipTool, " ***** Test Step 368 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_368(); - break; - case 369: - ChipLogProgress(chipTool, " ***** Test Step 369 : Write attribute NULLABLE_CHAR_STRING - Empty\n"); - err = TestWriteAttributeNullableCharStringEmpty_369(); - break; - case 370: - ChipLogProgress(chipTool, " ***** Test Step 370 : Read attribute NULLABLE_CHAR_STRING\n"); - err = TestReadAttributeNullableCharString_370(); - break; - case 371: - ChipLogProgress(chipTool, " ***** Test Step 371 : Read attribute NULLABLE_CHAR_STRING not ☉T☉\n"); - err = TestReadAttributeNullableCharStringNott_371(); - break; - case 372: - ChipLogProgress(chipTool, " ***** Test Step 372 : Read attribute from nonexistent endpoint.\n"); - err = TestReadAttributeFromNonexistentEndpoint_372(); - break; - case 373: - ChipLogProgress(chipTool, " ***** Test Step 373 : Read attribute from nonexistent cluster.\n"); - err = TestReadAttributeFromNonexistentCluster_373(); - break; - case 374: - ChipLogProgress(chipTool, " ***** Test Step 374 : Send a command that takes an optional parameter but do not set it.\n"); - err = TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_374(); - break; - case 375: - ChipLogProgress(chipTool, " ***** Test Step 375 : Send a command that takes an optional parameter but do not set it.\n"); - err = TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_375(); - break; - case 376: - ChipLogProgress(chipTool, " ***** Test Step 376 : Report: Subscribe to list attribute\n"); - err = TestReportSubscribeToListAttribute_376(); - break; - case 377: - ChipLogProgress(chipTool, " ***** Test Step 377 : Subscribe to list attribute\n"); - err = TestSubscribeToListAttribute_377(); - break; - case 378: - ChipLogProgress(chipTool, " ***** Test Step 378 : Write subscribed-to list attribute\n"); - err = TestWriteSubscribedToListAttribute_378(); - break; - case 379: - ChipLogProgress(chipTool, " ***** Test Step 379 : Check for list attribute report\n"); - err = TestCheckForListAttributeReport_379(); - break; - case 380: - ChipLogProgress(chipTool, " ***** Test Step 380 : Read range-restricted unsigned 8-bit integer\n"); - err = TestReadRangeRestrictedUnsigned8BitInteger_380(); - break; - case 381: - ChipLogProgress(chipTool, " ***** Test Step 381 : Write min value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedUnsigned8BitInteger_381(); - break; - case 382: - ChipLogProgress(chipTool, " ***** Test Step 382 : Write just-below-range value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedUnsigned8BitInteger_382(); - break; - case 383: - ChipLogProgress(chipTool, " ***** Test Step 383 : Write just-above-range value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedUnsigned8BitInteger_383(); - break; - case 384: - ChipLogProgress(chipTool, " ***** Test Step 384 : Write max value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedUnsigned8BitInteger_384(); - break; - case 385: - ChipLogProgress(chipTool, " ***** Test Step 385 : Verify range-restricted unsigned 8-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_385(); - break; - case 386: - ChipLogProgress(chipTool, " ***** Test Step 386 : Write min valid value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedUnsigned8BitInteger_386(); - break; - case 387: - ChipLogProgress(chipTool, " ***** Test Step 387 : Verify range-restricted unsigned 8-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_387(); - break; - case 388: - ChipLogProgress(chipTool, " ***** Test Step 388 : Write max valid value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedUnsigned8BitInteger_388(); - break; - case 389: - ChipLogProgress(chipTool, " ***** Test Step 389 : Verify range-restricted unsigned 8-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_389(); - break; - case 390: - ChipLogProgress(chipTool, " ***** Test Step 390 : Write middle valid value to a range-restricted unsigned 8-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedUnsigned8BitInteger_390(); - break; - case 391: - ChipLogProgress(chipTool, " ***** Test Step 391 : Verify range-restricted unsigned 8-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_391(); - break; - case 392: - ChipLogProgress(chipTool, " ***** Test Step 392 : Read range-restricted unsigned 16-bit integer\n"); - err = TestReadRangeRestrictedUnsigned16BitInteger_392(); - break; - case 393: - ChipLogProgress(chipTool, " ***** Test Step 393 : Write min value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedUnsigned16BitInteger_393(); - break; - case 394: - ChipLogProgress(chipTool, " ***** Test Step 394 : Write just-below-range value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedUnsigned16BitInteger_394(); - break; - case 395: - ChipLogProgress(chipTool, " ***** Test Step 395 : Write just-above-range value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedUnsigned16BitInteger_395(); - break; - case 396: - ChipLogProgress(chipTool, " ***** Test Step 396 : Write max value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedUnsigned16BitInteger_396(); - break; - case 397: - ChipLogProgress(chipTool, " ***** Test Step 397 : Verify range-restricted unsigned 16-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_397(); - break; - case 398: - ChipLogProgress(chipTool, " ***** Test Step 398 : Write min valid value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedUnsigned16BitInteger_398(); - break; - case 399: - ChipLogProgress(chipTool, " ***** Test Step 399 : Verify range-restricted unsigned 16-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_399(); - break; - case 400: - ChipLogProgress(chipTool, " ***** Test Step 400 : Write max valid value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedUnsigned16BitInteger_400(); - break; - case 401: - ChipLogProgress(chipTool, " ***** Test Step 401 : Verify range-restricted unsigned 16-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_401(); - break; - case 402: - ChipLogProgress(chipTool, " ***** Test Step 402 : Write middle valid value to a range-restricted unsigned 16-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedUnsigned16BitInteger_402(); - break; - case 403: - ChipLogProgress(chipTool, " ***** Test Step 403 : Verify range-restricted unsigned 16-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_403(); - break; - case 404: - ChipLogProgress(chipTool, " ***** Test Step 404 : Read range-restricted signed 8-bit integer\n"); - err = TestReadRangeRestrictedSigned8BitInteger_404(); - break; - case 405: - ChipLogProgress(chipTool, " ***** Test Step 405 : Write min value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedSigned8BitInteger_405(); - break; - case 406: - ChipLogProgress(chipTool, " ***** Test Step 406 : Write just-below-range value to a range-restricted signed 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedSigned8BitInteger_406(); - break; - case 407: - ChipLogProgress(chipTool, " ***** Test Step 407 : Write just-above-range value to a range-restricted signed 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedSigned8BitInteger_407(); - break; - case 408: - ChipLogProgress(chipTool, " ***** Test Step 408 : Write max value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedSigned8BitInteger_408(); - break; - case 409: - ChipLogProgress(chipTool, " ***** Test Step 409 : Verify range-restricted signed 8-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueHasNotChanged_409(); - break; - case 410: - ChipLogProgress(chipTool, " ***** Test Step 410 : Write min valid value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedSigned8BitInteger_410(); - break; - case 411: - ChipLogProgress(chipTool, " ***** Test Step 411 : Verify range-restricted signed 8-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMinValid_411(); - break; - case 412: - ChipLogProgress(chipTool, " ***** Test Step 412 : Write max valid value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedSigned8BitInteger_412(); - break; - case 413: - ChipLogProgress(chipTool, " ***** Test Step 413 : Verify range-restricted signed 8-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_413(); - break; - case 414: - ChipLogProgress(chipTool, " ***** Test Step 414 : Write middle valid value to a range-restricted signed 8-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedSigned8BitInteger_414(); - break; - case 415: - ChipLogProgress(chipTool, " ***** Test Step 415 : Verify range-restricted signed 8-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMidValid_415(); - break; - case 416: - ChipLogProgress(chipTool, " ***** Test Step 416 : Read range-restricted signed 16-bit integer\n"); - err = TestReadRangeRestrictedSigned16BitInteger_416(); - break; - case 417: - ChipLogProgress(chipTool, " ***** Test Step 417 : Write min value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMinValueToARangeRestrictedSigned16BitInteger_417(); - break; - case 418: - ChipLogProgress(chipTool, " ***** Test Step 418 : Write just-below-range value to a range-restricted signed 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToARangeRestrictedSigned16BitInteger_418(); - break; - case 419: - ChipLogProgress(chipTool, " ***** Test Step 419 : Write just-above-range value to a range-restricted signed 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToARangeRestrictedSigned16BitInteger_419(); - break; - case 420: - ChipLogProgress(chipTool, " ***** Test Step 420 : Write max value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValueToARangeRestrictedSigned16BitInteger_420(); - break; - case 421: - ChipLogProgress(chipTool, " ***** Test Step 421 : Verify range-restricted signed 16-bit integer value has not changed\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueHasNotChanged_421(); - break; - case 422: - ChipLogProgress(chipTool, " ***** Test Step 422 : Write min valid value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMinValidValueToARangeRestrictedSigned16BitInteger_422(); - break; - case 423: - ChipLogProgress(chipTool, " ***** Test Step 423 : Verify range-restricted signed 16-bit integer value is at min valid\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMinValid_423(); - break; - case 424: - ChipLogProgress(chipTool, " ***** Test Step 424 : Write max valid value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValidValueToARangeRestrictedSigned16BitInteger_424(); - break; - case 425: - ChipLogProgress(chipTool, " ***** Test Step 425 : Verify range-restricted signed 16-bit integer value is at max valid\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_425(); - break; - case 426: - ChipLogProgress(chipTool, " ***** Test Step 426 : Write middle valid value to a range-restricted signed 16-bit integer\n"); - err = TestWriteMiddleValidValueToARangeRestrictedSigned16BitInteger_426(); - break; - case 427: - ChipLogProgress(chipTool, " ***** Test Step 427 : Verify range-restricted signed 16-bit integer value is at mid valid\n"); - err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMidValid_427(); - break; - case 428: - ChipLogProgress(chipTool, " ***** Test Step 428 : Read nullable range-restricted unsigned 8-bit integer\n"); - err = TestReadNullableRangeRestrictedUnsigned8BitInteger_428(); - break; - case 429: - ChipLogProgress(chipTool, " ***** Test Step 429 : Write min value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedUnsigned8BitInteger_429(); - break; - case 430: - ChipLogProgress(chipTool, " ***** Test Step 430 : Write just-below-range value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned8BitInteger_430(); - break; - case 431: - ChipLogProgress(chipTool, " ***** Test Step 431 : Write just-above-range value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned8BitInteger_431(); - break; - case 432: - ChipLogProgress(chipTool, " ***** Test Step 432 : Write max value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedUnsigned8BitInteger_432(); - break; - case 433: - ChipLogProgress(chipTool, " ***** Test Step 433 : Verify nullable range-restricted unsigned 8-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_433(); - break; - case 434: - ChipLogProgress(chipTool, " ***** Test Step 434 : Write min valid value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedUnsigned8BitInteger_434(); - break; - case 435: - ChipLogProgress(chipTool, " ***** Test Step 435 : Verify nullable range-restricted unsigned 8-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_435(); - break; - case 436: - ChipLogProgress(chipTool, " ***** Test Step 436 : Write max valid value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedUnsigned8BitInteger_436(); - break; - case 437: - ChipLogProgress(chipTool, " ***** Test Step 437 : Verify nullable range-restricted unsigned 8-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_437(); - break; - case 438: - ChipLogProgress(chipTool, " ***** Test Step 438 : Write middle valid value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned8BitInteger_438(); - break; - case 439: - ChipLogProgress(chipTool, " ***** Test Step 439 : Verify nullable range-restricted unsigned 8-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_439(); - break; - case 440: - ChipLogProgress(chipTool, " ***** Test Step 440 : Write null value to a nullable range-restricted unsigned 8-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedUnsigned8BitInteger_440(); - break; - case 441: - ChipLogProgress(chipTool, " ***** Test Step 441 : Verify nullable range-restricted unsigned 8-bit integer value is null\n"); - err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsNull_441(); - break; - case 442: - ChipLogProgress(chipTool, " ***** Test Step 442 : Read nullable range-restricted unsigned 16-bit integer\n"); - err = TestReadNullableRangeRestrictedUnsigned16BitInteger_442(); - break; - case 443: - ChipLogProgress(chipTool, " ***** Test Step 443 : Write min value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedUnsigned16BitInteger_443(); - break; - case 444: - ChipLogProgress(chipTool, " ***** Test Step 444 : Write just-below-range value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned16BitInteger_444(); - break; - case 445: - ChipLogProgress(chipTool, " ***** Test Step 445 : Write just-above-range value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned16BitInteger_445(); - break; - case 446: - ChipLogProgress(chipTool, " ***** Test Step 446 : Write max value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedUnsigned16BitInteger_446(); - break; - case 447: - ChipLogProgress(chipTool, " ***** Test Step 447 : Verify nullable range-restricted unsigned 16-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_447(); - break; - case 448: - ChipLogProgress(chipTool, " ***** Test Step 448 : Write min valid value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedUnsigned16BitInteger_448(); - break; - case 449: - ChipLogProgress(chipTool, " ***** Test Step 449 : Verify nullable range-restricted unsigned 16-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_449(); - break; - case 450: - ChipLogProgress(chipTool, " ***** Test Step 450 : Write max valid value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedUnsigned16BitInteger_450(); - break; - case 451: - ChipLogProgress(chipTool, " ***** Test Step 451 : Verify nullable range-restricted unsigned 16-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_451(); - break; - case 452: - ChipLogProgress(chipTool, " ***** Test Step 452 : Write middle valid value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned16BitInteger_452(); - break; - case 453: - ChipLogProgress(chipTool, " ***** Test Step 453 : Verify nullable range-restricted unsigned 16-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_453(); - break; - case 454: - ChipLogProgress(chipTool, " ***** Test Step 454 : Write null value to a nullable range-restricted unsigned 16-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedUnsigned16BitInteger_454(); - break; - case 455: - ChipLogProgress(chipTool, " ***** Test Step 455 : Verify nullable range-restricted unsigned 16-bit integer value is null\n"); - err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsNull_455(); - break; - case 456: - ChipLogProgress(chipTool, " ***** Test Step 456 : Read nullable range-restricted signed 8-bit integer\n"); - err = TestReadNullableRangeRestrictedSigned8BitInteger_456(); - break; - case 457: - ChipLogProgress(chipTool, " ***** Test Step 457 : Write min value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedSigned8BitInteger_457(); - break; - case 458: - ChipLogProgress(chipTool, " ***** Test Step 458 : Write just-below-range value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned8BitInteger_458(); - break; - case 459: - ChipLogProgress(chipTool, " ***** Test Step 459 : Write just-above-range value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned8BitInteger_459(); - break; - case 460: - ChipLogProgress(chipTool, " ***** Test Step 460 : Write max value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedSigned8BitInteger_460(); - break; - case 461: - ChipLogProgress(chipTool, " ***** Test Step 461 : Verify nullable range-restricted signed 8-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueHasNotChanged_461(); - break; - case 462: - ChipLogProgress(chipTool, " ***** Test Step 462 : Write min valid value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedSigned8BitInteger_462(); - break; - case 463: - ChipLogProgress(chipTool, " ***** Test Step 463 : Verify nullable range-restricted signed 8-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMinValid_463(); - break; - case 464: - ChipLogProgress(chipTool, " ***** Test Step 464 : Write max valid value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedSigned8BitInteger_464(); - break; - case 465: - ChipLogProgress(chipTool, " ***** Test Step 465 : Verify nullable range-restricted signed 8-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_465(); - break; - case 466: - ChipLogProgress(chipTool, " ***** Test Step 466 : Write middle valid value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedSigned8BitInteger_466(); - break; - case 467: - ChipLogProgress(chipTool, " ***** Test Step 467 : Verify nullable range-restricted signed 8-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMidValid_467(); - break; - case 468: - ChipLogProgress(chipTool, " ***** Test Step 468 : Write null value to a nullable range-restricted signed 8-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedSigned8BitInteger_468(); - break; - case 469: - ChipLogProgress(chipTool, " ***** Test Step 469 : Verify nullable range-restricted signed 8-bit integer value is at null\n"); - err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtNull_469(); - break; - case 470: - ChipLogProgress(chipTool, " ***** Test Step 470 : Read nullable range-restricted signed 16-bit integer\n"); - err = TestReadNullableRangeRestrictedSigned16BitInteger_470(); - break; - case 471: - ChipLogProgress(chipTool, " ***** Test Step 471 : Write min value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMinValueToANullableRangeRestrictedSigned16BitInteger_471(); - break; - case 472: - ChipLogProgress(chipTool, " ***** Test Step 472 : Write just-below-range value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned16BitInteger_472(); - break; - case 473: - ChipLogProgress(chipTool, " ***** Test Step 473 : Write just-above-range value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned16BitInteger_473(); - break; - case 474: - ChipLogProgress(chipTool, " ***** Test Step 474 : Write max value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValueToANullableRangeRestrictedSigned16BitInteger_474(); - break; - case 475: - ChipLogProgress(chipTool, " ***** Test Step 475 : Verify nullable range-restricted signed 16-bit integer value has not changed\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueHasNotChanged_475(); - break; - case 476: - ChipLogProgress(chipTool, " ***** Test Step 476 : Write min valid value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMinValidValueToANullableRangeRestrictedSigned16BitInteger_476(); - break; - case 477: - ChipLogProgress(chipTool, " ***** Test Step 477 : Verify nullable range-restricted signed 16-bit integer value is at min valid\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMinValid_477(); - break; - case 478: - ChipLogProgress(chipTool, " ***** Test Step 478 : Write max valid value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMaxValidValueToANullableRangeRestrictedSigned16BitInteger_478(); - break; - case 479: - ChipLogProgress(chipTool, " ***** Test Step 479 : Verify nullable range-restricted signed 16-bit integer value is at max valid\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_479(); - break; - case 480: - ChipLogProgress(chipTool, " ***** Test Step 480 : Write middle valid value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteMiddleValidValueToANullableRangeRestrictedSigned16BitInteger_480(); - break; - case 481: - ChipLogProgress(chipTool, " ***** Test Step 481 : Verify nullable range-restricted signed 16-bit integer value is at mid valid\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMidValid_481(); - break; - case 482: - ChipLogProgress(chipTool, " ***** Test Step 482 : Write null value to a nullable range-restricted signed 16-bit integer\n"); - err = TestWriteNullValueToANullableRangeRestrictedSigned16BitInteger_482(); - break; - case 483: - ChipLogProgress(chipTool, " ***** Test Step 483 : Verify nullable range-restricted signed 16-bit integer value is null\n"); - err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsNull_483(); - break; - case 484: - ChipLogProgress(chipTool, " ***** Test Step 484 : Write attribute that returns general status on write\n"); - err = TestWriteAttributeThatReturnsGeneralStatusOnWrite_484(); - break; - case 485: - ChipLogProgress(chipTool, " ***** Test Step 485 : Write attribute that returns cluster-specific status on write\n"); - err = TestWriteAttributeThatReturnsClusterSpecificStatusOnWrite_485(); - break; - case 486: - ChipLogProgress(chipTool, " ***** Test Step 486 : Read attribute that returns general status on read\n"); - err = TestReadAttributeThatReturnsGeneralStatusOnRead_486(); - break; - case 487: - ChipLogProgress(chipTool, " ***** Test Step 487 : read attribute that returns cluster-specific status on read\n"); - err = TestReadAttributeThatReturnsClusterSpecificStatusOnRead_487(); - break; - case 488: - ChipLogProgress(chipTool, " ***** Test Step 488 : read AcceptedCommandList attribute\n"); - err = TestReadAcceptedCommandListAttribute_488(); - break; - case 489: - ChipLogProgress(chipTool, " ***** Test Step 489 : read GeneratedCommandList attribute\n"); - err = TestReadGeneratedCommandListAttribute_489(); - break; - case 490: - ChipLogProgress(chipTool, " ***** Test Step 490 : Write struct-typed attribute\n"); - err = TestWriteStructTypedAttribute_490(); - break; - case 491: - ChipLogProgress(chipTool, " ***** Test Step 491 : Read struct-typed attribute\n"); - err = TestReadStructTypedAttribute_491(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 115: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 116: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 117: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 118: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 119: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 120: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 121: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 122: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 123: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 124: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 125: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 126: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 127: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 128: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 129: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 130: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 131: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 132: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 133: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 134: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 135: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 136: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 137: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 138: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 139: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 140: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 141: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 142: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 143: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 144: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 145: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 146: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 147: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - break; - case 148: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - break; - case 149: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - break; - case 150: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - break; - case 151: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 152: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 153: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 154: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 155: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 156: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 157: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 158: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 159: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 160: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 161: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 162: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 163: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 164: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 165: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 166: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 167: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 168: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 169: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 170: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 171: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 172: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 173: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 174: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 175: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 176: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 177: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 178: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 179: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 180: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 181: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 182: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 183: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 184: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 185: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 186: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 187: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 188: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 189: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 190: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 191: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 192: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 193: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 194: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 195: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 196: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 197: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 198: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 199: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 200: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 201: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 202: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 203: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 204: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 205: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 206: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 207: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 208: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 209: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 210: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 211: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 212: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 213: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 214: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 215: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 216: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 217: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 218: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 219: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 220: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 221: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 222: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 223: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 224: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 225: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 226: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 227: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 228: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 229: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 230: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 231: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 232: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 233: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 234: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 235: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 236: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 237: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 238: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 239: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 240: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 241: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 242: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 243: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 244: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 245: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 246: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 247: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 248: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 249: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 250: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 251: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 252: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 253: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 254: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 255: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 256: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 257: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 258: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 259: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 260: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 261: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 262: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 263: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 264: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 265: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 266: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 267: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 268: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 269: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 270: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 271: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 272: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 273: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 274: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 275: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 276: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 277: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 278: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 279: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 280: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 281: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 282: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 283: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 284: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 285: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 286: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 287: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 288: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 289: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 290: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 291: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 292: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 293: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 294: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 295: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 296: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 297: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 298: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 299: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 300: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 301: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 302: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 303: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 304: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 305: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 306: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 307: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 308: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 309: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 310: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 311: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 312: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 313: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 314: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 315: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 316: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 317: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 318: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 319: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 320: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 321: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 322: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 323: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 324: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 325: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 326: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 327: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 328: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 329: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 330: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 331: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 332: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 333: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 334: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 335: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 336: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 337: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 338: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 339: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 340: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 341: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 342: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 343: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 344: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 345: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 346: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 347: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 348: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 349: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 350: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 351: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 352: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 353: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 354: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 355: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 356: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 357: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 358: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 359: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 360: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 361: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 362: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 363: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 364: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 365: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 366: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 367: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 368: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 369: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 370: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 371: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 372: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - break; - case 373: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - break; - case 374: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 375: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 376: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 377: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 378: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 379: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 380: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 381: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 382: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 383: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 384: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 385: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 386: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 387: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 388: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 389: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 390: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 391: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 392: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 393: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 394: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 395: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 396: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 397: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 398: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 399: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 400: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 401: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 402: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 403: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 404: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 405: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 406: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 407: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 408: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 409: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 410: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 411: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 412: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 413: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 414: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 415: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 416: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 417: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 418: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 419: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 420: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 421: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 422: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 423: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 424: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 425: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 426: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 427: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 428: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 429: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 430: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 431: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 432: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 433: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 434: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 435: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 436: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 437: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 438: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 439: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 440: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 441: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 442: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 443: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 444: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 445: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 446: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 447: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 448: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 449: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 450: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 451: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 452: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 453: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 454: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 455: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 456: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 457: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 458: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 459: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 460: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 461: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 462: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 463: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 464: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 465: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 466: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 467: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 468: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 469: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 470: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 471: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 472: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 473: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 474: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 475: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 476: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 477: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 478: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 479: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 480: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 481: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 482: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 483: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 484: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - break; - case 485: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 486: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - break; - case 487: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 488: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 489: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 490: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 491: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 492; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendTestCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command: Error: %@", err); - } else { - NSLog(@"Send Test Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestNotHandledCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testNotHandledWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Not Handled Command: Error: %@", err); - } else { - NSLog(@"Send Test Not Handled Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestSpecificCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testSpecificWithCompletion: - ^(MTRUnitTestingClusterTestSpecificResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Specific Command: Error: %@", err); - } else { - NSLog(@"Send Test Specific Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendFailingTestAddArgumentsCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:250U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:6U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send failing Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send failing Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanDefaultValue_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanTrue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [NSNumber numberWithBool:1]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanTrue_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanFalse_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [NSNumber numberWithBool:0]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN False: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN False: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanFalse_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN False: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN False: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8DefaultValue_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8MaxValue_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8MaxValue_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8MinValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8MinValue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16DefaultValue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16MaxValue_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16MaxValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16MinValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16MinValue_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32MaxValue_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32MaxValue_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32MinValue_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32MinValue_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64MaxValue_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64MaxValue_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64MinValue_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64MinValue_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uDefaultValue_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uMaxValue_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uMaxValue_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uMinValue_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uMinValue_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uDefaultValue_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uMaxValue_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uMaxValue_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uMinValue_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uMinValue_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uDefaultValue_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uMaxValue_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uMaxValue_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uMinValue_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uMinValue_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uDefaultValue_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uMaxValue_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uMaxValue_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uMinValue_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uMinValue_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sMaxValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:127]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sMaxValue_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sMinValue_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:-128]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sMinValue_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, -128)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sDefaultValue_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:0]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sMaxValue_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:32767]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sMaxValue_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sMinValue_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:-32768]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sMinValue_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, -32768)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sDefaultValue_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:0]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sMaxValue_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:2147483647L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sMaxValue_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sMinValue_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:-2147483648L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sMinValue_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, -2147483648L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sDefaultValue_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:0L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sMaxValue_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:9223372036854775807LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sMaxValue_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sMinValue_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sMinValue_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, -9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sDefaultValue_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:0LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleDefaultValue_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleMediumValue_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:0.1f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleMediumValue_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 0.1f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleLargeValue_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:17000000000.0f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE large Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleLargeValue_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE large Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 17000000000.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleSmallValue_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:1.7e-10f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE small Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleSmallValue_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE small Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 1.7e-10f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeSingleDefaultValue_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatSingleArgument; - floatSingleArgument = - [NSNumber numberWithFloat:0.0f]; - [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute SINGLE Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute SINGLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeSingleDefaultValue_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute SINGLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute SINGLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_single", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleDefaultValue_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleMediumValue_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:0.1234567890123]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleMediumValue_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 0.1234567890123)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleLargeValue_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:1.7e+200]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE large Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleLargeValue_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE large Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE large Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 1.7e+200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleSmallValue_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:1.7e-200]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE small Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleSmallValue_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE small Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE small Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 1.7e-200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeDoubleDefaultValue_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id floatDoubleArgument; - floatDoubleArgument = - [NSNumber numberWithDouble:0]; - [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute DOUBLE Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute DOUBLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeDoubleDefaultValue_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute DOUBLE Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute DOUBLE Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("float_double", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8DefaultValue_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8MaxValue_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8MaxValue_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 255U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8MinValue_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8MinValue_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16DefaultValue_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16MaxValue_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16MaxValue_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 65535U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16MinValue_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16MinValue_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringDefaultValue_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringWithEmbeddedNull_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"Tes\000ti\000ng" length:9]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING with embedded null: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING with embedded null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringWithEmbeddedNull_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING with embedded null: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING with embedded null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"Tes\000ti\000ng" length:9])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringWithHexFormat_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"\x00\x01\x02\x03\x04\x05" length:6]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING with hex: format: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING with hex: format: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringWithHexFormat_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING with hex: format: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING with hex: format: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"\x00\x01\x02\x03\x04\x05" length:6])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringWithWeirdChars_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"\015\012\377\042\240" length:5]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING with weird chars: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING with weird chars: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringWithWeirdChars_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING with weird chars: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING with weird chars: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"\x0d\x0a\xff\x22\xa0" length:5])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetString_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"TestValue" length:9]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetString_115() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetString_116() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"TestValueLongerThan10" length:21]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetString_117() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetString_118() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongOctetStringDefaultValue_119() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongOctetString_120() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longOctetStringArgument; - longOctetStringArgument = - [[NSData alloc] initWithBytes:"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" length:300]; - [cluster writeAttributeLongOctetStringWithValue:longOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongOctetString_121() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_octet_string", actualValue, [[NSData alloc] initWithBytes:"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" length:300])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongOctetString_122() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longOctetStringArgument; - longOctetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeLongOctetStringWithValue:longOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringDefaultValue_123() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharString_124() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"☉T☉"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharString_125() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"☉T☉")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueTooLong_126() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"☉TestValueLongerThan10☉"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING - Value too long: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING - Value too long: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharString_127() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"☉T☉")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringEmpty_128() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @""; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING - Empty: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING - Empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongCharStringDefaultValue_129() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_CHAR_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_CHAR_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongCharString_130() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longCharStringArgument; - longCharStringArgument = @"☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉"; - [cluster writeAttributeLongCharStringWithValue:longCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeLongCharString_131() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLongCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LONG_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LONG_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("long_char_string", actualValue, @"☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeLongCharString_132() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id longCharStringArgument; - longCharStringArgument = @""; - [cluster writeAttributeLongCharStringWithValue:longCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LONG_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LONG_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListLongOctetStringForChunkedRead_133() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListLongOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Error: %@", err); - } else { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_long_octet_string", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListLongOctetStringForChunkedWrite_134() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listLongOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[1] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[2] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[3] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[4] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - listLongOctetStringArgument = temp_0; - } - [cluster writeAttributeListLongOctetStringWithValue:listLongOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Error: %@", err); - } else { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListLongOctetStringForChunkedRead_135() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListLongOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Error: %@", err); - } else { - NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_long_octet_string", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - VerifyOrReturn(CheckValueAsString("", actualValue[4], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListLongOctetStringForChunkedWrite_136() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listLongOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[1] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[2] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - temp_0[3] = - [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; - listLongOctetStringArgument = temp_0; - } - [cluster writeAttributeListLongOctetStringWithValue:listLongOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Error: %@", err); - } else { - NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsDefaultValue_137() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsMaxValue_138() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsMaxValue_139() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 18446744073709551615ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsMinValue_140() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsMinValue_141() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSDefaultValue_142() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSMaxValue_143() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSMaxValue_144() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 4294967295UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSMinValue_145() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSMinValue_146() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeUnsupported_147() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeUnsupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute UNSUPPORTED: Error: %@", err); - } else { - NSLog(@"Read attribute UNSUPPORTED: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteattributeUnsupported_148() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id unsupportedArgument; - unsupportedArgument = - [NSNumber numberWithBool:0]; - [cluster writeAttributeUnsupportedWithValue:unsupportedArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Writeattribute UNSUPPORTED: Error: %@", err); - } else { - NSLog(@"Writeattribute UNSUPPORTED: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandToUnsupportedEndpoint_149() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(200) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command to unsupported endpoint: Error: %@", err); - } else { - NSLog(@"Send Test Command to unsupported endpoint: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandToUnsupportedCluster_150() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster testWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command to unsupported cluster: Error: %@", err); - } else { - NSLog(@"Send Test Command to unsupported cluster: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorIdDefaultValue_151() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeVendorId_152() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [NSNumber numberWithUnsignedShort:17U]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute vendor_id: Error: %@", err); - } else { - NSLog(@"Write attribute vendor_id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorId_153() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, 17U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreAttributeVendorId_154() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore attribute vendor_id: Error: %@", err); - } else { - NSLog(@"Restore attribute vendor_id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandWithAVendorIdAndEnum_155() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestEnumsRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedShort:20003U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:1U]; - [cluster testEnumsRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestEnumsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command with a vendor_id and enum: Error: %@", err); - } else { - NSLog(@"Send a command with a vendor_id and enum: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("arg1", actualValue, 20003U)); - } - - { - id actualValue = values.arg2; - VerifyOrReturn(CheckValue("arg2", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandWithAVendorIdAndInvalidEnum_156() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestEnumsRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedShort:20003U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:101U]; - [cluster testEnumsRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestEnumsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command with a vendor_id and invalid enum: Error: %@", err); - } else { - NSLog(@"Send a command with a vendor_id and invalid enum: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithStructArgumentAndArg1bIsTrue_157() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = - [NSNumber numberWithDouble:0]; - - [cluster testStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Struct Argument and arg1.b is true: Error: %@", err); - } else { - NSLog(@"Send Test Command With Struct Argument and arg1.b is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithStructArgumentAndArg1bIsFalse_158() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = - [NSNumber numberWithDouble:0]; - - [cluster testStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Struct Argument and arg1.b is false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Struct Argument and arg1.b is false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructArgumentAndArg1cbIsTrue_159() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStruct alloc] init]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - [cluster testNestedStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct Argument and arg1.c.b is true: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct Argument and arg1.c.b is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructArgumentArg1cbIsFalse_160() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStruct alloc] init]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStruct *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - [cluster testNestedStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct Argument arg1.c.b is false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct Argument arg1.c.b is false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndAllFieldsBOfArg1dAreTrue_161() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructListArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).h = - [NSNumber numberWithDouble:0]; - - temp_1[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) params.arg1).d = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_1[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_1[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).e = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_1[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_1[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).f = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_1[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).g = temp_1; - } - - [cluster testNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfArg1dAreFalse_162() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNestedStructListArgumentRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).h = - [NSNumber numberWithDouble:0]; - - temp_1[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) params.arg1).d = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_1[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_1[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).e = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_1[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_1[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).f = temp_1; - } - { - NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; - temp_1[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_1[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) params.arg1).g = temp_1; - } - - [cluster testNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithStructArgumentAndSeeWhatWeGetBack_163() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterSimpleStructEchoRequestParams alloc] init]; - params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = - [NSNumber numberWithUnsignedChar:17U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = - [NSNumber numberWithFloat:0.1f]; - ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = - [NSNumber numberWithDouble:0.1]; - - [cluster simpleStructEchoRequestWithParams:params completion: - ^(MTRUnitTestingClusterSimpleStructResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Struct Argument and see what we get back: Error: %@", err); - } else { - NSLog(@"Send Test Command With Struct Argument and see what we get back: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("a", ((MTRUnitTestingClusterSimpleStruct *) actualValue).a, 17U)); - VerifyOrReturn(CheckValue("b", ((MTRUnitTestingClusterSimpleStruct *) actualValue).b, false)); - VerifyOrReturn(CheckValue("c", ((MTRUnitTestingClusterSimpleStruct *) actualValue).c, 2U)); - VerifyOrReturn(CheckValueAsString("d", ((MTRUnitTestingClusterSimpleStruct *) actualValue).d, [[NSData alloc] initWithBytes:"octet_string" length:12])); - VerifyOrReturn(CheckValueAsString("e", ((MTRUnitTestingClusterSimpleStruct *) actualValue).e, @"char_string")); - VerifyOrReturn(CheckValue("f", ((MTRUnitTestingClusterSimpleStruct *) actualValue).f, 1U)); - VerifyOrReturn(CheckValue("g", ((MTRUnitTestingClusterSimpleStruct *) actualValue).g, 0.1f)); - VerifyOrReturn(CheckValue("h", ((MTRUnitTestingClusterSimpleStruct *) actualValue).h, 0.1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfInt8uAndNoneOfThemIsSetTo0_164() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - temp_0[4] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[5] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[6] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[7] = - [NSNumber numberWithUnsignedChar:8U]; - temp_0[8] = - [NSNumber numberWithUnsignedChar:9U]; - params.arg1 = temp_0; - } - [cluster testListInt8UArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of INT8U and none of them is set to 0: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of INT8U and none of them is set to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfInt8uAndOneOfThemIsSetTo0_165() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - temp_0[4] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[5] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[6] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[7] = - [NSNumber numberWithUnsignedChar:8U]; - temp_0[8] = - [NSNumber numberWithUnsignedChar:9U]; - temp_0[9] = - [NSNumber numberWithUnsignedChar:0U]; - params.arg1 = temp_0; - } - [cluster testListInt8UArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of INT8U and one of them is set to 0: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of INT8U and one of them is set to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfInt8uAndGetItReversed_166() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UReverseRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - temp_0[4] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[5] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[6] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[7] = - [NSNumber numberWithUnsignedChar:8U]; - temp_0[8] = - [NSNumber numberWithUnsignedChar:9U]; - params.arg1 = temp_0; - } - [cluster testListInt8UReverseRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestListInt8UReverseResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of INT8U and get it reversed: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of INT8U and get it reversed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("arg1", [actualValue count], static_cast(9))); - VerifyOrReturn(CheckValue("", actualValue[0], 9U)); - VerifyOrReturn(CheckValue("", actualValue[1], 8U)); - VerifyOrReturn(CheckValue("", actualValue[2], 7U)); - VerifyOrReturn(CheckValue("", actualValue[3], 6U)); - VerifyOrReturn(CheckValue("", actualValue[4], 5U)); - VerifyOrReturn(CheckValue("", actualValue[5], 4U)); - VerifyOrReturn(CheckValue("", actualValue[6], 3U)); - VerifyOrReturn(CheckValue("", actualValue[7], 2U)); - VerifyOrReturn(CheckValue("", actualValue[8], 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithEmptyListOfInt8uAndGetAnEmptyListBack_167() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListInt8UReverseRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.arg1 = temp_0; - } - [cluster testListInt8UReverseRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestListInt8UReverseResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With empty List of INT8U and get an empty list back: Error: %@", err); - } else { - NSLog(@"Send Test Command With empty List of INT8U and get an empty list back: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.arg1; - VerifyOrReturn(CheckValue("arg1", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsTrue_168() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListStructArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).d = - [[NSData alloc] initWithBytes:"first_octet_string" length:18]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).e = @"first_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).h = - [NSNumber numberWithDouble:0]; - - temp_0[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).d = - [[NSData alloc] initWithBytes:"second_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).e = @"second_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).h = - [NSNumber numberWithDouble:0]; - - params.arg1 = temp_0; - } - [cluster testListStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is true: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsFalse_169() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListStructArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).d = - [[NSData alloc] initWithBytes:"second_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).e = @"second_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).h = - [NSNumber numberWithDouble:0]; - - temp_0[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).d = - [[NSData alloc] initWithBytes:"first_octet_string" length:18]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).e = @"first_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).h = - [NSNumber numberWithDouble:0]; - - params.arg1 = temp_0; - } - [cluster testListStructArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is false: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithListOfNestedStructListArgumentAndAllFieldsBOfElementsOfArg1dAreTrue_170() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListNestedStructListArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).h = - [NSNumber numberWithDouble:0]; - - temp_2[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).d = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_2[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_2[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).e = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_2[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_2[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).f = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_2[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).g = temp_2; - } - - params.arg1 = temp_0; - } - [cluster testListNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true: Error: %@", err); - } else { - NSLog(@"Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfElementsOfArg1dAreFalse_171() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestListNestedStructListArgumentRequestParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterNestedStructList alloc] init]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).a = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).d = - [[NSData alloc] initWithBytes:"octet_string" length:12]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).e = @"char_string"; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).h = - [NSNumber numberWithDouble:0]; - - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).a = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).h = - [NSNumber numberWithDouble:0]; - - temp_2[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).a = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).b = - [NSNumber numberWithBool:false]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).c = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).d = - [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).e = @"nested_char_string"; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).f = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).g = - [NSNumber numberWithFloat:0.0f]; - ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).h = - [NSNumber numberWithDouble:0]; - - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).d = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedInt:1UL]; - temp_2[1] = - [NSNumber numberWithUnsignedInt:2UL]; - temp_2[2] = - [NSNumber numberWithUnsignedInt:3UL]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).e = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [[NSData alloc] initWithBytes:"octet_string_1" length:14]; - temp_2[1] = - [[NSData alloc] initWithBytes:"octect_string_2" length:15]; - temp_2[2] = - [[NSData alloc] initWithBytes:"octet_string_3" length:14]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).f = temp_2; - } - { - NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; - temp_2[0] = - [NSNumber numberWithUnsignedChar:0U]; - temp_2[1] = - [NSNumber numberWithUnsignedChar:255U]; - ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).g = temp_2; - } - - params.arg1 = temp_0; - } - [cluster testListNestedStructListArgumentRequestWithParams:params completion: - ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false: Error: %@", err); - } else { - NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListWithListOfInt8uAndNoneOfThemIsSetTo0_172() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of INT8U and none of them is set to 0: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of INT8U and none of them is set to 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithListOfInt8u_173() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With List of INT8U: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With List of INT8U: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - VerifyOrReturn(CheckValue("", actualValue[2], 3U)); - VerifyOrReturn(CheckValue("", actualValue[3], 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListWithListOfOctetString_174() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [[NSData alloc] initWithBytes:"Test0" length:5]; - temp_0[1] = - [[NSData alloc] initWithBytes:"Test1" length:5]; - temp_0[2] = - [[NSData alloc] initWithBytes:"Test2" length:5]; - temp_0[3] = - [[NSData alloc] initWithBytes:"Test3" length:5]; - listOctetStringArgument = temp_0; - } - [cluster writeAttributeListOctetStringWithValue:listOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithListOfOctetString_175() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With List of OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With List of OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_octet_string", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"Test0" length:5])); - VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"Test1" length:5])); - VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"Test2" length:5])); - VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"Test3" length:5])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListWithListOfListStructOctetString_176() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listStructOctetStringArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[0]).member1 = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[0]).member2 = - [[NSData alloc] initWithBytes:"Test0" length:5]; - - temp_0[1] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[1]).member1 = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[1]).member2 = - [[NSData alloc] initWithBytes:"Test1" length:5]; - - temp_0[2] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[2]).member1 = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[2]).member2 = - [[NSData alloc] initWithBytes:"Test2" length:5]; - - temp_0[3] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[3]).member1 = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRUnitTestingClusterTestListStructOctet *) temp_0[3]).member2 = - [[NSData alloc] initWithBytes:"Test3" length:5]; - - listStructOctetStringArgument = temp_0; - } - [cluster writeAttributeListStructOctetStringWithValue:listStructOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of LIST_STRUCT_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of LIST_STRUCT_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithListOfListStructOctetString_177() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListStructOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With List of LIST_STRUCT_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With List of LIST_STRUCT_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_struct_octet_string", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[0]).member1, 0ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[0]).member2, [[NSData alloc] initWithBytes:"Test0" length:5])); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[1]).member1, 1ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[1]).member2, [[NSData alloc] initWithBytes:"Test1" length:5])); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[2]).member1, 2ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[2]).member2, [[NSData alloc] initWithBytes:"Test2" length:5])); - VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[3]).member1, 3ULL)); - VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[3]).member2, [[NSData alloc] initWithBytes:"Test3" length:5])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithOptionalArgSet_178() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNullableOptionalRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:5U]; - [cluster testNullableOptionalRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestNullableOptionalResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command with optional arg set.: Error: %@", err); - } else { - NSLog(@"Send Test Command with optional arg set.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.wasPresent; - VerifyOrReturn(CheckValue("wasPresent", actualValue, true)); - } - - { - id actualValue = values.wasNull; - VerifyOrReturn(CheckValue("wasNull", actualValue, false)); - } - - { - id actualValue = values.value; - VerifyOrReturn(CheckValue("value", actualValue, 5U)); - } - - { - id actualValue = values.originalValue; - VerifyOrReturn(CheckValueNonNull("originalValue", actualValue)); - VerifyOrReturn(CheckValue("originalValue", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestCommandWithoutItsOptionalArg_179() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestNullableOptionalRequestParams alloc] init]; - [cluster testNullableOptionalRequestWithParams:params completion: - ^(MTRUnitTestingClusterTestNullableOptionalResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Command without its optional arg.: Error: %@", err); - } else { - NSLog(@"Send Test Command without its optional arg.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.wasPresent; - VerifyOrReturn(CheckValue("wasPresent", actualValue, false)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadListOfStructsContainingNullablesAndOptionals_180() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListNullablesAndOptionalsStructWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read list of structs containing nullables and optionals: Error: %@", err); - } else { - NSLog(@"Read list of structs containing nullables and optionals: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_nullables_and_optionals_struct", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueNull("NullableInt", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableInt)); - VerifyOrReturn(CheckValueNull("NullableString", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableString)); - VerifyOrReturn(CheckValueNull("NullableStruct", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableStruct)); - VerifyOrReturn(CheckValueNull("NullableList", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteListOfStructsContainingNullablesAndOptionals_181() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listNullablesAndOptionalsStructArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUnitTestingClusterNullablesAndOptionalsStruct alloc] init]; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableInt = nil; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableString = nil; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableStruct = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_3[1] = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableList = temp_3; - } - - listNullablesAndOptionalsStructArgument = temp_0; - } - [cluster writeAttributeListNullablesAndOptionalsStructWithValue:listNullablesAndOptionalsStructArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write list of structs containing nullables and optionals: Error: %@", err); - } else { - NSLog(@"Write list of structs containing nullables and optionals: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadListOfStructsContainingNullablesAndOptionalsAfterWriting_182() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListNullablesAndOptionalsStructWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read list of structs containing nullables and optionals after writing: Error: %@", err); - } else { - NSLog(@"Read list of structs containing nullables and optionals after writing: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_nullables_and_optionals_struct", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueNull("NullableInt", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableInt)); - VerifyOrReturn(CheckValueNull("NullableString", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableString)); - VerifyOrReturn(CheckValueNull("NullableStruct", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableStruct)); - VerifyOrReturn(CheckValueNonNull("NullableList", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList)); - VerifyOrReturn(CheckValue("NullableList", [((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList count], static_cast(2))); - VerifyOrReturn(CheckValue("", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList[0], 1U)); - VerifyOrReturn(CheckValue("", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanNull_183() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = nil; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BOOLEAN null: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BOOLEAN null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable booValueNull; - - CHIP_ERROR TestReadAttributeNullableBooleanNull_184() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BOOLEAN null: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BOOLEAN null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); - } - { - booValueNull = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanTrue_185() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = - [NSNumber numberWithBool:true]; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBooleanTrue_186() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BOOLEAN True: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BOOLEAN True: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); - VerifyOrReturn(CheckValue("nullable_boolean", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBooleanNotNull_187() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BOOLEAN not null: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BOOLEAN not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableBoolean", value, booValueNull)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap8MaxValue_188() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap8Argument; - nullableBitmap8Argument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap8MaxValue_189() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap8", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap8", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap8InvalidValue_190() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap8Argument; - nullableBitmap8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP8 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP8 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable nullableValue254; - - CHIP_ERROR TestReadAttributeNullableBitmap8UnchangedValue_191() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap8", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap8", actualValue, 254U)); - } - { - nullableValue254 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap8NullValue_192() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap8Argument; - nullableBitmap8Argument = nil; - [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP8 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap8NullValue_193() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap8", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap8Not254Value_194() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP8 not 254 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP8 not 254 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableBitmap8", value, nullableValue254)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap16MaxValue_195() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap16Argument; - nullableBitmap16Argument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap16MaxValue_196() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap16", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap16InvalidValue_197() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap16Argument; - nullableBitmap16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP16 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP16 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap16UnchangedValue_198() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP16 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP16 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap16", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap16NullValue_199() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap16Argument; - nullableBitmap16Argument = nil; - [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP16 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap16NullValue_200() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP16 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap16", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap32MaxValue_201() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap32Argument; - nullableBitmap32Argument = - [NSNumber numberWithUnsignedInt:4294967294UL]; - [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap32MaxValue_202() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP32 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP32 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap32", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap32", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap32InvalidValue_203() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap32Argument; - nullableBitmap32Argument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP32 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP32 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap32UnchangedValue_204() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP32 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP32 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap32", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap32", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap32NullValue_205() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap32Argument; - nullableBitmap32Argument = nil; - [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP32 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP32 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap32NullValue_206() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP32 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP32 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap32", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap64MaxValue_207() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap64Argument; - nullableBitmap64Argument = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap64MaxValue_208() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP64 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP64 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap64", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap64", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap64InvalidValue_209() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap64Argument; - nullableBitmap64Argument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP64 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP64 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap64UnchangedValue_210() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP64 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP64 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_bitmap64", actualValue)); - VerifyOrReturn(CheckValue("nullable_bitmap64", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBitmap64NullValue_211() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBitmap64Argument; - nullableBitmap64Argument = nil; - [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_BITMAP64 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_BITMAP64 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBitmap64NullValue_212() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_BITMAP64 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_BITMAP64 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_bitmap64", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uMinValue_213() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uMinValue_214() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uMaxValue_215() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uMaxValue_216() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uInvalidValue_217() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uUnchangedValue_218() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uUnchangedValueWithConstraint_219() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value with constraint: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U unchanged Value with constraint: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckValueNonNull("nullableInt8u", value)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uNullValue_220() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = nil; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNullValue_221() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int8u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNullValueRange_222() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8u", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8u", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNullValueNot_223() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8u", value, 254U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uValue_224() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:128U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uValueInRange_225() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8u", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8u", [value unsignedCharValue], 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uNotValueOk_226() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8u", value, 129U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uMinValue_227() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uMinValue_228() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uMaxValue_229() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uMaxValue_230() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uInvalidValue_231() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uUnchangedValue_232() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uNullValue_233() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = nil; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNullValue_234() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int16u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNullValueRange_235() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16u", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16u", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNullValueNot_236() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16u", value, 65534U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16uValue_237() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16uArgument; - nullableInt16uArgument = - [NSNumber numberWithUnsignedShort:32000U]; - [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uValueInRange_238() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16u", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16u", [value unsignedShortValue], 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16uNotValueOk_239() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16u", value, 32001U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uMinValue_240() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uMinValue_241() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uMaxValue_242() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:4294967294UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uMaxValue_243() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uInvalidValue_244() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:4294967295UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uUnchangedValue_245() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uNullValue_246() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = nil; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNullValue_247() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int32u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNullValueRange_248() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32u", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32u", [value unsignedIntValue], 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNullValueNot_249() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32u", value, 4294967294UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32uValue_250() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32uArgument; - nullableInt32uArgument = - [NSNumber numberWithUnsignedInt:2147483647UL]; - [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uValueInRange_251() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32u", [value unsignedIntValue], 0UL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32u", [value unsignedIntValue], 4294967294UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32uNotValueOk_252() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32u", value, 2147483648UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uMinValue_253() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uMinValue_254() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uMaxValue_255() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uMaxValue_256() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uInvalidValue_257() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uUnchangedValue_258() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uNullValue_259() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = nil; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNullValue_260() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int64u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNullValueRange_261() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64u", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64u", [value unsignedLongLongValue], 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNullValueNot_262() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64u", value, 18446744073709551614ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64uValue_263() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64uArgument; - nullableInt64uArgument = - [NSNumber numberWithUnsignedLongLong:18000000000000000000ULL]; - [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64U Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uValueInRange_264() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64u", [value unsignedLongLongValue], 0ULL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64u", [value unsignedLongLongValue], 18446744073709551614ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64uNotValueOk_265() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64U notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64U notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64u", value, 18000000000000000001ULL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sMinValue_266() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = - [NSNumber numberWithChar:-127]; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sMinValue_267() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8s", actualValue, -127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sInvalidValue_268() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = - [NSNumber numberWithChar:-128]; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sUnchangedValue_269() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8s", actualValue, -127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sNullValue_270() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = nil; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNullValue_271() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int8s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNullValueRange_272() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8s", [value charValue], -127)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8s", [value charValue], 127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNullValueNot_273() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8s", value, -127)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8sValue_274() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8sArgument; - nullableInt8sArgument = - [NSNumber numberWithChar:-127]; - [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sValueInRange_275() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt8s", [value charValue], -127)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt8s", [value charValue], 127)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8sNotValueOk_276() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt8s", value, -126)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sMinValue_277() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = - [NSNumber numberWithShort:-32767]; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sMinValue_278() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16s", actualValue, -32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sInvalidValue_279() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = - [NSNumber numberWithShort:-32768]; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sUnchangedValue_280() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int16s", actualValue, -32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sNullValue_281() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = nil; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNullValue_282() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int16s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNullValueRange_283() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16s", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16s", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNullValueNot_284() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16s", value, -32767)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt16sValue_285() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt16sArgument; - nullableInt16sArgument = - [NSNumber numberWithShort:-32767]; - [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT16S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT16S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sValueInRange_286() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt16s", [value shortValue], -32767)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt16s", [value shortValue], 32767)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt16sNotValueOk_287() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT16S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT16S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt16s", value, -32766)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sMinValue_288() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = - [NSNumber numberWithInt:-2147483647L]; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sMinValue_289() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32s", actualValue, -2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sInvalidValue_290() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = - [NSNumber numberWithInt:-2147483648L]; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sUnchangedValue_291() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int32s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int32s", actualValue, -2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sNullValue_292() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = nil; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNullValue_293() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int32s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNullValueRange_294() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32s", [value intValue], -2147483647L)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32s", [value intValue], 2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNullValueNot_295() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32s", value, -2147483647L)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt32sValue_296() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt32sArgument; - nullableInt32sArgument = - [NSNumber numberWithInt:-2147483647L]; - [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT32S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT32S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sValueInRange_297() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt32s", [value intValue], -2147483647L)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt32s", [value intValue], 2147483647L)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt32sNotValueOk_298() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT32S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT32S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt32s", value, -2147483646L)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sMinValue_299() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL]; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sMinValue_300() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64s", actualValue, -9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sInvalidValue_301() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL - 1LL]; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sUnchangedValue_302() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int64s", actualValue)); - VerifyOrReturn(CheckValue("nullable_int64s", actualValue, -9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sNullValue_303() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = nil; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNullValue_304() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_int64s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNullValueRange_305() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S null Value & range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S null Value & range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64s", [value longLongValue], -9223372036854775807LL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64s", [value longLongValue], 9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNullValueNot_306() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S null Value & not: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S null Value & not: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64s", value, -9223372036854775807LL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt64sValue_307() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt64sArgument; - nullableInt64sArgument = - [NSNumber numberWithLongLong:-9223372036854775807LL]; - [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT64S Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT64S Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sValueInRange_308() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S Value in range: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S Value in range: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinValue("nullableInt64s", [value longLongValue], -9223372036854775807LL)); - VerifyOrReturn(CheckConstraintMaxValue("nullableInt64s", [value longLongValue], 9223372036854775807LL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt64sNotValueOk_309() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT64S notValue OK: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT64S notValue OK: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableInt64s", value, -9223372036854775806LL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleMediumValue_310() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:0.1f]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleMediumValue_311() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, 0.1f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleLargestValue_312() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:INFINITY]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE largest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleLargestValue_313() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE largest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleSmallestValue_314() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:-INFINITY]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE smallest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleSmallestValue_315() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE smallest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, -INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingleNullValue_316() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = nil; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingleNullValue_317() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_float_single", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSingle0Value_318() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatSingleArgument; - nullableFloatSingleArgument = - [NSNumber numberWithFloat:0.0f]; - [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SINGLE 0 Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SINGLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSingle0Value_319() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SINGLE 0 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SINGLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_single", actualValue, 0.0f)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleMediumValue_320() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:0.1234567890123]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleMediumValue_321() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE medium Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE medium Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, 0.1234567890123)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleLargestValue_322() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:INFINITY]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE largest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleLargestValue_323() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE largest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE largest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleSmallestValue_324() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:-INFINITY]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE smallest Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleSmallestValue_325() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE smallest Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE smallest Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, -INFINITY)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDoubleNullValue_326() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = nil; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDoubleNullValue_327() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_float_double", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableDouble0Value_328() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableFloatDoubleArgument; - nullableFloatDoubleArgument = - [NSNumber numberWithDouble:0]; - [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_DOUBLE 0 Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_DOUBLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableDouble0Value_329() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_DOUBLE 0 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_DOUBLE 0 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); - VerifyOrReturn(CheckValue("nullable_float_double", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8MinValue_330() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8MinValue_331() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8MaxValue_332() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8MaxValue_333() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8InvalidValue_334() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8UnchangedValue_335() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum8NullValue_336() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum8Argument; - nullableEnum8Argument = nil; - [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM8 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum8NullValue_337() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM8 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM8 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_enum8", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16MinValue_338() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16MinValue_339() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16MaxValue_340() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16MaxValue_341() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16InvalidValue_342() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16UnchangedValue_343() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 65534U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableEnum16NullValue_344() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnum16Argument; - nullableEnum16Argument = nil; - [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_ENUM16 null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_ENUM16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableEnum16NullValue_345() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_ENUM16 null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_ENUM16 null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_enum16", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumMinValue_346() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Min Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumMinValue_347() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Min Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Min Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumMaxValue_348() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Max Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumMaxValue_349() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Max Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Max Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumInvalidValue_350() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Invalid Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Invalid Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable nullableEnumAttr3; - - CHIP_ERROR TestReadAttributeNullableSimpleEnumUnchangedValue_351() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM unchanged Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM unchanged Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); - VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 3U)); - } - { - nullableEnumAttr3 = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableSimpleEnumNullValue_352() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableEnumAttrArgument; - nullableEnumAttrArgument = nil; - [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM null Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumNullValue_353() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM null Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_enum_attr", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableSimpleEnumNot3Value_354() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM not 3 Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM not 3 Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableEnumAttr", value, nullableEnumAttr3)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetStringDefaultValue_355() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_356() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"TestValue" length:9]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSData * _Nullable nullableOctetStrTestValue; - - CHIP_ERROR TestReadAttributeNullableOctetString_357() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); - } - { - nullableOctetStrTestValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_358() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = nil; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_359() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_octet_string", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_360() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_361() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetStringNotTestValue_362() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING not TestValue: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING not TestValue: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableOctetString", value, nullableOctetStrTestValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringDefaultValue_363() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharString_364() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = @"☉T☉"; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nullable nullableCharStringSave; - - CHIP_ERROR TestReadAttributeNullableCharString_365() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"☉T☉")); - } - { - nullableCharStringSave = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharString_366() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (nullableCharStringSave == nil) { - VerifyOrReturn(CheckValueNull("nullable_char_string", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, nullableCharStringSave)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringValueTooLong_367() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = nil; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Value too long: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Value too long: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharString_368() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_char_string", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringEmpty_369() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = @""; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Empty: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING - Empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharString_370() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringNott_371() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING not ☉T☉: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING not ☉T☉: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckConstraintNotValue("nullableCharString", value, nullableCharStringSave)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeFromNonexistentEndpoint_372() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(200) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute from nonexistent endpoint.: Error: %@", err); - } else { - NSLog(@"Read attribute from nonexistent endpoint.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeFromNonexistentCluster_373() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute from nonexistent cluster.: Error: %@", err); - } else { - NSLog(@"Read attribute from nonexistent cluster.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_374() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestSimpleOptionalArgumentRequestParams alloc] init]; - [cluster testSimpleOptionalArgumentRequestWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Error: %@", err); - } else { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_375() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestSimpleOptionalArgumentRequestParams alloc] init]; - params.arg1 = - [NSNumber numberWithBool:1]; - [cluster testSimpleOptionalArgumentRequestWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Error: %@", err); - } else { - NSLog(@"Send a command that takes an optional parameter but do not set it.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestCluster_376_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestCluster_list_int8u_Reported - = nil; - - CHIP_ERROR TestReportSubscribeToListAttribute_376() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestCluster_list_int8u_Reported - = ^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe to list attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe to list attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - VerifyOrReturn(CheckValue("", actualValue[2], 3U)); - VerifyOrReturn(CheckValue("", actualValue[3], 4U)); - } - - testSendClusterTestCluster_376_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeToListAttribute_377() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeListInt8uWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestCluster_376_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe to list attribute: Error: %@", err); - } else { - NSLog(@"Subscribe to list attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestCluster_list_int8u_Reported - != nil) { - ResponseHandler callback = test_TestCluster_list_int8u_Reported; - test_TestCluster_list_int8u_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteSubscribedToListAttribute_378() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:5U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:6U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:7U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:8U]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write subscribed-to list attribute: Error: %@", err); - } else { - NSLog(@"Write subscribed-to list attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForListAttributeReport_379() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestCluster_list_int8u_Reported - = ^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for list attribute report: Error: %@", err); - } else { - NSLog(@"Check for list attribute report: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("", actualValue[0], 5U)); - VerifyOrReturn(CheckValue("", actualValue[1], 6U)); - VerifyOrReturn(CheckValue("", actualValue[2], 7U)); - VerifyOrReturn(CheckValue("", actualValue[3], 8U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedUnsigned8BitInteger_380() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedUnsigned8BitInteger_381() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedUnsigned8BitInteger_382() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:19U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedUnsigned8BitInteger_383() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:101U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedUnsigned8BitInteger_384() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:255U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_385() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedUnsigned8BitInteger_386() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:20U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_387() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 20U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedUnsigned8BitInteger_388() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:100U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_389() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedUnsigned8BitInteger_390() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8uArgument; - rangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:50U]; - [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_391() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedUnsigned16BitInteger_392() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedUnsigned16BitInteger_393() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedUnsigned16BitInteger_394() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:99U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedUnsigned16BitInteger_395() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1001U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedUnsigned16BitInteger_396() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:65535U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_397() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedUnsigned16BitInteger_398() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:100U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_399() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedUnsigned16BitInteger_400() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1000U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_401() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 1000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedUnsigned16BitInteger_402() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16uArgument; - rangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:500U]; - [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_403() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted unsigned 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedSigned8BitInteger_404() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedSigned8BitInteger_405() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-128]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedSigned8BitInteger_406() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-41]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedSigned8BitInteger_407() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:51]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedSigned8BitInteger_408() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:127]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueHasNotChanged_409() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedSigned8BitInteger_410() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-40]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMinValid_411() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -40)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedSigned8BitInteger_412() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:50]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_413() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, 50)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedSigned8BitInteger_414() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt8sArgument; - rangeRestrictedInt8sArgument = - [NSNumber numberWithChar:6]; - [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMidValid_415() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, 6)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadRangeRestrictedSigned16BitInteger_416() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToARangeRestrictedSigned16BitInteger_417() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-32768]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedSigned16BitInteger_418() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-151]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedSigned16BitInteger_419() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:201]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToARangeRestrictedSigned16BitInteger_420() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:32767]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueHasNotChanged_421() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToARangeRestrictedSigned16BitInteger_422() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-150]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMinValid_423() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -150)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedSigned16BitInteger_424() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:200]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_425() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, 200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedSigned16BitInteger_426() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id rangeRestrictedInt16sArgument; - rangeRestrictedInt16sArgument = - [NSNumber numberWithShort:7]; - [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMidValid_427() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify range-restricted signed 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify range-restricted signed 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, 7)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedUnsigned8BitInteger_428() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedUnsigned8BitInteger_429() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned8BitInteger_430() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:19U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned8BitInteger_431() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:101U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedUnsigned8BitInteger_432() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_433() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 70U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedUnsigned8BitInteger_434() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:20U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_435() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 20U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedUnsigned8BitInteger_436() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:100U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_437() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned8BitInteger_438() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = - [NSNumber numberWithUnsignedChar:50U]; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_439() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 50U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedUnsigned8BitInteger_440() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8uArgument; - nullableRangeRestrictedInt8uArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted unsigned 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsNull_441() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int8u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedUnsigned16BitInteger_442() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedUnsigned16BitInteger_443() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned16BitInteger_444() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:99U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned16BitInteger_445() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1001U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedUnsigned16BitInteger_446() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_447() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedUnsigned16BitInteger_448() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:100U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_449() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedUnsigned16BitInteger_450() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:1000U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_451() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 1000U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned16BitInteger_452() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = - [NSNumber numberWithUnsignedShort:500U]; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_453() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 500U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedUnsigned16BitInteger_454() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16uArgument; - nullableRangeRestrictedInt16uArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted unsigned 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsNull_455() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int16u", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedSigned8BitInteger_456() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedSigned8BitInteger_457() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-127]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned8BitInteger_458() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-41]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned8BitInteger_459() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:51]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedSigned8BitInteger_460() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:127]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueHasNotChanged_461() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedSigned8BitInteger_462() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:-40]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMinValid_463() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -40)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedSigned8BitInteger_464() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:50]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_465() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, 50)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedSigned8BitInteger_466() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = - [NSNumber numberWithChar:6]; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMidValid_467() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, 6)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedSigned8BitInteger_468() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt8sArgument; - nullableRangeRestrictedInt8sArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted signed 8-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted signed 8-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtNull_469() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int8s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNullableRangeRestrictedSigned16BitInteger_470() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Read nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedSigned16BitInteger_471() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-32767]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned16BitInteger_472() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-151]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-below-range value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned16BitInteger_473() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:201]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write just-above-range value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedSigned16BitInteger_474() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:32767]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueHasNotChanged_475() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value has not changed: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value has not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -100)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedSigned16BitInteger_476() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:-150]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write min valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write min valid value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMinValid_477() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at min valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at min valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -150)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedSigned16BitInteger_478() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:200]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write max valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write max valid value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_479() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at max valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at max valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, 200)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedSigned16BitInteger_480() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = - [NSNumber numberWithShort:7]; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write middle valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write middle valid value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMidValid_481() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at mid valid: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at mid valid: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); - VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, 7)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedSigned16BitInteger_482() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableRangeRestrictedInt16sArgument; - nullableRangeRestrictedInt16sArgument = nil; - [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write null value to a nullable range-restricted signed 16-bit integer: Error: %@", err); - } else { - NSLog(@"Write null value to a nullable range-restricted signed 16-bit integer: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsNull_483() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is null: Error: %@", err); - } else { - NSLog(@"Verify nullable range-restricted signed 16-bit integer value is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_range_restricted_int16s", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeThatReturnsGeneralStatusOnWrite_484() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id generalErrorBooleanArgument; - generalErrorBooleanArgument = - [NSNumber numberWithBool:false]; - [cluster writeAttributeGeneralErrorBooleanWithValue:generalErrorBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute that returns general status on write: Error: %@", err); - } else { - NSLog(@"Write attribute that returns general status on write: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeThatReturnsClusterSpecificStatusOnWrite_485() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id clusterErrorBooleanArgument; - clusterErrorBooleanArgument = - [NSNumber numberWithBool:false]; - [cluster writeAttributeClusterErrorBooleanWithValue:clusterErrorBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute that returns cluster-specific status on write: Error: %@", err); - } else { - NSLog(@"Write attribute that returns cluster-specific status on write: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeThatReturnsGeneralStatusOnRead_486() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneralErrorBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute that returns general status on read: Error: %@", err); - } else { - NSLog(@"Read attribute that returns general status on read: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeThatReturnsClusterSpecificStatusOnRead_487() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterErrorBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read attribute that returns cluster-specific status on read: Error: %@", err); - } else { - NSLog(@"read attribute that returns cluster-specific status on read: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAcceptedCommandListAttribute_488() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"read AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(20))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 2UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 7UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 8UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 9UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 10UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 11UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 12UL)); - VerifyOrReturn(CheckValue("", actualValue[10], 13UL)); - VerifyOrReturn(CheckValue("", actualValue[11], 14UL)); - VerifyOrReturn(CheckValue("", actualValue[12], 15UL)); - VerifyOrReturn(CheckValue("", actualValue[13], 17UL)); - VerifyOrReturn(CheckValue("", actualValue[14], 18UL)); - VerifyOrReturn(CheckValue("", actualValue[15], 19UL)); - VerifyOrReturn(CheckValue("", actualValue[16], 20UL)); - VerifyOrReturn(CheckValue("", actualValue[17], 21UL)); - VerifyOrReturn(CheckValue("", actualValue[18], 22UL)); - VerifyOrReturn(CheckValue("", actualValue[19], 23UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadGeneratedCommandListAttribute_489() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"read GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(10))); - VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 5UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 6UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 8UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 9UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 10UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 11UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 12UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteStructTypedAttribute_490() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id structAttrArgument; - structAttrArgument = [[MTRUnitTestingClusterSimpleStruct alloc] init]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).a = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).b = - [NSNumber numberWithBool:true]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).c = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).d = - [[NSData alloc] initWithBytes:"abc" length:3]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).e = @""; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).f = - [NSNumber numberWithUnsignedChar:17U]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).g = - [NSNumber numberWithFloat:1.5f]; - ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).h = - [NSNumber numberWithDouble:3.14159265358979]; - - [cluster writeAttributeStructAttrWithValue:structAttrArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write struct-typed attribute: Error: %@", err); - } else { - NSLog(@"Write struct-typed attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStructTypedAttribute_491() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStructAttrWithCompletion:^(MTRUnitTestingClusterSimpleStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read struct-typed attribute: Error: %@", err); - } else { - NSLog(@"Read struct-typed attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("a", ((MTRUnitTestingClusterSimpleStruct *) actualValue).a, 5U)); - VerifyOrReturn(CheckValue("b", ((MTRUnitTestingClusterSimpleStruct *) actualValue).b, true)); - VerifyOrReturn(CheckValue("c", ((MTRUnitTestingClusterSimpleStruct *) actualValue).c, 2U)); - VerifyOrReturn(CheckValueAsString("d", ((MTRUnitTestingClusterSimpleStruct *) actualValue).d, [[NSData alloc] initWithBytes:"abc" length:3])); - VerifyOrReturn(CheckValueAsString("e", ((MTRUnitTestingClusterSimpleStruct *) actualValue).e, @"")); - VerifyOrReturn(CheckValue("f", ((MTRUnitTestingClusterSimpleStruct *) actualValue).f, 17U)); - VerifyOrReturn(CheckValue("g", ((MTRUnitTestingClusterSimpleStruct *) actualValue).g, 1.5f)); - VerifyOrReturn(CheckValue("h", ((MTRUnitTestingClusterSimpleStruct *) actualValue).h, 3.14159265358979)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestConstraints : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestConstraints() - : TestCommandBridge("TestConstraints") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestConstraints() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestConstraints\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestConstraints\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write attribute LIST With List of INT8U\n"); - err = TestWriteAttributeListWithListOfInt8u_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute LIST With Partial List of INT8U that should be in it\n"); - err = TestReadAttributeListWithPartialListOfInt8uThatShouldBeInIt_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute LIST With Partial List of INT8U that should not be included\n"); - err = TestReadAttributeListWithPartialListOfInt8uThatShouldNotBeIncluded_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Write attribute LIST Back to Default Value\n"); - err = TestWriteAttributeListBackToDefaultValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Write attribute BITMAP32 with MaskVal1 and MaskVal3\n"); - err = TestWriteAttributeBitmap32WithMaskVal1AndMaskVal3_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal2IsNotSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal1IsSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal3IsSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskval1AndMaskVal3AreSet_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Write attribute BITMAP32 with MaskVal1\n"); - err = TestWriteAttributeBitmap32WithMaskVal1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set\n"); - err = TestReadAttributeBitmap32WithMaskVal1AndEnsureMaskval1OrMaskVal3AreSet_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Write attribute BITMAP32 Back to Default Value\n"); - err = TestWriteAttributeBitmap32BackToDefaultValue_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Write attribute INT32U Value\n"); - err = TestWriteAttributeInt32uValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read attribute INT32U Value MinValue Constraints\n"); - err = TestReadAttributeInt32uValueMinValueConstraints_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute INT32U Value MaxValue Constraints\n"); - err = TestReadAttributeInt32uValueMaxValueConstraints_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read attribute INT32U Value NotValue Constraints\n"); - err = TestReadAttributeInt32uValueNotValueConstraints_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Write attribute INT32U Value Back to Default Value\n"); - err = TestWriteAttributeInt32uValueBackToDefaultValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read attribute CHAR_STRING Value MinLength Constraints\n"); - err = TestReadAttributeCharStringValueMinLengthConstraints_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute CHAR_STRING Value MaxLength Constraints\n"); - err = TestReadAttributeCharStringValueMaxLengthConstraints_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read attribute CHAR_STRING Value StartsWith Constraints\n"); - err = TestReadAttributeCharStringValueStartsWithConstraints_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute CHAR_STRING Value EndsWith Constraints\n"); - err = TestReadAttributeCharStringValueEndsWithConstraints_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Write attribute CHAR_STRING Value with only digits\n"); - err = TestWriteAttributeCharStringValueWithOnlyDigits_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute CHAR_STRING Value with only non-letters\n"); - err = TestWriteAttributeCharStringValueWithOnlyNonLetters_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Write attribute CHAR_STRING Value with uppercase letters and symbols\n"); - err = TestWriteAttributeCharStringValueWithUppercaseLettersAndSymbols_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Write attribute CHAR_STRING Value with lowercase letters and symbols\n"); - err = TestWriteAttributeCharStringValueWithLowercaseLettersAndSymbols_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Write attribute CHAR_STRING Value which is empty\n"); - err = TestWriteAttributeCharStringValueWhichIsEmpty_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); - err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute CHAR_STRING Value isHexString Constraints\n"); - err = TestReadAttributeCharStringValueIsHexStringConstraints_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute CHAR_STRING Value\n"); - err = TestWriteAttributeCharStringValue_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute CHAR_STRING Value isHexString Constraints\n"); - err = TestReadAttributeCharStringValueIsHexStringConstraints_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Write attribute CHAR_STRING Value Back to Default Value\n"); - err = TestWriteAttributeCharStringValueBackToDefaultValue_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Write attribute NULLABLE_CHAR_STRING Value\n"); - err = TestWriteAttributeNullableCharStringValue_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints\n"); - err = TestReadAttributeNullableCharStringValueMinLengthConstraints_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints\n"); - err = TestReadAttributeNullableCharStringValueMaxLengthConstraints_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Write attribute NULLABLE_CHAR_STRING Value Back to Default Value\n"); - err = TestWriteAttributeNullableCharStringValueBackToDefaultValue_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Read attribute NULLABLE_INT8U Default Value\n"); - err = TestReadAttributeNullableInt8uDefaultValue_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Write attribute NULLABLE_INT8U with a value\n"); - err = TestWriteAttributeNullableInt8uWithAValue_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute NULLABLE_INT8U with a value\n"); - err = TestReadAttributeNullableInt8uWithAValue_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute NULLABLE_INT8U without a value\n"); - err = TestWriteAttributeNullableInt8uWithoutAValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute NULLABLE_INT8U with a value\n"); - err = TestReadAttributeNullableInt8uWithAValue_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Write attribute NULLABLE_INT8U back to Default Value\n"); - err = TestWriteAttributeNullableInt8uBackToDefaultValue_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Read attribute NULLABLE_OCTET_STRING Default Value\n"); - err = TestReadAttributeNullableOctetStringDefaultValue_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Write attribute NULLABLE_OCTET_STRING\n"); - err = TestWriteAttributeNullableOctetString_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Read attribute NULLABLE_OCTET_STRING\n"); - err = TestReadAttributeNullableOctetString_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Write attribute NULLABLE_OCTET_STRING back to Default Value\n"); - err = TestWriteAttributeNullableOctetStringBackToDefaultValue_60(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 61; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteAttributeListWithListOfInt8u_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedChar:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedChar:2U]; - temp_0[2] = - [NSNumber numberWithUnsignedChar:3U]; - temp_0[3] = - [NSNumber numberWithUnsignedChar:4U]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST With List of INT8U: Error: %@", err); - } else { - NSLog(@"Write attribute LIST With List of INT8U: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithPartialListOfInt8uThatShouldBeInIt_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With Partial List of INT8U that should be in it: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With Partial List of INT8U that should be in it: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintContains("listInt8u", value, 2U)); - VerifyOrReturn(CheckConstraintContains("listInt8u", value, 3U)); - VerifyOrReturn(CheckConstraintContains("listInt8u", value, 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeListWithPartialListOfInt8uThatShouldNotBeIncluded_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute LIST With Partial List of INT8U that should not be included: Error: %@", err); - } else { - NSLog(@"Read attribute LIST With Partial List of INT8U that should not be included: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintExcludes("listInt8u", value, 0U)); - VerifyOrReturn(CheckConstraintExcludes("listInt8u", value, 5U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeListBackToDefaultValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id listInt8uArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - listInt8uArgument = temp_0; - } - [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute LIST Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute LIST Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32WithMaskVal1AndMaskVal3_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:5UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 with MaskVal1 and MaskVal3: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 with MaskVal1 and MaskVal3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal2IsNotSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal1IsSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal3IsSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskval1AndMaskVal3AreSet_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32WithMaskVal1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 with MaskVal1: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 with MaskVal1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndEnsureMaskval1OrMaskVal3AreSet_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32BackToDefaultValue_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:5UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uValueMinValueConstraints_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Value MinValue Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Value MinValue Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("int32u", [value unsignedIntValue], 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uValueMaxValueConstraints_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Value MaxValue Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Value MaxValue Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxValue("int32u", [value unsignedIntValue], 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uValueNotValueConstraints_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Value NotValue Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Value NotValue Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int32u", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uValueBackToDefaultValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:0UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Value Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Value Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"** Test **"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueMinLengthConstraints_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value MinLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value MinLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinLength("charString", value, 5)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueMaxLengthConstraints_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value MaxLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value MaxLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMaxLength("charString", value, 20)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueStartsWithConstraints_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value StartsWith Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value StartsWith Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintStartsWith("charString", value, "**")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueEndsWithConstraints_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value EndsWith Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value EndsWith Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintEndsWith("charString", value, "**")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"lowercase"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"UPPERCASE"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"lowUPPER"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithOnlyDigits_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"1234567890"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with only digits: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with only digits: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithOnlyNonLetters_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"12.4,76:"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with only non-letters: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with only non-letters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithUppercaseLettersAndSymbols_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"ABC;.* "; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with uppercase letters and symbols: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with uppercase letters and symbols: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWithLowercaseLettersAndSymbols_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"abc;.* "; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value with lowercase letters and symbols: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value with lowercase letters and symbols: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueWhichIsEmpty_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @""; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value which is empty: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value which is empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); - VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"ABCDEF012V"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsHexStringConstraints_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsHexString("charString", value, false)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValue_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"ABCDEF0123"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringValueIsHexStringConstraints_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintIsHexString("charString", value, true)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringValueBackToDefaultValue_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @""; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute CHAR_STRING Value Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute CHAR_STRING Value Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringValue_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = nil; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringValueMinLengthConstraints_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMinLength("nullableCharString", value, 5)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableCharStringValueMaxLengthConstraints_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintMaxLength("nullableCharString", value, 20)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableCharStringValueBackToDefaultValue_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableCharStringArgument; - nullableCharStringArgument = @""; - [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value Back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_CHAR_STRING Value Back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uDefaultValue_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); - VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uWithAValue_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U with a value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U with a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uWithAValue_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uWithoutAValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = nil; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U without a value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U without a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableInt8uWithAValue_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_INT8U with a value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableInt8uBackToDefaultValue_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableInt8uArgument; - nullableInt8uArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_INT8U back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_INT8U back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetStringDefaultValue_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); - VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"TestValue" length:9]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetString_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = nil; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableOctetString_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); - } else { - NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableOctetStringBackToDefaultValue_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableOctetStringArgument; - nullableOctetStringArgument = - [[NSData alloc] initWithBytes:"" length:0]; - [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute NULLABLE_OCTET_STRING back to Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute NULLABLE_OCTET_STRING back to Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestDelayCommands : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestDelayCommands() - : TestCommandBridge("TestDelayCommands") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestDelayCommands() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestDelayCommands\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestDelayCommands\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Wait 100ms\n"); - err = TestWait100ms_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWait100ms_1() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } -}; - -class TestLogCommands : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestLogCommands() - : TestCommandBridge("TestLogCommands") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestLogCommands() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestLogCommands\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestLogCommands\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Log a simple message\n"); - err = TestLogASimpleMessage_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Do a simple user prompt message\n"); - err = TestDoASimpleUserPromptMessage_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestLogASimpleMessage_1() - { - - chip::app::Clusters::LogCommands::Commands::Log::Type value; - value.message = chip::Span("This is a simple messagegarbage: not in length on purpose", 24); - return Log("alpha", value); - } - - CHIP_ERROR TestDoASimpleUserPromptMessage_2() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("This is a simple messagegarbage: not in length on purpose", 24); - return UserPrompt("alpha", value); - } -}; - -class TestSaveAs : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSaveAs() - : TestCommandBridge("TestSaveAs") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSaveAs() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSaveAs\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSaveAs\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute BOOLEAN Default Value\n"); - err = TestReadAttributeBooleanDefaultValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write attribute BOOLEAN Not Default Value\n"); - err = TestWriteAttributeBooleanNotDefaultValue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute BOOLEAN Not Default Value\n"); - err = TestReadAttributeBooleanNotDefaultValue_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write attribute BOOLEAN DefaultValue\n"); - err = TestWriteAttributeBooleanDefaultValue_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BOOLEAN False\n"); - err = TestReadAttributeBooleanFalse_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read attribute BITMAP8 Default Value\n"); - err = TestReadAttributeBitmap8DefaultValue_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Write attribute BITMAP8 Not Default Value\n"); - err = TestWriteAttributeBitmap8NotDefaultValue_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read attribute BITMAP8 Not Default Value\n"); - err = TestReadAttributeBitmap8NotDefaultValue_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Write attribute BITMAP8 Default Value\n"); - err = TestWriteAttributeBitmap8DefaultValue_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read attribute BITMAP8 Default Value\n"); - err = TestReadAttributeBitmap8DefaultValue_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read attribute BITMAP16 Default Value\n"); - err = TestReadAttributeBitmap16DefaultValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Write attribute BITMAP16 Not Default Value\n"); - err = TestWriteAttributeBitmap16NotDefaultValue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute BITMAP16 Not Default Value\n"); - err = TestReadAttributeBitmap16NotDefaultValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write attribute BITMAP16 Default Value\n"); - err = TestWriteAttributeBitmap16DefaultValue_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read attribute BITMAP16 Default Value\n"); - err = TestReadAttributeBitmap16DefaultValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Write attribute BITMAP32 Not Default Value\n"); - err = TestWriteAttributeBitmap32NotDefaultValue_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute BITMAP32 Not Default Value\n"); - err = TestReadAttributeBitmap32NotDefaultValue_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Write attribute BITMAP32 Default Value\n"); - err = TestWriteAttributeBitmap32DefaultValue_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute BITMAP32 Default Value\n"); - err = TestReadAttributeBitmap32DefaultValue_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Write attribute BITMAP64 Not Default Value\n"); - err = TestWriteAttributeBitmap64NotDefaultValue_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Write attribute BITMAP64 Default Value\n"); - err = TestWriteAttributeBitmap64DefaultValue_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Read attribute BITMAP64 Default Value\n"); - err = TestReadAttributeBitmap64DefaultValue_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read attribute INT8U Default Value\n"); - err = TestReadAttributeInt8uDefaultValue_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Write attribute INT8U Not Default Value\n"); - err = TestWriteAttributeInt8uNotDefaultValue_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute INT8U Not Default Value\n"); - err = TestReadAttributeInt8uNotDefaultValue_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute INT8U Default Value\n"); - err = TestWriteAttributeInt8uDefaultValue_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute INT8U Default Value\n"); - err = TestReadAttributeInt8uDefaultValue_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Read attribute INT16U Default Value\n"); - err = TestReadAttributeInt16uDefaultValue_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Write attribute INT16U Not Default Value\n"); - err = TestWriteAttributeInt16uNotDefaultValue_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read attribute INT16U Not Default Value\n"); - err = TestReadAttributeInt16uNotDefaultValue_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Write attribute INT16U Default Value\n"); - err = TestWriteAttributeInt16uDefaultValue_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read attribute INT16U Default Value\n"); - err = TestReadAttributeInt16uDefaultValue_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Read attribute INT32U Default Value\n"); - err = TestReadAttributeInt32uDefaultValue_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Write attribute INT32U Not Default Value\n"); - err = TestWriteAttributeInt32uNotDefaultValue_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute INT32U Not Default Value\n"); - err = TestReadAttributeInt32uNotDefaultValue_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute INT32U Default Value\n"); - err = TestWriteAttributeInt32uDefaultValue_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute INT32U Default Value\n"); - err = TestReadAttributeInt32uDefaultValue_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Read attribute INT64U Default Value\n"); - err = TestReadAttributeInt64uDefaultValue_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Write attribute INT64U Not Default Value\n"); - err = TestWriteAttributeInt64uNotDefaultValue_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute INT64U Not Default Value\n"); - err = TestReadAttributeInt64uNotDefaultValue_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Write attribute INT64U Default Value\n"); - err = TestWriteAttributeInt64uDefaultValue_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Read attribute INT64U Default Value\n"); - err = TestReadAttributeInt64uDefaultValue_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Write attribute INT8S Not Default Value\n"); - err = TestWriteAttributeInt8sNotDefaultValue_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute INT8S Not Default Value\n"); - err = TestReadAttributeInt8sNotDefaultValue_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute INT8S Default Value\n"); - err = TestWriteAttributeInt8sDefaultValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute INT8S Default Value\n"); - err = TestReadAttributeInt8sDefaultValue_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Write attribute INT16S Not Default Value\n"); - err = TestWriteAttributeInt16sNotDefaultValue_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Read attribute INT16S Not Default Value\n"); - err = TestReadAttributeInt16sNotDefaultValue_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Write attribute INT16S Default Value\n"); - err = TestWriteAttributeInt16sDefaultValue_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Read attribute INT16S Default Value\n"); - err = TestReadAttributeInt16sDefaultValue_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Write attribute INT32S Not Default Value\n"); - err = TestWriteAttributeInt32sNotDefaultValue_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Read attribute INT32S Not Default Value\n"); - err = TestReadAttributeInt32sNotDefaultValue_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Write attribute INT32S Default Value\n"); - err = TestWriteAttributeInt32sDefaultValue_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Read attribute INT32S Default Value\n"); - err = TestReadAttributeInt32sDefaultValue_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Write attribute INTS Not Default Value\n"); - err = TestWriteAttributeIntsNotDefaultValue_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Read attribute INT64S Not Default Value\n"); - err = TestReadAttributeInt64sNotDefaultValue_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Write attribute INT64S Default Value\n"); - err = TestWriteAttributeInt64sDefaultValue_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Read attribute INT64S Default Value\n"); - err = TestReadAttributeInt64sDefaultValue_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Read attribute ENUM8 Default Value\n"); - err = TestReadAttributeEnum8DefaultValue_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Write attribute ENUM8 Not Default Value\n"); - err = TestWriteAttributeEnum8NotDefaultValue_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Read attribute ENUM8 Not Default Value\n"); - err = TestReadAttributeEnum8NotDefaultValue_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Write attribute ENUM8 Default Value\n"); - err = TestWriteAttributeEnum8DefaultValue_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Read attribute ENUM8 Default Value\n"); - err = TestReadAttributeEnum8DefaultValue_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Read attribute ENUM16 Default Value\n"); - err = TestReadAttributeEnum16DefaultValue_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Write attribute ENUM16 Not Default Value\n"); - err = TestWriteAttributeEnum16NotDefaultValue_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Read attribute ENUM16 Not Default Value\n"); - err = TestReadAttributeEnum16NotDefaultValue_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Write attribute ENUM16 Default Value\n"); - err = TestWriteAttributeEnum16DefaultValue_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Read attribute ENUM16 Default Value\n"); - err = TestReadAttributeEnum16DefaultValue_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Read attribute EPOCH_US Default Value\n"); - err = TestReadAttributeEpochUsDefaultValue_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Write attribute EPOCH_US Not Default Value\n"); - err = TestWriteAttributeEpochUsNotDefaultValue_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Read attribute EPOCH_US Not Default Value\n"); - err = TestReadAttributeEpochUsNotDefaultValue_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Write attribute EPOCH_US Default Value\n"); - err = TestWriteAttributeEpochUsDefaultValue_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Read attribute EPOCH_US Default Value\n"); - err = TestReadAttributeEpochUsDefaultValue_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Read attribute EPOCH_S Default Value\n"); - err = TestReadAttributeEpochSDefaultValue_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Write attribute EPOCH_S Not Default Value\n"); - err = TestWriteAttributeEpochSNotDefaultValue_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Read attribute EPOCH_S Not Default Value\n"); - err = TestReadAttributeEpochSNotDefaultValue_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Write attribute EPOCH_S Default Value\n"); - err = TestWriteAttributeEpochSDefaultValue_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Read attribute EPOCH_S Default Value\n"); - err = TestReadAttributeEpochSDefaultValue_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Read attribute vendor_id Default Value\n"); - err = TestReadAttributeVendorIdDefaultValue_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Write attribute vendor_id Not Default Value\n"); - err = TestWriteAttributeVendorIdNotDefaultValue_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Read attribute vendor_id Not Default Value\n"); - err = TestReadAttributeVendorIdNotDefaultValue_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Write attribute vendor_id Default Value\n"); - err = TestWriteAttributeVendorIdDefaultValue_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Read attribute vendor_id Default Value\n"); - err = TestReadAttributeVendorIdDefaultValue_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Read attribute char_string Default Value\n"); - err = TestReadAttributeCharStringDefaultValue_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Read attribute char_string Default Value and compare to saved value\n"); - err = TestReadAttributeCharStringDefaultValueAndCompareToSavedValue_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Write attribute char_string Not Default Value\n"); - err = TestWriteAttributeCharStringNotDefaultValue_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Read attribute char_string Not Default Value\n"); - err = TestReadAttributeCharStringNotDefaultValue_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Read attribute char_string Not Default Value and compare to saved value\n"); - err = TestReadAttributeCharStringNotDefaultValueAndCompareToSavedValue_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Write attribute char_string Not Default Value from saved value\n"); - err = TestWriteAttributeCharStringNotDefaultValueFromSavedValue_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Read attribute char_string Not Default Value and compare to expected value\n"); - err = TestReadAttributeCharStringNotDefaultValueAndCompareToExpectedValue_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Write attribute char_string Default Value\n"); - err = TestWriteAttributeCharStringDefaultValue_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Read attribute octet_string Default Value\n"); - err = TestReadAttributeOctetStringDefaultValue_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Read attribute octet_string Default Value and compare to saved value\n"); - err = TestReadAttributeOctetStringDefaultValueAndCompareToSavedValue_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Write attribute octet_string Not Default Value\n"); - err = TestWriteAttributeOctetStringNotDefaultValue_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Read attribute octet_string Not Default Value\n"); - err = TestReadAttributeOctetStringNotDefaultValue_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Read attribute octet_string Not Default Value and compare to saved value\n"); - err = TestReadAttributeOctetStringNotDefaultValueAndCompareToSavedValue_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Write attribute octet_string Not Default Value from saved value\n"); - err = TestWriteAttributeOctetStringNotDefaultValueFromSavedValue_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Read attribute octet_string Not Default Value and compare to expected value\n"); - err = TestReadAttributeOctetStringNotDefaultValueAndCompareToExpectedValue_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Write attribute octet_string Default Value\n"); - err = TestWriteAttributeOctetStringDefaultValue_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Read attribute nullable_boolean Default Value\n"); - err = TestReadAttributeNullableBooleanDefaultValue_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Write attribute nullable_boolean to null\n"); - err = TestWriteAttributeNullableBooleanToNull_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Read attribute nullable_boolean null Value\n"); - err = TestReadAttributeNullableBooleanNullValue_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Read attribute nullable_boolean null Value again and compare it to the previously saved value\n"); - err = TestReadAttributeNullableBooleanNullValueAgainAndCompareItToThePreviouslySavedValue_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Write attribute nullable_boolean Default Value\n"); - err = TestWriteAttributeNullableBooleanDefaultValue_114(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 115; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull TestAddArgumentDefaultValue; - - CHIP_ERROR TestSendTestAddArgumentsCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); - } - { - TestAddArgumentDefaultValue = values.returnValue; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, TestAddArgumentDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [TestAddArgumentDefaultValue copy]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("returnValue", values.returnValue, TestAddArgumentDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBooleanDefaultValue; - - CHIP_ERROR TestReadAttributeBooleanDefaultValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, 0)); - } - { - readAttributeBooleanDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanNotDefaultValue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [NSNumber numberWithBool:1]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanNotDefaultValue_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("boolean", value, readAttributeBooleanDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBooleanDefaultValue_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id booleanArgument; - booleanArgument = - [readAttributeBooleanDefaultValue copy]; - [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BOOLEAN DefaultValue: Error: %@", err); - } else { - NSLog(@"Write attribute BOOLEAN DefaultValue: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBooleanFalse_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BOOLEAN False: Error: %@", err); - } else { - NSLog(@"Read attribute BOOLEAN False: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("boolean", actualValue, readAttributeBooleanDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap8DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap8DefaultValue_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); - } - { - readAttributeBitmap8DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8NotDefaultValue_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8NotDefaultValue_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap8", value, readAttributeBitmap8DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap8DefaultValue_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap8Argument; - bitmap8Argument = - [readAttributeBitmap8DefaultValue copy]; - [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap8DefaultValue_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap8", actualValue, readAttributeBitmap8DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap16DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap16DefaultValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); - } - { - readAttributeBitmap16DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16NotDefaultValue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16NotDefaultValue_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap16", value, readAttributeBitmap16DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap16DefaultValue_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap16Argument; - bitmap16Argument = - [readAttributeBitmap16DefaultValue copy]; - [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap16DefaultValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap16", actualValue, readAttributeBitmap16DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap32DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); - } - { - readAttributeBitmap32DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32NotDefaultValue_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32NotDefaultValue_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap32", value, readAttributeBitmap32DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap32DefaultValue_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap32Argument; - bitmap32Argument = - [readAttributeBitmap32DefaultValue copy]; - [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap32DefaultValue_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP32 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap32", actualValue, readAttributeBitmap32DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeBitmap64DefaultValue; - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); - } - { - readAttributeBitmap64DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64NotDefaultValue_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("bitmap64", value, readAttributeBitmap64DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeBitmap64DefaultValue_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bitmap64Argument; - bitmap64Argument = - [readAttributeBitmap64DefaultValue copy]; - [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeBitmap64DefaultValue_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute BITMAP64 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("bitmap64", actualValue, readAttributeBitmap64DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt8uDefaultValue; - - CHIP_ERROR TestReadAttributeInt8uDefaultValue_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); - } - { - readAttributeInt8uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uNotDefaultValue_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uNotDefaultValue_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int8u", value, readAttributeInt8uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8uDefaultValue_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8uArgument; - int8uArgument = - [readAttributeInt8uDefaultValue copy]; - [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8uDefaultValue_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8u", actualValue, readAttributeInt8uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt16uDefaultValue; - - CHIP_ERROR TestReadAttributeInt16uDefaultValue_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); - } - { - readAttributeInt16uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uNotDefaultValue_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uNotDefaultValue_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int16u", value, readAttributeInt16uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16uDefaultValue_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16uArgument; - int16uArgument = - [readAttributeInt16uDefaultValue copy]; - [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16uDefaultValue_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16u", actualValue, readAttributeInt16uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt32uDefaultValue; - - CHIP_ERROR TestReadAttributeInt32uDefaultValue_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); - } - { - readAttributeInt32uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uNotDefaultValue_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uNotDefaultValue_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int32u", value, readAttributeInt32uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32uDefaultValue_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32uArgument; - int32uArgument = - [readAttributeInt32uDefaultValue copy]; - [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32uDefaultValue_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32u", actualValue, readAttributeInt32uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt64uDefaultValue; - - CHIP_ERROR TestReadAttributeInt64uDefaultValue_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); - } - { - readAttributeInt64uDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uNotDefaultValue_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uNotDefaultValue_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int64u", value, readAttributeInt64uDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64uDefaultValue_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64uArgument; - int64uArgument = - [readAttributeInt64uDefaultValue copy]; - [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64uDefaultValue_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64U Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64U Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64u", actualValue, readAttributeInt64uDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt8sDefaultValue; - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, 0)); - } - { - readAttributeInt8sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sNotDefaultValue_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [NSNumber numberWithChar:1]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sNotDefaultValue_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int8s", value, readAttributeInt8sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt8sDefaultValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int8sArgument; - int8sArgument = - [readAttributeInt8sDefaultValue copy]; - [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt8sDefaultValue_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT8S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT8S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int8s", actualValue, readAttributeInt8sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt16sDefaultValue; - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, 0)); - } - { - readAttributeInt16sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sNotDefaultValue_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [NSNumber numberWithShort:1]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sNotDefaultValue_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int16s", value, readAttributeInt16sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt16sDefaultValue_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int16sArgument; - int16sArgument = - [readAttributeInt16sDefaultValue copy]; - [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt16sDefaultValue_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT16S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT16S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int16s", actualValue, readAttributeInt16sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt32sDefaultValue; - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); - } - { - readAttributeInt32sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sNotDefaultValue_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [NSNumber numberWithInt:1L]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sNotDefaultValue_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int32s", value, readAttributeInt32sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt32sDefaultValue_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int32sArgument; - int32sArgument = - [readAttributeInt32sDefaultValue copy]; - [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt32sDefaultValue_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT32S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT32S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int32s", actualValue, readAttributeInt32sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeInt64sDefaultValue; - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); - } - { - readAttributeInt64sDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeIntsNotDefaultValue_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [NSNumber numberWithLongLong:1LL]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INTS Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INTS Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sNotDefaultValue_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("int64s", value, readAttributeInt64sDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeInt64sDefaultValue_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id int64sArgument; - int64sArgument = - [readAttributeInt64sDefaultValue copy]; - [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeInt64sDefaultValue_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute INT64S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute INT64S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("int64s", actualValue, readAttributeInt64sDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEnum8DefaultValue; - - CHIP_ERROR TestReadAttributeEnum8DefaultValue_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); - } - { - readAttributeEnum8DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8NotDefaultValue_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8NotDefaultValue_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("enum8", value, readAttributeEnum8DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum8DefaultValue_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum8Argument; - enum8Argument = - [readAttributeEnum8DefaultValue copy]; - [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum8DefaultValue_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM8 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum8", actualValue, readAttributeEnum8DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEnum16DefaultValue; - - CHIP_ERROR TestReadAttributeEnum16DefaultValue_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); - } - { - readAttributeEnum16DefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16NotDefaultValue_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16NotDefaultValue_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("enum16", value, readAttributeEnum16DefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEnum16DefaultValue_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id enum16Argument; - enum16Argument = - [readAttributeEnum16DefaultValue copy]; - [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEnum16DefaultValue_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute ENUM16 Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("enum16", actualValue, readAttributeEnum16DefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEpochUSDefaultValue; - - CHIP_ERROR TestReadAttributeEpochUsDefaultValue_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); - } - { - readAttributeEpochUSDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsNotDefaultValue_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsNotDefaultValue_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("epochUs", value, readAttributeEpochUSDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochUsDefaultValue_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochUsArgument; - epochUsArgument = - [readAttributeEpochUSDefaultValue copy]; - [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochUsDefaultValue_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_US Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_us", actualValue, readAttributeEpochUSDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeEpochSDefaultValue; - - CHIP_ERROR TestReadAttributeEpochSDefaultValue_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); - } - { - readAttributeEpochSDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSNotDefaultValue_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSNotDefaultValue_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("epochS", value, readAttributeEpochSDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeEpochSDefaultValue_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id epochSArgument; - epochSArgument = - [readAttributeEpochSDefaultValue copy]; - [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeEpochSDefaultValue_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute EPOCH_S Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("epoch_s", actualValue, readAttributeEpochSDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull readAttributeVendorIdDefaultValue; - - CHIP_ERROR TestReadAttributeVendorIdDefaultValue_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, 0U)); - } - { - readAttributeVendorIdDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeVendorIdNotDefaultValue_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [NSNumber numberWithUnsignedShort:1U]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute vendor_id Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute vendor_id Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorIdNotDefaultValue_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("vendorId", value, readAttributeVendorIdDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeVendorIdDefaultValue_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id vendorIdArgument; - vendorIdArgument = - [readAttributeVendorIdDefaultValue copy]; - [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeVendorIdDefaultValue_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute vendor_id Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("vendor_id", actualValue, readAttributeVendorIdDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull readAttributeCharStringDefaultValue; - - CHIP_ERROR TestReadAttributeCharStringDefaultValue_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"")); - } - { - readAttributeCharStringDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringDefaultValueAndCompareToSavedValue_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, readAttributeCharStringDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringNotDefaultValue_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = @"NotDefault"; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute char_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute char_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull readAttributeCharStringNotDefaultValue; - - CHIP_ERROR TestReadAttributeCharStringNotDefaultValue_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"NotDefault")); - } - - VerifyOrReturn(CheckConstraintNotValue("charString", value, readAttributeCharStringDefaultValue)); - { - readAttributeCharStringNotDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringNotDefaultValueAndCompareToSavedValue_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Not Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Not Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, readAttributeCharStringNotDefaultValue)); - } - - VerifyOrReturn(CheckConstraintNotValue("charString", value, readAttributeCharStringDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringNotDefaultValueFromSavedValue_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = - [readAttributeCharStringNotDefaultValue copy]; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute char_string Not Default Value from saved value: Error: %@", err); - } else { - NSLog(@"Write attribute char_string Not Default Value from saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeCharStringNotDefaultValueAndCompareToExpectedValue_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute char_string Not Default Value and compare to expected value: Error: %@", err); - } else { - NSLog(@"Read attribute char_string Not Default Value and compare to expected value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"NotDefault")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeCharStringDefaultValue_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id charStringArgument; - charStringArgument = - [readAttributeCharStringDefaultValue copy]; - [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute char_string Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute char_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSData * _Nonnull readAttributeOctetStringDefaultValue; - - CHIP_ERROR TestReadAttributeOctetStringDefaultValue_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); - } - { - readAttributeOctetStringDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringDefaultValueAndCompareToSavedValue_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, readAttributeOctetStringDefaultValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringNotDefaultValue_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [[NSData alloc] initWithBytes:"NotDefault" length:10]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute octet_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute octet_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSData * _Nonnull readAttributeOctetStringNotDefaultValue; - - CHIP_ERROR TestReadAttributeOctetStringNotDefaultValue_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Not Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Not Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"NotDefault" length:10])); - } - - VerifyOrReturn(CheckConstraintNotValue("octetString", value, readAttributeOctetStringDefaultValue)); - { - readAttributeOctetStringNotDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringNotDefaultValueAndCompareToSavedValue_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Not Default Value and compare to saved value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Not Default Value and compare to saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, readAttributeOctetStringNotDefaultValue)); - } - - VerifyOrReturn(CheckConstraintNotValue("octetString", value, readAttributeOctetStringDefaultValue)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringNotDefaultValueFromSavedValue_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [readAttributeOctetStringNotDefaultValue copy]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute octet_string Not Default Value from saved value: Error: %@", err); - } else { - NSLog(@"Write attribute octet_string Not Default Value from saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeOctetStringNotDefaultValueAndCompareToExpectedValue_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute octet_string Not Default Value and compare to expected value: Error: %@", err); - } else { - NSLog(@"Read attribute octet_string Not Default Value and compare to expected value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"NotDefault" length:10])); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeOctetStringDefaultValue_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id octetStringArgument; - octetStringArgument = - [readAttributeOctetStringDefaultValue copy]; - [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute octet_string Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute octet_string Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable readAttributeNullableBooleanDefaultValue; - - CHIP_ERROR TestReadAttributeNullableBooleanDefaultValue_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute nullable_boolean Default Value: Error: %@", err); - } else { - NSLog(@"Read attribute nullable_boolean Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); - VerifyOrReturn(CheckValue("nullable_boolean", actualValue, false)); - } - { - readAttributeNullableBooleanDefaultValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanToNull_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = nil; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute nullable_boolean to null: Error: %@", err); - } else { - NSLog(@"Write attribute nullable_boolean to null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable readAttributeNullableBooleanNullValue; - - CHIP_ERROR TestReadAttributeNullableBooleanNullValue_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute nullable_boolean null Value: Error: %@", err); - } else { - NSLog(@"Read attribute nullable_boolean null Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); - } - { - readAttributeNullableBooleanNullValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeNullableBooleanNullValueAgainAndCompareItToThePreviouslySavedValue_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute nullable_boolean null Value again and compare it to the previously saved value: Error: %@", err); - } else { - NSLog(@"Read attribute nullable_boolean null Value again and compare it to the previously saved value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (readAttributeNullableBooleanNullValue == nil) { - VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); - VerifyOrReturn(CheckValue("nullable_boolean", actualValue, readAttributeNullableBooleanNullValue)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteAttributeNullableBooleanDefaultValue_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nullableBooleanArgument; - nullableBooleanArgument = - [readAttributeNullableBooleanDefaultValue copy]; - [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write attribute nullable_boolean Default Value: Error: %@", err); - } else { - NSLog(@"Write attribute nullable_boolean Default Value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestConfigVariables : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestConfigVariables() - : TestCommandBridge("TestConfigVariables") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("arg1", 0, UINT8_MAX, &mArg1); - AddArgument("returnValueWithArg1", 0, UINT8_MAX, &mReturnValueWithArg1); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestConfigVariables() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestConfigVariables\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestConfigVariables\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Add Arguments Command\n"); - err = TestSendTestAddArgumentsCommand_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mArg1; - chip::Optional mReturnValueWithArg1; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull TestAddArgumentDefaultValue; - - CHIP_ERROR TestSendTestAddArgumentsCommand_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = - [NSNumber numberWithUnsignedChar:3U]; - params.arg2 = - [NSNumber numberWithUnsignedChar:17U]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); - } - { - TestAddArgumentDefaultValue = values.returnValue; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendTestAddArgumentsCommand_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; - params.arg1 = mArg1.HasValue() ? [NSNumber numberWithUnsignedChar:mArg1.Value()] : [NSNumber numberWithUnsignedChar:5U]; - params.arg2 = - [TestAddArgumentDefaultValue copy]; - [cluster testAddArgumentsWithParams:params completion: - ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Test Add Arguments Command: Error: %@", err); - } else { - NSLog(@"Send Test Add Arguments Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.returnValue; - VerifyOrReturn(CheckValue("returnValue", actualValue, mReturnValueWithArg1.HasValue() ? mReturnValueWithArg1.Value() : 25U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestDescriptorCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestDescriptorCluster() - : TestCommandBridge("TestDescriptorCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestDescriptorCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestDescriptorCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestDescriptorCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Device list\n"); - err = TestReadAttributeDeviceList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute Server list\n"); - err = TestReadAttributeServerList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute Client list\n"); - err = TestReadAttributeClientList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute Parts list\n"); - err = TestReadAttributePartsList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute ClusterRevision\n"); - err = TestReadAttributeClusterRevision_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute Tag list\n"); - err = TestReadAttributeTagList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read feature map Attribute\n"); - err = TestReadFeatureMapAttribute_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAttributeDeviceList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Device list: Error: %@", err); - } else { - NSLog(@"Read attribute Device list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DeviceTypeList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("DeviceType", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[0]).deviceType, 17UL)); - VerifyOrReturn(CheckValue("Revision", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[0]).revision, 1U)); - VerifyOrReturn(CheckValue("DeviceType", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[1]).deviceType, 22UL)); - VerifyOrReturn(CheckValue("Revision", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[1]).revision, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeServerList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeServerListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Server list: Error: %@", err); - } else { - NSLog(@"Read attribute Server list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ServerList", [actualValue count], static_cast(28))); - VerifyOrReturn(CheckValue("", actualValue[0], 3UL)); - VerifyOrReturn(CheckValue("", actualValue[1], 4UL)); - VerifyOrReturn(CheckValue("", actualValue[2], 29UL)); - VerifyOrReturn(CheckValue("", actualValue[3], 30UL)); - VerifyOrReturn(CheckValue("", actualValue[4], 31UL)); - VerifyOrReturn(CheckValue("", actualValue[5], 40UL)); - VerifyOrReturn(CheckValue("", actualValue[6], 42UL)); - VerifyOrReturn(CheckValue("", actualValue[7], 43UL)); - VerifyOrReturn(CheckValue("", actualValue[8], 44UL)); - VerifyOrReturn(CheckValue("", actualValue[9], 45UL)); - VerifyOrReturn(CheckValue("", actualValue[10], 46UL)); - VerifyOrReturn(CheckValue("", actualValue[11], 47UL)); - VerifyOrReturn(CheckValue("", actualValue[12], 48UL)); - VerifyOrReturn(CheckValue("", actualValue[13], 49UL)); - VerifyOrReturn(CheckValue("", actualValue[14], 50UL)); - VerifyOrReturn(CheckValue("", actualValue[15], 51UL)); - VerifyOrReturn(CheckValue("", actualValue[16], 52UL)); - VerifyOrReturn(CheckValue("", actualValue[17], 53UL)); - VerifyOrReturn(CheckValue("", actualValue[18], 54UL)); - VerifyOrReturn(CheckValue("", actualValue[19], 55UL)); - VerifyOrReturn(CheckValue("", actualValue[20], 56UL)); - VerifyOrReturn(CheckValue("", actualValue[21], 60UL)); - VerifyOrReturn(CheckValue("", actualValue[22], 62UL)); - VerifyOrReturn(CheckValue("", actualValue[23], 63UL)); - VerifyOrReturn(CheckValue("", actualValue[24], 64UL)); - VerifyOrReturn(CheckValue("", actualValue[25], 65UL)); - VerifyOrReturn(CheckValue("", actualValue[26], 1029UL)); - VerifyOrReturn(CheckValue("", actualValue[27], 4294048774UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeClientList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClientListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Client list: Error: %@", err); - } else { - NSLog(@"Read attribute Client list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClientList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributePartsList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePartsListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Parts list: Error: %@", err); - } else { - NSLog(@"Read attribute Parts list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PartsList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeClusterRevision_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute ClusterRevision: Error: %@", err); - } else { - NSLog(@"Read attribute ClusterRevision: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadAttributeTagList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTagListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read attribute Tag list: Error: %@", err); - } else { - NSLog(@"Read attribute Tag list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TagList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValueNull("MfgCode", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).mfgCode)); - VerifyOrReturn(CheckValue("NamespaceID", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).namespaceID, 7U)); - VerifyOrReturn(CheckValue("Tag", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).tag, 0U)); - VerifyOrReturn(CheckValueNull("MfgCode", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).mfgCode)); - VerifyOrReturn(CheckValue("NamespaceID", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).namespaceID, 8U)); - VerifyOrReturn(CheckValue("Tag", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).tag, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFeatureMapAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read feature map Attribute: Error: %@", err); - } else { - NSLog(@"Read feature map Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestFabricRemovalWhileSubscribed : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestFabricRemovalWhileSubscribed() - : TestCommandBridge("TestFabricRemovalWhileSubscribed") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestFabricRemovalWhileSubscribed() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestFabricRemovalWhileSubscribed\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestFabricRemovalWhileSubscribed\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of commissioned fabrics\n"); - err = TestReadNumberOfCommissionedFabrics_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current fabric index\n"); - err = TestReadCurrentFabricIndex_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Open commissioning window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Commission from beta\n"); - err = TestCommissionFromBeta_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Report: Subscribe Fabrics Attribute from beta\n"); - err = TestReportSubscribeFabricsAttributeFromBeta_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Subscribe Fabrics Attribute from beta\n"); - err = TestSubscribeFabricsAttributeFromBeta_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Remove single own fabric\n"); - err = TestRemoveSingleOwnFabric_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadNumberOfCommissionedFabrics_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of commissioned fabrics: Error: %@", err); - } else { - NSLog(@"Read number of commissioned fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CommissionedFabrics", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestReadCurrentFabricIndex_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current fabric index: Error: %@", err); - } else { - NSLog(@"Read current fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open commissioning window from alpha: Error: %@", err); - } else { - NSLog(@"Open commissioning window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_4() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = 74565ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = 74565ULL; - return WaitForCommissionee("beta", value); - } - bool testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - = nil; - - CHIP_ERROR TestReportSubscribeFabricsAttributeFromBeta_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - = ^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe Fabrics Attribute from beta: Error: %@", err); - } else { - NSLog(@"Report: Subscribe Fabrics Attribute from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fabrics", "list", "list")); - testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeFabricsAttributeFromBeta_7() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeFabricsWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe Fabrics Attribute from beta: Error: %@", err); - } else { - NSLog(@"Subscribe Fabrics Attribute from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - != nil) { - ResponseHandler callback = test_TestFabricRemovalWhileSubscribed_Fabrics_Reported; - test_TestFabricRemovalWhileSubscribed_Fabrics_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveSingleOwnFabric_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [ourFabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove single own fabric: Error: %@", err); - } else { - NSLog(@"Remove single own fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestGeneralCommissioning : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestGeneralCommissioning() - : TestCommandBridge("TestGeneralCommissioning") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestGeneralCommissioning() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestGeneralCommissioning\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestGeneralCommissioning\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write Breadcrumb (1/2)\n"); - err = TestWriteBreadcrumb12_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read back Breadcrumb (1/2)\n"); - err = TestReadBackBreadcrumb12_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write Breadcrumb (2/2)\n"); - err = TestWriteBreadcrumb22_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read back Breadcrumb (2/2)\n"); - err = TestReadBackBreadcrumb22_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Reboot to reset Breadcrumb\n"); - err = TestRebootToResetBreadcrumb_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Connect to the device again\n"); - err = TestConnectToTheDeviceAgain_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read back Breadcrumb after reboot and ensure it was not persisted\n"); - err = TestReadBackBreadcrumbAfterRebootAndEnsureItWasNotPersisted_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Set Breadcrumb to nonzero value\n"); - err = TestSetBreadcrumbToNonzeroValue_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Check Breadcrumb set worked\n"); - err = TestCheckBreadcrumbSetWorked_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Send CommissioningComplete without armed fail-safe\n"); - err = TestSendCommissioningCompleteWithoutArmedFailSafe_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Check Breadcrumb was not touched by invalid CommissioningComplete\n"); - err = TestCheckBreadcrumbWasNotTouchedByInvalidCommissioningComplete_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Try to arm fail-safe\n"); - err = TestTryToArmFailSafe_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Check Breadcrumb was not touched by ArmFailSafe with commissioning window open\n"); - err = TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithCommissioningWindowOpen_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Reset Breadcrumb to 0 so we can commission\n"); - err = TestResetBreadcrumbTo0SoWeCanCommission_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Commission from beta\n"); - err = TestCommissionFromBeta_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Arm fail-safe\n"); - err = TestArmFailSafe_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Check Breadcrumb was properly set by ArmFailSafe\n"); - err = TestCheckBreadcrumbWasProperlySetByArmFailSafe_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Try to arm fail-safe from wrong fabric\n"); - err = TestTryToArmFailSafeFromWrongFabric_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed\n"); - err = TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithExistingFailSafeArmed_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Send CommissioningComplete from wrong fabric\n"); - err = TestSendCommissioningCompleteFromWrongFabric_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Check Breadcrumb was not touched by CommissioningComplete from wrong fabric\n"); - err = TestCheckBreadcrumbWasNotTouchedByCommissioningCompleteFromWrongFabric_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Close out the fail-safe gracefully\n"); - err = TestCloseOutTheFailSafeGracefully_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Check Breadcrumb was reset to 0 by CommissioningComplete\n"); - err = TestCheckBreadcrumbWasResetTo0ByCommissioningComplete_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Arm fail-safe again\n"); - err = TestArmFailSafeAgain_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Check Breadcrumb was set by arming fail-safe again\n"); - err = TestCheckBreadcrumbWasSetByArmingFailSafeAgain_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Force-expire the fail-safe\n"); - err = TestForceExpireTheFailSafe_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Check Breadcrumb was reset by expiring the fail-safe\n"); - err = TestCheckBreadcrumbWasResetByExpiringTheFailSafe_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Validate presence of SupportsConcurrentConnection\n"); - err = TestValidatePresenceOfSupportsConcurrentConnection_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Read original regulatory location\n"); - err = TestReadOriginalRegulatoryLocation_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Read original location\n"); - err = TestReadOriginalLocation_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Try to SetRegulatoryConfig with 0-length country code\n"); - err = TestTryToSetRegulatoryConfigWith0LengthCountryCode_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Read back location\n"); - err = TestReadBackLocation_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Try to SetRegulatoryConfig with length-1 country code\n"); - err = TestTryToSetRegulatoryConfigWithLength1CountryCode_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Read back location second time\n"); - err = TestReadBackLocationSecondTime_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Try to SetRegulatoryConfig with length-2 country code\n"); - err = TestTryToSetRegulatoryConfigWithLength2CountryCode_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Read back location third time\n"); - err = TestReadBackLocationThirdTime_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Restore initial values\n"); - err = TestRestoreInitialValues_39(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 40; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteBreadcrumb12_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:137438953472ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write Breadcrumb (1/2): Error: %@", err); - } else { - NSLog(@"Write Breadcrumb (1/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackBreadcrumb12_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back Breadcrumb (1/2): Error: %@", err); - } else { - NSLog(@"Read back Breadcrumb (1/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 137438953472ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteBreadcrumb22_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:81ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write Breadcrumb (2/2): Error: %@", err); - } else { - NSLog(@"Write Breadcrumb (2/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackBreadcrumb22_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back Breadcrumb (2/2): Error: %@", err); - } else { - NSLog(@"Read back Breadcrumb (2/2): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 81ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootToResetBreadcrumb_5() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestConnectToTheDeviceAgain_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadBackBreadcrumbAfterRebootAndEnsureItWasNotPersisted_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back Breadcrumb after reboot and ensure it was not persisted: Error: %@", err); - } else { - NSLog(@"Read back Breadcrumb after reboot and ensure it was not persisted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetBreadcrumbToNonzeroValue_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:1ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Breadcrumb to nonzero value: Error: %@", err); - } else { - NSLog(@"Set Breadcrumb to nonzero value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbSetWorked_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb set worked: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb set worked: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendCommissioningCompleteWithoutArmedFailSafe_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster commissioningCompleteWithCompletion: - ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send CommissioningComplete without armed fail-safe: Error: %@", err); - } else { - NSLog(@"Send CommissioningComplete without armed fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByInvalidCommissioningComplete_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by invalid CommissioningComplete: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by invalid CommissioningComplete: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToArmFailSafe_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:10U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:5000ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to arm fail-safe: Error: %@", err); - } else { - NSLog(@"Try to arm fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithCommissioningWindowOpen_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with commissioning window open: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with commissioning window open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResetBreadcrumbTo0SoWeCanCommission_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id breadcrumbArgument; - breadcrumbArgument = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reset Breadcrumb to 0 so we can commission: Error: %@", err); - } else { - NSLog(@"Reset Breadcrumb to 0 so we can commission: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_16() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = 74565ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = 74565ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestArmFailSafe_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:500U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:2ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Arm fail-safe: Error: %@", err); - } else { - NSLog(@"Arm fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasProperlySetByArmFailSafe_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was properly set by ArmFailSafe: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was properly set by ArmFailSafe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToArmFailSafeFromWrongFabric_20() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:10U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:5000ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to arm fail-safe from wrong fabric: Error: %@", err); - } else { - NSLog(@"Try to arm fail-safe from wrong fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithExistingFailSafeArmed_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendCommissioningCompleteFromWrongFabric_22() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster commissioningCompleteWithCompletion: - ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send CommissioningComplete from wrong fabric: Error: %@", err); - } else { - NSLog(@"Send CommissioningComplete from wrong fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByCommissioningCompleteFromWrongFabric_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was not touched by CommissioningComplete from wrong fabric: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was not touched by CommissioningComplete from wrong fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseOutTheFailSafeGracefully_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster commissioningCompleteWithCompletion: - ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close out the fail-safe gracefully: Error: %@", err); - } else { - NSLog(@"Close out the fail-safe gracefully: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasResetTo0ByCommissioningComplete_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was reset to 0 by CommissioningComplete: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was reset to 0 by CommissioningComplete: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestArmFailSafeAgain_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:500U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:3ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Arm fail-safe again: Error: %@", err); - } else { - NSLog(@"Arm fail-safe again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasSetByArmingFailSafeAgain_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was set by arming fail-safe again: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was set by arming fail-safe again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 3ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestForceExpireTheFailSafe_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:0U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:4ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Force-expire the fail-safe: Error: %@", err); - } else { - NSLog(@"Force-expire the fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckBreadcrumbWasResetByExpiringTheFailSafe_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check Breadcrumb was reset by expiring the fail-safe: Error: %@", err); - } else { - NSLog(@"Check Breadcrumb was reset by expiring the fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestValidatePresenceOfSupportsConcurrentConnection_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportsConcurrentConnectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate presence of SupportsConcurrentConnection: Error: %@", err); - } else { - NSLog(@"Validate presence of SupportsConcurrentConnection: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportsConcurrentConnection", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull originalRegulatoryConfig; - - CHIP_ERROR TestReadOriginalRegulatoryLocation_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeRegulatoryConfigWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read original regulatory location: Error: %@", err); - } else { - NSLog(@"Read original regulatory location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - originalRegulatoryConfig = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSString * _Nonnull originalLocation; - - CHIP_ERROR TestReadOriginalLocation_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read original location: Error: %@", err); - } else { - NSLog(@"Read original location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, @"XX")); - } - { - originalLocation = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToSetRegulatoryConfigWith0LengthCountryCode_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [NSNumber numberWithUnsignedChar:0U]; - params.countryCode = @""; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to SetRegulatoryConfig with 0-length country code: Error: %@", err); - } else { - NSLog(@"Try to SetRegulatoryConfig with 0-length country code: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocation_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back location: Error: %@", err); - } else { - NSLog(@"Read back location: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, originalLocation)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToSetRegulatoryConfigWithLength1CountryCode_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [NSNumber numberWithUnsignedChar:0U]; - params.countryCode = @"U"; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to SetRegulatoryConfig with length-1 country code: Error: %@", err); - } else { - NSLog(@"Try to SetRegulatoryConfig with length-1 country code: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocationSecondTime_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back location second time: Error: %@", err); - } else { - NSLog(@"Read back location second time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, originalLocation)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToSetRegulatoryConfigWithLength2CountryCode_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [NSNumber numberWithUnsignedChar:0U]; - params.countryCode = @"US"; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to SetRegulatoryConfig with length-2 country code: Error: %@", err); - } else { - NSLog(@"Try to SetRegulatoryConfig with length-2 country code: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - { - id actualValue = values.debugText; - VerifyOrReturn(CheckValueAsString("DebugText", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackLocationThirdTime_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back location third time: Error: %@", err); - } else { - NSLog(@"Read back location third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Location", actualValue, @"US")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRestoreInitialValues_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; - params.newRegulatoryConfig = - [originalRegulatoryConfig copy]; - params.countryCode = - [originalLocation copy]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster setRegulatoryConfigWithParams:params completion: - ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Restore initial values: Error: %@", err); - } else { - NSLog(@"Restore initial values: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestIdentifyCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestIdentifyCluster() - : TestCommandBridge("TestIdentifyCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestIdentifyCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestIdentifyCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestIdentifyCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Send Identify command and expect success response\n"); - err = TestSendIdentifyCommandAndExpectSuccessResponse_1(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 2; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendIdentifyCommandAndExpectSuccessResponse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; - params.identifyTime = - [NSNumber numberWithUnsignedShort:0U]; - [cluster identifyWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Identify command and expect success response: Error: %@", err); - } else { - NSLog(@"Send Identify command and expect success response: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestOperationalCredentialsCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestOperationalCredentialsCluster() - : TestCommandBridge("TestOperationalCredentialsCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestOperationalCredentialsCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestOperationalCredentialsCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestOperationalCredentialsCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of supported fabrics\n"); - err = TestReadNumberOfSupportedFabrics_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read number of commissioned fabrics\n"); - err = TestReadNumberOfCommissionedFabrics_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read current fabric index\n"); - err = TestReadCurrentFabricIndex_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Remove nonexistent fabric\n"); - err = TestRemoveNonexistentFabric_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read fabric list before setting label\n"); - err = TestReadFabricListBeforeSettingLabel_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Set the fabric label\n"); - err = TestSetTheFabricLabel_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read fabric list after setting label\n"); - err = TestReadFabricListAfterSettingLabel_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadNumberOfSupportedFabrics_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of supported fabrics: Error: %@", err); - } else { - NSLog(@"Read number of supported fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("supportedFabrics", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("supportedFabrics", [value unsignedCharValue], 4U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadNumberOfCommissionedFabrics_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of commissioned fabrics: Error: %@", err); - } else { - NSLog(@"Read number of commissioned fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("commissionedFabrics", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestReadCurrentFabricIndex_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current fabric index: Error: %@", err); - } else { - NSLog(@"Read current fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveNonexistentFabric_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [NSNumber numberWithUnsignedChar:243U]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove nonexistent fabric: Error: %@", err); - } else { - NSLog(@"Remove nonexistent fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.statusCode; - VerifyOrReturn(CheckValue("StatusCode", actualValue, 11U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFabricListBeforeSettingLabel_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fabric list before setting label: Error: %@", err); - } else { - NSLog(@"Read fabric list before setting label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"")); - VerifyOrReturn(CheckValue("FabricIndex", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).fabricIndex, ourFabricIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTheFabricLabel_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; - params.label = @"Batcave"; - [cluster updateFabricLabelWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set the fabric label: Error: %@", err); - } else { - NSLog(@"Set the fabric label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.statusCode; - VerifyOrReturn(CheckValue("StatusCode", actualValue, 0U)); - } - - { - id actualValue = values.fabricIndex; - VerifyOrReturn(CheckValue("FabricIndex", actualValue, ourFabricIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFabricListAfterSettingLabel_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fabric list after setting label: Error: %@", err); - } else { - NSLog(@"Read fabric list after setting label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"Batcave")); - VerifyOrReturn(CheckValue("FabricIndex", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).fabricIndex, ourFabricIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestModeSelectCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestModeSelectCluster() - : TestCommandBridge("TestModeSelectCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestModeSelectCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestModeSelectCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestModeSelectCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Description\n"); - err = TestReadDescription_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read StandardNamespace\n"); - err = TestReadStandardNamespace_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read SupportedModes\n"); - err = TestReadSupportedModes_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read CurrentMode\n"); - err = TestReadCurrentMode_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read StartUpMode\n"); - err = TestReadStartUpMode_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read OnMode\n"); - err = TestReadOnMode_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Change to Supported Mode\n"); - err = TestChangeToSupportedMode_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify Current Mode Change\n"); - err = TestVerifyCurrentModeChange_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Change to Unsupported Mode\n"); - err = TestChangeToUnsupportedMode_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Toggle OnOff\n"); - err = TestToggleOnOff_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Toggle OnOff\n"); - err = TestToggleOnOff_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Verify Current Mode does not change when OnMode is null\n"); - err = TestVerifyCurrentModeDoesNotChangeWhenOnModeIsNull_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Change to Unsupported OnMode\n"); - err = TestChangeToUnsupportedOnMode_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Change OnMode\n"); - err = TestChangeOnMode_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Verify OnMode\n"); - err = TestVerifyOnMode_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Toggle OnOff\n"); - err = TestToggleOnOff_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Toggle OnOff\n"); - err = TestToggleOnOff_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Verify Current Mode Changes if OnMode is not null\n"); - err = TestVerifyCurrentModeChangesIfOnModeIsNotNull_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Change to Unsupported StartUp Mode\n"); - err = TestChangeToUnsupportedStartUpMode_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Change to Supported StartUp Mode\n"); - err = TestChangeToSupportedStartUpMode_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Verify StartUp Mode Change\n"); - err = TestVerifyStartUpModeChange_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Change CurrentMode to another value\n"); - err = TestChangeCurrentModeToAnotherValue_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Change On Mode\n"); - err = TestChangeOnMode_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Set StartUpOnOff\n"); - err = TestSetStartUpOnOff_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Reboot target device\n"); - err = TestRebootTargetDevice_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Verify Current Mode Change based on OnMode, as it overwrites StartUpMode\n"); - err = TestVerifyCurrentModeChangeBasedOnOnModeAsItOverwritesStartUpMode_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Change On Mode to Null\n"); - err = TestChangeOnModeToNull_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Reboot target device\n"); - err = TestRebootTargetDevice_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Verify Current Mode Change based on new StartUp Mode\n"); - err = TestVerifyCurrentModeChangeBasedOnNewStartUpMode_31(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 32; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadDescription_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Description: Error: %@", err); - } else { - NSLog(@"Read Description: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("Description", actualValue, @"Coffee")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStandardNamespace_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStandardNamespaceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read StandardNamespace: Error: %@", err); - } else { - NSLog(@"Read StandardNamespace: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StandardNamespace", actualValue)); - VerifyOrReturn(CheckValue("StandardNamespace", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadSupportedModes_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedModesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read SupportedModes: Error: %@", err); - } else { - NSLog(@"Read SupportedModes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SupportedModes", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).label, @"Black")); - VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).mode, 0U)); - VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).semanticTags count], static_cast(1))); - VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).semanticTags[0]).value, 0U)); - VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).label, @"Cappuccino")); - VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).mode, 4U)); - VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).semanticTags count], static_cast(1))); - VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).semanticTags[0]).value, 0U)); - VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).label, @"Espresso")); - VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).mode, 7U)); - VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).semanticTags count], static_cast(1))); - VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).semanticTags[0]).value, 0U)); - } - - VerifyOrReturn(CheckConstraintType("supportedModes", "list", "list")); - VerifyOrReturn(CheckConstraintMinLength("supportedModes", value, 3)); - VerifyOrReturn(CheckConstraintMaxLength("supportedModes", value, 3)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentMode_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read CurrentMode: Error: %@", err); - } else { - NSLog(@"Read CurrentMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStartUpMode_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read StartUpMode: Error: %@", err); - } else { - NSLog(@"Read StartUpMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartUpMode", actualValue)); - VerifyOrReturn(CheckValue("StartUpMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadOnMode_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnMode: Error: %@", err); - } else { - NSLog(@"Read OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("OnMode", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToSupportedMode_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; - params.newMode = - [NSNumber numberWithUnsignedChar:4U]; - [cluster changeToModeWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Supported Mode: Error: %@", err); - } else { - NSLog(@"Change to Supported Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull currentModeBeforeToggle; - - CHIP_ERROR TestVerifyCurrentModeChange_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Change: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 4U)); - } - { - currentModeBeforeToggle = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToUnsupportedMode_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; - params.newMode = - [NSNumber numberWithUnsignedChar:2U]; - [cluster changeToModeWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Unsupported Mode: Error: %@", err); - } else { - NSLog(@"Change to Unsupported Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCurrentModeDoesNotChangeWhenOnModeIsNull_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode does not change when OnMode is null: Error: %@", err); - } else { - NSLog(@"Verify Current Mode does not change when OnMode is null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, currentModeBeforeToggle)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToUnsupportedOnMode_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Unsupported OnMode: Error: %@", err); - } else { - NSLog(@"Change to Unsupported OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeOnMode_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = - [NSNumber numberWithUnsignedChar:7U]; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change OnMode: Error: %@", err); - } else { - NSLog(@"Change OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable OnModeValue; - - CHIP_ERROR TestVerifyOnMode_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify OnMode: Error: %@", err); - } else { - NSLog(@"Verify OnMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnMode", actualValue)); - VerifyOrReturn(CheckValue("OnMode", actualValue, 7U)); - } - { - OnModeValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestToggleOnOff_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Toggle OnOff: Error: %@", err); - } else { - NSLog(@"Toggle OnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCurrentModeChangesIfOnModeIsNotNull_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Changes if OnMode is not null: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Changes if OnMode is not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, OnModeValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToUnsupportedStartUpMode_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpModeArgument; - startUpModeArgument = - [NSNumber numberWithUnsignedChar:2U]; - [cluster writeAttributeStartUpModeWithValue:startUpModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Unsupported StartUp Mode: Error: %@", err); - } else { - NSLog(@"Change to Unsupported StartUp Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeToSupportedStartUpMode_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpModeArgument; - startUpModeArgument = - [NSNumber numberWithUnsignedChar:7U]; - [cluster writeAttributeStartUpModeWithValue:startUpModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change to Supported StartUp Mode: Error: %@", err); - } else { - NSLog(@"Change to Supported StartUp Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyStartUpModeChange_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStartUpModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify StartUp Mode Change: Error: %@", err); - } else { - NSLog(@"Verify StartUp Mode Change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("StartUpMode", actualValue)); - VerifyOrReturn(CheckValue("StartUpMode", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeCurrentModeToAnotherValue_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; - params.newMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster changeToModeWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change CurrentMode to another value: Error: %@", err); - } else { - NSLog(@"Change CurrentMode to another value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeOnMode_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = - [NSNumber numberWithUnsignedChar:4U]; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change On Mode: Error: %@", err); - } else { - NSLog(@"Change On Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetStartUpOnOff_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id startUpOnOffArgument; - startUpOnOffArgument = - [NSNumber numberWithUnsignedChar:1U]; - [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set StartUpOnOff: Error: %@", err); - } else { - NSLog(@"Set StartUpOnOff: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTargetDevice_25() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_26() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestVerifyCurrentModeChangeBasedOnOnModeAsItOverwritesStartUpMode_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Change based on OnMode, as it overwrites StartUpMode: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Change based on OnMode, as it overwrites StartUpMode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestChangeOnModeToNull_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onModeArgument; - onModeArgument = nil; - [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Change On Mode to Null: Error: %@", err); - } else { - NSLog(@"Change On Mode to Null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTargetDevice_29() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_30() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestVerifyCurrentModeChangeBasedOnNewStartUpMode_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Current Mode Change based on new StartUp Mode: Error: %@", err); - } else { - NSLog(@"Verify Current Mode Change based on new StartUp Mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CurrentMode", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestTemperatureControl : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestTemperatureControl() - : TestCommandBridge("TestTemperatureControl") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestTemperatureControl() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestTemperatureControl\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestTemperatureControl\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read supported temperature levels\n"); - err = TestReadSupportedTemperatureLevels_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read selected temperature level\n"); - err = TestReadSelectedTemperatureLevel_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Set temperature level to different level\n"); - err = TestSetTemperatureLevelToDifferentLevel_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read back selected temperature level\n"); - err = TestReadBackSelectedTemperatureLevel_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Set temperature level to different level\n"); - err = TestSetTemperatureLevelToDifferentLevel_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read back selected temperature level\n"); - err = TestReadBackSelectedTemperatureLevel_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadSupportedTemperatureLevels_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read supported temperature levels: Error: %@", err); - } else { - NSLog(@"Read supported temperature levels: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SupportedTemperatureLevels", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValueAsString("", actualValue[0], @"Hot")); - VerifyOrReturn(CheckValueAsString("", actualValue[1], @"Warm")); - VerifyOrReturn(CheckValueAsString("", actualValue[2], @"Freezing")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadSelectedTemperatureLevel_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read selected temperature level: Error: %@", err); - } else { - NSLog(@"Read selected temperature level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTemperatureLevelToDifferentLevel_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = - [NSNumber numberWithUnsignedChar:1U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set temperature level to different level: Error: %@", err); - } else { - NSLog(@"Set temperature level to different level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSelectedTemperatureLevel_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back selected temperature level: Error: %@", err); - } else { - NSLog(@"Read back selected temperature level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTemperatureLevelToDifferentLevel_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; - params.targetTemperatureLevel = - [NSNumber numberWithUnsignedChar:3U]; - [cluster setTemperatureWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set temperature level to different level: Error: %@", err); - } else { - NSLog(@"Set temperature level to different level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSelectedTemperatureLevel_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back selected temperature level: Error: %@", err); - } else { - NSLog(@"Read back selected temperature level: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestSelfFabricRemoval : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSelfFabricRemoval() - : TestCommandBridge("TestSelfFabricRemoval") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSelfFabricRemoval() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSelfFabricRemoval\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSelfFabricRemoval\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of commissioned fabrics\n"); - err = TestReadNumberOfCommissionedFabrics_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current fabric index\n"); - err = TestReadCurrentFabricIndex_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Remove single own fabric\n"); - err = TestRemoveSingleOwnFabric_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadNumberOfCommissionedFabrics_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read number of commissioned fabrics: Error: %@", err); - } else { - NSLog(@"Read number of commissioned fabrics: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("CommissionedFabrics", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestReadCurrentFabricIndex_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current fabric index: Error: %@", err); - } else { - NSLog(@"Read current fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); - VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveSingleOwnFabric_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [ourFabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove single own fabric: Error: %@", err); - } else { - NSLog(@"Remove single own fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestSystemCommands : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSystemCommands() - : TestCommandBridge("TestSystemCommands") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("payload", &mPayload); - AddArgument("secondNodeId", 0, UINT64_MAX, &mSecondNodeId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSystemCommands() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSystemCommands\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSystemCommands\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Start the default accessory with no command line options\n"); - err = TestStartTheDefaultAccessoryWithNoCommandLineOptions_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Stop the default accessory by key\n"); - err = TestStopTheDefaultAccessoryByKey_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Start the default accessory with discriminator command line option\n"); - err = TestStartTheDefaultAccessoryWithDiscriminatorCommandLineOption_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Start the default accessory with discriminator and port command line options\n"); - err = TestStartTheDefaultAccessoryWithDiscriminatorAndPortCommandLineOptions_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Start the default accessory with minCommissioningTimeout only\n"); - err = TestStartTheDefaultAccessoryWithMinCommissioningTimeoutOnly_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Stop the default accessory\n"); - err = TestStopTheDefaultAccessory_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Start the default accessory by key with all command line options\n"); - err = TestStartTheDefaultAccessoryByKeyWithAllCommandLineOptions_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Start a second accessory with all command line options\n"); - err = TestStartASecondAccessoryWithAllCommandLineOptions_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Commission second accessory from alpha\n"); - err = TestCommissionSecondAccessoryFromAlpha_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for the second commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheSecondCommissionedDeviceToBeRetrievedForAlpha_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Stop the second accessory\n"); - err = TestStopTheSecondAccessory_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Start a second accessory with different KVS\n"); - err = TestStartASecondAccessoryWithDifferentKvs_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Commission second accessory with new KVS from alpha\n"); - err = TestCommissionSecondAccessoryWithNewKvsFromAlpha_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait for the second commissioned device with new KVS to be retrieved for alpha\n"); - err = TestWaitForTheSecondCommissionedDeviceWithNewKvsToBeRetrievedForAlpha_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Reboot the default accessory\n"); - err = TestRebootTheDefaultAccessory_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Reboot the default accessory by key\n"); - err = TestRebootTheDefaultAccessoryByKey_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Reboot the second accessory\n"); - err = TestRebootTheSecondAccessory_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Factory Reset the default accessory\n"); - err = TestFactoryResetTheDefaultAccessory_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Factory Reset the default accessory by key\n"); - err = TestFactoryResetTheDefaultAccessoryByKey_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Factory Reset the second accessory\n"); - err = TestFactoryResetTheSecondAccessory_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Commission the now-reset second accessory from alpha\n"); - err = TestCommissionTheNowResetSecondAccessoryFromAlpha_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Wait for the second commissioned device (after reset) to be retrieved for alpha\n"); - err = TestWaitForTheSecondCommissionedDeviceAfterResetToBeRetrievedForAlpha_25(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 26; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPayload; - chip::Optional mSecondNodeId; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_1() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithNoCommandLineOptions_2() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessoryByKey_3() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithDiscriminatorCommandLineOption_4() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.discriminator.Emplace(); - value.discriminator.Value() = 1111U; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_5() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithDiscriminatorAndPortCommandLineOptions_6() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.discriminator.Emplace(); - value.discriminator.Value() = 1111U; - value.port.Emplace(); - value.port.Value() = 5560U; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_7() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryWithMinCommissioningTimeoutOnly_8() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.minCommissioningTimeout.Emplace(); - value.minCommissioningTimeout.Value() = 10U; - return Start("alpha", value); - } - - CHIP_ERROR TestStopTheDefaultAccessory_9() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTheDefaultAccessoryByKeyWithAllCommandLineOptions_10() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - value.discriminator.Emplace(); - value.discriminator.Value() = 1111U; - value.port.Emplace(); - value.port.Value() = 5560U; - value.kvs.Emplace(); - value.kvs.Value() = chip::Span("/tmp/chip_kvs_defaultgarbage: not in length on purpose", 21); - value.minCommissioningTimeout.Emplace(); - value.minCommissioningTimeout.Value() = 10U; - return Start("alpha", value); - } - - CHIP_ERROR TestStartASecondAccessoryWithAllCommandLineOptions_11() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - value.discriminator.Emplace(); - value.discriminator.Value() = 50U; - value.port.Emplace(); - value.port.Value() = 5561U; - value.kvs.Emplace(); - value.kvs.Value() = chip::Span("/tmp/chip_kvs_lockgarbage: not in length on purpose", 18); - return Start("alpha", value); - } - - CHIP_ERROR TestCommissionSecondAccessoryFromAlpha_12() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheSecondCommissionedDeviceToBeRetrievedForAlpha_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStopTheSecondAccessory_14() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - return Stop("alpha", value); - } - - CHIP_ERROR TestStartASecondAccessoryWithDifferentKvs_15() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - value.discriminator.Emplace(); - value.discriminator.Value() = 50U; - value.port.Emplace(); - value.port.Value() = 5561U; - value.kvs.Emplace(); - value.kvs.Value() = chip::Span("/tmp/chip_kvs_lock2garbage: not in length on purpose", 19); - return Start("alpha", value); - } - - CHIP_ERROR TestCommissionSecondAccessoryWithNewKvsFromAlpha_16() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheSecondCommissionedDeviceWithNewKvsToBeRetrievedForAlpha_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestRebootTheDefaultAccessory_18() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestRebootTheDefaultAccessoryByKey_19() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - return Reboot("alpha", value); - } - - CHIP_ERROR TestRebootTheSecondAccessory_20() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - return Reboot("alpha", value); - } - - CHIP_ERROR TestFactoryResetTheDefaultAccessory_21() - { - - chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; - return FactoryReset("alpha", value); - } - - CHIP_ERROR TestFactoryResetTheDefaultAccessoryByKey_22() - { - - chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); - return FactoryReset("alpha", value); - } - - CHIP_ERROR TestFactoryResetTheSecondAccessory_23() - { - - chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; - value.registerKey.Emplace(); - value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); - return FactoryReset("alpha", value); - } - - CHIP_ERROR TestCommissionTheNowResetSecondAccessoryFromAlpha_24() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestWaitForTheSecondCommissionedDeviceAfterResetToBeRetrievedForAlpha_25() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; - return WaitForCommissionee("alpha", value); - } -}; - -class TestBinding : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestBinding() - : TestCommandBridge("TestBinding") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestBinding() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestBinding\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestBinding\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write empty binding table\n"); - err = TestWriteEmptyBindingTable_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read empty binding table\n"); - err = TestReadEmptyBindingTable_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write invalid binding table\n"); - err = TestWriteInvalidBindingTable_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Write binding table (endpoint 1)\n"); - err = TestWriteBindingTableEndpoint1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read binding table (endpoint 1)\n"); - err = TestReadBindingTableEndpoint1_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Write binding table (endpoint 0)\n"); - err = TestWriteBindingTableEndpoint0_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read binding table (endpoint 0)\n"); - err = TestReadBindingTableEndpoint0_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify endpoint 1 not changed\n"); - err = TestVerifyEndpoint1NotChanged_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write over-long binding table on endpoint 1\n"); - err = TestWriteOverLongBindingTableOnEndpoint1_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteEmptyBindingTable_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write empty binding table: Error: %@", err); - } else { - NSLog(@"Write empty binding table: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadEmptyBindingTable_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read empty binding table: Error: %@", err); - } else { - NSLog(@"Read empty binding table: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteInvalidBindingTable_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).node = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).group = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write invalid binding table: Error: %@", err); - } else { - NSLog(@"Write invalid binding table: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteBindingTableEndpoint1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).group = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).node = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).node = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write binding table (endpoint 1): Error: %@", err); - } else { - NSLog(@"Write binding table (endpoint 1): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBindingTableEndpoint1_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read binding table (endpoint 1): Error: %@", err); - } else { - NSLog(@"Read binding table (endpoint 1): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Group", ((MTRBindingClusterTargetStruct *) actualValue[0]).group, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[1]).node, 1ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[1]).endpoint, 1U)); - VerifyOrReturn(CheckValue("Cluster", ((MTRBindingClusterTargetStruct *) actualValue[1]).cluster, 6UL)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[2]).node, 2ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[2]).endpoint, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[2]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteBindingTableEndpoint0_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).node = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write binding table (endpoint 0): Error: %@", err); - } else { - NSLog(@"Write binding table (endpoint 0): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBindingTableEndpoint0_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read binding table (endpoint 0): Error: %@", err); - } else { - NSLog(@"Read binding table (endpoint 0): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[0]).node, 3ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[0]).endpoint, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyEndpoint1NotChanged_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify endpoint 1 not changed: Error: %@", err); - } else { - NSLog(@"Verify endpoint 1 not changed: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("Group", ((MTRBindingClusterTargetStruct *) actualValue[0]).group, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[1]).node, 1ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[1]).endpoint, 1U)); - VerifyOrReturn(CheckValue("Cluster", ((MTRBindingClusterTargetStruct *) actualValue[1]).cluster, 6UL)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[1]).fabricIndex, 1U)); - VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[2]).node, 2ULL)); - VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[2]).endpoint, 1U)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[2]).fabricIndex, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteOverLongBindingTableOnEndpoint1_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id bindingArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).node = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).endpoint = - [NSNumber numberWithUnsignedShort:1U]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).node = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = - [NSNumber numberWithUnsignedShort:2U]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[2] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).node = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).endpoint = - [NSNumber numberWithUnsignedShort:3U]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[2]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[3] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).node = - [NSNumber numberWithUnsignedLongLong:4ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).endpoint = - [NSNumber numberWithUnsignedShort:4U]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[3]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[4] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).node = - [NSNumber numberWithUnsignedLongLong:5ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).endpoint = - [NSNumber numberWithUnsignedShort:5U]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[4]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[5] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).node = - [NSNumber numberWithUnsignedLongLong:6ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).endpoint = - [NSNumber numberWithUnsignedShort:6U]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[5]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[6] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).node = - [NSNumber numberWithUnsignedLongLong:7ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).endpoint = - [NSNumber numberWithUnsignedShort:7U]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[6]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[7] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).node = - [NSNumber numberWithUnsignedLongLong:8ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).endpoint = - [NSNumber numberWithUnsignedShort:8U]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[7]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[8] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).node = - [NSNumber numberWithUnsignedLongLong:9ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).endpoint = - [NSNumber numberWithUnsignedShort:9U]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[8]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[9] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).node = - [NSNumber numberWithUnsignedLongLong:10ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).endpoint = - [NSNumber numberWithUnsignedShort:10U]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[9]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - temp_0[10] = [[MTRBindingClusterTargetStruct alloc] init]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).node = - [NSNumber numberWithUnsignedLongLong:11ULL]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).endpoint = - [NSNumber numberWithUnsignedShort:11U]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).cluster = - [NSNumber numberWithUnsignedInt:6UL]; - ((MTRBindingClusterTargetStruct *) temp_0[10]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - bindingArgument = temp_0; - } - [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write over-long binding table on endpoint 1: Error: %@", err); - } else { - NSLog(@"Write over-long binding table on endpoint 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestUserLabelCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestUserLabelCluster() - : TestCommandBridge("TestUserLabelCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestUserLabelCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestUserLabelCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestUserLabelCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Commit User Label List\n"); - err = TestCommitUserLabelList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Verify committed User Label List\n"); - err = TestVerifyCommittedUserLabelList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Clear User Label List\n"); - err = TestClearUserLabelList_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read User Label List\n"); - err = TestReadUserLabelList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write User Label List\n"); - err = TestWriteUserLabelList_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Reboot target device\n"); - err = TestRebootTargetDevice_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Verify User Label List after reboot\n"); - err = TestVerifyUserLabelListAfterReboot_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCommitUserLabelList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 1"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"South"; - - temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"2"; - - temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"direction"; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"down"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Commit User Label List: Error: %@", err); - } else { - NSLog(@"Commit User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCommittedUserLabelList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify committed User Label List: Error: %@", err); - } else { - NSLog(@"Verify committed User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 1")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"South")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"2")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"direction")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"down")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearUserLabelList_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear User Label List: Error: %@", err); - } else { - NSLog(@"Clear User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadUserLabelList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read User Label List: Error: %@", err); - } else { - NSLog(@"Read User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteUserLabelList_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 2"; - - temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"orientation"; - ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"North"; - - temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; - ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"5"; - - temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"direction"; - ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"up"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write User Label List: Error: %@", err); - } else { - NSLog(@"Write User Label List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRebootTargetDevice_6() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_7() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestVerifyUserLabelListAfterReboot_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify User Label List after reboot: Error: %@", err); - } else { - NSLog(@"Verify User Label List after reboot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 2")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"orientation")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"North")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"5")); - VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"direction")); - VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"up")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestUserLabelClusterConstraints : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestUserLabelClusterConstraints() - : TestCommandBridge("TestUserLabelClusterConstraints") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestUserLabelClusterConstraints() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestUserLabelClusterConstraints\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestUserLabelClusterConstraints\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Attempt to write overly long item for label\n"); - err = TestAttemptToWriteOverlyLongItemForLabel_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Attempt to write overly long item for value\n"); - err = TestAttemptToWriteOverlyLongItemForValue_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestAttemptToWriteOverlyLongItemForLabel_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"this is longer than sixteen characters"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 2"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Attempt to write overly long item for label: Error: %@", err); - } else { - NSLog(@"Attempt to write overly long item for label: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAttemptToWriteOverlyLongItemForValue_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id labelListArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"test"; - ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"this is longer than sixteen characters"; - - labelListArgument = temp_0; - } - [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Attempt to write overly long item for value: Error: %@", err); - } else { - NSLog(@"Attempt to write overly long item for value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestArmFailSafe : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestArmFailSafe() - : TestCommandBridge("TestArmFailSafe") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestArmFailSafe() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestArmFailSafe\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestArmFailSafe\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Reboot target device\n"); - err = TestRebootTargetDevice_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Wait for the alpha device to be retrieved \n"); - err = TestWaitForTheAlphaDeviceToBeRetrieved_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Query fabrics list\n"); - err = TestQueryFabricsList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : ArmFailSafe on target device with timeout 0\n"); - err = TestArmFailSafeOnTargetDeviceWithTimeout0_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Reads NodeLabel mandatory attribute of target device\n"); - err = TestReadsNodeLabelMandatoryAttributeOfTargetDevice_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Invoke AddTrustedRootCertificate without fail-safe\n"); - err = TestInvokeAddTrustedRootCertificateWithoutFailSafe_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Invoke AddNOC without fail-safe\n"); - err = TestInvokeAddNOCWithoutFailSafe_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Invoke UpdateNOC without fail-safe\n"); - err = TestInvokeUpdateNOCWithoutFailSafe_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Invoke CSRRequest without fail-safe\n"); - err = TestInvokeCSRRequestWithoutFailSafe_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestRebootTargetDevice_0() - { - - chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; - return Reboot("alpha", value); - } - - CHIP_ERROR TestWaitForTheAlphaDeviceToBeRetrieved_1() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestQueryFabricsList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Query fabrics list: Error: %@", err); - } else { - NSLog(@"Query fabrics list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("NodeID", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).nodeID, mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL)); - VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"")); - } - - VerifyOrReturn(CheckConstraintType("fabrics", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestArmFailSafeOnTargetDeviceWithTimeout0_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; - params.expiryLengthSeconds = - [NSNumber numberWithUnsignedShort:0U]; - params.breadcrumb = - [NSNumber numberWithUnsignedLongLong:0ULL]; - [cluster armFailSafeWithParams:params completion: - ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"ArmFailSafe on target device with timeout 0: Error: %@", err); - } else { - NSLog(@"ArmFailSafe on target device with timeout 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.errorCode; - VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadsNodeLabelMandatoryAttributeOfTargetDevice_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reads NodeLabel mandatory attribute of target device: Error: %@", err); - } else { - NSLog(@"Reads NodeLabel mandatory attribute of target device: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeAddTrustedRootCertificateWithoutFailSafe_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterAddTrustedRootCertificateParams alloc] init]; - params.rootCACertificate = - [[NSData alloc] initWithBytes:"00000000" length:8]; - [cluster addTrustedRootCertificateWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke AddTrustedRootCertificate without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke AddTrustedRootCertificate without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeAddNOCWithoutFailSafe_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterAddNOCParams alloc] init]; - params.nocValue = - [[NSData alloc] initWithBytes:"00112233" length:8]; - params.ipkValue = - [[NSData alloc] initWithBytes:"\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007" length:16]; - params.caseAdminSubject = - [NSNumber numberWithUnsignedLongLong:1234ULL]; - params.adminVendorId = - [NSNumber numberWithUnsignedShort:65521U]; - [cluster addNOCWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke AddNOC without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke AddNOC without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeUpdateNOCWithoutFailSafe_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterUpdateNOCParams alloc] init]; - params.nocValue = - [[NSData alloc] initWithBytes:"00112233" length:8]; - [cluster updateNOCWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke UpdateNOC without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke UpdateNOC without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestInvokeCSRRequestWithoutFailSafe_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterCSRRequestParams alloc] init]; - params.csrNonce = - [[NSData alloc] initWithBytes:"\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007" length:32]; - [cluster CSRRequestWithParams:params completion: - ^(MTROperationalCredentialsClusterCSRResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Invoke CSRRequest without fail-safe: Error: %@", err); - } else { - NSLog(@"Invoke CSRRequest without fail-safe: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestFanControl : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestFanControl() - : TestCommandBridge("TestFanControl") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestFanControl() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestFanControl\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestFanControl\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Write fan mode\n"); - err = TestWriteFanMode_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read back fan mode\n"); - err = TestReadBackFanMode_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Write percent setting\n"); - err = TestWritePercentSetting_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read back percent setting\n"); - err = TestReadBackPercentSetting_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read back speed current\n"); - err = TestReadBackSpeedCurrent_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write percent setting\n"); - err = TestWritePercentSetting_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read back percent setting\n"); - err = TestReadBackPercentSetting_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Write speed setting\n"); - err = TestWriteSpeedSetting_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read back percent setting\n"); - err = TestReadBackPercentSetting_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read back percent current\n"); - err = TestReadBackPercentCurrent_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Write speed setting\n"); - err = TestWriteSpeedSetting_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Write fan mode\n"); - err = TestWriteFanMode_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read back percent setting\n"); - err = TestReadBackPercentSetting_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read back percent current\n"); - err = TestReadBackPercentCurrent_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read back speed current\n"); - err = TestReadBackSpeedCurrent_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Write fan mode\n"); - err = TestWriteFanMode_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read back percent setting\n"); - err = TestReadBackPercentSetting_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Read back speed setting\n"); - err = TestReadBackSpeedSetting_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestWriteFanMode_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id fanModeArgument; - fanModeArgument = - [NSNumber numberWithUnsignedChar:3U]; - [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write fan mode: Error: %@", err); - } else { - NSLog(@"Write fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackFanMode_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back fan mode: Error: %@", err); - } else { - NSLog(@"Read back fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FanMode", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWritePercentSetting_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id percentSettingArgument; - percentSettingArgument = - [NSNumber numberWithUnsignedChar:84U]; - [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write percent setting: Error: %@", err); - } else { - NSLog(@"Write percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedCurrent_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed current: Error: %@", err); - } else { - NSLog(@"Read back speed current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SpeedCurrent", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWritePercentSetting_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id percentSettingArgument; - percentSettingArgument = nil; - [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write percent setting: Error: %@", err); - } else { - NSLog(@"Write percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 84U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteSpeedSetting_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id speedSettingArgument; - speedSettingArgument = - [NSNumber numberWithUnsignedChar:73U]; - [cluster writeAttributeSpeedSettingWithValue:speedSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write speed setting: Error: %@", err); - } else { - NSLog(@"Write speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentCurrent_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent current: Error: %@", err); - } else { - NSLog(@"Read back percent current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PercentCurrent", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteSpeedSetting_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id speedSettingArgument; - speedSettingArgument = nil; - [cluster writeAttributeSpeedSettingWithValue:speedSettingArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write speed setting: Error: %@", err); - } else { - NSLog(@"Write speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 73U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteFanMode_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id fanModeArgument; - fanModeArgument = - [NSNumber numberWithUnsignedChar:0U]; - [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write fan mode: Error: %@", err); - } else { - NSLog(@"Write fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); - VerifyOrReturn(CheckValue("PercentSetting", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentCurrent_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent current: Error: %@", err); - } else { - NSLog(@"Read back percent current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("PercentCurrent", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); - VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedCurrent_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed current: Error: %@", err); - } else { - NSLog(@"Read back speed current: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("SpeedCurrent", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteFanMode_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id fanModeArgument; - fanModeArgument = - [NSNumber numberWithUnsignedChar:5U]; - [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write fan mode: Error: %@", err); - } else { - NSLog(@"Write fan mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackPercentSetting_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back percent setting: Error: %@", err); - } else { - NSLog(@"Read back percent setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("PercentSetting", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackSpeedSetting_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back speed setting: Error: %@", err); - } else { - NSLog(@"Read back speed setting: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("SpeedSetting", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestAccessControlConstraints : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestAccessControlConstraints() - : TestCommandBridge("TestAccessControlConstraints") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestAccessControlConstraints() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestAccessControlConstraints\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestAccessControlConstraints\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Constraint error: PASE reserved for future (TC-ACL-2.4 step 29)\n"); - err = TestConstraintErrorPaseReservedForFutureTcAcl24Step29_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31)\n"); - err = TestConstraintErrorInvalidCombinationAdministerGroupTcAcl24Step31_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Constraint error: Invalid auth mode (TC-ACL-2.4 step 33)\n"); - err = TestConstraintErrorInvalidAuthModeTcAcl24Step33_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Constraint error: Invalid subject (TC-ACL-2.4 step 34)\n"); - err = TestConstraintErrorInvalidSubjectTcAcl24Step34_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Constraint error: Invalid target (TC-ACL-2.4 step 38)\n"); - err = TestConstraintErrorInvalidTargetTcAcl24Step38_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42)\n"); - err = TestConstraintErrorTargetHasBothEndpointAndDeviceTypeTcAcl24Step42_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Constraint error: Invalid privilege value step 32)\n"); - err = TestConstraintErrorInvalidPrivilegeValueStep32_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFfffFfffFfffTcAcl24Step35_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFffd00000000TcAcl24Step36_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37)\n"); - err = TestConstraintErrorInvalidSubject0xFFFFFfffFfff0000TcAcl24Step37_10(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 11; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestConstraintErrorPaseReservedForFutureTcAcl24Step29_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:1U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: PASE reserved for future (TC-ACL-2.4 step 29): Error: %@", err); - } else { - NSLog(@"Constraint error: PASE reserved for future (TC-ACL-2.4 step 29): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidCombinationAdministerGroupTcAcl24Step31_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:3U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidAuthModeTcAcl24Step33_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:4U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid auth mode (TC-ACL-2.4 step 33): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid auth mode (TC-ACL-2.4 step 33): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubjectTcAcl24Step34_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid subject (TC-ACL-2.4 step 34): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid subject (TC-ACL-2.4 step 34): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidTargetTcAcl24Step38_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid target (TC-ACL-2.4 step 38): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid target (TC-ACL-2.4 step 38): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorTargetHasBothEndpointAndDeviceTypeTcAcl24Step42_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = - [NSNumber numberWithUnsignedShort:22U]; - ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = - [NSNumber numberWithUnsignedInt:33UL]; - - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42): Error: %@", err); - } else { - NSLog(@"Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidPrivilegeValueStep32_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:6U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: Invalid privilege value step 32): Error: %@", err); - } else { - NSLog(@"Constraint error: Invalid privilege value step 32): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfffFfffTcAcl24Step35_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35): Error: %@", err); - } else { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFffd00000000TcAcl24Step36_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:18446744060824649728ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36): Error: %@", err); - } else { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfff0000TcAcl24Step37_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:112233ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = - [NSNumber numberWithUnsignedChar:3U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [NSNumber numberWithUnsignedLongLong:18446744073709486080ULL]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37): Error: %@", err); - } else { - NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestLevelControlWithOnOffDependency : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestLevelControlWithOnOffDependency() - : TestCommandBridge("TestLevelControlWithOnOffDependency") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestLevelControlWithOnOffDependency() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestLevelControlWithOnOffDependency\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestLevelControlWithOnOffDependency\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Sends a MoveToLevel command to set CurrentLevel to min value\n"); - err = TestSendsAMoveToLevelCommandToSetCurrentLevelToMinValue_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 100 ms\n"); - err = TestWait100Ms_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Reads CurrentLevel attribute from DUT\n"); - err = TestReadsCurrentLevelAttributeFromDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Write OnOffTransitionTime attribute\n"); - err = TestWriteOnOffTransitionTimeAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 100 ms\n"); - err = TestWait100Ms_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read OnOffTransitionTime attribute\n"); - err = TestReadOnOffTransitionTimeAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Write OnLevel attribute\n"); - err = TestWriteOnLevelAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 100 ms\n"); - err = TestWait100Ms_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read OnLevel attribute\n"); - err = TestReadOnLevelAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read MinValue attribute\n"); - err = TestReadMinValueAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Send On Command\n"); - err = TestSendOnCommand_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Check on/off attribute value is true after on command\n"); - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : If OnLevel is defined, check CurrentLevel is OnLevel value\n"); - err = TestIfOnLevelIsDefinedCheckCurrentLevelIsOnLevelValue_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Send Off Command\n"); - err = TestSendOffCommand_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : If OnLevel is defined, check CurrentLevel is min value\n"); - err = TestIfOnLevelIsDefinedCheckCurrentLevelIsMinValue_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Sends a MoveToLevel command to set CurrentLevel to a mid value\n"); - err = TestSendsAMoveToLevelCommandToSetCurrentLevelToAMidValue_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 100 ms\n"); - err = TestWait100Ms_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Reads CurrentLevel attribute from DUT\n"); - err = TestReadsCurrentLevelAttributeFromDut_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Set OnLevel attribute to null\n"); - err = TestSetOnLevelAttributeToNull_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Wait 100 ms\n"); - err = TestWait100Ms_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Read OnLevel attribute\n"); - err = TestReadOnLevelAttribute_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Send On Command\n"); - err = TestSendOnCommand_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Check on/off attribute value is true after on command\n"); - err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : If OnLevel is not defined, check CurrentLevel is restored\n"); - err = TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Send Off Command\n"); - err = TestSendOffCommand_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); - err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Wait OnOffTransitionTime\n"); - err = TestWaitOnOffTransitionTime_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : If OnLevel is not defined, check CurrentLevel is restored\n"); - err = TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_32(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 33; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSendsAMoveToLevelCommandToSetCurrentLevelToMinValue_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to min value: Error: %@", err); - } else { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to min value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadsCurrentLevelAttributeFromDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteOnOffTransitionTimeAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onOffTransitionTimeArgument; - onOffTransitionTimeArgument = - [NSNumber numberWithUnsignedShort:0U]; - [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Write OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadOnOffTransitionTimeAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnOffTransitionTime attribute: Error: %@", err); - } else { - NSLog(@"Read OnOffTransitionTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOffTransitionTime", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteOnLevelAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = - [NSNumber numberWithUnsignedChar:254U]; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Write OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_8() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadOnLevelAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Read OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("OnLevel", actualValue)); - VerifyOrReturn(CheckValue("OnLevel", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMinValueAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read MinValue attribute: Error: %@", err); - } else { - NSLog(@"Read MinValue attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("MinLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOnCommand_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send On Command: Error: %@", err); - } else { - NSLog(@"Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsDefinedCheckCurrentLevelIsOnLevelValue_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is defined, check CurrentLevel is OnLevel value: Error: %@", err); - } else { - NSLog(@"If OnLevel is defined, check CurrentLevel is OnLevel value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 254U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOffCommand_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Off Command: Error: %@", err); - } else { - NSLog(@"Send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_17() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 0UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsDefinedCheckCurrentLevelIsMinValue_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is defined, check CurrentLevel is min value: Error: %@", err); - } else { - NSLog(@"If OnLevel is defined, check CurrentLevel is min value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendsAMoveToLevelCommandToSetCurrentLevelToAMidValue_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:127U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:1U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:1U]; - [cluster moveToLevelWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to a mid value: Error: %@", err); - } else { - NSLog(@"Sends a MoveToLevel command to set CurrentLevel to a mid value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_20() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadsCurrentLevelAttributeFromDut_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reads CurrentLevel attribute from DUT: Error: %@", err); - } else { - NSLog(@"Reads CurrentLevel attribute from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetOnLevelAttributeToNull_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id onLevelArgument; - onLevelArgument = nil; - [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set OnLevel attribute to null: Error: %@", err); - } else { - NSLog(@"Set OnLevel attribute to null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait100Ms_23() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestReadOnLevelAttribute_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read OnLevel attribute: Error: %@", err); - } else { - NSLog(@"Read OnLevel attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("OnLevel", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOnCommand_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send On Command: Error: %@", err); - } else { - NSLog(@"Send On Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is true after on command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_27() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 100UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Error: %@", err); - } else { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSendOffCommand_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Send Off Command: Error: %@", err); - } else { - NSLog(@"Send Off Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); - } else { - NSLog(@"Check on/off attribute value is false after off command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitOnOffTransitionTime_31() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 0UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Error: %@", err); - } else { - NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCommissioningWindow : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCommissioningWindow() - : TestCommandBridge("TestCommissioningWindow") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("cluster", &mCluster); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCommissioningWindow() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCommissioningWindow\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCommissioningWindow\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Get alpha's fabric index\n"); - err = TestGetAlphasFabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Check that commissioning window is not open\n"); - err = TestCheckThatCommissioningWindowIsNotOpen_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Check that there is no AdminFabricIndex\n"); - err = TestCheckThatThereIsNoAdminFabricIndex_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Check that there is no AdminVendorId\n"); - err = TestCheckThatThereIsNoAdminVendorId_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Check that commissioning window is open\n"); - err = TestCheckThatCommissioningWindowIsOpen_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Check the AdminFabricIndex\n"); - err = TestCheckTheAdminFabricIndex_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Check the AdminVendorId is not null\n"); - err = TestCheckTheAdminVendorIdIsNotNull_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Close Commissioning Window\n"); - err = TestCloseCommissioningWindow_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Check that commissioning window is again not open\n"); - err = TestCheckThatCommissioningWindowIsAgainNotOpen_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Check that again there is no AdminFabricIndex\n"); - err = TestCheckThatAgainThereIsNoAdminFabricIndex_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Check that again there is no AdminVendorId\n"); - err = TestCheckThatAgainThereIsNoAdminVendorId_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Open Commissioning Window from alpha again\n"); - err = TestOpenCommissioningWindowFromAlphaAgain_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Commission from beta\n"); - err = TestCommissionFromBeta_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Check that commissioning window is not open for the third time\n"); - err = TestCheckThatCommissioningWindowIsNotOpenForTheThirdTime_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check that there is no AdminFabricIndex for the third time\n"); - err = TestCheckThatThereIsNoAdminFabricIndexForTheThirdTime_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Check that there is no AdminVendorId for the third time\n"); - err = TestCheckThatThereIsNoAdminVendorIdForTheThirdTime_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Get beta's fabric index\n"); - err = TestGetBetasFabricIndex_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Open Commissioning Window from beta\n"); - err = TestOpenCommissioningWindowFromBeta_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Check that commissioning window is open again\n"); - err = TestCheckThatCommissioningWindowIsOpenAgain_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Check the AdminFabricIndex again\n"); - err = TestCheckTheAdminFabricIndexAgain_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Check the AdminVendorId is not null again\n"); - err = TestCheckTheAdminVendorIdIsNotNullAgain_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Remove beta fabric\n"); - err = TestRemoveBetaFabric_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Check that commissioning window is still open\n"); - err = TestCheckThatCommissioningWindowIsStillOpen_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Check the AdminFabricIndex got reset\n"); - err = TestCheckTheAdminFabricIndexGotReset_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Check the AdminVendorId did not get reset\n"); - err = TestCheckTheAdminVendorIdDidNotGetReset_27(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 28; - - chip::Optional mNodeId; - chip::Optional mNodeId2; - chip::Optional mEndpoint; - chip::Optional mCluster; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull alphaIndex; - - CHIP_ERROR TestGetAlphasFabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get alpha's fabric index: Error: %@", err); - } else { - NSLog(@"Get alpha's fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - alphaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsNotOpen_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is not open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is not open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminFabricIndex_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminVendorId_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsOpen_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminFabricIndex_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check the AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (alphaIndex == nil) { - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, alphaIndex)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminVendorIdIsNotNull_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminVendorId is not null: Error: %@", err); - } else { - NSLog(@"Check the AdminVendorId is not null: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckValueNonNull("adminVendorId", value)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseCommissioningWindow_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close Commissioning Window: Error: %@", err); - } else { - NSLog(@"Close Commissioning Window: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsAgainNotOpen_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is again not open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is again not open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatAgainThereIsNoAdminFabricIndex_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that again there is no AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check that again there is no AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatAgainThereIsNoAdminVendorId_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that again there is no AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check that again there is no AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlphaAgain_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha again: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_14() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsNotOpenForTheThirdTime_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is not open for the third time: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is not open for the third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminFabricIndexForTheThirdTime_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminFabricIndex for the third time: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminFabricIndex for the third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatThereIsNoAdminVendorIdForTheThirdTime_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that there is no AdminVendorId for the third time: Error: %@", err); - } else { - NSLog(@"Check that there is no AdminVendorId for the third time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull betaIndex; - - CHIP_ERROR TestGetBetasFabricIndex_19() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get beta's fabric index: Error: %@", err); - } else { - NSLog(@"Get beta's fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - betaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromBeta_20() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from beta: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsOpenAgain_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is open again: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is open again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminFabricIndexAgain_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminFabricIndex again: Error: %@", err); - } else { - NSLog(@"Check the AdminFabricIndex again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (betaIndex == nil) { - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, betaIndex)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable adminVendorId; - - CHIP_ERROR TestCheckTheAdminVendorIdIsNotNullAgain_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminVendorId is not null again: Error: %@", err); - } else { - NSLog(@"Check the AdminVendorId is not null again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - } - VerifyOrReturn(CheckValueNonNull("adminVendorId", value)); - { - adminVendorId = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveBetaFabric_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [betaIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove beta fabric: Error: %@", err); - } else { - NSLog(@"Remove beta fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatCommissioningWindowIsStillOpen_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that commissioning window is still open: Error: %@", err); - } else { - NSLog(@"Check that commissioning window is still open: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminFabricIndexGotReset_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminFabricIndex got reset: Error: %@", err); - } else { - NSLog(@"Check the AdminFabricIndex got reset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckTheAdminVendorIdDidNotGetReset_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check the AdminVendorId did not get reset: Error: %@", err); - } else { - NSLog(@"Check the AdminVendorId did not get reset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (adminVendorId == nil) { - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminVendorId", actualValue)); - VerifyOrReturn(CheckValue("AdminVendorId", actualValue, adminVendorId)); - } - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestCommissionerNodeId : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestCommissionerNodeId() - : TestCommandBridge("TestCommissionerNodeId") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("cluster", &mCluster); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestCommissionerNodeId() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestCommissionerNodeId\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestCommissionerNodeId\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Commission from beta\n"); - err = TestCommissionFromBeta_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Commission from gamma\n"); - err = TestCommissionFromGamma_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved for gamma\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read the fabric ID from the alpha fabric\n"); - err = TestReadTheFabricIdFromTheAlphaFabric_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read the commissioner node ID from the alpha fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheAlphaFabric_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read the fabric ID from the beta fabric\n"); - err = TestReadTheFabricIdFromTheBetaFabric_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read the commissioner node ID from the beta fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheBetaFabric_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read the fabric ID from the gamma fabric\n"); - err = TestReadTheFabricIdFromTheGammaFabric_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read the commissioner node ID from the gamma fabric\n"); - err = TestReadTheCommissionerNodeIdFromTheGammaFabric_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read the ACL from alpha and check commissioner node id\n"); - err = TestReadTheAclFromAlphaAndCheckCommissionerNodeId_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read the ACL from beta and check commissioner node id\n"); - err = TestReadTheAclFromBetaAndCheckCommissionerNodeId_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read the ACL from gamma and check commissioner node id\n"); - err = TestReadTheAclFromGammaAndCheckCommissionerNodeId_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Write the ACL using the commissioner node id value\n"); - err = TestWriteTheAclUsingTheCommissionerNodeIdValue_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Write the ACL using the commissioner node id value\n"); - err = TestWriteTheAclUsingTheCommissionerNodeIdValue_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read the ACL from beta and check commissioner node id\n"); - err = TestReadTheAclFromBetaAndCheckCommissionerNodeId_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read the ACL from gamma and check commissioner node id\n"); - err = TestReadTheAclFromGammaAndCheckCommissionerNodeId_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Remove beta fabric\n"); - err = TestRemoveBetaFabric_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Remove gamma fabric\n"); - err = TestRemoveGammaFabric_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mEndpoint; - chip::Optional mCluster; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_2() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromGamma_5() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("gamma", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_6() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("gamma", value); - } - NSNumber * _Nonnull alphaIndex; - - CHIP_ERROR TestReadTheFabricIdFromTheAlphaFabric_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the fabric ID from the alpha fabric: Error: %@", err); - } else { - NSLog(@"Read the fabric ID from the alpha fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - alphaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdAlpha; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheAlphaFabric_8() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdAlpha = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - NSNumber * _Nonnull betaIndex; - - CHIP_ERROR TestReadTheFabricIdFromTheBetaFabric_9() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the fabric ID from the beta fabric: Error: %@", err); - } else { - NSLog(@"Read the fabric ID from the beta fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - betaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdBeta; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheBetaFabric_10() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("beta", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdBeta = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - NSNumber * _Nonnull gammaIndex; - - CHIP_ERROR TestReadTheFabricIdFromTheGammaFabric_11() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the fabric ID from the gamma fabric: Error: %@", err); - } else { - NSLog(@"Read the fabric ID from the gamma fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - gammaIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull commissionerNodeIdGamma; - - CHIP_ERROR TestReadTheCommissionerNodeIdFromTheGammaFabric_12() - { - - chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; - return GetCommissionerNodeId("gamma", value, ^(const chip::GetCommissionerNodeIdResponse & values) { - { - commissionerNodeIdGamma = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; - } - NextTest(); - }); - } - - CHIP_ERROR TestReadTheAclFromAlphaAndCheckCommissionerNodeId_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from alpha and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from alpha and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdAlpha)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, alphaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromBetaAndCheckCommissionerNodeId_14() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from beta and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from beta and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdBeta)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, betaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromGammaAndCheckCommissionerNodeId_15() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from gamma and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from gamma and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdGamma)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, gammaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheAclUsingTheCommissionerNodeIdValue_16() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdBeta copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [betaIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write the ACL using the commissioner node id value: Error: %@", err); - } else { - NSLog(@"Write the ACL using the commissioner node id value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheAclUsingTheCommissionerNodeIdValue_17() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id aclArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = - [NSNumber numberWithUnsignedChar:5U]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = - [NSNumber numberWithUnsignedChar:2U]; - { - NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; - temp_3[0] = - [commissionerNodeIdGamma copy]; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; - } - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; - ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = - [gammaIndex copy]; - - aclArgument = temp_0; - } - [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write the ACL using the commissioner node id value: Error: %@", err); - } else { - NSLog(@"Write the ACL using the commissioner node id value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromBetaAndCheckCommissionerNodeId_18() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from beta and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from beta and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdBeta)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, betaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheAclFromGammaAndCheckCommissionerNodeId_19() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the ACL from gamma and check commissioner node id: Error: %@", err); - } else { - NSLog(@"Read the ACL from gamma and check commissioner node id: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); - VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); - VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); - VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); - VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdGamma)); - VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); - VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, gammaIndex)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveBetaFabric_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [betaIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove beta fabric: Error: %@", err); - } else { - NSLog(@"Remove beta fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveGammaFabric_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [gammaIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove gamma fabric: Error: %@", err); - } else { - NSLog(@"Remove gamma fabric: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestTimeSynchronization : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestTimeSynchronization() - : TestCommandBridge("TestTimeSynchronization") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestTimeSynchronization() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestTimeSynchronization\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestTimeSynchronization\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Time Zone\n"); - err = TestReadTimeZone_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Set Time Zone list\n"); - err = TestSetTimeZoneList_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Time Zone\n"); - err = TestReadTimeZone_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Set Time Zone with missing optional name field\n"); - err = TestSetTimeZoneWithMissingOptionalNameField_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read Time Zone\n"); - err = TestReadTimeZone_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Set Time Zone with very long name\n"); - err = TestSetTimeZoneWithVeryLongName_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Set Time Zone with first item validAt not zero\n"); - err = TestSetTimeZoneWithFirstItemValidAtNotZero_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Set Time Zone with second item validAt zero\n"); - err = TestSetTimeZoneWithSecondItemValidAtZero_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Set Time Zone with more than supported list count\n"); - err = TestSetTimeZoneWithMoreThanSupportedListCount_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Set Time Zone empty\n"); - err = TestSetTimeZoneEmpty_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read Time Zone\n"); - err = TestReadTimeZone_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read DSTOffset\n"); - err = TestReadDSTOffset_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Set DSTOffset single item\n"); - err = TestSetDSTOffsetSingleItem_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Set DSTOffset empty\n"); - err = TestSetDSTOffsetEmpty_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Set DSTOffset with more than 1 null value\n"); - err = TestSetDSTOffsetWithMoreThan1NullValue_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Set unsorted DSTOffset entries\n"); - err = TestSetUnsortedDSTOffsetEntries_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Set DSTOffset with multiple entries\n"); - err = TestSetDSTOffsetWithMultipleEntries_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Read DSTOffset\n"); - err = TestReadDSTOffset_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Set DSTOffset with same validStarting and validUntil\n"); - err = TestSetDSTOffsetWithSameValidStartingAndValidUntil_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Set DSTOffset with more than supported list count\n"); - err = TestSetDSTOffsetWithMoreThanSupportedListCount_20(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 21; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadTimeZone_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 0L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CET"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone list: Error: %@", err); - } else { - NSLog(@"Set Time Zone list: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.dstOffsetRequired; - VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTimeZone_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 100L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - VerifyOrReturn(CheckValueAsString("Name", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).name, @"CET")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithMissingOptionalNameField_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with missing optional name field: Error: %@", err); - } else { - NSLog(@"Set Time Zone with missing optional name field: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.dstOffsetRequired; - VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTimeZone_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 100L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithVeryLongName_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"MunichOnTheLongRiverOfIsarInNiceSummerWeatherWithAugustinerBeerss"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with very long name: Error: %@", err); - } else { - NSLog(@"Set Time Zone with very long name: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithFirstItemValidAtNotZero_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CDT"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with first item validAt not zero: Error: %@", err); - } else { - NSLog(@"Set Time Zone with first item validAt not zero: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithSecondItemValidAtZero_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CST"; - - temp_0[1] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:200L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).name = @"CDT"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with second item validAt zero: Error: %@", err); - } else { - NSLog(@"Set Time Zone with second item validAt zero: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneWithMoreThanSupportedListCount_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:100L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = - [NSNumber numberWithUnsignedLongLong:0ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CST"; - - temp_0[1] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:200L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).validAt = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).name = @"CDT"; - - temp_0[2] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).offset = - [NSNumber numberWithInt:200L]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).validAt = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).name = @"CET"; - - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone with more than supported list count: Error: %@", err); - } else { - NSLog(@"Set Time Zone with more than supported list count: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetTimeZoneEmpty_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.timeZone = temp_0; - } - [cluster setTimeZoneWithParams:params completion: - ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set Time Zone empty: Error: %@", err); - } else { - NSLog(@"Set Time Zone empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.dstOffsetRequired; - VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTimeZone_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Time Zone: Error: %@", err); - } else { - NSLog(@"Read Time Zone: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 0L)); - VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadDSTOffset_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDSTOffsetWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read DSTOffset: Error: %@", err); - } else { - NSLog(@"Read DSTOffset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DSTOffset", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetSingleItem_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:2ULL]; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset single item: Error: %@", err); - } else { - NSLog(@"Set DSTOffset single item: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetEmpty_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset empty: Error: %@", err); - } else { - NSLog(@"Set DSTOffset empty: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithMoreThan1NullValue_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = nil; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with more than 1 null value: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with more than 1 null value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetUnsortedDSTOffsetEntries_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:2ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:3ULL]; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set unsorted DSTOffset entries: Error: %@", err); - } else { - NSLog(@"Set unsorted DSTOffset entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithMultipleEntries_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:2ULL]; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with multiple entries: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with multiple entries: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadDSTOffset_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDSTOffsetWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read DSTOffset: Error: %@", err); - } else { - NSLog(@"Read DSTOffset: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("DSTOffset", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).offset, 1L)); - VerifyOrReturn(CheckValue("ValidStarting", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validStarting, 1ULL)); - VerifyOrReturn(CheckValueNonNull("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validUntil)); - VerifyOrReturn(CheckValue("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validUntil, 2ULL)); - VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).offset, 0L)); - VerifyOrReturn(CheckValue("ValidStarting", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).validStarting, 3ULL)); - VerifyOrReturn(CheckValueNull("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).validUntil)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithSameValidStartingAndValidUntil_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:1ULL]; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with same validStarting and validUntil: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with same validStarting and validUntil: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetDSTOffsetWithMoreThanSupportedListCount_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = - [NSNumber numberWithInt:1L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = - [NSNumber numberWithUnsignedLongLong:1ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = - [NSNumber numberWithUnsignedLongLong:2ULL]; - - temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = - [NSNumber numberWithUnsignedLongLong:3ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = - [NSNumber numberWithUnsignedLongLong:5ULL]; - - temp_0[2] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).offset = - [NSNumber numberWithInt:0L]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).validStarting = - [NSNumber numberWithUnsignedLongLong:6ULL]; - ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).validUntil = nil; - - params.dstOffset = temp_0; - } - [cluster setDSTOffsetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set DSTOffset with more than supported list count: Error: %@", err); - } else { - NSLog(@"Set DSTOffset with more than supported list count: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestOperationalState : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestOperationalState() - : TestCommandBridge("TestOperationalState") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestOperationalState() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestOperationalState\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestOperationalState\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Phase List\n"); - err = TestReadPhaseList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current Phase\n"); - err = TestReadCurrentPhase_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Countdown Time\n"); - err = TestReadCountdownTime_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read Operational State List\n"); - err = TestReadOperationalStateList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read current Operational Error\n"); - err = TestReadCurrentOperationalError_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Start Command\n"); - err = TestStartCommand_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Pause Command\n"); - err = TestPauseCommand_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Resume Command\n"); - err = TestResumeCommand_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Stop Command\n"); - err = TestStopCommand_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadPhaseList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhaseListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Phase List: Error: %@", err); - } else { - NSLog(@"Read Phase List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("PhaseList", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentPhase_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPhaseWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Phase: Error: %@", err); - } else { - NSLog(@"Read current Phase: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CurrentPhase", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCountdownTime_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCountdownTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Countdown Time: Error: %@", err); - } else { - NSLog(@"Read Countdown Time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CountdownTime", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadOperationalStateList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Operational State List: Error: %@", err); - } else { - NSLog(@"Read Operational State List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalError_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalErrorWithCompletion:^(MTROperationalStateClusterErrorStateStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational Error: Error: %@", err); - } else { - NSLog(@"Read current Operational Error: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStartCommand_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Start Command: Error: %@", err); - } else { - NSLog(@"Start Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPauseCommand_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Pause Command: Error: %@", err); - } else { - NSLog(@"Pause Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResumeCommand_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resumeWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Resume Command: Error: %@", err); - } else { - NSLog(@"Resume Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStopCommand_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Stop Command: Error: %@", err); - } else { - NSLog(@"Stop Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestRVCOperationalState : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestRVCOperationalState() - : TestCommandBridge("TestRVCOperationalState") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestRVCOperationalState() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestRVCOperationalState\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestRVCOperationalState\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Phase List\n"); - err = TestReadPhaseList_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read current Phase\n"); - err = TestReadCurrentPhase_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Countdown Time\n"); - err = TestReadCountdownTime_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read Operational State List\n"); - err = TestReadOperationalStateList_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read current Operational Error\n"); - err = TestReadCurrentOperationalError_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Start Command\n"); - err = TestStartCommand_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Pause Command\n"); - err = TestPauseCommand_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Resume Command\n"); - err = TestResumeCommand_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Stop Command\n"); - err = TestStopCommand_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Read current Operational State\n"); - err = TestReadCurrentOperationalState_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadPhaseList_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributePhaseListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Phase List: Error: %@", err); - } else { - NSLog(@"Read Phase List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("PhaseList", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentPhase_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentPhaseWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Phase: Error: %@", err); - } else { - NSLog(@"Read current Phase: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CurrentPhase", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCountdownTime_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCountdownTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Countdown Time: Error: %@", err); - } else { - NSLog(@"Read Countdown Time: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("CountdownTime", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadOperationalStateList_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Operational State List: Error: %@", err); - } else { - NSLog(@"Read Operational State List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(7))); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[4]).operationalStateID, 64U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[5]).operationalStateID, 65U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[6]).operationalStateID, 66U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalError_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalErrorWithCompletion:^(MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational Error: Error: %@", err); - } else { - NSLog(@"Read current Operational Error: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStartCommand_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster startWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Start Command: Error: %@", err); - } else { - NSLog(@"Start Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPauseCommand_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster pauseWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Pause Command: Error: %@", err); - } else { - NSLog(@"Pause Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResumeCommand_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster resumeWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Resume Command: Error: %@", err); - } else { - NSLog(@"Resume Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.commandResponseState; - VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStopCommand_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster stopWithCompletion: - ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Stop Command: Error: %@", err); - } else { - NSLog(@"Stop Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadCurrentOperationalState_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read current Operational State: Error: %@", err); - } else { - NSLog(@"Read current Operational State: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestDishwasherAlarm : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestDishwasherAlarm() - : TestCommandBridge("TestDishwasherAlarm") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestDishwasherAlarm() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestDishwasherAlarm\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestDishwasherAlarm\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read Supported Attribute\n"); - err = TestReadSupportedAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read State Attribute\n"); - err = TestReadStateAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Read feature map Attribute\n"); - err = TestReadFeatureMapAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Modify enabled alarms Command\n"); - err = TestModifyEnabledAlarmsCommand_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read State Attribute\n"); - err = TestReadStateAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Modify enabled alarms Command\n"); - err = TestModifyEnabledAlarmsCommand_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read State Attribute\n"); - err = TestReadStateAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Modify enabled alarms Command\n"); - err = TestModifyEnabledAlarmsCommand_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read State Attribute\n"); - err = TestReadStateAttribute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Reset Command\n"); - err = TestResetCommand_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read Mask Attribute\n"); - err = TestReadMaskAttribute_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Read Latch Attribute\n"); - err = TestReadLatchAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read State Attribute\n"); - err = TestReadStateAttribute_21(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 22; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadSupportedAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Supported Attribute: Error: %@", err); - } else { - NSLog(@"Read Supported Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Supported", actualValue, 47UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 47UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 7UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFeatureMapAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read feature map Attribute: Error: %@", err); - } else { - NSLog(@"Read feature map Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyEnabledAlarmsCommand_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; - params.mask = - [NSNumber numberWithUnsignedInt:41UL]; - [cluster modifyEnabledAlarmsWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify enabled alarms Command: Error: %@", err); - } else { - NSLog(@"Modify enabled alarms Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyEnabledAlarmsCommand_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; - params.mask = - [NSNumber numberWithUnsignedInt:105UL]; - [cluster modifyEnabledAlarmsWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify enabled alarms Command: Error: %@", err); - } else { - NSLog(@"Modify enabled alarms Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyEnabledAlarmsCommand_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; - params.mask = - [NSNumber numberWithUnsignedInt:59UL]; - [cluster modifyEnabledAlarmsWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify enabled alarms Command: Error: %@", err); - } else { - NSLog(@"Modify enabled alarms Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 1UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestResetCommand_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDishwasherAlarmClusterResetParams alloc] init]; - params.alarms = - [NSNumber numberWithUnsignedInt:1UL]; - [cluster resetWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reset Command: Error: %@", err); - } else { - NSLog(@"Reset Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadMaskAttribute_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Mask Attribute: Error: %@", err); - } else { - NSLog(@"Read Mask Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLatchAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Latch Attribute: Error: %@", err); - } else { - NSLog(@"Read Latch Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadStateAttribute_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read State Attribute: Error: %@", err); - } else { - NSLog(@"Read State Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("State", actualValue, 0UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestMultiAdmin : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestMultiAdmin() - : TestCommandBridge("TestMultiAdmin") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("nodeIdForDuplicateCommissioning", 0, UINT64_MAX, &mNodeIdForDuplicateCommissioning); - AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); - AddArgument("nodeId3", 0, UINT64_MAX, &mNodeId3); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("payload", &mPayload); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestMultiAdmin() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestMultiAdmin\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestMultiAdmin\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Stop target device\n"); - err = TestStopTargetDevice_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Start target device with the provided discriminator for basic commissioning advertisement\n"); - err = TestStartTargetDeviceWithTheProvidedDiscriminatorForBasicCommissioningAdvertisement_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Wait for the commissioned device to be retrieved for alpha\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Commission from alpha when the commissioning window is not opened\n"); - err = TestCommissionFromAlphaWhenTheCommissioningWindowIsNotOpened_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Commission from alpha again\n"); - err = TestCommissionFromAlphaAgain_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Check that we just have the one fabric and did not add a new one\n"); - err = TestCheckThatWeJustHaveTheOneFabricAndDidNotAddANewOne_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Close Commissioning Window after failed commissioning\n"); - err = TestCloseCommissioningWindowAfterFailedCommissioning_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Open Commissioning Window from alpha again\n"); - err = TestOpenCommissioningWindowFromAlphaAgain_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Commission from beta\n"); - err = TestCommissionFromBeta_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Wait for the commissioned device to be retrieved for beta\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Open Commissioning Window from beta\n"); - err = TestOpenCommissioningWindowFromBeta_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Commission from gamma\n"); - err = TestCommissionFromGamma_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for the commissioned device to be retrieved for gamma\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : read the mandatory attribute: NodeLabel from alpha\n"); - err = TestReadTheMandatoryAttributeNodeLabelFromAlpha_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : write the mandatory attribute NodeLabel from beta\n"); - err = TestWriteTheMandatoryAttributeNodeLabelFromBeta_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : read the mandatory attribute: NodeLabel from gamma\n"); - err = TestReadTheMandatoryAttributeNodeLabelFromGamma_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : write the mandatory attribute NodeLabel back to default\n"); - err = TestWriteTheMandatoryAttributeNodeLabelBackToDefault_17(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 18; - - chip::Optional mNodeId; - chip::Optional mNodeIdForDuplicateCommissioning; - chip::Optional mNodeId2; - chip::Optional mNodeId3; - chip::Optional mEndpoint; - chip::Optional mDiscriminator; - chip::Optional mPayload; - chip::Optional mTimeout; - - CHIP_ERROR TestStopTargetDevice_0() - { - - chip::app::Clusters::SystemCommands::Commands::Stop::Type value; - return Stop("alpha", value); - } - - CHIP_ERROR TestStartTargetDeviceWithTheProvidedDiscriminatorForBasicCommissioningAdvertisement_1() - { - - chip::app::Clusters::SystemCommands::Commands::Start::Type value; - value.discriminator.Emplace(); - value.discriminator.Value() = mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U; - return Start("alpha", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_2() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCommissionFromAlphaWhenTheCommissioningWindowIsNotOpened_3() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeIdForDuplicateCommissioning.HasValue() ? mNodeIdForDuplicateCommissioning.Value() : 17ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromAlphaAgain_5() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeIdForDuplicateCommissioning.HasValue() ? mNodeIdForDuplicateCommissioning.Value() : 17ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("alpha", value); - } - - CHIP_ERROR TestCheckThatWeJustHaveTheOneFabricAndDidNotAddANewOne_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = false; - [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that we just have the one fabric and did not add a new one: Error: %@", err); - } else { - NSLog(@"Check that we just have the one fabric and did not add a new one: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("NodeID", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).nodeID, mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseCommissioningWindowAfterFailedCommissioning_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close Commissioning Window after failed commissioning: Error: %@", err); - } else { - NSLog(@"Close Commissioning Window after failed commissioning: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlphaAgain_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha again: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha again: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromBeta_9() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_10() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; - return WaitForCommissionee("beta", value); - } - - CHIP_ERROR TestOpenCommissioningWindowFromBeta_11() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from beta: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCommissionFromGamma_12() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("gamma", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; - return WaitForCommissionee("gamma", value); - } - NSString * _Nonnull readFromAlpha; - - CHIP_ERROR TestReadTheMandatoryAttributeNodeLabelFromAlpha_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read the mandatory attribute: NodeLabel from alpha: Error: %@", err); - } else { - NSLog(@"read the mandatory attribute: NodeLabel from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"")); - } - { - readFromAlpha = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheMandatoryAttributeNodeLabelFromBeta_15() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = @"written from beta"; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"write the mandatory attribute NodeLabel from beta: Error: %@", err); - } else { - NSLog(@"write the mandatory attribute NodeLabel from beta: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheMandatoryAttributeNodeLabelFromGamma_16() - { - - MTRBaseDevice * device = GetDevice("gamma"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"read the mandatory attribute: NodeLabel from gamma: Error: %@", err); - } else { - NSLog(@"read the mandatory attribute: NodeLabel from gamma: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintNotValue("nodeLabel", value, readFromAlpha)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteTheMandatoryAttributeNodeLabelBackToDefault_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id nodeLabelArgument; - nodeLabelArgument = - [readFromAlpha copy]; - [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"write the mandatory attribute NodeLabel back to default: Error: %@", err); - } else { - NSLog(@"write the mandatory attribute NodeLabel back to default: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DGSW_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DGSW_1_1() - : TestCommandBridge("Test_TC_DGSW_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DGSW_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGSW_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGSW_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DGSW.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DGSW.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDGSWSF00WatermarksEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList\n"); - if (ShouldSkip("DGSW.S.A0000")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributeThreadMetricsInAttributeList_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList\n"); - if (ShouldSkip("DGSW.S.A0001")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptionalAttributeCurrentHeapFreeInAttributeList_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList\n"); - if (ShouldSkip("DGSW.S.A0002")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionalAttributeCurrentHeapUsedInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList\n"); - if (ShouldSkip("( DGSW.S.F00 || DGSW.S.A0003 )")) { - NextTest(); - return; - } - err = TestStep4eThReadsFeatureDependentAttributeCurrentHeapHighWatermarkInAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip("DGSW.S.E00 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5b: TH reads EventList from DUT\n"); - if (ShouldSkip(" !DGSW.S.E00 && PICS_EVENT_LIST_ENABLED ")) { - NextTest(); - return; - } - NextTest(); - return; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip("DGSW.S.F00")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads AcceptedCommandList from DUT\n"); - if (ShouldSkip(" !DGSW.S.F00 ")) { - NextTest(); - return; - } - err = TestStep6ThReadsAcceptedCommandListFromDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH reads GeneratedCommandList from DUT\n"); - err = TestStep7ThReadsGeneratedCommandListFromDut_14(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 15; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDGSWSF00WatermarksEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributeThreadMetricsInAttributeList_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptionalAttributeCurrentHeapFreeInAttributeList_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionalAttributeCurrentHeapUsedInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFeatureDependentAttributeCurrentHeapHighWatermarkInAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestSubscribe_OnOff : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSubscribe_OnOff() - : TestCommandBridge("TestSubscribe_OnOff") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSubscribe_OnOff() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSubscribe_OnOff\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSubscribe_OnOff\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Set OnOff Attribute to false\n"); - err = TestSetOnOffAttributeToFalse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Report: Subscribe OnOff Attribute\n"); - err = TestReportSubscribeOnOffAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Subscribe OnOff Attribute\n"); - err = TestSubscribeOnOffAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Turn On the light to see attribute change\n"); - err = TestTurnOnTheLightToSeeAttributeChange_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Check for attribute report\n"); - err = TestCheckForAttributeReport_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Turn Off the light to see attribute change\n"); - err = TestTurnOffTheLightToSeeAttributeChange_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Check for attribute report\n"); - err = TestCheckForAttributeReport_7(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 8; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestSetOnOffAttributeToFalse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set OnOff Attribute to false: Error: %@", err); - } else { - NSLog(@"Set OnOff Attribute to false: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_OnOff_OnOff_Reported - = nil; - - CHIP_ERROR TestReportSubscribeOnOffAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_OnOff_OnOff_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe OnOff Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe OnOff Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, false)); - } - - testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeOnOffAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 5U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeOnOffWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe OnOff Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe OnOff Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_OnOff_OnOff_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_OnOff_OnOff_Reported; - test_TestSubscribe_OnOff_OnOff_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster onWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn On the light to see attribute change: Error: %@", err); - } else { - NSLog(@"Turn On the light to see attribute change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForAttributeReport_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_OnOff_OnOff_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for attribute report: Error: %@", err); - } else { - NSLog(@"Check for attribute report: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, true)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster offWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Turn Off the light to see attribute change: Error: %@", err); - } else { - NSLog(@"Turn Off the light to see attribute change: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForAttributeReport_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_OnOff_OnOff_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for attribute report: Error: %@", err); - } else { - NSLog(@"Check for attribute report: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OnOff", actualValue, false)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } -}; - -class TestSubscribe_AdministratorCommissioning : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestSubscribe_AdministratorCommissioning() - : TestCommandBridge("TestSubscribe_AdministratorCommissioning") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("ourVendorId", 0, UINT16_MAX, &mOurVendorId); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestSubscribe_AdministratorCommissioning() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestSubscribe_AdministratorCommissioning\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestSubscribe_AdministratorCommissioning\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Get ourfabric index\n"); - err = TestGetOurfabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Report: Subscribe WindowStatus Attribute\n"); - err = TestReportSubscribeWindowStatusAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Subscribe WindowStatus Attribute\n"); - err = TestSubscribeWindowStatusAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Open the commissioning window 1\n"); - err = TestOpenTheCommissioningWindow1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Check for first attribute report for WindowStatus\n"); - err = TestCheckForFirstAttributeReportForWindowStatus_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Close the commissioning window 1\n"); - err = TestCloseTheCommissioningWindow1_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Check for second attribute report for WindowStatus\n"); - err = TestCheckForSecondAttributeReportForWindowStatus_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Report: Subscribe AdminVendorId Attribute\n"); - err = TestReportSubscribeAdminVendorIdAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Subscribe AdminVendorId Attribute\n"); - err = TestSubscribeAdminVendorIdAttribute_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Open the commissioning window 2\n"); - err = TestOpenTheCommissioningWindow2_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Check for first attribute report for AdminVendorId\n"); - err = TestCheckForFirstAttributeReportForAdminVendorId_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Close the commissioning window 2\n"); - err = TestCloseTheCommissioningWindow2_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Check for second attribute report for AdminVendorId\n"); - err = TestCheckForSecondAttributeReportForAdminVendorId_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Report: Subscribe AdminFabricIndex Attribute\n"); - err = TestReportSubscribeAdminFabricIndexAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Subscribe AdminFabricIndex Attribute\n"); - err = TestSubscribeAdminFabricIndexAttribute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Open the commissioning window 3\n"); - err = TestOpenTheCommissioningWindow3_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Check for first attribute report for AdminFabricIndex\n"); - err = TestCheckForFirstAttributeReportForAdminFabricIndex_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Close the commissioning window 2\n"); - err = TestCloseTheCommissioningWindow2_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Check for second attribute report for AdminFabricIndex\n"); - err = TestCheckForSecondAttributeReportForAdminFabricIndex_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mOurVendorId; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull ourFabricIndex; - - CHIP_ERROR TestGetOurfabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get ourfabric index: Error: %@", err); - } else { - NSLog(@"Get ourfabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - ourFabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = nil; - - CHIP_ERROR TestReportSubscribeWindowStatusAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe WindowStatus Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe WindowStatus Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeWindowStatusAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 50U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeWindowStatusWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe WindowStatus Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe WindowStatus Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported; - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenTheCommissioningWindow1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open the commissioning window 1: Error: %@", err); - } else { - NSLog(@"Open the commissioning window 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForFirstAttributeReportForWindowStatus_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for first attribute report for WindowStatus: Error: %@", err); - } else { - NSLog(@"Check for first attribute report for WindowStatus: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseTheCommissioningWindow1_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close the commissioning window 1: Error: %@", err); - } else { - NSLog(@"Close the commissioning window 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForSecondAttributeReportForWindowStatus_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for second attribute report for WindowStatus: Error: %@", err); - } else { - NSLog(@"Check for second attribute report for WindowStatus: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = nil; - - CHIP_ERROR TestReportSubscribeAdminVendorIdAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe AdminVendorId Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe AdminVendorId Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeAdminVendorIdAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 50U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeAdminVendorIdWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe AdminVendorId Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe AdminVendorId Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported; - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenTheCommissioningWindow2_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open the commissioning window 2: Error: %@", err); - } else { - NSLog(@"Open the commissioning window 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForFirstAttributeReportForAdminVendorId_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for first attribute report for AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check for first attribute report for AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("AdminVendorId", actualValue)); - VerifyOrReturn(CheckValue("AdminVendorId", actualValue, mOurVendorId.HasValue() ? mOurVendorId.Value() : 65521U)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseTheCommissioningWindow2_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close the commissioning window 2: Error: %@", err); - } else { - NSLog(@"Close the commissioning window 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForSecondAttributeReportForAdminVendorId_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for second attribute report for AdminVendorId: Error: %@", err); - } else { - NSLog(@"Check for second attribute report for AdminVendorId: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - bool testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled = false; - ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = nil; - - CHIP_ERROR TestReportSubscribeAdminFabricIndexAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Report: Subscribe AdminFabricIndex Attribute: Error: %@", err); - } else { - NSLog(@"Report: Subscribe AdminFabricIndex Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled = true; - }; - - NextTest(); - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSubscribeAdminFabricIndexAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - uint16_t minIntervalArgument = 2U; - uint16_t maxIntervalArgument = 50U; - __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; - params.filterByFabric = true; - params.replaceExistingSubscriptions = true; - [cluster subscribeAttributeAdminFabricIndexWithParams:params - subscriptionEstablished:^{ - VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); - NextTest(); - } - reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Subscribe AdminFabricIndex Attribute: Error: %@", err); - } else { - NSLog(@"Subscribe AdminFabricIndex Attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - if (test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - != nil) { - ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported; - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = nil; - callback(value, err); - } - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenTheCommissioningWindow3_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - [cluster openBasicCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open the commissioning window 3: Error: %@", err); - } else { - NSLog(@"Open the commissioning window 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForFirstAttributeReportForAdminFabricIndex_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for first attribute report for AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check for first attribute report for AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - if (ourFabricIndex == nil) { - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, ourFabricIndex)); - } - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCloseTheCommissioningWindow2_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster revokeCommissioningWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Close the commissioning window 2: Error: %@", err); - } else { - NSLog(@"Close the commissioning window 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckForSecondAttributeReportForAdminFabricIndex_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported - = ^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check for second attribute report for AdminFabricIndex: Error: %@", err); - } else { - NSLog(@"Check for second attribute report for AdminFabricIndex: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); - } - - NextTest(); - }; - - return CHIP_NO_ERROR; - } -}; - -class DL_UsersAndCredentials : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - DL_UsersAndCredentials() - : TestCommandBridge("DL_UsersAndCredentials") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~DL_UsersAndCredentials() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: DL_UsersAndCredentials\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: DL_UsersAndCredentials\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Read available user slot and verify response fields\n"); - err = TestReadAvailableUserSlotAndVerifyResponseFields_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Get number of supported users and verify default value\n"); - err = TestGetNumberOfSupportedUsersAndVerifyDefaultValue_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Read fails for user with index 0\n"); - err = TestReadFailsForUserWithIndex0_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Read fails for user with index greater than Number Of Users Supported\n"); - err = TestReadFailsForUserWithIndexGreaterThanNumberOfUsersSupported_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Create new user with default parameters\n"); - err = TestCreateNewUserWithDefaultParameters_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Read the user back and verify its fields\n"); - err = TestReadTheUserBackAndVerifyItsFields_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Set user at the occupied index fails with appropriate response\n"); - err = TestSetUserAtTheOccupiedIndexFailsWithAppropriateResponse_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Modify userName for existing user\n"); - err = TestModifyUserNameForExistingUser_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Modify userUniqueId for existing user\n"); - err = TestModifyUserUniqueIdForExistingUser_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Modify userStatus for existing user\n"); - err = TestModifyUserStatusForExistingUser_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Modify userType for existing user\n"); - err = TestModifyUserTypeForExistingUser_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Modify credentialRule for existing user\n"); - err = TestModifyCredentialRuleForExistingUser_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Modify all fields for existing user\n"); - err = TestModifyAllFieldsForExistingUser_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Read the modified user back and verify its fields\n"); - err = TestReadTheModifiedUserBackAndVerifyItsFields_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Add another user with non-default fields\n"); - err = TestAddAnotherUserWithNonDefaultFields_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Read the new user back and verify its fields\n"); - err = TestReadTheNewUserBackAndVerifyItsFields_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Try to add a user with userStatus 0\n"); - err = TestTryToAddAUserWithUserStatus0_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Make sure the user did not get created\n"); - err = TestMakeSureTheUserDidNotGetCreated_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Try to add a user with userStatus 2\n"); - err = TestTryToAddAUserWithUserStatus2_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Make sure the user did not get created\n"); - err = TestMakeSureTheUserDidNotGetCreated_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Try to add a user with userStatus 3\n"); - err = TestTryToAddAUserWithUserStatus3_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Read the new third user back and verify its fields\n"); - err = TestReadTheNewThirdUserBackAndVerifyItsFields_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Create user in the last slot\n"); - err = TestCreateUserInTheLastSlot_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Read the last user back and verify its fields\n"); - err = TestReadTheLastUserBackAndVerifyItsFields_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : User creation in the 0 slot fails\n"); - err = TestUserCreationInThe0SlotFails_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : User creation in the out-of-bounds slot fails\n"); - err = TestUserCreationInTheOutOfBoundsSlotFails_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Clear first user\n"); - err = TestClearFirstUser_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Read cleared user and verify it is available\n"); - err = TestReadClearedUserAndVerifyItIsAvailable_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Create new user in the cleared slot\n"); - err = TestCreateNewUserInTheClearedSlot_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Read the user in the previously cleared slot and verify its fields\n"); - err = TestReadTheUserInThePreviouslyClearedSlotAndVerifyItsFields_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Clear user with index 0 fails\n"); - err = TestClearUserWithIndex0Fails_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Clear user with out-of-bounds index fails\n"); - err = TestClearUserWithOutOfBoundsIndexFails_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Clear all users\n"); - err = TestClearAllUsers_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Read first cleared user and verify it is available\n"); - err = TestReadFirstClearedUserAndVerifyItIsAvailable_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Read last cleared user and verify it is available\n"); - err = TestReadLastClearedUserAndVerifyItIsAvailable_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Get number of supported PIN credentials and verify default value\n"); - err = TestGetNumberOfSupportedPinCredentialsAndVerifyDefaultValue_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Check that PIN credential does not exist\n"); - err = TestCheckThatPinCredentialDoesNotExist_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Reading PIN credential with index 0 returns no credential\n"); - err = TestReadingPinCredentialWithIndex0ReturnsNoCredential_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Reading PIN credential with out-of-bounds index returns no credential\n"); - err = TestReadingPinCredentialWithOutOfBoundsIndexReturnsNoCredential_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Verify that a user with UserStatus = 0 cannot be added via SetCredential\n"); - err = TestVerifyThatAUserWithUserStatus0CannotBeAddedViaSetCredential_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Verify that a user with UserStatus = 2 cannot be added via SetCredential\n"); - err = TestVerifyThatAUserWithUserStatus2CannotBeAddedViaSetCredential_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Create new PIN credential and user\n"); - err = TestCreateNewPinCredentialAndUser_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Verify created user\n"); - err = TestVerifyCreatedUser_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Verify created PIN credential\n"); - err = TestVerifyCreatedPinCredential_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Create new PIN credential and user with index 0 fails\n"); - err = TestCreateNewPinCredentialAndUserWithIndex0Fails_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Create new PIN credential and user with out-of-bounds index fails\n"); - err = TestCreateNewPinCredentialAndUserWithOutOfBoundsIndexFails_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Get number of supported RFID credentials and verify default value\n"); - err = TestGetNumberOfSupportedRfidCredentialsAndVerifyDefaultValue_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Reading RFID credential with index 0 returns no credential\n"); - err = TestReadingRfidCredentialWithIndex0ReturnsNoCredential_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Reading RFID credential with out-of-bounds index returns no credential\n"); - err = TestReadingRfidCredentialWithOutOfBoundsIndexReturnsNoCredential_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Check that RFID credential does not exist\n"); - err = TestCheckThatRfidCredentialDoesNotExist_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Create new RFID credential and add it to existing user with non-null UserStatus should fail\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserStatusShouldFail_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Create new RFID credential and add it to existing user with non-null UserType should fail\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeShouldFail_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeAndUserStatusShouldFail_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Create new RFID credential and add it to existing user\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUser_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Verify modified user\n"); - err = TestVerifyModifiedUser_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Verify created credential\n"); - err = TestVerifyCreatedCredential_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Create new RFID credential and user with index 0 fails\n"); - err = TestCreateNewRfidCredentialAndUserWithIndex0Fails_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Create new RFID credential and user with out-of-bounds index fails\n"); - err = TestCreateNewRfidCredentialAndUserWithOutOfBoundsIndexFails_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Create new credential and try to add it to 0 user\n"); - err = TestCreateNewCredentialAndTryToAddItTo0User_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Create new credential and try to add it to out-of-bounds user\n"); - err = TestCreateNewCredentialAndTryToAddItToOutOfBoundsUser_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Create new PIN with too short data\n"); - err = TestCreateNewPinWithTooShortData_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Create new PIN with too long data\n"); - err = TestCreateNewPinWithTooLongData_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Create new RFID with too short data\n"); - err = TestCreateNewRfidWithTooShortData_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Create new PIN with Programming user type fails\n"); - err = TestCreateNewPinWithProgrammingUserTypeFails_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Create new RFID with too short data\n"); - err = TestCreateNewRfidWithTooShortData_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Create new PIN credential with data the would cause duplicate\n"); - err = TestCreateNewPinCredentialWithDataTheWouldCauseDuplicate_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Create new RFID credential with data the would cause duplicate\n"); - err = TestCreateNewRfidCredentialWithDataTheWouldCauseDuplicate_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Modify credentialData of existing PIN credential with non-null UserStatus should fail\n"); - err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusShouldFail_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Modify credentialData of existing PIN credential with non-null UserType should fail\n"); - err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserTypeShouldFail_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail\n"); - err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusAndUserTypeShouldFail_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Modify credentialData of existing PIN credential\n"); - err = TestModifyCredentialDataOfExistingPinCredential_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Verify that credential was changed by creating new credential with old data\n"); - err = TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithOldData_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Verify that credential was changed by creating new credential with new data\n"); - err = TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithNewData_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Create new RFID credential and add it to existing user\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUser_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Verify modified user\n"); - err = TestVerifyModifiedUser_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Create new RFID credential and add it to existing user\n"); - err = TestCreateNewRfidCredentialAndAddItToExistingUser_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Verify modified user\n"); - err = TestVerifyModifiedUser_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Clear first PIN credential\n"); - err = TestClearFirstPinCredential_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Read back the credential and make sure it is deleted\n"); - err = TestReadBackTheCredentialAndMakeSureItIsDeleted_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Read the user back and make sure PIN credential is deleted\n"); - err = TestReadTheUserBackAndMakeSurePinCredentialIsDeleted_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Clear the second PIN credential\n"); - err = TestClearTheSecondPinCredential_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Read back the credential and make sure it is deleted\n"); - err = TestReadBackTheCredentialAndMakeSureItIsDeleted_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Read the user back and make sure related user is deleted\n"); - err = TestReadTheUserBackAndMakeSureRelatedUserIsDeleted_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Create new RFID credential with user\n"); - err = TestCreateNewRfidCredentialWithUser_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Clear all the RFID credentials\n"); - err = TestClearAllTheRfidCredentials_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Read back the fist RFID credential and make sure it is deleted\n"); - err = TestReadBackTheFistRfidCredentialAndMakeSureItIsDeleted_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Read back the second RFID credential and make sure it is deleted\n"); - err = TestReadBackTheSecondRfidCredentialAndMakeSureItIsDeleted_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Read back the third RFID credential and make sure it is deleted\n"); - err = TestReadBackTheThirdRfidCredentialAndMakeSureItIsDeleted_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Read the user related with first RFID back and make sure it has only PIN credential\n"); - err = TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItHasOnlyPinCredential_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Read the user related with second RFID back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithSecondRfidBackAndMakeSureItIsDeleted_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Create new PIN credential with user\n"); - err = TestCreateNewPinCredentialWithUser_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Create new RFID credential with user\n"); - err = TestCreateNewRfidCredentialWithUser_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Create another RFID credential with user\n"); - err = TestCreateAnotherRfidCredentialWithUser_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Clear all the credentials\n"); - err = TestClearAllTheCredentials_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Read back the first PIN credential and make sure it is deleted\n"); - err = TestReadBackTheFirstPinCredentialAndMakeSureItIsDeleted_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Read back the first RFID credential and make sure it is deleted\n"); - err = TestReadBackTheFirstRfidCredentialAndMakeSureItIsDeleted_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Read back the second PIN credential and make sure it is deleted\n"); - err = TestReadBackTheSecondPinCredentialAndMakeSureItIsDeleted_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Read the user related with first PIN back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithFirstPinBackAndMakeSureItIsDeleted_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Read the user related with first RFID back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItIsDeleted_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Read the user related with second PIN back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithSecondPinBackAndMakeSureItIsDeleted_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Read the user related with last RFID back and make sure it is deleted\n"); - err = TestReadTheUserRelatedWithLastRfidBackAndMakeSureItIsDeleted_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Create new Programming PIN credential with invalid index\n"); - err = TestCreateNewProgrammingPinCredentialWithInvalidIndex_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Create new Programming PIN credential with valid index\n"); - err = TestCreateNewProgrammingPinCredentialWithValidIndex_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Verify created user\n"); - err = TestVerifyCreatedUser_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Verify created programming PIN credential\n"); - err = TestVerifyCreatedProgrammingPinCredential_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Modify the Programming PIN credential\n"); - err = TestModifyTheProgrammingPinCredential_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Clearing Programming PIN fails\n"); - err = TestClearingProgrammingPinFails_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Clearing Programming PIN with invalid index fails\n"); - err = TestClearingProgrammingPinWithInvalidIndexFails_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Clearing PIN credential with zero index fails\n"); - err = TestClearingPinCredentialWithZeroIndexFails_114(); - break; - case 115: - ChipLogProgress(chipTool, " ***** Test Step 115 : Clearing PIN credential with out-of-bound index fails\n"); - err = TestClearingPinCredentialWithOutOfBoundIndexFails_115(); - break; - case 116: - ChipLogProgress(chipTool, " ***** Test Step 116 : Clearing RFID credential with zero index fails\n"); - err = TestClearingRfidCredentialWithZeroIndexFails_116(); - break; - case 117: - ChipLogProgress(chipTool, " ***** Test Step 117 : Clearing RFID credential with out-of-bound index fails\n"); - err = TestClearingRfidCredentialWithOutOfBoundIndexFails_117(); - break; - case 118: - ChipLogProgress(chipTool, " ***** Test Step 118 : Clear the Programming PIN user\n"); - err = TestClearTheProgrammingPinUser_118(); - break; - case 119: - ChipLogProgress(chipTool, " ***** Test Step 119 : Make sure Programming PIN user is deleted\n"); - err = TestMakeSureProgrammingPinUserIsDeleted_119(); - break; - case 120: - ChipLogProgress(chipTool, " ***** Test Step 120 : Make sure programming PIN credential is deleted\n"); - err = TestMakeSureProgrammingPinCredentialIsDeleted_120(); - break; - case 121: - ChipLogProgress(chipTool, " ***** Test Step 121 : Create new PIN credential and user\n"); - err = TestCreateNewPinCredentialAndUser_121(); - break; - case 122: - ChipLogProgress(chipTool, " ***** Test Step 122 : Create second PIN credential and add it to existing user\n"); - err = TestCreateSecondPinCredentialAndAddItToExistingUser_122(); - break; - case 123: - ChipLogProgress(chipTool, " ***** Test Step 123 : Create third PIN credential and add it to existing user\n"); - err = TestCreateThirdPinCredentialAndAddItToExistingUser_123(); - break; - case 124: - ChipLogProgress(chipTool, " ***** Test Step 124 : Create fourth PIN credential and add it to existing user\n"); - err = TestCreateFourthPinCredentialAndAddItToExistingUser_124(); - break; - case 125: - ChipLogProgress(chipTool, " ***** Test Step 125 : Create fifth PIN credential and add it to existing user\n"); - err = TestCreateFifthPinCredentialAndAddItToExistingUser_125(); - break; - case 126: - ChipLogProgress(chipTool, " ***** Test Step 126 : Try to create sixth PIN credential and make sure it fails\n"); - err = TestTryToCreateSixthPinCredentialAndMakeSureItFails_126(); - break; - case 127: - ChipLogProgress(chipTool, " ***** Test Step 127 : Final clean-up\n"); - err = TestFinalCleanUp_127(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 115: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 116: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 117: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 118: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 119: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 120: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 121: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 122: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 123: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 124: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 125: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 126: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 127: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 128; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestReadAvailableUserSlotAndVerifyResponseFields_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read available user slot and verify response fields: Error: %@", err); - } else { - NSLog(@"Read available user slot and verify response fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedUsersAndVerifyDefaultValue_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported users and verify default value: Error: %@", err); - } else { - NSLog(@"Get number of supported users and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfTotalUsersSupported", actualValue, 10U)); - } - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFailsForUserWithIndex0_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fails for user with index 0: Error: %@", err); - } else { - NSLog(@"Read fails for user with index 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFailsForUserWithIndexGreaterThanNumberOfUsersSupported_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read fails for user with index greater than Number Of Users Supported: Error: %@", err); - } else { - NSLog(@"Read fails for user with index greater than Number Of Users Supported: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewUserWithDefaultParameters_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user with default parameters: Error: %@", err); - } else { - NSLog(@"Create new user with default parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndVerifyItsFields_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestSetUserAtTheOccupiedIndexFailsWithAppropriateResponse_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Set user at the occupied index fails with appropriate response: Error: %@", err); - } else { - NSLog(@"Set user at the occupied index fails with appropriate response: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserNameForExistingUser_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"new_user"; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userName for existing user: Error: %@", err); - } else { - NSLog(@"Modify userName for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserUniqueIdForExistingUser_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:305441741UL]; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userUniqueId for existing user: Error: %@", err); - } else { - NSLog(@"Modify userUniqueId for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserStatusForExistingUser_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = - [NSNumber numberWithUnsignedChar:3U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userStatus for existing user: Error: %@", err); - } else { - NSLog(@"Modify userStatus for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyUserTypeForExistingUser_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:6U]; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify userType for existing user: Error: %@", err); - } else { - NSLog(@"Modify userType for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 6U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialRuleForExistingUser_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = - [NSNumber numberWithUnsignedChar:2U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialRule for existing user: Error: %@", err); - } else { - NSLog(@"Modify credentialRule for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 6U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 2U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyAllFieldsForExistingUser_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"test_user"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:466460832UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:1U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify all fields for existing user: Error: %@", err); - } else { - NSLog(@"Modify all fields for existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the modified user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the modified user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 466460832UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 1U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddAnotherUserWithNonDefaultFields_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = @"test_user2"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:12648430UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:1U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:2U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add another user with non-default fields: Error: %@", err); - } else { - NSLog(@"Add another user with non-default fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheNewUserBackAndVerifyItsFields_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the new user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the new user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user2")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 12648430UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 1U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 2U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToAddAUserWithUserStatus0_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - params.userName = @"test_user3"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:47802UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:0U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to add a user with userStatus 0: Error: %@", err); - } else { - NSLog(@"Try to add a user with userStatus 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureTheUserDidNotGetCreated_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure the user did not get created: Error: %@", err); - } else { - NSLog(@"Make sure the user did not get created: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToAddAUserWithUserStatus2_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - params.userName = @"test_user3"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:47802UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:2U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to add a user with userStatus 2: Error: %@", err); - } else { - NSLog(@"Try to add a user with userStatus 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureTheUserDidNotGetCreated_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure the user did not get created: Error: %@", err); - } else { - NSLog(@"Make sure the user did not get created: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToAddAUserWithUserStatus3_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - params.userName = @"test_user3"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:47802UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:3U]; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to add a user with userStatus 3: Error: %@", err); - } else { - NSLog(@"Try to add a user with userStatus 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheNewThirdUserBackAndVerifyItsFields_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the new third user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the new third user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user3")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 47802UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateUserInTheLastSlot_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NumberOfTotalUsersSupportedValue copy]; - params.userName = @"last_user"; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create user in the last slot: Error: %@", err); - } else { - NSLog(@"Create user in the last slot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheLastUserBackAndVerifyItsFields_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NumberOfTotalUsersSupportedValue copy]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the last user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the last user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, NumberOfTotalUsersSupportedValue)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"last_user")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestUserCreationInThe0SlotFails_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"User creation in the 0 slot fails: Error: %@", err); - } else { - NSLog(@"User creation in the 0 slot fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestUserCreationInTheOutOfBoundsSlotFails_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"User creation in the out-of-bounds slot fails: Error: %@", err); - } else { - NSLog(@"User creation in the out-of-bounds slot fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearFirstUser_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear first user: Error: %@", err); - } else { - NSLog(@"Clear first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadClearedUserAndVerifyItIsAvailable_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read cleared user and verify it is available: Error: %@", err); - } else { - NSLog(@"Read cleared user and verify it is available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewUserInTheClearedSlot_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user in the cleared slot: Error: %@", err); - } else { - NSLog(@"Create new user in the cleared slot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserInThePreviouslyClearedSlotAndVerifyItsFields_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user in the previously cleared slot and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the user in the previously cleared slot and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearUserWithIndex0Fails_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear user with index 0 fails: Error: %@", err); - } else { - NSLog(@"Clear user with index 0 fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearUserWithOutOfBoundsIndexFails_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear user with out-of-bounds index fails: Error: %@", err); - } else { - NSLog(@"Clear user with out-of-bounds index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllUsers_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all users: Error: %@", err); - } else { - NSLog(@"Clear all users: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadFirstClearedUserAndVerifyItIsAvailable_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read first cleared user and verify it is available: Error: %@", err); - } else { - NSLog(@"Read first cleared user and verify it is available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadLastClearedUserAndVerifyItIsAvailable_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NumberOfTotalUsersSupportedValue copy]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read last cleared user and verify it is available: Error: %@", err); - } else { - NSLog(@"Read last cleared user and verify it is available: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, NumberOfTotalUsersSupportedValue)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfPINUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedPinCredentialsAndVerifyDefaultValue_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfPINUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported PIN credentials and verify default value: Error: %@", err); - } else { - NSLog(@"Get number of supported PIN credentials and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfPINUsersSupported", actualValue, 10U)); - } - { - NumberOfPINUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatPinCredentialDoesNotExist_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that PIN credential does not exist: Error: %@", err); - } else { - NSLog(@"Check that PIN credential does not exist: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingPinCredentialWithIndex0ReturnsNoCredential_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading PIN credential with index 0 returns no credential: Error: %@", err); - } else { - NSLog(@"Reading PIN credential with index 0 returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingPinCredentialWithOutOfBoundsIndexReturnsNoCredential_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading PIN credential with out-of-bounds index returns no credential: Error: %@", err); - } else { - NSLog(@"Reading PIN credential with out-of-bounds index returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatAUserWithUserStatus0CannotBeAddedViaSetCredential_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = - [NSNumber numberWithUnsignedChar:0U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that a user with UserStatus = 0 cannot be added via SetCredential: Error: %@", err); - } else { - NSLog(@"Verify that a user with UserStatus = 0 cannot be added via SetCredential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatAUserWithUserStatus2CannotBeAddedViaSetCredential_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = - [NSNumber numberWithUnsignedChar:2U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that a user with UserStatus = 2 cannot be added via SetCredential: Error: %@", err); - } else { - NSLog(@"Verify that a user with UserStatus = 2 cannot be added via SetCredential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUser_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedUser_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created user: Error: %@", err); - } else { - NSLog(@"Verify created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedPinCredential_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created PIN credential: Error: %@", err); - } else { - NSLog(@"Verify created PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUserWithIndex0Fails_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user with index 0 fails: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user with index 0 fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUserWithOutOfBoundsIndexFails_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user with out-of-bounds index fails: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user with out-of-bounds index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfRFIDUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedRfidCredentialsAndVerifyDefaultValue_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfRFIDUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported RFID credentials and verify default value: Error: %@", err); - } else { - NSLog(@"Get number of supported RFID credentials and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfRFIDUsersSupported", actualValue, 10U)); - } - { - NumberOfRFIDUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingRfidCredentialWithIndex0ReturnsNoCredential_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading RFID credential with index 0 returns no credential: Error: %@", err); - } else { - NSLog(@"Reading RFID credential with index 0 returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadingRfidCredentialWithOutOfBoundsIndexReturnsNoCredential_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Reading RFID credential with out-of-bounds index returns no credential: Error: %@", err); - } else { - NSLog(@"Reading RFID credential with out-of-bounds index returns no credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCheckThatRfidCredentialDoesNotExist_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Check that RFID credential does not exist: Error: %@", err); - } else { - NSLog(@"Check that RFID credential does not exist: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserStatusShouldFail_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserStatus should fail: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserStatus should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeShouldFail_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType should fail: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeAndUserStatusShouldFail_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyModifiedUser_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify modified user: Error: %@", err); - } else { - NSLog(@"Verify modified user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedCredential_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created credential: Error: %@", err); - } else { - NSLog(@"Verify created credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndUserWithIndex0Fails_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"new_rfid_data_field" length:19]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and user with index 0 fails: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and user with index 0 fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndUserWithOutOfBoundsIndexFails_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"new_rfid_data_field" length:19]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and user with out-of-bounds index fails: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and user with out-of-bounds index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewCredentialAndTryToAddItTo0User_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123465" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new credential and try to add it to 0 user: Error: %@", err); - } else { - NSLog(@"Create new credential and try to add it to 0 user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewCredentialAndTryToAddItToOutOfBoundsUser_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123465" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new credential and try to add it to out-of-bounds user: Error: %@", err); - } else { - NSLog(@"Create new credential and try to add it to out-of-bounds user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinWithTooShortData_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"12345" length:5]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN with too short data: Error: %@", err); - } else { - NSLog(@"Create new PIN with too short data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinWithTooLongData_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456789" length:9]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN with too long data: Error: %@", err); - } else { - NSLog(@"Create new PIN with too long data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidWithTooShortData_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data" length:9]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID with too short data: Error: %@", err); - } else { - NSLog(@"Create new RFID with too short data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinWithProgrammingUserTypeFails_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:3U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN with Programming user type fails: Error: %@", err); - } else { - NSLog(@"Create new PIN with Programming user type fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidWithTooShortData_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"very_long_rfid_data_to_test_boundaries" length:38]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID with too short data: Error: %@", err); - } else { - NSLog(@"Create new RFID with too short data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialWithDataTheWouldCauseDuplicate_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential with data the would cause duplicate: Error: %@", err); - } else { - NSLog(@"Create new PIN credential with data the would cause duplicate: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialWithDataTheWouldCauseDuplicate_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential with data the would cause duplicate: Error: %@", err); - } else { - NSLog(@"Create new RFID credential with data the would cause duplicate: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusShouldFail_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus should fail: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserTypeShouldFail_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserType should fail: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserType should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusAndUserTypeShouldFail_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyCredentialDataOfExistingPinCredential_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify credentialData of existing PIN credential: Error: %@", err); - } else { - NSLog(@"Modify credentialData of existing PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithOldData_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that credential was changed by creating new credential with old data: Error: %@", err); - } else { - NSLog(@"Verify that credential was changed by creating new credential with old data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithNewData_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that credential was changed by creating new credential with new data: Error: %@", err); - } else { - NSLog(@"Verify that credential was changed by creating new credential with new data: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_7890" length:14]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyModifiedUser_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify modified user: Error: %@", err); - } else { - NSLog(@"Verify modified user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 2U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"789012" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyModifiedUser_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify modified user: Error: %@", err); - } else { - NSLog(@"Verify modified user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 2U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[3]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[3]).credentialIndex, 3U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearFirstPinCredential_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear first PIN credential: Error: %@", err); - } else { - NSLog(@"Clear first PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheCredentialAndMakeSureItIsDeleted_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndMakeSurePinCredentialIsDeleted_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and make sure PIN credential is deleted: Error: %@", err); - } else { - NSLog(@"Read the user back and make sure PIN credential is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(3))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 2U)); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 3U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearTheSecondPinCredential_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear the second PIN credential: Error: %@", err); - } else { - NSLog(@"Clear the second PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheCredentialAndMakeSureItIsDeleted_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndMakeSureRelatedUserIsDeleted_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and make sure related user is deleted: Error: %@", err); - } else { - NSLog(@"Read the user back and make sure related user is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialWithUser_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_12345" length:15]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential with user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllTheRfidCredentials_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:65534U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all the RFID credentials: Error: %@", err); - } else { - NSLog(@"Clear all the RFID credentials: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheFistRfidCredentialAndMakeSureItIsDeleted_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the fist RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the fist RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheSecondRfidCredentialAndMakeSureItIsDeleted_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the second RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the second RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheThirdRfidCredentialAndMakeSureItIsDeleted_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the third RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the third RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItHasOnlyPinCredential_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with first RFID back and make sure it has only PIN credential: Error: %@", err); - } else { - NSLog(@"Read the user related with first RFID back and make sure it has only PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 3U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithSecondRfidBackAndMakeSureItIsDeleted_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with second RFID back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with second RFID back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialWithUser_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential with user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewRfidCredentialWithUser_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_1234" length:14]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new RFID credential with user: Error: %@", err); - } else { - NSLog(@"Create new RFID credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherRfidCredentialWithUser_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:6U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"rfid_data_9876" length:14]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another RFID credential with user: Error: %@", err); - } else { - NSLog(@"Create another RFID credential with user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 4U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllTheCredentials_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = nil; - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all the credentials: Error: %@", err); - } else { - NSLog(@"Clear all the credentials: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheFirstPinCredentialAndMakeSureItIsDeleted_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the first PIN credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the first PIN credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheFirstRfidCredentialAndMakeSureItIsDeleted_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the first RFID credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the first RFID credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadBackTheSecondPinCredentialAndMakeSureItIsDeleted_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:6U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read back the second PIN credential and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read back the second PIN credential and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithFirstPinBackAndMakeSureItIsDeleted_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with first PIN back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with first PIN back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItIsDeleted_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with first RFID back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with first RFID back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithSecondPinBackAndMakeSureItIsDeleted_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:3U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with second PIN back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with second PIN back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserRelatedWithLastRfidBackAndMakeSureItIsDeleted_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:4U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user related with last RFID back and make sure it is deleted: Error: %@", err); - } else { - NSLog(@"Read the user related with last RFID back and make sure it is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 4U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewProgrammingPinCredentialWithInvalidIndex_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new Programming PIN credential with invalid index: Error: %@", err); - } else { - NSLog(@"Create new Programming PIN credential with invalid index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewProgrammingPinCredentialWithValidIndex_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new Programming PIN credential with valid index: Error: %@", err); - } else { - NSLog(@"Create new Programming PIN credential with valid index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedUser_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created user: Error: %@", err); - } else { - NSLog(@"Verify created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 0U)); - VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 0U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedProgrammingPinCredential_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created programming PIN credential: Error: %@", err); - } else { - NSLog(@"Verify created programming PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestModifyTheProgrammingPinCredential_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"654321" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Modify the Programming PIN credential: Error: %@", err); - } else { - NSLog(@"Modify the Programming PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingProgrammingPinFails_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing Programming PIN fails: Error: %@", err); - } else { - NSLog(@"Clearing Programming PIN fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingProgrammingPinWithInvalidIndexFails_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing Programming PIN with invalid index fails: Error: %@", err); - } else { - NSLog(@"Clearing Programming PIN with invalid index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingPinCredentialWithZeroIndexFails_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing PIN credential with zero index fails: Error: %@", err); - } else { - NSLog(@"Clearing PIN credential with zero index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingPinCredentialWithOutOfBoundIndexFails_115() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing PIN credential with out-of-bound index fails: Error: %@", err); - } else { - NSLog(@"Clearing PIN credential with out-of-bound index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingRfidCredentialWithZeroIndexFails_116() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing RFID credential with zero index fails: Error: %@", err); - } else { - NSLog(@"Clearing RFID credential with zero index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearingRfidCredentialWithOutOfBoundIndexFails_117() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clearing RFID credential with out-of-bound index fails: Error: %@", err); - } else { - NSLog(@"Clearing RFID credential with out-of-bound index fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearTheProgrammingPinUser_118() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear the Programming PIN user: Error: %@", err); - } else { - NSLog(@"Clear the Programming PIN user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureProgrammingPinUserIsDeleted_119() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure Programming PIN user is deleted: Error: %@", err); - } else { - NSLog(@"Make sure Programming PIN user is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureProgrammingPinCredentialIsDeleted_120() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:0U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure programming PIN credential is deleted: Error: %@", err); - } else { - NSLog(@"Make sure programming PIN credential is deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndUser_121() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000000" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateSecondPinCredentialAndAddItToExistingUser_122() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:2U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000001" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create second PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create second PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateThirdPinCredentialAndAddItToExistingUser_123() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:3U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000002" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create third PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create third PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateFourthPinCredentialAndAddItToExistingUser_124() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:4U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000003" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create fourth PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create fourth PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 5U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateFifthPinCredentialAndAddItToExistingUser_125() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:5U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000004" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create fifth PIN credential and add it to existing user: Error: %@", err); - } else { - NSLog(@"Create fifth PIN credential and add it to existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 6U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTryToCreateSixthPinCredentialAndMakeSureItFails_126() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:6U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"000005" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Try to create sixth PIN credential and make sure it fails: Error: %@", err); - } else { - NSLog(@"Try to create sixth PIN credential and make sure it fails: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 137U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 7U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestFinalCleanUp_127() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Final clean-up: Error: %@", err); - } else { - NSLog(@"Final clean-up: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class DL_Schedules : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - DL_Schedules() - : TestCommandBridge("DL_Schedules") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~DL_Schedules() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: DL_Schedules\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: DL_Schedules\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Create new PIN credential and schedule user\n"); - err = TestCreateNewPinCredentialAndScheduleUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Get number of supported users\n"); - err = TestGetNumberOfSupportedUsers_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Get Max number of Week Day schedules for user and verify default value\n"); - err = TestGetMaxNumberOfWeekDaySchedulesForUserAndVerifyDefaultValue_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Get Max number of Year Day schedules for user and verify default value\n"); - err = TestGetMaxNumberOfYearDaySchedulesForUserAndVerifyDefaultValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Get Max number of Holiday schedules and verify default value\n"); - err = TestGetMaxNumberOfHolidaySchedulesAndVerifyDefaultValue_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Create Week Day schedule with 0 index\n"); - err = TestCreateWeekDayScheduleWith0Index_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Create Week Day schedule with out-of-bounds index\n"); - err = TestCreateWeekDayScheduleWithOutOfBoundsIndex_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Create Week Day schedule with 0 user index\n"); - err = TestCreateWeekDayScheduleWith0UserIndex_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Create Week Day schedule with out-of-bounds user index\n"); - err = TestCreateWeekDayScheduleWithOutOfBoundsUserIndex_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Create Week Day schedule for non-existing user\n"); - err = TestCreateWeekDayScheduleForNonExistingUser_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Create Week Day schedule with 0 days mask\n"); - err = TestCreateWeekDayScheduleWith0DaysMask_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Create Week Day schedule for Sunday and Monday\n"); - err = TestCreateWeekDayScheduleForSundayAndMonday_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Create Week Day schedule for Sunday Wednesday and Saturday\n"); - err = TestCreateWeekDayScheduleForSundayWednesdayAndSaturday_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Create Week Day schedule with invalid start hour\n"); - err = TestCreateWeekDayScheduleWithInvalidStartHour_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Create Week Day schedule with invalid start minute\n"); - err = TestCreateWeekDayScheduleWithInvalidStartMinute_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Create Week Day schedule with invalid end hour\n"); - err = TestCreateWeekDayScheduleWithInvalidEndHour_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Create Week Day schedule with invalid end minute\n"); - err = TestCreateWeekDayScheduleWithInvalidEndMinute_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Create Week Day schedule with start hour later that end hour\n"); - err = TestCreateWeekDayScheduleWithStartHourLaterThatEndHour_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Create Week Day schedule with start minute later that end minute when hours are equal\n"); - err = TestCreateWeekDayScheduleWithStartMinuteLaterThatEndMinuteWhenHoursAreEqual_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Make sure that previous operations did not create a schedule\n"); - err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Get Week Day schedule with 0 index\n"); - err = TestGetWeekDayScheduleWith0Index_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Get Week Day schedule with out-of-bounds index\n"); - err = TestGetWeekDayScheduleWithOutOfBoundsIndex_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Get Week Day schedule with 0 user index\n"); - err = TestGetWeekDayScheduleWith0UserIndex_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Get Week Day schedule with out-of-bounds user index\n"); - err = TestGetWeekDayScheduleWithOutOfBoundsUserIndex_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Get Week Day schedule with non-existing user index\n"); - err = TestGetWeekDayScheduleWithNonExistingUserIndex_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Create Year Day schedule with 0 index\n"); - err = TestCreateYearDayScheduleWith0Index_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Create Year Day schedule with out-of-bounds index\n"); - err = TestCreateYearDayScheduleWithOutOfBoundsIndex_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Create Year Day schedule with 0 user index\n"); - err = TestCreateYearDayScheduleWith0UserIndex_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Create Year Day schedule with out-of-bounds user index\n"); - err = TestCreateYearDayScheduleWithOutOfBoundsUserIndex_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Create Year Day schedule for non-existing user\n"); - err = TestCreateYearDayScheduleForNonExistingUser_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Create Year Day schedule with start hour later that end hour\n"); - err = TestCreateYearDayScheduleWithStartHourLaterThatEndHour_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Make sure that previous operations did not create a schedule\n"); - err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Get Year Day schedule with 0 index\n"); - err = TestGetYearDayScheduleWith0Index_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Get Year Day schedule with out-of-bounds index\n"); - err = TestGetYearDayScheduleWithOutOfBoundsIndex_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Get Year Day schedule with 0 user index\n"); - err = TestGetYearDayScheduleWith0UserIndex_35(); - break; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Get Year Day schedule with out-of-bounds user index\n"); - err = TestGetYearDayScheduleWithOutOfBoundsUserIndex_36(); - break; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Get Year Day schedule with non-existing user index\n"); - err = TestGetYearDayScheduleWithNonExistingUserIndex_37(); - break; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Create Holiday schedule with 0 index\n"); - err = TestCreateHolidayScheduleWith0Index_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Create Holiday schedule with out-of-bounds index\n"); - err = TestCreateHolidayScheduleWithOutOfBoundsIndex_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Create Holiday schedule with start hour later that end hour\n"); - err = TestCreateHolidayScheduleWithStartHourLaterThatEndHour_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Create Holiday schedule with invalid operating mode\n"); - err = TestCreateHolidayScheduleWithInvalidOperatingMode_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Make sure that previous operations did not create a schedule\n"); - err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Get Holiday schedule with 0 index\n"); - err = TestGetHolidayScheduleWith0Index_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Get Holiday schedule with out-of-bounds index\n"); - err = TestGetHolidayScheduleWithOutOfBoundsIndex_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Create Holiday schedule with valid parameters\n"); - err = TestCreateHolidayScheduleWithValidParameters_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Verify created schedule\n"); - err = TestVerifyCreatedSchedule_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Create Week Day schedule with valid parameters\n"); - err = TestCreateWeekDayScheduleWithValidParameters_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Verify created schedule\n"); - err = TestVerifyCreatedSchedule_48(); - break; - case 49: - ChipLogProgress(chipTool, " ***** Test Step 49 : Create Year Day schedule with valid parameters\n"); - err = TestCreateYearDayScheduleWithValidParameters_49(); - break; - case 50: - ChipLogProgress(chipTool, " ***** Test Step 50 : Verify created schedule\n"); - err = TestVerifyCreatedSchedule_50(); - break; - case 51: - ChipLogProgress(chipTool, " ***** Test Step 51 : Clear Week Day schedule with 0 index\n"); - err = TestClearWeekDayScheduleWith0Index_51(); - break; - case 52: - ChipLogProgress(chipTool, " ***** Test Step 52 : Clear Week Day schedule with out-of-bounds index\n"); - err = TestClearWeekDayScheduleWithOutOfBoundsIndex_52(); - break; - case 53: - ChipLogProgress(chipTool, " ***** Test Step 53 : Clear Week Day schedule with 0 user index\n"); - err = TestClearWeekDayScheduleWith0UserIndex_53(); - break; - case 54: - ChipLogProgress(chipTool, " ***** Test Step 54 : Clear Week Day schedule with out-of-bounds user index\n"); - err = TestClearWeekDayScheduleWithOutOfBoundsUserIndex_54(); - break; - case 55: - ChipLogProgress(chipTool, " ***** Test Step 55 : Clear Week Day schedule with non-existing user\n"); - err = TestClearWeekDayScheduleWithNonExistingUser_55(); - break; - case 56: - ChipLogProgress(chipTool, " ***** Test Step 56 : Make sure that week day schedule was not deleted\n"); - err = TestMakeSureThatWeekDayScheduleWasNotDeleted_56(); - break; - case 57: - ChipLogProgress(chipTool, " ***** Test Step 57 : Make sure that year day schedule was not deleted\n"); - err = TestMakeSureThatYearDayScheduleWasNotDeleted_57(); - break; - case 58: - ChipLogProgress(chipTool, " ***** Test Step 58 : Make sure that holiday schedule was not deleted\n"); - err = TestMakeSureThatHolidayScheduleWasNotDeleted_58(); - break; - case 59: - ChipLogProgress(chipTool, " ***** Test Step 59 : Clear Year Day schedule with 0 index\n"); - err = TestClearYearDayScheduleWith0Index_59(); - break; - case 60: - ChipLogProgress(chipTool, " ***** Test Step 60 : Clear Year Day schedule with out-of-bounds index\n"); - err = TestClearYearDayScheduleWithOutOfBoundsIndex_60(); - break; - case 61: - ChipLogProgress(chipTool, " ***** Test Step 61 : Clear Year Day schedule with 0 user index\n"); - err = TestClearYearDayScheduleWith0UserIndex_61(); - break; - case 62: - ChipLogProgress(chipTool, " ***** Test Step 62 : Clear Year Day schedule with out-of-bounds user index\n"); - err = TestClearYearDayScheduleWithOutOfBoundsUserIndex_62(); - break; - case 63: - ChipLogProgress(chipTool, " ***** Test Step 63 : Clear Year Day schedule with non-existing user\n"); - err = TestClearYearDayScheduleWithNonExistingUser_63(); - break; - case 64: - ChipLogProgress(chipTool, " ***** Test Step 64 : Make sure that week day schedule was not deleted\n"); - err = TestMakeSureThatWeekDayScheduleWasNotDeleted_64(); - break; - case 65: - ChipLogProgress(chipTool, " ***** Test Step 65 : Make sure that year day schedule was not deleted\n"); - err = TestMakeSureThatYearDayScheduleWasNotDeleted_65(); - break; - case 66: - ChipLogProgress(chipTool, " ***** Test Step 66 : Make sure that holiday schedule was not deleted\n"); - err = TestMakeSureThatHolidayScheduleWasNotDeleted_66(); - break; - case 67: - ChipLogProgress(chipTool, " ***** Test Step 67 : Clear Holiday schedule with 0 index\n"); - err = TestClearHolidayScheduleWith0Index_67(); - break; - case 68: - ChipLogProgress(chipTool, " ***** Test Step 68 : Clear Holiday schedule with out-of-bounds index\n"); - err = TestClearHolidayScheduleWithOutOfBoundsIndex_68(); - break; - case 69: - ChipLogProgress(chipTool, " ***** Test Step 69 : Make sure that week day schedule was not deleted\n"); - err = TestMakeSureThatWeekDayScheduleWasNotDeleted_69(); - break; - case 70: - ChipLogProgress(chipTool, " ***** Test Step 70 : Make sure that year day schedule was not deleted\n"); - err = TestMakeSureThatYearDayScheduleWasNotDeleted_70(); - break; - case 71: - ChipLogProgress(chipTool, " ***** Test Step 71 : Make sure that holiday schedule was not deleted\n"); - err = TestMakeSureThatHolidayScheduleWasNotDeleted_71(); - break; - case 72: - ChipLogProgress(chipTool, " ***** Test Step 72 : Create another Week Day schedule with valid parameters\n"); - err = TestCreateAnotherWeekDayScheduleWithValidParameters_72(); - break; - case 73: - ChipLogProgress(chipTool, " ***** Test Step 73 : Verify created week day schedule\n"); - err = TestVerifyCreatedWeekDaySchedule_73(); - break; - case 74: - ChipLogProgress(chipTool, " ***** Test Step 74 : Create another Year Day schedule with valid parameters\n"); - err = TestCreateAnotherYearDayScheduleWithValidParameters_74(); - break; - case 75: - ChipLogProgress(chipTool, " ***** Test Step 75 : Verify created year day schedule\n"); - err = TestVerifyCreatedYearDaySchedule_75(); - break; - case 76: - ChipLogProgress(chipTool, " ***** Test Step 76 : Create another Holiday schedule with valid parameters\n"); - err = TestCreateAnotherHolidayScheduleWithValidParameters_76(); - break; - case 77: - ChipLogProgress(chipTool, " ***** Test Step 77 : Verify created holiday schedule\n"); - err = TestVerifyCreatedHolidaySchedule_77(); - break; - case 78: - ChipLogProgress(chipTool, " ***** Test Step 78 : Clear a single week day schedule for the first user\n"); - err = TestClearASingleWeekDayScheduleForTheFirstUser_78(); - break; - case 79: - ChipLogProgress(chipTool, " ***** Test Step 79 : Verify cleared week day schedule\n"); - err = TestVerifyClearedWeekDaySchedule_79(); - break; - case 80: - ChipLogProgress(chipTool, " ***** Test Step 80 : Clear all remaining week day schedules for the first user\n"); - err = TestClearAllRemainingWeekDaySchedulesForTheFirstUser_80(); - break; - case 81: - ChipLogProgress(chipTool, " ***** Test Step 81 : Verify cleared week schedule\n"); - err = TestVerifyClearedWeekSchedule_81(); - break; - case 82: - ChipLogProgress(chipTool, " ***** Test Step 82 : Make sure that first year day schedule was not deleted\n"); - err = TestMakeSureThatFirstYearDayScheduleWasNotDeleted_82(); - break; - case 83: - ChipLogProgress(chipTool, " ***** Test Step 83 : Make sure that second year day schedule was not deleted\n"); - err = TestMakeSureThatSecondYearDayScheduleWasNotDeleted_83(); - break; - case 84: - ChipLogProgress(chipTool, " ***** Test Step 84 : Make sure that first holiday schedule was not deleted\n"); - err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_84(); - break; - case 85: - ChipLogProgress(chipTool, " ***** Test Step 85 : Make sure that second holiday schedule was not deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasNotDeleted_85(); - break; - case 86: - ChipLogProgress(chipTool, " ***** Test Step 86 : Create another Week Day schedule with valid parameters\n"); - err = TestCreateAnotherWeekDayScheduleWithValidParameters_86(); - break; - case 87: - ChipLogProgress(chipTool, " ***** Test Step 87 : Clear a single year day schedule for the first user\n"); - err = TestClearASingleYearDayScheduleForTheFirstUser_87(); - break; - case 88: - ChipLogProgress(chipTool, " ***** Test Step 88 : Verify cleared year day schedule\n"); - err = TestVerifyClearedYearDaySchedule_88(); - break; - case 89: - ChipLogProgress(chipTool, " ***** Test Step 89 : Clear all remaining year schedules for the first user\n"); - err = TestClearAllRemainingYearSchedulesForTheFirstUser_89(); - break; - case 90: - ChipLogProgress(chipTool, " ***** Test Step 90 : Verify that second year day schedule was cleared\n"); - err = TestVerifyThatSecondYearDayScheduleWasCleared_90(); - break; - case 91: - ChipLogProgress(chipTool, " ***** Test Step 91 : Verify created week day schedule\n"); - err = TestVerifyCreatedWeekDaySchedule_91(); - break; - case 92: - ChipLogProgress(chipTool, " ***** Test Step 92 : Clear all remaining week day schedules for the first user\n"); - err = TestClearAllRemainingWeekDaySchedulesForTheFirstUser_92(); - break; - case 93: - ChipLogProgress(chipTool, " ***** Test Step 93 : Create new user without credential so we can add more schedules to it\n"); - err = TestCreateNewUserWithoutCredentialSoWeCanAddMoreSchedulesToIt_93(); - break; - case 94: - ChipLogProgress(chipTool, " ***** Test Step 94 : Create Week Day schedule with valid parameters for first user\n"); - err = TestCreateWeekDayScheduleWithValidParametersForFirstUser_94(); - break; - case 95: - ChipLogProgress(chipTool, " ***** Test Step 95 : Verify created week day schedule for first user\n"); - err = TestVerifyCreatedWeekDayScheduleForFirstUser_95(); - break; - case 96: - ChipLogProgress(chipTool, " ***** Test Step 96 : Create Year Day schedule for first user\n"); - err = TestCreateYearDayScheduleForFirstUser_96(); - break; - case 97: - ChipLogProgress(chipTool, " ***** Test Step 97 : Verify created year day schedule for first\n"); - err = TestVerifyCreatedYearDayScheduleForFirst_97(); - break; - case 98: - ChipLogProgress(chipTool, " ***** Test Step 98 : Create Week Day schedule with valid parameters for second user\n"); - err = TestCreateWeekDayScheduleWithValidParametersForSecondUser_98(); - break; - case 99: - ChipLogProgress(chipTool, " ***** Test Step 99 : Verify created week day schedule for first user\n"); - err = TestVerifyCreatedWeekDayScheduleForFirstUser_99(); - break; - case 100: - ChipLogProgress(chipTool, " ***** Test Step 100 : Create Year Day schedule for second user\n"); - err = TestCreateYearDayScheduleForSecondUser_100(); - break; - case 101: - ChipLogProgress(chipTool, " ***** Test Step 101 : Verify created year day schedule for first\n"); - err = TestVerifyCreatedYearDayScheduleForFirst_101(); - break; - case 102: - ChipLogProgress(chipTool, " ***** Test Step 102 : Cleanup the user\n"); - err = TestCleanupTheUser_102(); - break; - case 103: - ChipLogProgress(chipTool, " ***** Test Step 103 : Make sure clearing first user also cleared week day schedules\n"); - err = TestMakeSureClearingFirstUserAlsoClearedWeekDaySchedules_103(); - break; - case 104: - ChipLogProgress(chipTool, " ***** Test Step 104 : Make sure clearing first user also cleared year day schedules\n"); - err = TestMakeSureClearingFirstUserAlsoClearedYearDaySchedules_104(); - break; - case 105: - ChipLogProgress(chipTool, " ***** Test Step 105 : Make sure clearing second user also cleared week day schedules\n"); - err = TestMakeSureClearingSecondUserAlsoClearedWeekDaySchedules_105(); - break; - case 106: - ChipLogProgress(chipTool, " ***** Test Step 106 : Make sure clearing second user also cleared year day schedules\n"); - err = TestMakeSureClearingSecondUserAlsoClearedYearDaySchedules_106(); - break; - case 107: - ChipLogProgress(chipTool, " ***** Test Step 107 : Make sure that first holiday schedule was not deleted\n"); - err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_107(); - break; - case 108: - ChipLogProgress(chipTool, " ***** Test Step 108 : Make sure that second holiday schedule was not deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasNotDeleted_108(); - break; - case 109: - ChipLogProgress(chipTool, " ***** Test Step 109 : Create another Holiday schedule at the last slot\n"); - err = TestCreateAnotherHolidayScheduleAtTheLastSlot_109(); - break; - case 110: - ChipLogProgress(chipTool, " ***** Test Step 110 : Verify Created Holiday Schedule\n"); - err = TestVerifyCreatedHolidaySchedule_110(); - break; - case 111: - ChipLogProgress(chipTool, " ***** Test Step 111 : Create new PIN credential and schedule user\n"); - err = TestCreateNewPinCredentialAndScheduleUser_111(); - break; - case 112: - ChipLogProgress(chipTool, " ***** Test Step 112 : Create Week Day schedule for first user\n"); - err = TestCreateWeekDayScheduleForFirstUser_112(); - break; - case 113: - ChipLogProgress(chipTool, " ***** Test Step 113 : Create Year Day schedule for first user\n"); - err = TestCreateYearDayScheduleForFirstUser_113(); - break; - case 114: - ChipLogProgress(chipTool, " ***** Test Step 114 : Clear a single holiday schedule\n"); - err = TestClearASingleHolidaySchedule_114(); - break; - case 115: - ChipLogProgress(chipTool, " ***** Test Step 115 : Make sure that first holiday schedule was not deleted\n"); - err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_115(); - break; - case 116: - ChipLogProgress(chipTool, " ***** Test Step 116 : Make sure that second holiday schedule was deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasDeleted_116(); - break; - case 117: - ChipLogProgress(chipTool, " ***** Test Step 117 : Make sure that third holiday schedule was not deleted\n"); - err = TestMakeSureThatThirdHolidayScheduleWasNotDeleted_117(); - break; - case 118: - ChipLogProgress(chipTool, " ***** Test Step 118 : Make sure clearing holiday schedule did not clear week day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_118(); - break; - case 119: - ChipLogProgress(chipTool, " ***** Test Step 119 : Make sure clearing holiday schedule did not clear year day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_119(); - break; - case 120: - ChipLogProgress(chipTool, " ***** Test Step 120 : Clear all remaining holiday schedules\n"); - err = TestClearAllRemainingHolidaySchedules_120(); - break; - case 121: - ChipLogProgress(chipTool, " ***** Test Step 121 : Make sure that first holiday is still deleted\n"); - err = TestMakeSureThatFirstHolidayIsStillDeleted_121(); - break; - case 122: - ChipLogProgress(chipTool, " ***** Test Step 122 : Make sure that second holiday schedule was deleted\n"); - err = TestMakeSureThatSecondHolidayScheduleWasDeleted_122(); - break; - case 123: - ChipLogProgress(chipTool, " ***** Test Step 123 : Make sure that third holiday schedule was not deleted\n"); - err = TestMakeSureThatThirdHolidayScheduleWasNotDeleted_123(); - break; - case 124: - ChipLogProgress(chipTool, " ***** Test Step 124 : Make sure clearing holiday schedule did not clear week day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_124(); - break; - case 125: - ChipLogProgress(chipTool, " ***** Test Step 125 : Make sure clearing holiday schedule did not clear year day schedule\n"); - err = TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_125(); - break; - case 126: - ChipLogProgress(chipTool, " ***** Test Step 126 : Final Cleanup\n"); - err = TestFinalCleanup_126(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 49: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 50: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 51: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 52: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 53: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 54: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 55: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 56: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 57: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 58: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 59: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 60: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 61: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 62: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 63: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - break; - case 64: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 65: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 66: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 67: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 68: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 69: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 70: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 71: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 72: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 73: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 74: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 75: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 76: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 77: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 78: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 79: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 80: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 81: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 82: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 83: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 84: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 85: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 86: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 87: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 88: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 89: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 90: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 91: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 92: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 93: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 94: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 95: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 96: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 97: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 98: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 99: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 100: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 101: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 102: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 103: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 104: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 105: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 106: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 107: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 108: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 109: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 110: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 111: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 112: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 113: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 114: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 115: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 116: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 117: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 118: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 119: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 120: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 121: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 122: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 123: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 124: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 125: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 126: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 127; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCreateNewPinCredentialAndScheduleUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and schedule user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and schedule user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestGetNumberOfSupportedUsers_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get number of supported users: Error: %@", err); - } else { - NSLog(@"Get number of supported users: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfTotalUsersSupported", actualValue, 10U)); - } - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfWeekDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestGetMaxNumberOfWeekDaySchedulesForUserAndVerifyDefaultValue_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Max number of Week Day schedules for user and verify default value: Error: %@", err); - } else { - NSLog(@"Get Max number of Week Day schedules for user and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfWeekDaySchedulesSupportedPerUser", actualValue, 10U)); - } - { - NumberOfWeekDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfYearDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestGetMaxNumberOfYearDaySchedulesForUserAndVerifyDefaultValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfYearDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Max number of Year Day schedules for user and verify default value: Error: %@", err); - } else { - NSLog(@"Get Max number of Year Day schedules for user and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfYearDaySchedulesSupportedPerUser", actualValue, 10U)); - } - { - NumberOfYearDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfHolidaySchedulesSupportedValue; - - CHIP_ERROR TestGetMaxNumberOfHolidaySchedulesAndVerifyDefaultValue_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfHolidaySchedulesSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Max number of Holiday schedules and verify default value: Error: %@", err); - } else { - NSLog(@"Get Max number of Holiday schedules and verify default value: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NumberOfHolidaySchedulesSupported", actualValue, 10U)); - } - { - NumberOfHolidaySchedulesSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWith0Index_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithOutOfBoundsIndex_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWith0UserIndex_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithOutOfBoundsUserIndex_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForNonExistingUser_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for non-existing user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWith0DaysMask_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:0U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with 0 days mask: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with 0 days mask: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForSundayAndMonday_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:3U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for Sunday and Monday: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for Sunday and Monday: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForSundayWednesdayAndSaturday_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:73U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for Sunday Wednesday and Saturday: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for Sunday Wednesday and Saturday: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidStartHour_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:24U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid start hour: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid start hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidStartMinute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:60U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid start minute: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid start minute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidEndHour_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:24U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid end hour: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithInvalidEndMinute_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:60U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with invalid end minute: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with invalid end minute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithStartHourLaterThatEndHour_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:19U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with start hour later that end hour: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with start hour later that end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithStartMinuteLaterThatEndMinuteWhenHoursAreEqual_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:50U]; - params.endHour = - [NSNumber numberWithUnsignedChar:15U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:49U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with start minute later that end minute when hours are equal: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with start minute later that end minute when hours are equal: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); - } else { - NSLog(@"Make sure that previous operations did not create a schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWith0Index_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWithOutOfBoundsIndex_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, [NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWith0UserIndex_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 0U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWithOutOfBoundsUserIndex_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, [NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetWeekDayScheduleWithNonExistingUserIndex_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Week Day schedule with non-existing user index: Error: %@", err); - } else { - NSLog(@"Get Week Day schedule with non-existing user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWith0Index_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithOutOfBoundsIndex_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWith0UserIndex_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithOutOfBoundsUserIndex_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForNonExistingUser_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for non-existing user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithStartHourLaterThatEndHour_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345688UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with start hour later that end hour: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with start hour later that end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); - } else { - NSLog(@"Make sure that previous operations did not create a schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWith0Index_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWithOutOfBoundsIndex_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, [NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWith0UserIndex_35() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 0U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWithOutOfBoundsUserIndex_36() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, [NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetYearDayScheduleWithNonExistingUserIndex_37() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Year Day schedule with non-existing user index: Error: %@", err); - } else { - NSLog(@"Get Year Day schedule with non-existing user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWith0Index_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithOutOfBoundsIndex_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithStartHourLaterThatEndHour_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345688UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with start hour later that end hour: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with start hour later that end hour: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithInvalidOperatingMode_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:5U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with invalid operating mode: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with invalid operating mode: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); - } else { - NSLog(@"Make sure that previous operations did not create a schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetHolidayScheduleWith0Index_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:0U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Holiday schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Get Holiday schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 0U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetHolidayScheduleWithOutOfBoundsIndex_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Holiday schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Get Holiday schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, [NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateHolidayScheduleWithValidParameters_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Holiday schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create Holiday schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedSchedule_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created schedule: Error: %@", err); - } else { - NSLog(@"Verify created schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithValidParameters_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:16U]; - params.endHour = - [NSNumber numberWithUnsignedChar:18U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedSchedule_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created schedule: Error: %@", err); - } else { - NSLog(@"Verify created schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleWithValidParameters_49() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:12345UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:12345689UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedSchedule_50() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created schedule: Error: %@", err); - } else { - NSLog(@"Verify created schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWith0Index_51() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWithOutOfBoundsIndex_52() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWith0UserIndex_53() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWithOutOfBoundsUserIndex_54() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearWeekDayScheduleWithNonExistingUser_55() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Week Day schedule with non-existing user: Error: %@", err); - } else { - NSLog(@"Clear Week Day schedule with non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_56() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that week day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_57() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_58() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWith0Index_59() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWithOutOfBoundsIndex_60() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWith0UserIndex_61() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with 0 user index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with 0 user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWithOutOfBoundsUserIndex_62() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with out-of-bounds user index: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with out-of-bounds user index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearYearDayScheduleWithNonExistingUser_63() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Year Day schedule with non-existing user: Error: %@", err); - } else { - NSLog(@"Clear Year Day schedule with non-existing user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_64() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that week day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_65() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_66() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearHolidayScheduleWith0Index_67() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:0U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Holiday schedule with 0 index: Error: %@", err); - } else { - NSLog(@"Clear Holiday schedule with 0 index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearHolidayScheduleWithOutOfBoundsIndex_68() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear Holiday schedule with out-of-bounds index: Error: %@", err); - } else { - NSLog(@"Clear Holiday schedule with out-of-bounds index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_69() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that week day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_70() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_71() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherWeekDayScheduleWithValidParameters_72() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:2U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Week Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Week Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDaySchedule_73() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherYearDayScheduleWithValidParameters_74() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:9000UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:888888888UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Year Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Year Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedYearDaySchedule_75() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created year day schedule: Error: %@", err); - } else { - NSLog(@"Verify created year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherHolidayScheduleWithValidParameters_76() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:123456UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:1234567UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:1U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Holiday schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Holiday schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedHolidaySchedule_77() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created holiday schedule: Error: %@", err); - } else { - NSLog(@"Verify created holiday schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearASingleWeekDayScheduleForTheFirstUser_78() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a single week day schedule for the first user: Error: %@", err); - } else { - NSLog(@"Clear a single week day schedule for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyClearedWeekDaySchedule_79() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify cleared week day schedule: Error: %@", err); - } else { - NSLog(@"Verify cleared week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingWeekDaySchedulesForTheFirstUser_80() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:254U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining week day schedules for the first user: Error: %@", err); - } else { - NSLog(@"Clear all remaining week day schedules for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyClearedWeekSchedule_81() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify cleared week schedule: Error: %@", err); - } else { - NSLog(@"Verify cleared week schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstYearDayScheduleWasNotDeleted_82() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondYearDayScheduleWasNotDeleted_83() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second year day schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second year day schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_84() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasNotDeleted_85() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherWeekDayScheduleWithValidParameters_86() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:2U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Week Day schedule with valid parameters: Error: %@", err); - } else { - NSLog(@"Create another Week Day schedule with valid parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearASingleYearDayScheduleForTheFirstUser_87() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a single year day schedule for the first user: Error: %@", err); - } else { - NSLog(@"Clear a single year day schedule for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyClearedYearDaySchedule_88() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify cleared year day schedule: Error: %@", err); - } else { - NSLog(@"Verify cleared year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingYearSchedulesForTheFirstUser_89() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:254U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining year schedules for the first user: Error: %@", err); - } else { - NSLog(@"Clear all remaining year schedules for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyThatSecondYearDayScheduleWasCleared_90() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify that second year day schedule was cleared: Error: %@", err); - } else { - NSLog(@"Verify that second year day schedule was cleared: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDaySchedule_91() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingWeekDaySchedulesForTheFirstUser_92() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:254U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining week day schedules for the first user: Error: %@", err); - } else { - NSLog(@"Clear all remaining week day schedules for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewUserWithoutCredentialSoWeCanAddMoreSchedulesToIt_93() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user without credential so we can add more schedules to it: Error: %@", err); - } else { - NSLog(@"Create new user without credential so we can add more schedules to it: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithValidParametersForFirstUser_94() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with valid parameters for first user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with valid parameters for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDayScheduleForFirstUser_95() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule for first user: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForFirstUser_96() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:9000UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:888888888UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for first user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedYearDayScheduleForFirst_97() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created year day schedule for first: Error: %@", err); - } else { - NSLog(@"Verify created year day schedule for first: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleWithValidParametersForSecondUser_98() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:64U]; - params.startHour = - [NSNumber numberWithUnsignedChar:23U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule with valid parameters for second user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule with valid parameters for second user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedWeekDayScheduleForFirstUser_99() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created week day schedule for first user: Error: %@", err); - } else { - NSLog(@"Verify created week day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 64U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 23U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForSecondUser_100() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:55555UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:7777777UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for second user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for second user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedYearDayScheduleForFirst_101() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created year day schedule for first: Error: %@", err); - } else { - NSLog(@"Verify created year day schedule for first: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 55555UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 7777777UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheUser_102() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the user: Error: %@", err); - } else { - NSLog(@"Cleanup the user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingFirstUserAlsoClearedWeekDaySchedules_103() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing first user also cleared week day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing first user also cleared week day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingFirstUserAlsoClearedYearDaySchedules_104() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing first user also cleared year day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing first user also cleared year day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingSecondUserAlsoClearedWeekDaySchedules_105() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:4U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing second user also cleared week day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing second user also cleared week day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 4U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingSecondUserAlsoClearedYearDaySchedules_106() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing second user also cleared year day schedules: Error: %@", err); - } else { - NSLog(@"Make sure clearing second user also cleared year day schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_107() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasNotDeleted_108() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateAnotherHolidayScheduleAtTheLastSlot_109() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:1UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:100UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:4U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create another Holiday schedule at the last slot: Error: %@", err); - } else { - NSLog(@"Create another Holiday schedule at the last slot: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedHolidaySchedule_110() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify Created Holiday Schedule: Error: %@", err); - } else { - NSLog(@"Verify Created Holiday Schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 100UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndScheduleUser_111() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = nil; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and schedule user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and schedule user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateWeekDayScheduleForFirstUser_112() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:1U]; - params.startHour = - [NSNumber numberWithUnsignedChar:0U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:0U]; - params.endHour = - [NSNumber numberWithUnsignedChar:23U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:59U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Week Day schedule for first user: Error: %@", err); - } else { - NSLog(@"Create Week Day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateYearDayScheduleForFirstUser_113() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:9000UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:888888888UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create Year Day schedule for first user: Error: %@", err); - } else { - NSLog(@"Create Year Day schedule for first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearASingleHolidaySchedule_114() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a single holiday schedule: Error: %@", err); - } else { - NSLog(@"Clear a single holiday schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_115() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasDeleted_116() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatThirdHolidayScheduleWasNotDeleted_117() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that third holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that third holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 100UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 4U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_118() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_119() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAllRemainingHolidaySchedules_120() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:254U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear all remaining holiday schedules: Error: %@", err); - } else { - NSLog(@"Clear all remaining holiday schedules: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatFirstHolidayIsStillDeleted_121() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that first holiday is still deleted: Error: %@", err); - } else { - NSLog(@"Make sure that first holiday is still deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasDeleted_122() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:2U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that second holiday schedule was deleted: Error: %@", err); - } else { - NSLog(@"Make sure that second holiday schedule was deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureThatThirdHolidayScheduleWasNotDeleted_123() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NumberOfHolidaySchedulesSupportedValue copy]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure that third holiday schedule was not deleted: Error: %@", err); - } else { - NSLog(@"Make sure that third holiday schedule was not deleted: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_124() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); - } - - { - id actualValue = values.endHour; - VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); - } - - { - id actualValue = values.endMinute; - VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_125() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Error: %@", err); - } else { - NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestFinalCleanup_126() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:65534U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Final Cleanup: Error: %@", err); - } else { - NSLog(@"Final Cleanup: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_1_1() - : TestCommandBridge("Test_TC_DRLK_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); - err = TestStep2ThReadsTheClusterRevisionFromDut_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); - if (ShouldSkip(" !DRLK.S.F00 && !DRLK.S.F01 && !DRLK.S.F02 && !DRLK.S.F04 && !DRLK.S.F05 && !DRLK.S.F06 && !DRLK.S.F07 && !DRLK.S.F08 && !DRLK.S.F0a && !DRLK.S.F0b && !DRLK.S.F0c ")) { - NextTest(); - return; - } - err = TestStep3aThReadsTheFeatureMapFromDut_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenDrlksf00pinEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenDrlksf01ridEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenDrlksf02fgpEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep3eGivenDrlksf04wdschEnsureFeaturemapHasTheCorrectBitSet_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F05")) { - NextTest(); - return; - } - err = TestStep3fGivenDrlksf05dpsEnsureFeaturemapHasTheCorrectBitSet_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F06")) { - NextTest(); - return; - } - err = TestStep3gGivenDrlksf06faceEnsureFeaturemapHasTheCorrectBitSet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F07")) { - NextTest(); - return; - } - err = TestStep3hGivenDrlksf07cotaEnsureFeaturemapHasTheCorrectBitSet_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep3iGivenDrlksf08usrEnsureFeaturemapHasTheCorrectBitSet_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep3jGivenDRLKSF0aYDSCHEnsureFeaturemapHasTheCorrectBitSet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep3kGivenDRLKSF0bHDSCHEnsureFeaturemapHasTheCorrectBitSet_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("DRLK.S.F0c")) { - NextTest(); - return; - } - err = TestStep3lGivenDRLKSF0cUBOLTEnsureFeaturemapHasTheCorrectBitSet_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads AttributeList from DUT\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsAttributeListFromDut_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F05")) { - NextTest(); - return; - } - err = TestStep4bThReadsFeatureDependentDRLKSF05AttributesInAttributeList_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep4cThReadsFeatureDependentDRLKSF08AttributesInAttributeList_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep4dThReadsFeatureDependentDRLKSF00AttributesInAttributeList_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F01")) { - NextTest(); - return; - } - err = TestStep4eThReadsFeatureDependentDRLKSF01AttributesInAttributeList_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep4fThReadsFeatureDependentDRLKSF04AttributeInAttributeList_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep4gThReadsFeatureDependentDRLKSF0aAttributeInAttributeList_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep4hThReadsFeatureDependentDRLKSF0bAttributeInAttributeList_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList\n"); - if (ShouldSkip("DRLK.S.F00 || DRLK.S.F01")) { - NextTest(); - return; - } - err = TestStep4iThReadsFeatureDependentDRLKSF00OrDrlksf01AttributesInAttributeList_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("DRLK.S.F07 || DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep4jThReadsFeatureDependentDRLKSF07OrDrlksf00AttributeInAttributeList_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4k: TH reads optional attribute(Language) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0021")) { - NextTest(); - return; - } - err = TestStep4kThReadsOptionalAttributeLanguageInAttributeList_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4l: TH reads optional attribute(LEDSettings) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0022")) { - NextTest(); - return; - } - err = TestStep4lThReadsOptionalAttributeLEDSettingsInAttributeList_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0023")) { - NextTest(); - return; - } - err = TestStep4mThReadsOptionalAttributeAutoRelockTimeInAttributeList_27(); - break; - case 28: - ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4n: TH reads optional attribute(SoundVolume) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0024")) { - NextTest(); - return; - } - err = TestStep4nThReadsOptionalAttributeSoundVolumeInAttributeList_28(); - break; - case 29: - ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0027")) { - NextTest(); - return; - } - err = TestStep4oThReadsOptionalAttributeDefaultConfigurationRegisterInAttributeList_29(); - break; - case 30: - ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0028")) { - NextTest(); - return; - } - err = TestStep4pThReadsOptionalAttributeEnableLocalProgrammingInAttributeList_30(); - break; - case 31: - ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A0029")) { - NextTest(); - return; - } - err = TestStep4qThReadsOptionalAttributeEnableOneTouchLockingInAttributeList_31(); - break; - case 32: - ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A002a")) { - NextTest(); - return; - } - err = TestStep4rThReadsOptionalAttributeEnableInsideStatusLEDInAttributeList_32(); - break; - case 33: - ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A002b")) { - NextTest(); - return; - } - err = TestStep4sThReadsOptionalAttributeEnablePrivacyModeButtonInAttributeList_33(); - break; - case 34: - ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList\n"); - if (ShouldSkip("DRLK.S.A002c")) { - NextTest(); - return; - } - err = TestStep4tThReadsOptionalAttributeLocalProgrammingFeaturesInAttributeList_34(); - break; - case 35: - ChipLogProgress(chipTool, " ***** Test Step 35 : Step 5a: TH reads EventList from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 36: - ChipLogProgress(chipTool, " ***** Test Step 36 : Step 5b: TH reads optional event(Door position sensor) in EventList\n"); - if (ShouldSkip("DRLK.S.F05 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 37: - ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5c: TH reads optional event(User commands and database) in EventList\n"); - if (ShouldSkip("DRLK.S.F08 && PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 38: - ChipLogProgress(chipTool, " ***** Test Step 38 : Step 6a: TH reads AcceptedCommandList from DUT\n"); - err = TestStep6aThReadsAcceptedCommandListFromDut_38(); - break; - case 39: - ChipLogProgress(chipTool, " ***** Test Step 39 : Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep6bThReadsFeatureDependentCommandsDRLKSF04InAcceptedCommandList_39(); - break; - case 40: - ChipLogProgress(chipTool, " ***** Test Step 40 : Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep6cThReadsFeatureDependentCommandsDRLKSF0aInAcceptedCommandList_40(); - break; - case 41: - ChipLogProgress(chipTool, " ***** Test Step 41 : Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep6dThReadsFeatureDependentCommandsDRLKSF0bInAcceptedCommandList_41(); - break; - case 42: - ChipLogProgress(chipTool, " ***** Test Step 42 : Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F0c")) { - NextTest(); - return; - } - err = TestStep6eThReadsFeatureDependentCommandsDRLKSF0cInAcceptedCommandList_42(); - break; - case 43: - ChipLogProgress(chipTool, " ***** Test Step 43 : Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep6fThReadsFeatureDependentCommandsDRLKSF08InAcceptedCommandList_43(); - break; - case 44: - ChipLogProgress(chipTool, " ***** Test Step 44 : Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList\n"); - if (ShouldSkip("DRLK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep6gThReadsOptionalCommandsDRLKSC03RspInAcceptedCommandList_44(); - break; - case 45: - ChipLogProgress(chipTool, " ***** Test Step 45 : Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F04")) { - NextTest(); - return; - } - err = TestStep7aThReadsFeatureDependentCommandDRLKSF04InGeneratedCommandList_45(); - break; - case 46: - ChipLogProgress(chipTool, " ***** Test Step 46 : Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F0a")) { - NextTest(); - return; - } - err = TestStep7bThReadsFeatureDependentCommandDRLKSF0aInGeneratedCommandList_46(); - break; - case 47: - ChipLogProgress(chipTool, " ***** Test Step 47 : Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F0b")) { - NextTest(); - return; - } - err = TestStep7cThReadsFeatureDependentCommandDRLKSF0bInGeneratedCommandList_47(); - break; - case 48: - ChipLogProgress(chipTool, " ***** Test Step 48 : Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList\n"); - if (ShouldSkip("DRLK.S.F08")) { - NextTest(); - return; - } - err = TestStep7dThReadsFeatureDependentCommandDRLKSF08InGeneratedCommandList_48(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 28: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 29: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 30: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 31: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 32: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 33: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 34: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 35: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 36: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 37: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 38: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 39: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 40: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 41: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 42: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 43: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 44: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 45: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 46: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 47: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 48: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 49; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 7U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenDrlksf00pinEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenDrlksf01ridEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenDrlksf02fgpEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3eGivenDrlksf04wdschEnsureFeaturemapHasTheCorrectBitSet_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3fGivenDrlksf05dpsEnsureFeaturemapHasTheCorrectBitSet_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3gGivenDrlksf06faceEnsureFeaturemapHasTheCorrectBitSet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3hGivenDrlksf07cotaEnsureFeaturemapHasTheCorrectBitSet_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3iGivenDrlksf08usrEnsureFeaturemapHasTheCorrectBitSet_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3jGivenDRLKSF0aYDSCHEnsureFeaturemapHasTheCorrectBitSet_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3kGivenDRLKSF0bHDSCHEnsureFeaturemapHasTheCorrectBitSet_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3lGivenDRLKSF0cUBOLTEnsureFeaturemapHasTheCorrectBitSet_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsAttributeListFromDut_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsFeatureDependentDRLKSF05AttributesInAttributeList_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsFeatureDependentDRLKSF08AttributesInAttributeList_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsFeatureDependentDRLKSF00AttributesInAttributeList_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsFeatureDependentDRLKSF01AttributesInAttributeList_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThReadsFeatureDependentDRLKSF04AttributeInAttributeList_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4gThReadsFeatureDependentDRLKSF0aAttributeInAttributeList_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4hThReadsFeatureDependentDRLKSF0bAttributeInAttributeList_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4iThReadsFeatureDependentDRLKSF00OrDrlksf01AttributesInAttributeList_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4jThReadsFeatureDependentDRLKSF07OrDrlksf00AttributeInAttributeList_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4kThReadsOptionalAttributeLanguageInAttributeList_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4k: TH reads optional attribute(Language) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4k: TH reads optional attribute(Language) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4lThReadsOptionalAttributeLEDSettingsInAttributeList_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4l: TH reads optional attribute(LEDSettings) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4l: TH reads optional attribute(LEDSettings) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4mThReadsOptionalAttributeAutoRelockTimeInAttributeList_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4nThReadsOptionalAttributeSoundVolumeInAttributeList_28() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4n: TH reads optional attribute(SoundVolume) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4n: TH reads optional attribute(SoundVolume) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4oThReadsOptionalAttributeDefaultConfigurationRegisterInAttributeList_29() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 39UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4pThReadsOptionalAttributeEnableLocalProgrammingInAttributeList_30() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4qThReadsOptionalAttributeEnableOneTouchLockingInAttributeList_31() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4rThReadsOptionalAttributeEnableInsideStatusLEDInAttributeList_32() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4sThReadsOptionalAttributeEnablePrivacyModeButtonInAttributeList_33() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 43UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4tThReadsOptionalAttributeLocalProgrammingFeaturesInAttributeList_34() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 44UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsAcceptedCommandListFromDut_38() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsFeatureDependentCommandsDRLKSF04InAcceptedCommandList_39() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 12UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 13UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsFeatureDependentCommandsDRLKSF0aInAcceptedCommandList_40() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 14UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 15UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 16UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsFeatureDependentCommandsDRLKSF0bInAcceptedCommandList_41() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 17UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 18UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 19UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6eThReadsFeatureDependentCommandsDRLKSF0cInAcceptedCommandList_42() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 39UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6fThReadsFeatureDependentCommandsDRLKSF08InAcceptedCommandList_43() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 26UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 27UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 29UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 34UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 36UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 38UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6gThReadsOptionalCommandsDRLKSC03RspInAcceptedCommandList_44() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsFeatureDependentCommandDRLKSF04InGeneratedCommandList_45() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 12UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsFeatureDependentCommandDRLKSF0aInGeneratedCommandList_46() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 15UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7cThReadsFeatureDependentCommandDRLKSF0bInGeneratedCommandList_47() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 18UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7dThReadsFeatureDependentCommandDRLKSF08InGeneratedCommandList_48() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList: Error: %@", err); - } else { - NSLog(@"Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 28UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 35UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 37UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_4() - : TestCommandBridge("Test_TC_DRLK_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Create new user\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestCreateNewUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read the user back and verify its fields\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Create new PIN credential and lock/unlock user\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestCreateNewPinCredentialAndLockUnlockUser_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Verify created PIN credential\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestVerifyCreatedPinCredential_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY && !DRLK.S.M.AutoRelockTimeAttributeWritable")) { - NextTest(); - return; - } - err = TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && !DRLK.S.M.AutoRelockTimeAttributeWritable")) { - NextTest(); - return; - } - err = TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds\n"); - if (ShouldSkip(" DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP ")) { - NextTest(); - return; - } - err = TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds\n"); - if (ShouldSkip(" (!DRLK.S.F08 || !DRLK.S.F00) && DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP ")) { - NextTest(); - return; - } - err = TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestWaitForAutoRelockTimeExpires_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for AutoRelockTime Expires\n"); - if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestWaitForAutoRelockTimeExpires_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2c: TH reads LockState attribute\n"); - if (ShouldSkip("DRLK.S.A0000 && DRLK.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2cThReadsLockStateAttribute_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Cleanup the created user\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestCleanupTheCreatedUser_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Clean the created credential\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestCleanTheCreatedCredential_16(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 17; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestCreateNewUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new user: Error: %@", err); - } else { - NSLog(@"Create new user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCreateNewPinCredentialAndLockUnlockUser_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = - [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Create new PIN credential and lock/unlock user: Error: %@", err); - } else { - NSLog(@"Create new PIN credential and lock/unlock user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestVerifyCreatedPinCredential_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Verify created PIN credential: Error: %@", err); - } else { - NSLog(@"Verify created PIN credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:10UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id autoRelockTimeArgument; - autoRelockTimeArgument = - [NSNumber numberWithUnsignedInt:60UL]; - [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Error: %@", err); - } else { - NSLog(@"Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; - params.timeout = - [NSNumber numberWithUnsignedShort:10U]; - params.pinCode = - [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unlockWithTimeoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; - params.timeout = - [NSNumber numberWithUnsignedShort:60U]; - params.pinCode = - [[NSData alloc] initWithBytes:"123456" length:6]; - [cluster unlockWithTimeoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; - params.timeout = - [NSNumber numberWithUnsignedShort:60U]; - [cluster unlockWithTimeoutWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitForAutoRelockTimeExpires_12() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 11000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestWaitForAutoRelockTimeExpires_13() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 70000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestStep2cThReadsLockStateAttribute_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLockStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH reads LockState attribute: Error: %@", err); - } else { - NSLog(@"Step 2c: TH reads LockState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("LockState", actualValue)); - VerifyOrReturn(CheckValue("LockState", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUser_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user: Error: %@", err); - } else { - NSLog(@"Cleanup the created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanTheCreatedCredential_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clean the created credential: Error: %@", err); - } else { - NSLog(@"Clean the created credential: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_5() - : TestCommandBridge("Test_TC_DRLK_2_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); - err = TestPreconditionCreateNewUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.A0014")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH send Set Week Day Schedule Command\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendSetWeekDayScheduleCommand_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH send Get Week Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep4ThSendGetWeekDayScheduleCommandToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Week Day Schedule Command\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendSetWeekDayScheduleCommand_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH send Get Week Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep6ThSendGetWeekDayScheduleCommandToDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH sends Get Week Day Schedule Command to DUT for non-existent User\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep7ThSendsGetWeekDayScheduleCommandToDutForNonExistentUser_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 8: TH sends Clear Week Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0d.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsClearWeekDayScheduleCommandToDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 9: TH sends Get Week Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { - NextTest(); - return; - } - err = TestStep9ThSendsGetWeekDayScheduleCommandToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Cleanup the created user\n"); - err = TestCleanupTheCreatedUser_12(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 13; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionCreateNewUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Create new user: Error: %@", err); - } else { - NSLog(@"Precondition: Create new user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Precondition: Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfWeekDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); - { - NumberOfWeekDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendSetWeekDayScheduleCommand_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:2U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:45U]; - params.endHour = - [NSNumber numberWithUnsignedChar:16U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:55U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH send Set Week Day Schedule Command: Error: %@", err); - } else { - NSLog(@"Step 3: TH send Set Week Day Schedule Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendGetWeekDayScheduleCommandToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH send Get Week Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4: TH send Get Week Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.daysMask; - VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); - } - - { - id actualValue = values.startHour; - VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); - } - - { - id actualValue = values.startMinute; - VerifyOrReturn(CheckValue("StartMinute", actualValue, 45U)); - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, true)); - if (values.endHour != nil) { - - VerifyOrReturn(CheckConstraintMinValue("endHour", [values.endHour unsignedCharValue], 16U)); - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, true)); - if (values.endMinute != nil) { - - VerifyOrReturn(CheckConstraintMinValue("endMinute", [values.endMinute unsignedCharValue], 55U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendSetWeekDayScheduleCommand_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.daysMask = - [NSNumber numberWithUnsignedChar:7U]; - params.startHour = - [NSNumber numberWithUnsignedChar:15U]; - params.startMinute = - [NSNumber numberWithUnsignedChar:45U]; - params.endHour = - [NSNumber numberWithUnsignedChar:16U]; - params.endMinute = - [NSNumber numberWithUnsignedChar:55U]; - [cluster setWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH send Set Week Day Schedule Command: Error: %@", err); - } else { - NSLog(@"Step 5: TH send Set Week Day Schedule Command: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendGetWeekDayScheduleCommandToDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH send Get Week Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH send Get Week Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); - if (values.daysMask != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); - if (values.startHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); - if (values.startMinute != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); - if (values.endHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); - if (values.endMinute != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsGetWeekDayScheduleCommandToDutForNonExistentUser_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends Get Week Day Schedule Command to DUT for non-existent User: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends Get Week Day Schedule Command to DUT for non-existent User: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); - if (values.daysMask != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); - if (values.startHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); - if (values.startMinute != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); - if (values.endHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); - if (values.endMinute != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsClearWeekDayScheduleCommandToDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearWeekDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Clear Week Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Clear Week Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsGetWeekDayScheduleCommandToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; - params.weekDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getWeekDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends Get Week Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends Get Week Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.weekDayIndex; - VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); - if (values.daysMask != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); - if (values.startHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); - if (values.startMinute != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); - if (values.endHour != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); - if (values.endMinute != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUser_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user: Error: %@", err); - } else { - NSLog(@"Cleanup the created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_6 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_6() - : TestCommandBridge("Test_TC_DRLK_2_6") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_6() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_6\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_6\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for commissionee\n"); - err = TestWaitForCommissionee_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.A0016")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C11.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20SecondsCLocalEndTimeAs30SecondsDOperatingModeAs0_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep3aThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value)\n"); - if (ShouldSkip("DRLK.S.C11.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20CLocalEndTimeAs30DOperatingModeAs5InvalidValue_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep5ThSendsGetHolidayScheduleCommandToDutWithInvalidHolidayIndexAs15_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available)\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep6ThSendsGetHolidayScheduleCommandToDutWithTheHolidayIndexAs10ValueIsInTheTheRangeOfStep1ButHolidayScheduleEntryNotAvailable_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C13.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendClearHolidayScheduleCommandToDutWithHolidayIndexAs1_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1\n"); - if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { - NextTest(); - return; - } - err = TestStep8ThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Cleanup the created user\n"); - err = TestCleanupTheCreatedUser_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForCommissionee_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull NumberOfHolidaySchedulesSupportedValue; - - CHIP_ERROR TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfHolidaySchedulesSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 255U)); - { - NumberOfHolidaySchedulesSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20SecondsCLocalEndTimeAs30SecondsDOperatingModeAs0_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:20UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:30UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 20UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 30UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 21UL)); - } - - { - id actualValue = values.operatingMode; - VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20CLocalEndTimeAs30DOperatingModeAs5InvalidValue_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:20UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:30UL]; - params.operatingMode = - [NSNumber numberWithUnsignedChar:5U]; - [cluster setHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value): Error: %@", err); - } else { - NSLog(@"Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsGetHolidayScheduleCommandToDutWithInvalidHolidayIndexAs15_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:15U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 15U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsGetHolidayScheduleCommandToDutWithTheHolidayIndexAs10ValueIsInTheTheRangeOfStep1ButHolidayScheduleEntryNotAvailable_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:10U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available): Error: %@", err); - } else { - NSLog(@"Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 10U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendClearHolidayScheduleCommandToDutWithHolidayIndexAs1_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster clearHolidayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; - params.holidayIndex = - [NSNumber numberWithUnsignedChar:1U]; - [cluster getHolidayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.holidayIndex; - VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUser_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user: Error: %@", err); - } else { - NSLog(@"Cleanup the created user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_7 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_7() - : TestCommandBridge("Test_TC_DRLK_2_7") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_7() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_7\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_7\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); - err = TestPreconditionCreateNewUser_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.A0015")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends Set Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsSetYearDayScheduleCommandToDut_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep4a4bThSendsGetYearDayScheduleCommandToDut_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendSetYearDayScheduleCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH sends Get Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep6ThSendsGetYearDayScheduleCommandToDut_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7a: Create a user with userIndex as 5\n"); - err = TestStep7aCreateAUserWithUserIndexAs5_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7b: TH sends Get Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep7bThSendsGetYearDayScheduleCommandToDut_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 8: TH sends Clear Year Day Schedule to DUT\n"); - if (ShouldSkip("DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep8ThSendsClearYearDayScheduleToDut_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 9: TH sends Get Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsGetYearDayScheduleCommandToDut_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 10: TH sends Set Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.C0e.Rsp")) { - NextTest(); - return; - } - err = TestStep10ThSendsSetYearDayScheduleCommandToDut_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 11: TH sends Get Year Day Schedule Command to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep11ThSendsGetYearDayScheduleCommandToDut_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 12: TH sends Get Year Day Schedule Command to DUT for non-existent User\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { - NextTest(); - return; - } - err = TestStep12ThSendsGetYearDayScheduleCommandToDutForNonExistentUser_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 13: TH sends Clear Year Day Schedule to DUT\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestStep13ThSendsClearYearDayScheduleToDut_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Clear a year day schedule for the first user\n"); - if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { - NextTest(); - return; - } - err = TestClearAYearDayScheduleForTheFirstUser_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Cleanup the created user with UserIndex 1\n"); - err = TestCleanupTheCreatedUserWithUserIndex1_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Cleanup the created user with UserIndex 5\n"); - err = TestCleanupTheCreatedUserWithUserIndex5_19(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 20; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionCreateNewUser_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Create new user: Error: %@", err); - } else { - NSLog(@"Precondition: Create new user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Precondition: Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfYearDaySchedulesSupportedPerUserValue; - - CHIP_ERROR TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfYearDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); - { - NumberOfYearDaySchedulesSupportedPerUserValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; - - CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - NumberOfTotalUsersSupportedValue = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsSetYearDayScheduleCommandToDut_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:960UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:1980UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends Set Year Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends Set Year Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4a4bThSendsGetYearDayScheduleCommandToDut_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 960UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1980UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 961UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendSetYearDayScheduleCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:15U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:1020UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:2040UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH send Set Year Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 5: TH send Set Year Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThSendsGetYearDayScheduleCommandToDut_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:15U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH sends Get Year Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 6: TH sends Get Year Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 15U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 133U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aCreateAUserWithUserIndexAs5_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:5U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: Create a user with userIndex as 5: Error: %@", err); - } else { - NSLog(@"Step 7a: Create a user with userIndex as 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThSendsGetYearDayScheduleCommandToDut_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NumberOfYearDaySchedulesSupportedPerUserValue copy]; - params.userIndex = - [NSNumber numberWithUnsignedShort:5U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH sends Get Year Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 7b: TH sends Get Year Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, NumberOfYearDaySchedulesSupportedPerUserValue)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 5U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsClearYearDayScheduleToDut_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Clear Year Day Schedule to DUT: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Clear Year Day Schedule to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsGetYearDayScheduleCommandToDut_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends Get Year Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends Get Year Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThSendsSetYearDayScheduleCommandToDut_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.localStartTime = - [NSNumber numberWithUnsignedInt:1080UL]; - params.localEndTime = - [NSNumber numberWithUnsignedInt:2100UL]; - [cluster setYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends Set Year Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends Set Year Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep11ThSendsGetYearDayScheduleCommandToDut_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 11: TH sends Get Year Day Schedule Command to DUT: Error: %@", err); - } else { - NSLog(@"Step 11: TH sends Get Year Day Schedule Command to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.localStartTime; - VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1080UL)); - } - - { - id actualValue = values.localEndTime; - VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 2100UL)); - } - - if (values.localEndTime != nil) { - - VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 1081UL)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep12ThSendsGetYearDayScheduleCommandToDutForNonExistentUser_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getYearDayScheduleWithParams:params completion: - ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 12: TH sends Get Year Day Schedule Command to DUT for non-existent User: Error: %@", err); - } else { - NSLog(@"Step 12: TH sends Get Year Day Schedule Command to DUT for non-existent User: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.yearDayIndex; - VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); - if (values.localStartTime != nil) { - } - - VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); - if (values.localEndTime != nil) { - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep13ThSendsClearYearDayScheduleToDut_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:0U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 13: TH sends Clear Year Day Schedule to DUT: Error: %@", err); - } else { - NSLog(@"Step 13: TH sends Clear Year Day Schedule to DUT: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestClearAYearDayScheduleForTheFirstUser_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; - params.yearDayIndex = - [NSNumber numberWithUnsignedChar:1U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearYearDayScheduleWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Clear a year day schedule for the first user: Error: %@", err); - } else { - NSLog(@"Clear a year day schedule for the first user: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex1_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user with UserIndex 1: Error: %@", err); - } else { - NSLog(@"Cleanup the created user with UserIndex 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex5_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:5U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Cleanup the created user with UserIndex 5: Error: %@", err); - } else { - NSLog(@"Cleanup the created user with UserIndex 5: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_8 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_8() - : TestCommandBridge("Test_TC_DRLK_2_8") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_8() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_8\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_8\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends Get User Command to DUT with UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6b: TH sends Get User Command to DUT with UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.C1a.Rsp && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { - NextTest(); - return; - } - err = TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH sends Get User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 9: TH sends Clear User Command to DUT with the UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { - NextTest(); - return; - } - err = TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 10: TH sends Get User Command to DUT with the UserIndex as 1\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { - NextTest(); - return; - } - err = TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { - NextTest(); - return; - } - err = TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); - VerifyOrReturn(CheckValue("clusterStatus present", status.mClusterStatus.HasValue(), true)); - VerifyOrReturn(CheckValue("clusterStatus value", status.mClusterStatus.Value(), 3)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 14; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull Current_NumberOfTotalUsersSupported; - - CHIP_ERROR TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); - { - Current_NumberOfTotalUsersSupported = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0: Error: %@", err); - } else { - NSLog(@"Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends Get User Command to DUT with UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends Get User Command to DUT with UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:10U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:3U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3: Error: %@", err); - } else { - NSLog(@"Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:8965UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0: Error: %@", err); - } else { - NSLog(@"Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Error: %@", err); - } else { - NSLog(@"Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH sends Get User Command to DUT with UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Step 6b: TH sends Get User Command to DUT with UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:2U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - params.userName = nil; - params.userUniqueID = nil; - params.userStatus = nil; - params.userType = nil; - params.credentialRule = nil; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Error: %@", err); - } else { - NSLog(@"Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH sends Get User Command to DUT with the UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Step 8: TH sends Get User Command to DUT with the UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH sends Clear User Command to DUT with the UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 9: TH sends Clear User Command to DUT with the UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 10: TH sends Get User Command to DUT with the UserIndex as 1: Error: %@", err); - } else { - NSLog(@"Step 10: TH sends Get User Command to DUT with the UserIndex as 1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); - VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster clearUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:2U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2: Error: %@", err); - } else { - NSLog(@"Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNull("UserName", actualValue)); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNull("UserType", actualValue)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNull("Credentials", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_DRLK_2_11 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_DRLK_2_11() - : TestCommandBridge("Test_TC_DRLK_2_11") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("PINCredentialData", &mPINCredentialData); - AddArgument("RFIDCredentialData", &mRFIDCredentialData); - AddArgument("FingerVeinCredentialData", &mFingerVeinCredentialData); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_DRLK_2_11() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_11\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_11\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user with default parameters\n"); - err = TestPreconditionCreateNewUserWithDefaultParameters_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); - err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { - NextTest(); - return; - } - err = TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1b: TH reads MinPINCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1c: TH reads MaxPINCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { - NextTest(); - return; - } - err = TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1d: TH reads MinRFIDCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A001a")) { - NextTest(); - return; - } - err = TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1e: TH reads MaxRFIDCodeLength and saves for future use.\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A0019")) { - NextTest(); - return; - } - err = TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2a: TH sends Set Credential Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2b: TH sends Set Credential Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH sends Set Credential Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { - NextTest(); - return; - } - err = TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3a: TH sends Get Credential Status Command with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3b: TH sends Get Credential Status Command with type RFID\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4a: TH sends Clear Credential Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4b: TH sends Get Credential Status Command with type RFID\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4c: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4d: TH sends Clear Credential Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4e: TH sends Get Credential Status Command with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4f: TH sends Clear Credential Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { - NextTest(); - return; - } - err = TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5a: TH sends Get Credential Status Command to DUT with type PIN\n"); - if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5b: TH sends Get Credential Status Command to DUT with type RFID\n"); - if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein\n"); - if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { - NextTest(); - return; - } - err = TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 23; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPINCredentialData; - chip::Optional mRFIDCredentialData; - chip::Optional mFingerVeinCredentialData; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestPreconditionCreateNewUserWithDefaultParameters_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userName = @"xxx"; - params.userUniqueID = - [NSNumber numberWithUnsignedInt:6452UL]; - params.userStatus = - [NSNumber numberWithUnsignedChar:1U]; - params.userType = - [NSNumber numberWithUnsignedChar:0U]; - params.credentialRule = - [NSNumber numberWithUnsignedChar:0U]; - [cluster setUserWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Create new user with default parameters: Error: %@", err); - } else { - NSLog(@"Precondition: Create new user with default parameters: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - [cluster getUserWithParams:params completion: - ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); - } else { - NSLog(@"Precondition: Read the user back and verify its fields: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.userName; - VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); - VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); - } - - { - id actualValue = values.userUniqueID; - VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); - VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); - } - - { - id actualValue = values.userStatus; - VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); - VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); - } - - { - id actualValue = values.userType; - VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); - VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); - } - - { - id actualValue = values.credentialRule; - VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); - VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); - } - - { - id actualValue = values.credentials; - VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); - VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextUserIndex; - VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65535U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1b: TH reads MinPINCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1b: TH reads MinPINCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("minPINCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minPINCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1c: TH reads MaxPINCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1c: TH reads MaxPINCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("maxPINCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxPINCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMinRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1d: TH reads MinRFIDCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1d: TH reads MinRFIDCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("minRFIDCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("minRFIDCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeMaxRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 1e: TH reads MaxRFIDCodeLength and saves for future use.: Error: %@", err); - } else { - NSLog(@"Step 1e: TH reads MaxRFIDCodeLength and saves for future use.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintMinValue("maxRFIDCodeLength", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("maxRFIDCodeLength", [value unsignedCharValue], 255U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mPINCredentialData.HasValue() ? [NSData dataWithBytes:mPINCredentialData.Value().data() length:mPINCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456" length:6]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends Set Credential Command to DUT with type PIN: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends Set Credential Command to DUT with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mRFIDCredentialData.HasValue() ? [NSData dataWithBytes:mRFIDCredentialData.Value().data() length:mRFIDCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456789A" length:10]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends Set Credential Command to DUT with type RFID: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends Set Credential Command to DUT with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; - params.operationType = - [NSNumber numberWithUnsignedChar:0U]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - params.credentialData = mFingerVeinCredentialData.HasValue() ? [NSData dataWithBytes:mFingerVeinCredentialData.Value().data() length:mFingerVeinCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456789A" length:10]; - params.userIndex = - [NSNumber numberWithUnsignedShort:1U]; - params.userStatus = nil; - params.userType = nil; - [cluster setCredentialWithParams:params completion: - ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2c: TH sends Set Credential Command to DUT with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 2c: TH sends Set Credential Command to DUT with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); - VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH sends Get Credential Status Command with type PIN: Error: %@", err); - } else { - NSLog(@"Step 3a: TH sends Get Credential Status Command with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH sends Get Credential Status Command with type RFID: Error: %@", err); - } else { - NSLog(@"Step 3b: TH sends Get Credential Status Command with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 3c: TH sends Get Credential Status Command with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH sends Clear Credential Command to DUT with type PIN: Error: %@", err); - } else { - NSLog(@"Step 4a: TH sends Clear Credential Command to DUT with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH sends Get Credential Status Command with type RFID: Error: %@", err); - } else { - NSLog(@"Step 4b: TH sends Get Credential Status Command with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 4c: TH sends Get Credential Status Command with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH sends Clear Credential Command to DUT with type RFID: Error: %@", err); - } else { - NSLog(@"Step 4d: TH sends Clear Credential Command to DUT with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 4e: TH sends Get Credential Status Command with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); - } - - VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); - VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); - VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster clearCredentialWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4f: TH sends Clear Credential Command to DUT with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 4f: TH sends Clear Credential Command to DUT with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:1U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH sends Get Credential Status Command to DUT with type PIN: Error: %@", err); - } else { - NSLog(@"Step 5a: TH sends Get Credential Status Command to DUT with type PIN: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:2U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH sends Get Credential Status Command to DUT with type RFID: Error: %@", err); - } else { - NSLog(@"Step 5b: TH sends Get Credential Status Command to DUT with type RFID: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; - params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = - [NSNumber numberWithUnsignedChar:4U]; - ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = - [NSNumber numberWithUnsignedShort:1U]; - - [cluster getCredentialStatusWithParams:params completion: - ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein: Error: %@", err); - } else { - NSLog(@"Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.credentialExists; - VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); - } - - { - id actualValue = values.userIndex; - VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); - } - - { - id actualValue = values.creatorFabricIndex; - VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); - } - - { - id actualValue = values.lastModifiedFabricIndex; - VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); - } - - { - id actualValue = values.nextCredentialIndex; - VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestGroupsCluster : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestGroupsCluster() - : TestCommandBridge("TestGroupsCluster") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestGroupsCluster() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestGroupsCluster\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestGroupsCluster\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : View Group 0 (invalid)\n"); - err = TestViewGroup0Invalid_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : View First Group (not found)\n"); - err = TestViewFirstGroupNotFound_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Add First Group (no keys)\n"); - err = TestAddFirstGroupNoKeys_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Add KeySet\n"); - err = TestAddKeySet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Write Group Keys\n"); - err = TestWriteGroupKeys_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Add First Group (name too long)\n"); - err = TestAddFirstGroupNameTooLong_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Add First Group (new)\n"); - err = TestAddFirstGroupNew_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : View First Group (new)\n"); - err = TestViewFirstGroupNew_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : View Second Group (not found)\n"); - err = TestViewSecondGroupNotFound_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Get Group Membership 1 (all)\n"); - err = TestGetGroupMembership1All_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Add Second Group (new)\n"); - err = TestAddSecondGroupNew_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : View Second Group (new)\n"); - err = TestViewSecondGroupNew_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : View Group 3 (not found)\n"); - err = TestViewGroup3NotFound_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : View First Group (existing)\n"); - err = TestViewFirstGroupExisting_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : View Second Group (existing)\n"); - err = TestViewSecondGroupExisting_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Get Group Membership 2\n"); - err = TestGetGroupMembership2_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Remove Group 0 (invalid)\n"); - err = TestRemoveGroup0Invalid_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Remove Group 4 (not found)\n"); - err = TestRemoveGroup4NotFound_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Remove Second Group (existing)\n"); - err = TestRemoveSecondGroupExisting_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : View First Group (not removed)\n"); - err = TestViewFirstGroupNotRemoved_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : View Second Group (removed)\n"); - err = TestViewSecondGroupRemoved_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Get Group Membership 3\n"); - err = TestGetGroupMembership3_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Remove All\n"); - err = TestRemoveAll_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : View First Group (removed)\n"); - err = TestViewFirstGroupRemoved_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : View Second Group (still removed)\n"); - err = TestViewSecondGroupStillRemoved_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : View Group 3 (removed)\n"); - err = TestViewGroup3Removed_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Get Group Membership 4\n"); - err = TestGetGroupMembership4_27(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 28; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestViewGroup0Invalid_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:0U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Group 0 (invalid): Error: %@", err); - } else { - NSLog(@"View Group 0 (invalid): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 135U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupNotFound_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (not found): Error: %@", err); - } else { - NSLog(@"View First Group (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddFirstGroupNoKeys_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - params.groupName = @"Group #1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add First Group (no keys): Error: %@", err); - } else { - NSLog(@"Add First Group (no keys): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 126U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddKeySet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1110000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1110001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1110002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add KeySet: Error: %@", err); - } else { - NSLog(@"Add KeySet: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWriteGroupKeys_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = - [NSNumber numberWithUnsignedShort:257U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - temp_0[1] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupId = - [NSNumber numberWithUnsignedShort:258U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Write Group Keys: Error: %@", err); - } else { - NSLog(@"Write Group Keys: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddFirstGroupNameTooLong_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - params.groupName = @"12345678901234567"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add First Group (name too long): Error: %@", err); - } else { - NSLog(@"Add First Group (name too long): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 135U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddFirstGroupNew_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - params.groupName = @"Group #101234567"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add First Group (new): Error: %@", err); - } else { - NSLog(@"Add First Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupNew_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (new): Error: %@", err); - } else { - NSLog(@"View First Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupNotFound_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (not found): Error: %@", err); - } else { - NSLog(@"View Second Group (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership1All_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 1 (all): Error: %@", err); - } else { - NSLog(@"Get Group Membership 1 (all): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestAddSecondGroupNew_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - params.groupName = @"Group #2"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Add Second Group (new): Error: %@", err); - } else { - NSLog(@"Add Second Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupNew_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (new): Error: %@", err); - } else { - NSLog(@"View Second Group (new): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #2")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewGroup3NotFound_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:32767U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Group 3 (not found): Error: %@", err); - } else { - NSLog(@"View Group 3 (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 32767U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupExisting_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (existing): Error: %@", err); - } else { - NSLog(@"View First Group (existing): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupExisting_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (existing): Error: %@", err); - } else { - NSLog(@"View Second Group (existing): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #2")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership2_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedShort:258U]; - temp_0[1] = - [NSNumber numberWithUnsignedShort:259U]; - temp_0[2] = - [NSNumber numberWithUnsignedShort:32767U]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 2: Error: %@", err); - } else { - NSLog(@"Get Group Membership 2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveGroup0Invalid_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:0U]; - [cluster removeGroupWithParams:params completion: - ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove Group 0 (invalid): Error: %@", err); - } else { - NSLog(@"Remove Group 0 (invalid): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 135U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 0U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveGroup4NotFound_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:260U]; - [cluster removeGroupWithParams:params completion: - ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove Group 4 (not found): Error: %@", err); - } else { - NSLog(@"Remove Group 4 (not found): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 260U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveSecondGroupExisting_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster removeGroupWithParams:params completion: - ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove Second Group (existing): Error: %@", err); - } else { - NSLog(@"Remove Second Group (existing): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupNotRemoved_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (not removed): Error: %@", err); - } else { - NSLog(@"View First Group (not removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - { - id actualValue = values.groupName; - VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupRemoved_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (removed): Error: %@", err); - } else { - NSLog(@"View Second Group (removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership3_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedShort:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedShort:257U]; - temp_0[2] = - [NSNumber numberWithUnsignedShort:258U]; - temp_0[3] = - [NSNumber numberWithUnsignedShort:3U]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 3: Error: %@", err); - } else { - NSLog(@"Get Group Membership 3: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); - VerifyOrReturn(CheckValue("", actualValue[0], 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestRemoveAll_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster removeAllGroupsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Remove All: Error: %@", err); - } else { - NSLog(@"Remove All: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewFirstGroupRemoved_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:257U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View First Group (removed): Error: %@", err); - } else { - NSLog(@"View First Group (removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewSecondGroupStillRemoved_25() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:258U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Second Group (still removed): Error: %@", err); - } else { - NSLog(@"View Second Group (still removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestViewGroup3Removed_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; - params.groupID = - [NSNumber numberWithUnsignedShort:32767U]; - [cluster viewGroupWithParams:params completion: - ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"View Group 3 (removed): Error: %@", err); - } else { - NSLog(@"View Group 3 (removed): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 139U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, 32767U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestGetGroupMembership4_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = - [NSNumber numberWithUnsignedShort:1U]; - temp_0[1] = - [NSNumber numberWithUnsignedShort:257U]; - temp_0[2] = - [NSNumber numberWithUnsignedShort:258U]; - temp_0[3] = - [NSNumber numberWithUnsignedShort:3U]; - temp_0[4] = - [NSNumber numberWithUnsignedShort:32767U]; - params.groupList = temp_0; - } - [cluster getGroupMembershipWithParams:params completion: - ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Get Group Membership 4: Error: %@", err); - } else { - NSLog(@"Get Group Membership 4: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } - - { - id actualValue = values.groupList; - VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(0))); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_G_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_G_1_1() - : TestCommandBridge("Test_TC_G_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_G_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_G_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_G_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip(" !G.S.F00 ")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given G.S.F00 ensure featuremap has the correct bit set\n"); - if (ShouldSkip("G.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenGsf00EnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 9; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenGsf00EnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given G.S.F00 ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given G.S.F00 ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestScenesFabricRemoval : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestScenesFabricRemoval() - : TestCommandBridge("TestScenesFabricRemoval") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("payload", &mPayload); - AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); - AddArgument("waitAfterCommissioning", 0, UINT16_MAX, &mWaitAfterCommissioning); - AddArgument("PakeVerifier", &mPakeVerifier); - AddArgument("G1", 0, UINT16_MAX, &mG1); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestScenesFabricRemoval() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestScenesFabricRemoval\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestScenesFabricRemoval\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH1\n"); - err = TestCommissionDutToTh1_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : TH1 reads the fabric index\n"); - err = TestTh1ReadsTheFabricIndex_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Open Commissioning Window from alpha\n"); - err = TestOpenCommissioningWindowFromAlpha_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Waiting after opening commissioning window\n"); - err = TestWaitingAfterOpeningCommissioningWindow_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Commission from TH2\n"); - err = TestCommissionFromTh2_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved for TH2\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : TH2 reads the fabric index\n"); - err = TestTh2ReadsTheFabricIndex_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : TH1 sends a RemoveAllGroups command to DUT.\n"); - err = TestTh1SendsARemoveAllGroupsCommandToDut_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : TH 1 Add Group KeySet.\n"); - err = TestTh1AddGroupKeySet_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : TH1 Map KeySets to GroupId.\n"); - err = TestTh1MapKeySetsToGroupId_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : TH1 sends a AddGroup command to DUT for G1.\n"); - err = TestTh1SendsAAddGroupCommandToDutForG1_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Preparation step : TH2 Add Group KeySet.\n"); - err = TestPreparationStepTh2AddGroupKeySet_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Preparation step TH2 Map KeySets to GroupId.\n"); - err = TestPreparationStepTh2MapKeySetsToGroupId_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : TH2 sends a AddGroup command to DUT for G1.\n"); - err = TestTh2SendsAAddGroupCommandToDutForG1_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : TH1 confirms its Scene table is empty and gets its capacity\n"); - err = TestTh1ConfirmsItsSceneTableIsEmptyAndGetsItsCapacity_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : TH2 confirms its Scene table is empty and has the same capacity as TH1\n"); - err = TestTh2ConfirmsItsSceneTableIsEmptyAndHasTheSameCapacityAsTh1_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : TH1 sends an AddScene command to DUT for Scene 1 G1\n"); - err = TestTh1SendsAnAddSceneCommandToDutForScene1G1_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : TH1 sends an AddScene command to DUT for Scene 2 G1\n"); - err = TestTh1SendsAnAddSceneCommandToDutForScene2G1_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : TH2 sends an AddScene command to DUT for Scene 1 G1\n"); - err = TestTh2SendsAnAddSceneCommandToDutForScene1G1_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : TH2 sends an AddScene command to DUT for Scene 2 G1\n"); - err = TestTh2SendsAnAddSceneCommandToDutForScene2G1_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : TH1 confirms its G1 holds 2 scenes\n"); - err = TestTh1ConfirmsItsG1Holds2Scenes_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : TH2 confirms its G1 holds 2 scenes\n"); - err = TestTh2ConfirmsItsG1Holds2Scenes_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : TH1 sends RemoveFabric command for TH2\n"); - err = TestTh1SendsRemoveFabricCommandForTh2_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : TH1 confirms its G1 still holds 2 scenes\n"); - err = TestTh1ConfirmsItsG1StillHolds2Scenes_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mPayload; - chip::Optional mDiscriminator; - chip::Optional mWaitAfterCommissioning; - chip::Optional mPakeVerifier; - chip::Optional mG1; - chip::Optional mTimeout; - - CHIP_ERROR TestCommissionDutToTh1_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - NSNumber * _Nonnull th1FabricIndex; - - CHIP_ERROR TestTh1ReadsTheFabricIndex_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 reads the fabric index: Error: %@", err); - } else { - NSLog(@"TH1 reads the fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th1FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestOpenCommissioningWindowFromAlpha_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRAdministratorCommissioningClusterOpenCommissioningWindowParams alloc] init]; - params.commissioningTimeout = - [NSNumber numberWithUnsignedShort:180U]; - params.pakePasscodeVerifier = mPakeVerifier.HasValue() ? [NSData dataWithBytes:mPakeVerifier.Value().data() length:mPakeVerifier.Value().size()] : [[NSData alloc] initWithBytes:"\xb9\x61\x70\xaa\xe8\x03\x34\x68\x84\x72\x4f\xe9\xa3\xb2\x87\xc3\x03\x30\xc2\xa6\x60\x37\x5d\x17\xbb\x20\x5a\x8c\xf1\xae\xcb\x35\x04\x57\xf8\xab\x79\xee\x25\x3a\xb6\xa8\xe4\x6b\xb0\x9e\x54\x3a\xe4\x22\x73\x6d\xe5\x01\xe3\xdb\x37\xd4\x41\xfe\x34\x49\x20\xd0\x95\x48\xe4\xc1\x82\x40\x63\x0c\x4f\xf4\x91\x3c\x53\x51\x38\x39\xb7\xc0\x7f\xcc\x06\x27\xa1\xb8\x57\x3a\x14\x9f\xcd\x1f\xa4\x66\xcf" length:97]; - params.discriminator = mDiscriminator.HasValue() ? [NSNumber numberWithUnsignedShort:mDiscriminator.Value()] : [NSNumber numberWithUnsignedShort:3840U]; - params.iterations = - [NSNumber numberWithUnsignedInt:1000UL]; - params.salt = - [[NSData alloc] initWithBytes:"SPAKE2P Key Salt" length:16]; - [cluster openCommissioningWindowWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Open Commissioning Window from alpha: Error: %@", err); - } else { - NSLog(@"Open Commissioning Window from alpha: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWaitingAfterOpeningCommissioningWindow_3() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = mWaitAfterCommissioning.HasValue() ? mWaitAfterCommissioning.Value() : 5000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestCommissionFromTh2_4() - { - - chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); - return PairWithCode("beta", value); - } - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_5() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("beta", value); - } - NSNumber * _Nonnull th2FabricIndex; - - CHIP_ERROR TestTh2ReadsTheFabricIndex_6() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 reads the fabric index: Error: %@", err); - } else { - NSLog(@"TH2 reads the fabric index: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - th2FabricIndex = value; - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsARemoveAllGroupsCommandToDut_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster removeAllGroupsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends a RemoveAllGroups command to DUT.: Error: %@", err); - } else { - NSLog(@"TH1 sends a RemoveAllGroups command to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1AddGroupKeySet_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1110000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1110001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1110002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH 1 Add Group KeySet.: Error: %@", err); - } else { - NSLog(@"TH 1 Add Group KeySet.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1MapKeySetsToGroupId_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 Map KeySets to GroupId.: Error: %@", err); - } else { - NSLog(@"TH1 Map KeySets to GroupId.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsAAddGroupCommandToDutForG1_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.groupName = @"Group1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends a AddGroup command to DUT for G1.: Error: %@", err); - } else { - NSLog(@"TH1 sends a AddGroup command to DUT for G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreparationStepTh2AddGroupKeySet_11() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:418U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1120000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1120001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1120002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Preparation step : TH2 Add Group KeySet.: Error: %@", err); - } else { - NSLog(@"Preparation step : TH2 Add Group KeySet.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestPreparationStepTh2MapKeySetsToGroupId_12() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:418U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:0U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Preparation step TH2 Map KeySets to GroupId.: Error: %@", err); - } else { - NSLog(@"Preparation step TH2 Map KeySets to GroupId.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2SendsAAddGroupCommandToDutForG1_13() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.groupName = @"Group1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 sends a AddGroup command to DUT for G1.: Error: %@", err); - } else { - NSLog(@"TH2 sends a AddGroup command to DUT for G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - NSNumber * _Nullable fabricCapacity; - - CHIP_ERROR TestTh1ConfirmsItsSceneTableIsEmptyAndGetsItsCapacity_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 confirms its Scene table is empty and gets its capacity: Error: %@", err); - } else { - NSLog(@"TH1 confirms its Scene table is empty and gets its capacity: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - fabricCapacity = values.capacity; - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2ConfirmsItsSceneTableIsEmptyAndHasTheSameCapacityAsTh1_15() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 confirms its Scene table is empty and has the same capacity as TH1: Error: %@", err); - } else { - NSLog(@"TH2 confirms its Scene table is empty and has the same capacity as TH1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - if (fabricCapacity == nil) { - VerifyOrReturn(CheckValueNull("Capacity", actualValue)); - } else { - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, fabricCapacity)); - } - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsAnAddSceneCommandToDutForScene1G1_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:1U]; - params.sceneName = @"Scene1"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 1 G1: Error: %@", err); - } else { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 1 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsAnAddSceneCommandToDutForScene2G1_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:2U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.sceneName = @"Scene2"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 2 G1: Error: %@", err); - } else { - NSLog(@"TH1 sends an AddScene command to DUT for Scene 2 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2SendsAnAddSceneCommandToDutForScene1G1_18() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:1U]; - params.sceneName = @"Scene1"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 1 G1: Error: %@", err); - } else { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 1 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2SendsAnAddSceneCommandToDutForScene2G1_19() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:2U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.sceneName = @"Scene2"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 2 G1: Error: %@", err); - } else { - NSLog(@"TH2 sends an AddScene command to DUT for Scene 2 G1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1ConfirmsItsG1Holds2Scenes_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 confirms its G1 holds 2 scenes: Error: %@", err); - } else { - NSLog(@"TH1 confirms its G1 holds 2 scenes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneList; - VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh2ConfirmsItsG1Holds2Scenes_21() - { - - MTRBaseDevice * device = GetDevice("beta"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH2 confirms its G1 holds 2 scenes: Error: %@", err); - } else { - NSLog(@"TH2 confirms its G1 holds 2 scenes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneList; - VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1SendsRemoveFabricCommandForTh2_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; - params.fabricIndex = - [th2FabricIndex copy]; - [cluster removeFabricWithParams:params completion: - ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 sends RemoveFabric command for TH2: Error: %@", err); - } else { - NSLog(@"TH1 sends RemoveFabric command for TH2: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestTh1ConfirmsItsG1StillHolds2Scenes_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster getSceneMembershipWithParams:params completion: - ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH1 confirms its G1 still holds 2 scenes: Error: %@", err); - } else { - NSLog(@"TH1 confirms its G1 still holds 2 scenes: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.capacity; - VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); - VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneList; - VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); - VerifyOrReturn(CheckValue("", actualValue[0], 1U)); - VerifyOrReturn(CheckValue("", actualValue[1], 2U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_S_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_S_1_1() - : TestCommandBridge("Test_TC_S_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_S_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532)\n"); - if (ShouldSkip("(!S.S.F00)")) { - NextTest(); - return; - } - err = TestStep3aThReadsFeatureMapNameSupportBitGlobalAttribute65532_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532)\n"); - if (ShouldSkip("S.S.F00")) { - NextTest(); - return; - } - err = TestStep3aThReadsFeatureMapNameSupportBitGlobalAttribute65532_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532)\n"); - if (ShouldSkip("(!S.S.F01)")) { - NextTest(); - return; - } - err = TestStep3bThReadsFeatureMapExplicitBitGlobalAttribute65532_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532)\n"); - if (ShouldSkip("S.S.F01")) { - NextTest(); - return; - } - err = TestStep3bThReadsFeatureMapExplicitBitGlobalAttribute65532_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532)\n"); - if (ShouldSkip("(!S.S.F02)")) { - NextTest(); - return; - } - err = TestStep3cThReadsFeatureMapTableSizeBitGlobalAttribute65532_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532)\n"); - if (ShouldSkip("S.S.F02")) { - NextTest(); - return; - } - err = TestStep3cThReadsFeatureMapTableSizeBitGlobalAttribute65532_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532)\n"); - if (ShouldSkip("(!S.S.F03)")) { - NextTest(); - return; - } - err = TestStep3dThReadsFeatureMapFabricSceneBitGlobalAttribute65532_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532)\n"); - if (ShouldSkip("S.S.F03")) { - NextTest(); - return; - } - err = TestStep3dThReadsFeatureMapFabricSceneBitGlobalAttribute65532_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4: TH reads from the DUT the AttributeList attribute\n"); - if (ShouldSkip("S.S")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: TH reads optional attributes(SceneCount, CurrentScene, CurrentGroup, SceneValid) in AttributeList (global attribute 65531)\n"); - if (ShouldSkip("(!S.S.F03)")) { - NextTest(); - return; - } - err = TestStep4bThReadsOptionalAttributesSceneCountCurrentSceneCurrentGroupSceneValidInAttributeListGlobalAttribute65531_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: TH reads optinnal attribute(LastConfiguredBy) in AttributeList (global attribute 65531)\n"); - if (ShouldSkip("S.S.A0005")) { - NextTest(); - return; - } - err = TestStep4cThReadsOptinnalAttributeLastConfiguredByInAttributeListGlobalAttribute65531_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4d: TH reads optionnal attribute(SceneTableSize) in AttributeList (global attribute 65531)\n"); - if (ShouldSkip("S.S.F02")) { - NextTest(); - return; - } - err = TestStep4dThReadsOptionnalAttributeSceneTableSizeInAttributeListGlobalAttribute65531_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4e: TH reads optional attribute(FabricSceneInfo) in AttributeList (global attribute 65531)\n"); - if (ShouldSkip("S.S.F03")) { - NextTest(); - return; - } - err = TestStep4eThReadsOptionalAttributeFabricSceneInfoInAttributeListGlobalAttribute65531_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5: TH reads from the DUT the EventList attribute\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6a:TH reads from the DUT the AcceptedCommandList attribute\n"); - if (ShouldSkip("S.S")) { - NextTest(); - return; - } - err = TestStep6aTHReadsFromTheDutTheAcceptedCommandListAttribute_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6b: TH reads optional command(EnhancedAddSceneResponse) AcceptedCommandList (global attribute 65529)\n"); - if (ShouldSkip("S.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsOptionalCommandEnhancedAddSceneResponseAcceptedCommandListGlobalAttribute65529_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6c: TH reads optional command(EnhancedViewSceneResponse) AcceptedCommandList (global attribute 65529)\n"); - if (ShouldSkip("S.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep6cThReadsOptionalCommandEnhancedViewSceneResponseAcceptedCommandListGlobalAttribute65529_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6d: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529)\n"); - if (ShouldSkip("S.S.C42.Rsp")) { - NextTest(); - return; - } - err = TestStep6dThReadsOptionalCommandCopySceneResponseAcceptedCommandListGlobalAttribute65529_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7a: TH reads from the DUT the GeneratedCommandList attribute\n"); - err = TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Step 7b: TH reads optional command(EnhancedAddSceneResponse) in GeneratedCommandList (global attribute 65528)\n"); - if (ShouldSkip("S.S.C40.Rsp")) { - NextTest(); - return; - } - err = TestStep7bThReadsOptionalCommandEnhancedAddSceneResponseInGeneratedCommandListGlobalAttribute65528_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : Step 7c: TH reads optional command(EnhancedViewSceneResponse) in GeneratedCommandList (global attribute 65528)\n"); - if (ShouldSkip("S.S.C41.Rsp")) { - NextTest(); - return; - } - err = TestStep7cThReadsOptionalCommandEnhancedViewSceneResponseInGeneratedCommandListGlobalAttribute65528_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : Step 7d: TH reads optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528)\n"); - if (ShouldSkip("S.S.C42.Rsp")) { - NextTest(); - return; - } - err = TestStep7dThReadsOptionalCommandCopySceneResponseInGeneratedCommandListGlobalAttribute65528_23(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 24; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFeatureMapNameSupportBitGlobalAttribute65532_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFeatureMapNameSupportBitGlobalAttribute65532_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFeatureMapExplicitBitGlobalAttribute65532_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bThReadsFeatureMapExplicitBitGlobalAttribute65532_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFeatureMapTableSizeBitGlobalAttribute65532_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cThReadsFeatureMapTableSizeBitGlobalAttribute65532_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsFeatureMapFabricSceneBitGlobalAttribute65532_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dThReadsFeatureMapFabricSceneBitGlobalAttribute65532_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532): Error: %@", err); - } else { - NSLog(@"Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsOptionalAttributesSceneCountCurrentSceneCurrentGroupSceneValidInAttributeListGlobalAttribute65531_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads optional attributes(SceneCount, CurrentScene, CurrentGroup, SceneValid) in AttributeList (global attribute 65531): Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads optional attributes(SceneCount, CurrentScene, CurrentGroup, SceneValid) in AttributeList (global attribute 65531): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsOptinnalAttributeLastConfiguredByInAttributeListGlobalAttribute65531_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads optinnal attribute(LastConfiguredBy) in AttributeList (global attribute 65531): Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads optinnal attribute(LastConfiguredBy) in AttributeList (global attribute 65531): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsOptionnalAttributeSceneTableSizeInAttributeListGlobalAttribute65531_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads optionnal attribute(SceneTableSize) in AttributeList (global attribute 65531): Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads optionnal attribute(SceneTableSize) in AttributeList (global attribute 65531): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsOptionalAttributeFabricSceneInfoInAttributeListGlobalAttribute65531_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads optional attribute(FabricSceneInfo) in AttributeList (global attribute 65531): Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads optional attribute(FabricSceneInfo) in AttributeList (global attribute 65531): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aTHReadsFromTheDutTheAcceptedCommandListAttribute_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a:TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 6a:TH reads from the DUT the AcceptedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsOptionalCommandEnhancedAddSceneResponseAcceptedCommandListGlobalAttribute65529_17() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads optional command(EnhancedAddSceneResponse) AcceptedCommandList (global attribute 65529): Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads optional command(EnhancedAddSceneResponse) AcceptedCommandList (global attribute 65529): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6cThReadsOptionalCommandEnhancedViewSceneResponseAcceptedCommandListGlobalAttribute65529_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6c: TH reads optional command(EnhancedViewSceneResponse) AcceptedCommandList (global attribute 65529): Error: %@", err); - } else { - NSLog(@"Step 6c: TH reads optional command(EnhancedViewSceneResponse) AcceptedCommandList (global attribute 65529): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 65UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6dThReadsOptionalCommandCopySceneResponseAcceptedCommandListGlobalAttribute65529_19() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6d: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529): Error: %@", err); - } else { - NSLog(@"Step 6d: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 66UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); - } else { - NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 6UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7bThReadsOptionalCommandEnhancedAddSceneResponseInGeneratedCommandListGlobalAttribute65528_21() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH reads optional command(EnhancedAddSceneResponse) in GeneratedCommandList (global attribute 65528): Error: %@", err); - } else { - NSLog(@"Step 7b: TH reads optional command(EnhancedAddSceneResponse) in GeneratedCommandList (global attribute 65528): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 64UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7cThReadsOptionalCommandEnhancedViewSceneResponseInGeneratedCommandListGlobalAttribute65528_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7c: TH reads optional command(EnhancedViewSceneResponse) in GeneratedCommandList (global attribute 65528): Error: %@", err); - } else { - NSLog(@"Step 7c: TH reads optional command(EnhancedViewSceneResponse) in GeneratedCommandList (global attribute 65528): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 65UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7dThReadsOptionalCommandCopySceneResponseInGeneratedCommandListGlobalAttribute65528_23() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7d: TH reads optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528): Error: %@", err); - } else { - NSLog(@"Step 7d: TH reads optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528): Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 66UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_S_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_S_2_1() - : TestCommandBridge("Test_TC_S_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_S_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SceneCount attribute\n"); - if (ShouldSkip("S.S.A0000 && (!S.S.F03)")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheSceneCountAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the CurrentScene attribute\n"); - if (ShouldSkip("S.S.A0001 && (!S.S.F03)")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheCurrentSceneAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the CurrentGroup attribute\n"); - if (ShouldSkip("S.S.A0002 && (!S.S.F03)")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheCurrentGroupAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the SceneValid attribute\n"); - if (ShouldSkip("S.S.A0003 && (!S.S.F03)")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheSceneValidAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the NameSupport attribute\n"); - if (ShouldSkip("S.S.A0004 && S.S.F00")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheNameSupportAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the NameSupport attribute\n"); - if (ShouldSkip("S.S.A0004 && (!S.S.F00)")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheNameSupportAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the LastConfiguredBy attribute\n"); - if (ShouldSkip("S.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheLastConfiguredByAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH reads from the DUT the SceneTableSize attribute\n"); - if (ShouldSkip("S.S.A0006")) { - NextTest(); - return; - } - err = TestStep8ThReadsFromTheDutTheSceneTableSizeAttribute_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: TH reads from the DUT the FabricSceneInfo attribute\n"); - if (ShouldSkip("S.S.A0007")) { - NextTest(); - return; - } - err = TestStep9ThReadsFromTheDutTheFabricSceneInfoAttribute_9(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 10; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheSceneCountAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSceneCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the SceneCount attribute: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the SceneCount attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("sceneCount", "int8u", "int8u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheCurrentSceneAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentSceneWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the CurrentScene attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the CurrentScene attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentScene", "int8u", "int8u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheCurrentGroupAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentGroupWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the CurrentGroup attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the CurrentGroup attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("currentGroup", "group_id", "group_id")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheSceneValidAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSceneValidWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the SceneValid attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the SceneValid attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("sceneValid", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheNameSupportAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNameSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the NameSupport attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the NameSupport attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NameSupport", actualValue, 128U)); - } - - VerifyOrReturn(CheckConstraintType("nameSupport", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheNameSupportAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeNameSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the NameSupport attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the NameSupport attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("NameSupport", actualValue, 0U)); - } - - VerifyOrReturn(CheckConstraintType("nameSupport", "bitmap8", "bitmap8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheLastConfiguredByAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLastConfiguredByWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the LastConfiguredBy attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the LastConfiguredBy attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lastConfiguredBy", "node_id", "node_id")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThReadsFromTheDutTheSceneTableSizeAttribute_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeSceneTableSizeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH reads from the DUT the SceneTableSize attribute: Error: %@", err); - } else { - NSLog(@"Step 8: TH reads from the DUT the SceneTableSize attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("sceneTableSize", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep9ThReadsFromTheDutTheFabricSceneInfoAttribute_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRReadParams alloc] init]; - params.filterByFabric = true; - [cluster readAttributeFabricSceneInfoWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 9: TH reads from the DUT the FabricSceneInfo attribute: Error: %@", err); - } else { - NSLog(@"Step 9: TH reads from the DUT the FabricSceneInfo attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("fabricSceneInfo", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_S_2_4 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_S_2_4() - : TestCommandBridge("Test_TC_S_2_4") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("G1", 0, UINT16_MAX, &mG1); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_S_2_4() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_2_4\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_2_4\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002\n"); - err = TestStep0aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutUsingAKeyThatIsPreInstalledOnTheThGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a12GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime022200005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime122200017EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime22220002_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1\n"); - err = TestStep0bThBindsGroupId0x0001WithGroupKeySetID0x01a1InTheGroupKeyMapAttributeListOnGroupKeyManagementClusterByWritingTheGroupKeyMapAttributeWithOneEntryAsFollowsListItem11FabricIndex12GroupId0x00013GroupKeySetId0x01a1_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0c: TH sends a RemoveAllGroups command to DUT.\n"); - if (ShouldSkip("G.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep0cThSendsARemoveAllGroupsCommandToDut_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.\n"); - if (ShouldSkip("G.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep2aThSendsAAddGroupCommandToDutWithTheGroupIDFieldSetToG1_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.\n"); - if (ShouldSkip("S.S.C03.Rsp")) { - NextTest(); - return; - } - err = TestStep2bThSendsARemoveAllScenesCommandToDutWithTheGroupIDFieldSetToG1_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x0014 (20s) and no extension field sets.\n"); - if (ShouldSkip("S.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep3ThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x001420sAndNoExtensionFieldSets_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.\n"); - if (ShouldSkip("S.S.C04.Rsp")) { - NextTest(); - return; - } - err = TestStep4bThSendsAStoreSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 1s for level to change\n"); - err = TestWait1sForLevelToChange_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter1sWhichIsDifferentFromAc1_12(); - break; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.\n"); - if (ShouldSkip("S.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep5bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldOmitted_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 20s\n"); - err = TestWait20s_15(); - break; - case 16: - ChipLogProgress(chipTool, " ***** Test Step 16 : TH confirm the DUT reached AC1 (on level control cluster) after 20s\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestThConfirmTheDutReachedAc1OnLevelControlClusterAfter20s_16(); - break; - case 17: - ChipLogProgress(chipTool, " ***** Test Step 17 : DUT transitions to AC1 over 20s.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestDutTransitionsToAc1Over20s_17(); - break; - case 18: - ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_18(); - break; - case 19: - ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP && PICS_SC_RECALL_SCENE_TRANSITION_TIME")) { - NextTest(); - return; - } - err = TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_19(); - break; - case 20: - ChipLogProgress(chipTool, " ***** Test Step 20 : Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 0x0032 (5s).\n"); - if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME")) { - NextTest(); - return; - } - err = TestStep6bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetTo0x00325s_20(); - break; - case 21: - ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 5s\n"); - if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME")) { - NextTest(); - return; - } - err = TestWait5s_21(); - break; - case 22: - ChipLogProgress(chipTool, " ***** Test Step 22 : TH confirm the DUT reached AC2 (on level control cluster) after 5s\n"); - if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME && PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter5s_22(); - break; - case 23: - ChipLogProgress(chipTool, " ***** Test Step 23 : DUT transitions to AC1 over 5.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestDutTransitionsToAc1Over5_23(); - break; - case 24: - ChipLogProgress(chipTool, " ***** Test Step 24 : Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SDK_CI_ONLY")) { - NextTest(); - return; - } - err = TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_24(); - break; - case 25: - ChipLogProgress(chipTool, " ***** Test Step 25 : Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); - if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_25(); - break; - case 26: - ChipLogProgress(chipTool, " ***** Test Step 26 : Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).\n"); - if (ShouldSkip("S.S.C05.Rsp")) { - NextTest(); - return; - } - err = TestStep7bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetToNullNoTransitionTimeOverride_26(); - break; - case 27: - ChipLogProgress(chipTool, " ***** Test Step 27 : Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1\n"); - err = TestStep8ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a1_27(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 16: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 17: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 18: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 19: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 20: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 21: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 22: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 23: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 24: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 25: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 26: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 27: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 28; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mG1; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep0aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutUsingAKeyThatIsPreInstalledOnTheThGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a12GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime022200005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime122200017EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime22220002_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; - params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = - [NSNumber numberWithUnsignedChar:0U]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = - [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = - [NSNumber numberWithUnsignedLongLong:1110000ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = - [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = - [NSNumber numberWithUnsignedLongLong:1110001ULL]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = - [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; - ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = - [NSNumber numberWithUnsignedLongLong:1110002ULL]; - - [cluster keySetWriteWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002: Error: %@", err); - } else { - NSLog(@"Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0bThBindsGroupId0x0001WithGroupKeySetID0x01a1InTheGroupKeyMapAttributeListOnGroupKeyManagementClusterByWritingTheGroupKeyMapAttributeWithOneEntryAsFollowsListItem11FabricIndex12GroupId0x00013GroupKeySetId0x01a1_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - id groupKeyMapArgument; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = - [NSNumber numberWithUnsignedChar:1U]; - - groupKeyMapArgument = temp_0; - } - [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1: Error: %@", err); - } else { - NSLog(@"Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep0cThSendsARemoveAllGroupsCommandToDut_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster removeAllGroupsWithCompletion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 0c: TH sends a RemoveAllGroups command to DUT.: Error: %@", err); - } else { - NSLog(@"Step 0c: TH sends a RemoveAllGroups command to DUT.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2aThSendsAAddGroupCommandToDutWithTheGroupIDFieldSetToG1_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.groupName = @"Group1"; - [cluster addGroupWithParams:params completion: - ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.: Error: %@", err); - } else { - NSLog(@"Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep2bThSendsARemoveAllScenesCommandToDutWithTheGroupIDFieldSetToG1_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRemoveAllScenesParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - [cluster removeAllScenesWithParams:params completion: - ^(MTRScenesManagementClusterRemoveAllScenesResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.: Error: %@", err); - } else { - NSLog(@"Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x001420sAndNoExtensionFieldSets_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:20U]; - params.sceneName = @"Scene1"; - { - NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; - params.extensionFieldSets = temp_0; - } - [cluster addSceneWithParams:params completion: - ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x0014 (20s) and no extension field sets.: Error: %@", err); - } else { - NSLog(@"Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x0014 (20s) and no extension field sets.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:100U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_8() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC1 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep4bThSendsAStoreSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterStoreSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - [cluster storeSceneWithParams:params completion: - ^(MTRScenesManagementClusterStoreSceneResponseParams * _Nullable values, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.: Error: %@", err); - } else { - NSLog(@"Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = values.status; - VerifyOrReturn(CheckValue("Status", actualValue, 0U)); - } - - { - id actualValue = values.groupID; - VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); - } - - { - id actualValue = values.sceneID; - VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait1sForLevelToChange_11() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 1000UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter1sWhichIsDifferentFromAc1_12() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1: Error: %@", err); - } else { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_13() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep5bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldOmitted_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - [cluster recallSceneWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.: Error: %@", err); - } else { - NSLog(@"Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait20s_15() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 20500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThConfirmTheDutReachedAc1OnLevelControlClusterAfter20s_16() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH confirm the DUT reached AC1 (on level control cluster) after 20s: Error: %@", err); - } else { - NSLog(@"TH confirm the DUT reached AC1 (on level control cluster) after 20s: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutTransitionsToAc1Over20s_17() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please confirm that transition to AC1 was made over 20sgarbage: not in length on purpose", 55); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_18() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_19() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep6bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetTo0x00325s_20() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:50U]; - [cluster recallSceneWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 0x0032 (5s).: Error: %@", err); - } else { - NSLog(@"Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 0x0032 (5s).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestWait5s_21() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; - value.ms = 5500UL; - return WaitForMs("alpha", value); - } - - CHIP_ERROR TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter5s_22() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 5s: Error: %@", err); - } else { - NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 5s: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); - VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestDutTransitionsToAc1Over5_23() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please confirm that transition to AC1 was made over 5sgarbage: not in length on purpose", 54); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_24() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; - params.level = - [NSNumber numberWithUnsignedChar:200U]; - params.transitionTime = - [NSNumber numberWithUnsignedShort:0U]; - params.optionsMask = - [NSNumber numberWithUnsignedChar:0U]; - params.optionsOverride = - [NSNumber numberWithUnsignedChar:0U]; - [cluster moveToLevelWithOnOffWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); - } else { - NSLog(@"Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_25() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep7bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetToNullNoTransitionTimeOverride_26() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; - params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; - params.sceneID = - [NSNumber numberWithUnsignedChar:1U]; - params.transitionTime = nil; - [cluster recallSceneWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).: Error: %@", err); - } else { - NSLog(@"Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep8ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a1_27() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; - params.groupKeySetID = - [NSNumber numberWithUnsignedShort:417U]; - [cluster keySetRemoveWithParams:params completion: - ^(NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1: Error: %@", err); - } else { - NSLog(@"Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestActivatedCarbonFilterMonitoring : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestActivatedCarbonFilterMonitoring() - : TestCommandBridge("TestActivatedCarbonFilterMonitoring") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestActivatedCarbonFilterMonitoring() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestActivatedCarbonFilterMonitoring\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestActivatedCarbonFilterMonitoring\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Validate the feature map\n"); - err = TestValidateTheFeatureMap_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read Replacement Product List\n"); - err = TestReadReplacementProductList_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestValidateTheFeatureMap_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate the feature map: Error: %@", err); - } else { - NSLog(@"Validate the feature map: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadReplacementProductList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Replacement Product List: Error: %@", err); - } else { - NSLog(@"Read Replacement Product List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ReplacementProductList", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierType, 0U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierValue, @"111112222233")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierType, 1U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierValue, @"gtin8xxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierType, 2U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierValue, @"4444455555666")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierType, 3U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierValue, @"gtin14xxxxxxxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierType, 4U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierValue, @"oem20xxxxxxxxxxxxxxx")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class TestHepaFilterMonitoring : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - TestHepaFilterMonitoring() - : TestCommandBridge("TestHepaFilterMonitoring") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~TestHepaFilterMonitoring() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: TestHepaFilterMonitoring\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: TestHepaFilterMonitoring\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); - err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Validate the feature map\n"); - err = TestValidateTheFeatureMap_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Read Replacement Product List\n"); - err = TestReadReplacementProductList_2(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 3; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestValidateTheFeatureMap_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Validate the feature map: Error: %@", err); - } else { - NSLog(@"Validate the feature map: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestReadReplacementProductList_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Read Replacement Product List: Error: %@", err); - } else { - NSLog(@"Read Replacement Product List: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ReplacementProductList", [actualValue count], static_cast(5))); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierType, 0U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierValue, @"111112222233")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierType, 1U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierValue, @"gtin8xxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierType, 2U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierValue, @"4444455555666")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierType, 3U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierValue, @"gtin14xxxxxxxx")); - VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierType, 4U)); - VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierValue, @"oem20xxxxxxxxxxxxxxx")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACFREMON_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACFREMON_1_1() - : TestCommandBridge("Test_TC_ACFREMON_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACFREMON_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACFREMON_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACFREMON_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!ACFREMON.S.F00 && !ACFREMON.S.F01 && !ACFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("ACFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenACFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("ACFREMON.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenACFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given ACFREMON.S.F01(ReplacementProductList) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("ACFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenACFREMONSF01ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentACFREMONSF00AttributeInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorAcfremonsa0003InAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeLastChangedTimeAcfremonsa0004InAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList\n"); - if (ShouldSkip("ACFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeReplacementProductListAcfremonsf02InAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads EventList attribute from DUT\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); - if (ShouldSkip("!ACFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList\n"); - if (ShouldSkip("ACFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6bThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 16; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenACFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenACFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenACFREMONSF01ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given ACFREMON.S.F01(ReplacementProductList) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given ACFREMON.S.F01(ReplacementProductList) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentACFREMONSF00AttributeInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorAcfremonsa0003InAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeLastChangedTimeAcfremonsa0004InAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeReplacementProductListAcfremonsf02InAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6bThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_ACFREMON_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_ACFREMON_2_1() - : TestCommandBridge("Test_TC_ACFREMON_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_ACFREMON_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACFREMON_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACFREMON_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); - err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the Condition attribute.\n"); - if (ShouldSkip("ACFREMON.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheConditionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the DegradationDirection attribute..\n"); - if (ShouldSkip("ACFREMON.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the ChangeIndication attribute.\n"); - if (ShouldSkip("ACFREMON.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the InPlaceIndicator attribute\n"); - if (ShouldSkip("ACFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the LastChangedTime attribute\n"); - if (ShouldSkip("ACFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the ReplacementProductList attribute\n"); - if (ShouldSkip("ACFREMON.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheConditionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConditionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("condition", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("condition", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("condition", [value unsignedCharValue], 100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDegradationDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("degradationDirection", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("degradationDirection", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("degradationDirection", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChangeIndicationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("changeIndication", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("changeIndication", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("changeIndication", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInPlaceIndicatorWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("inPlaceIndicator", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLastChangedTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lastChangedTime", "epoch_s", "epoch_s")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("replacementProductList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_HEPAFREMON_1_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_HEPAFREMON_1_1() - : TestCommandBridge("Test_TC_HEPAFREMON_1_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_HEPAFREMON_1_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_HEPAFREMON_1_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_HEPAFREMON_1_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); - err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); - if (ShouldSkip("!HEPAFREMON.S.F00 && !HEPAFREMON.S.F01 && !HEPAFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("HEPAFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep3bGivenHEPAFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("HEPAFREMON.S.F01")) { - NextTest(); - return; - } - err = TestStep3cGivenHEPAFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set\n"); - if (ShouldSkip("HEPAFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep3dGivenHEPAFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_6(); - break; - case 7: - ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); - if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_7(); - break; - case 8: - ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.F00")) { - NextTest(); - return; - } - err = TestStep4bThReadsTheFeatureDependentHEPAFREMONSF00AttributeInAttributeList_8(); - break; - case 9: - ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorHepafremonsa0003InAttributeList_9(); - break; - case 10: - ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep4dThReadsTheOptionalAttributeLastChangedTimeHepafremonsa0004InAttributeList_10(); - break; - case 11: - ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList\n"); - if (ShouldSkip("HEPAFREMON.S.F02")) { - NextTest(); - return; - } - err = TestStep4eThReadsTheOptionalAttributeReplacementProductListHepafremonsf02InAttributeList_11(); - break; - case 12: - ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads from the DUT the EventList attribute.\n"); - if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { - NextTest(); - return; - } - NextTest(); - return; - case 13: - ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); - if (ShouldSkip("!HEPAFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13(); - break; - case 14: - ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList\n"); - if (ShouldSkip("HEPAFREMON.S.C00.Rsp")) { - NextTest(); - return; - } - err = TestStep6ThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14(); - break; - case 15: - ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); - err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 7: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 8: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 9: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 10: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 11: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 12: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 13: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 14: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 15: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 16; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); - } - - VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); - } else { - NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); - } - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3bGivenHEPAFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3cGivenHEPAFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3dGivenHEPAFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Error: %@", err); - } else { - NSLog(@"Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_7() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4bThReadsTheFeatureDependentHEPAFREMONSF00AttributeInAttributeList_8() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorHepafremonsa0003InAttributeList_9() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4dThReadsTheOptionalAttributeLastChangedTimeHepafremonsa0004InAttributeList_10() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4eThReadsTheOptionalAttributeReplacementProductListHepafremonsf02InAttributeList_11() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList: Error: %@", err); - } else { - NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); - VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); - } - - VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -class Test_TC_HEPAFREMON_2_1 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_HEPAFREMON_2_1() - : TestCommandBridge("Test_TC_HEPAFREMON_2_1") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_HEPAFREMON_2_1() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_HEPAFREMON_2_1\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_HEPAFREMON_2_1\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); - err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the Condition attribute.\n"); - if (ShouldSkip("HEPAFREMON.S.A0000")) { - NextTest(); - return; - } - err = TestStep2ThReadsFromTheDutTheConditionAttribute_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the DegradationDirection attribute..\n"); - if (ShouldSkip("HEPAFREMON.S.A0001")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the ChangeIndication attribute.\n"); - if (ShouldSkip("HEPAFREMON.S.A0002")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3(); - break; - case 4: - ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the InPlaceIndicator attribute\n"); - if (ShouldSkip("HEPAFREMON.S.A0003")) { - NextTest(); - return; - } - err = TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4(); - break; - case 5: - ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the LastChangedTime attribute\n"); - if (ShouldSkip("HEPAFREMON.S.A0004")) { - NextTest(); - return; - } - err = TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5(); - break; - case 6: - ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the ReplacementProductList attribute\n"); - if (ShouldSkip("HEPAFREMON.S.A0005")) { - NextTest(); - return; - } - err = TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 4: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 5: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 6: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 7; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ThReadsFromTheDutTheConditionAttribute_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeConditionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Error: %@", err); - } else { - NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("condition", "percent", "percent")); - VerifyOrReturn(CheckConstraintMinValue("condition", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("condition", [value unsignedCharValue], 100U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeDegradationDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("degradationDirection", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("degradationDirection", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("degradationDirection", [value unsignedCharValue], 1U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeChangeIndicationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("changeIndication", "enum8", "enum8")); - VerifyOrReturn(CheckConstraintMinValue("changeIndication", [value unsignedCharValue], 0U)); - VerifyOrReturn(CheckConstraintMaxValue("changeIndication", [value unsignedCharValue], 2U)); - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeInPlaceIndicatorWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Error: %@", err); - } else { - NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("inPlaceIndicator", "boolean", "boolean")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeLastChangedTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Error: %@", err); - } else { - NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - if (value != nil) { - - VerifyOrReturn(CheckConstraintType("lastChangedTime", "epoch_s", "epoch_s")); - } - - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Error: %@", err); - } else { - NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - VerifyOrReturn(CheckConstraintType("replacementProductList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } -}; - -#endif // CONFIG_ENABLE_YAML_TESTS - -void registerCommandsTests(Commands & commands) -{ - const char * clusterName = "Tests"; - - commands_list clusterCommands = { -#if CONFIG_ENABLE_YAML_TESTS - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), - make_unique(), -#endif // CONFIG_ENABLE_YAML_TESTS - }; - - commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for running YAML tests."); -} From 2e0f6ca54fb929947c8165480febc36bc7d2a597 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Fri, 19 Jan 2024 14:48:39 -0300 Subject: [PATCH 30/89] revert zap gen --- .../zap-generated/test/Commands.h | 194454 +++++++++++++++ 1 file changed, 194454 insertions(+) create mode 100644 zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h new file mode 100644 index 00000000000000..f1221333410d6b --- /dev/null +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -0,0 +1,194454 @@ +/* + * + * Copyright (c) 2022 Project CHIP Authors + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +// THIS FILE IS GENERATED BY ZAP + +#pragma once + +#if CONFIG_ENABLE_YAML_TESTS + +#include +#include +#include +#include + +#include // For INFINITY + +typedef void (^ResponseHandler)(id _Nullable value, NSError * _Nullable error); + +class TestList : public Command { +public: + TestList() + : Command("list") {}; + CHIP_ERROR Run() override + { + printf("TestAccessControlCluster\n"); + printf("Test_TC_ACL_1_1\n"); + printf("Test_TC_ACL_2_1\n"); + printf("Test_TC_ACL_2_3\n"); + printf("Test_TC_ACE_1_1\n"); + printf("Test_TC_ACE_1_5\n"); + printf("Test_TC_AIRQUAL_1_1\n"); + printf("Test_TC_AIRQUAL_2_1\n"); + printf("Test_TC_BOOL_1_1\n"); + printf("Test_TC_BOOL_2_1\n"); + printf("Test_TC_BRBINFO_1_1\n"); + printf("Test_TC_ACT_1_1\n"); + printf("Test_TC_BIND_1_1\n"); + printf("Test_TC_CC_1_1\n"); + printf("Test_TC_CC_2_1\n"); + printf("Test_TC_CC_3_2\n"); + printf("Test_TC_CC_3_3\n"); + printf("Test_TC_CC_4_1\n"); + printf("Test_TC_CC_4_2\n"); + printf("Test_TC_CC_4_3\n"); + printf("Test_TC_CC_4_4\n"); + printf("Test_TC_CC_5_1\n"); + printf("Test_TC_CC_5_2\n"); + printf("Test_TC_CC_5_3\n"); + printf("Test_TC_CC_6_1\n"); + printf("Test_TC_CC_6_5\n"); + printf("Test_TC_CC_7_3\n"); + printf("Test_TC_CC_7_4\n"); + printf("TestColorControl_9_1\n"); + printf("TestColorControl_9_2\n"); + printf("Test_TC_CDOCONC_1_1\n"); + printf("Test_TC_CDOCONC_2_1\n"); + printf("Test_TC_CMOCONC_1_1\n"); + printf("Test_TC_CMOCONC_2_1\n"); + printf("Test_TC_FLDCONC_1_1\n"); + printf("Test_TC_FLDCONC_2_1\n"); + printf("Test_TC_NDOCONC_1_1\n"); + printf("Test_TC_NDOCONC_2_1\n"); + printf("Test_TC_OZCONC_1_1\n"); + printf("Test_TC_OZCONC_2_1\n"); + printf("Test_TC_PMHCONC_1_1\n"); + printf("Test_TC_PMHCONC_2_1\n"); + printf("Test_TC_PMICONC_1_1\n"); + printf("Test_TC_PMICONC_2_1\n"); + printf("Test_TC_PMKCONC_1_1\n"); + printf("Test_TC_PMKCONC_2_1\n"); + printf("Test_TC_RNCONC_1_1\n"); + printf("Test_TC_RNCONC_2_1\n"); + printf("Test_TC_TVOCCONC_1_1\n"); + printf("Test_TC_TVOCCONC_2_1\n"); + printf("Test_TC_OPCREDS_1_2\n"); + printf("Test_TC_BINFO_1_1\n"); + printf("Test_TC_CNET_1_3\n"); + printf("Test_TC_DESC_1_1\n"); + printf("Test_TC_DLOG_1_1\n"); + printf("Test_TC_DGETH_1_1\n"); + printf("Test_TC_DGETH_2_1\n"); + printf("Test_TC_DGETH_2_2\n"); + printf("Test_TC_FLW_1_1\n"); + printf("Test_TC_FLABEL_1_1\n"); + printf("Test_TC_FAN_1_1\n"); + printf("Test_TC_FAN_2_1\n"); + printf("Test_TC_FAN_2_2\n"); + printf("Test_TC_FAN_2_3\n"); + printf("Test_TC_FAN_2_4\n"); + printf("Test_TC_FAN_3_1\n"); + printf("Test_TC_FAN_3_2\n"); + printf("Test_TC_FAN_3_6\n"); + printf("Test_TC_CGEN_1_1\n"); + printf("Test_TC_CGEN_2_1\n"); + printf("Test_TC_DGGEN_1_1\n"); + printf("Test_TC_GRPKEY_1_1\n"); + printf("Test_TC_GRPKEY_2_2\n"); + printf("Test_TC_ICDM_1_1\n"); + printf("Test_TC_I_1_1\n"); + printf("Test_TC_I_2_1\n"); + printf("Test_TC_I_2_2\n"); + printf("Test_TC_I_2_3\n"); + printf("Test_TC_ILL_1_1\n"); + printf("Test_TC_ILL_2_1\n"); + printf("Test_TC_ILL_2_2\n"); + printf("Test_TC_LVL_1_1\n"); + printf("Test_TC_LVL_2_1\n"); + printf("Test_TC_LVL_2_2\n"); + printf("Test_TC_LVL_3_1\n"); + printf("Test_TC_LVL_4_1\n"); + printf("Test_TC_LVL_5_1\n"); + printf("Test_TC_LVL_6_1\n"); + printf("Test_TC_LVL_7_1\n"); + printf("Test_TC_LCFG_1_1\n"); + printf("Test_TC_LUNIT_1_2\n"); + printf("Test_TC_LUNIT_3_1\n"); + printf("Test_TC_LTIME_1_2\n"); + printf("Test_TC_LTIME_3_1\n"); + printf("Test_TC_LWM_1_1\n"); + printf("Test_TC_LWM_2_1\n"); + printf("Test_TC_WASHERCTRL_1_1\n"); + printf("Test_TC_WASHERCTRL_2_1\n"); + printf("Test_TC_WASHERCTRL_2_2\n"); + printf("Test_TC_DRYERCTRL_1_1\n"); + printf("Test_TC_DRYERCTRL_2_1\n"); + printf("Test_TC_LOWPOWER_1_1\n"); + printf("Test_TC_KEYPADINPUT_1_2\n"); + printf("Test_TC_APPLAUNCHER_1_3\n"); + printf("Test_TC_MEDIAINPUT_1_4\n"); + printf("Test_TC_WAKEONLAN_1_5\n"); + printf("Test_TC_CHANNEL_1_6\n"); + printf("Test_TC_MEDIAPLAYBACK_1_7\n"); + printf("Test_TC_AUDIOOUTPUT_1_8\n"); + printf("Test_TC_TGTNAV_1_9\n"); + printf("Test_TC_APBSC_1_10\n"); + printf("Test_TC_CONTENTLAUNCHER_1_11\n"); + printf("Test_TC_ALOGIN_1_12\n"); + printf("Test_TC_LOWPOWER_2_1\n"); + printf("Test_TC_KEYPADINPUT_3_2\n"); + printf("Test_TC_KEYPADINPUT_3_3\n"); + printf("Test_TC_APPLAUNCHER_3_5\n"); + printf("Test_TC_APPLAUNCHER_3_6\n"); + printf("Test_TC_MEDIAINPUT_3_10\n"); + printf("Test_TC_MEDIAINPUT_3_11\n"); + printf("Test_TC_MEDIAINPUT_3_12\n"); + printf("Test_TC_MEDIAINPUT_3_13\n"); + printf("Test_TC_CHANNEL_5_1\n"); + printf("Test_TC_CHANNEL_5_2\n"); + printf("Test_TC_CHANNEL_5_3\n"); + printf("Test_TC_MEDIAPLAYBACK_6_1\n"); + printf("Test_TC_MEDIAPLAYBACK_6_2\n"); + printf("Test_TC_MEDIAPLAYBACK_6_3\n"); + printf("Test_TC_MEDIAPLAYBACK_6_4\n"); + printf("Test_TC_AUDIOOUTPUT_7_1\n"); + printf("Test_TC_AUDIOOUTPUT_7_2\n"); + printf("Test_TC_TGTNAV_8_1\n"); + printf("Test_TC_APBSC_9_1\n"); + printf("Test_TC_CONTENTLAUNCHER_10_1\n"); + printf("Test_TC_WAKEONLAN_4_1\n"); + printf("Test_TC_ALOGIN_12_1\n"); + printf("Test_TC_CONTENTLAUNCHER_10_3\n"); + printf("Test_TC_CONTENTLAUNCHER_10_5\n"); + printf("Test_TC_CONTENTLAUNCHER_10_7\n"); + printf("Test_TC_MOD_1_1\n"); + printf("OTA_SuccessfulTransfer\n"); + printf("Test_TC_OCC_1_1\n"); + printf("Test_TC_OCC_2_1\n"); + printf("Test_TC_OCC_2_3\n"); + printf("Test_TC_OO_1_1\n"); + printf("Test_TC_OO_2_1\n"); + printf("Test_TC_OO_2_2\n"); + printf("Test_TC_OO_2_4\n"); + printf("Test_TC_OPSTATE_1_1\n"); + printf("Test_TC_PS_1_1\n"); + printf("Test_TC_PS_2_1\n"); + printf("Test_TC_PRS_1_1\n"); + printf("Test_TC_PRS_2_1\n"); + printf("Test_TC_PRS_2_2\n"); + printf("Test_TC_PCC_1_1\n"); + printf("Test_TC_PCC_2_1\n"); + printf("Test_TC_PCC_2_2\n"); + printf("Test_TC_PCC_2_3\n"); + printf("Test_TC_PCC_2_4\n"); + printf("Test_TC_REFALM_1_1\n"); + printf("Test_TC_REFALM_2_1\n"); + printf("Test_TC_RH_1_1\n"); + printf("Test_TC_RVCCLEANM_1_1\n"); + printf("Test_TC_RVCRUNM_1_1\n"); + printf("Test_TC_RVCOPSTATE_1_1\n"); + printf("Test_TC_SMOKECO_1_1\n"); + printf("Test_TC_SMOKECO_2_1\n"); + printf("Test_TC_SWTCH_1_1\n"); + printf("Test_TC_TCCM_1_1\n"); + printf("Test_TC_TCTL_1_1\n"); + printf("Test_TC_TCTL_2_2\n"); + printf("Test_TC_TCTL_2_3\n"); + printf("Test_TC_TCTL_3_2\n"); + printf("Test_TC_TCTL_3_3\n"); + printf("Test_TC_TMP_1_1\n"); + printf("Test_TC_TMP_2_1\n"); + printf("Test_TC_TSTAT_1_1\n"); + printf("Test_TC_TSUIC_1_1\n"); + printf("Test_TC_TSUIC_2_1\n"); + printf("Test_TC_TSUIC_2_2\n"); + printf("Test_TC_DGTHREAD_1_1\n"); + printf("Test_TC_TIMESYNC_1_1\n"); + printf("Test_TC_TIMESYNC_2_3\n"); + printf("Test_TC_ULABEL_1_1\n"); + printf("Test_TC_ULABEL_2_1\n"); + printf("Test_TC_ULABEL_2_2\n"); + printf("Test_TC_ULABEL_2_3\n"); + printf("Test_TC_ULABEL_2_4\n"); + printf("Test_TC_DGWIFI_1_1\n"); + printf("Test_TC_DGWIFI_2_1\n"); + printf("Test_TC_DGWIFI_2_3\n"); + printf("Test_TC_WNCV_1_1\n"); + printf("Test_TC_WNCV_2_1\n"); + printf("Test_TC_WNCV_2_2\n"); + printf("Test_TC_WNCV_2_3\n"); + printf("Test_TC_WNCV_2_5\n"); + printf("Test_TC_WNCV_3_1\n"); + printf("Test_TC_WNCV_3_2\n"); + printf("Test_TC_WNCV_3_3\n"); + printf("Test_TC_WNCV_3_4\n"); + printf("Test_TC_WNCV_3_5\n"); + printf("Test_TC_WNCV_4_1\n"); + printf("Test_TC_WNCV_4_2\n"); + printf("Test_TC_WNCV_4_3\n"); + printf("Test_TC_WNCV_4_4\n"); + printf("Test_TC_WNCV_4_5\n"); + printf("TV_TargetNavigatorCluster\n"); + printf("TV_AudioOutputCluster\n"); + printf("TV_ApplicationLauncherCluster\n"); + printf("TV_KeypadInputCluster\n"); + printf("TV_AccountLoginCluster\n"); + printf("TV_WakeOnLanCluster\n"); + printf("TV_ApplicationBasicCluster\n"); + printf("TV_MediaPlaybackCluster\n"); + printf("TV_ChannelCluster\n"); + printf("TV_LowPowerCluster\n"); + printf("TV_ContentLauncherCluster\n"); + printf("TV_MediaInputCluster\n"); + printf("TestCASERecovery\n"); + printf("TestCluster\n"); + printf("TestConstraints\n"); + printf("TestDelayCommands\n"); + printf("TestLogCommands\n"); + printf("TestSaveAs\n"); + printf("TestConfigVariables\n"); + printf("TestDescriptorCluster\n"); + printf("TestFabricRemovalWhileSubscribed\n"); + printf("TestGeneralCommissioning\n"); + printf("TestIdentifyCluster\n"); + printf("TestOperationalCredentialsCluster\n"); + printf("TestModeSelectCluster\n"); + printf("TestTemperatureControl\n"); + printf("TestSelfFabricRemoval\n"); + printf("TestSystemCommands\n"); + printf("TestBinding\n"); + printf("TestUserLabelCluster\n"); + printf("TestUserLabelClusterConstraints\n"); + printf("TestArmFailSafe\n"); + printf("TestFanControl\n"); + printf("TestAccessControlConstraints\n"); + printf("TestLevelControlWithOnOffDependency\n"); + printf("TestCommissioningWindow\n"); + printf("TestCommissionerNodeId\n"); + printf("TestTimeSynchronization\n"); + printf("TestOperationalState\n"); + printf("TestRVCOperationalState\n"); + printf("TestDishwasherAlarm\n"); + printf("TestMultiAdmin\n"); + printf("Test_TC_DGSW_1_1\n"); + printf("TestSubscribe_OnOff\n"); + printf("TestSubscribe_AdministratorCommissioning\n"); + printf("DL_UsersAndCredentials\n"); + printf("DL_Schedules\n"); + printf("Test_TC_DRLK_1_1\n"); + printf("Test_TC_DRLK_2_4\n"); + printf("Test_TC_DRLK_2_5\n"); + printf("Test_TC_DRLK_2_6\n"); + printf("Test_TC_DRLK_2_7\n"); + printf("Test_TC_DRLK_2_8\n"); + printf("Test_TC_DRLK_2_11\n"); + printf("TestGroupsCluster\n"); + printf("Test_TC_G_1_1\n"); + printf("TestScenesFabricRemoval\n"); + printf("Test_TC_S_1_1\n"); + printf("Test_TC_S_2_1\n"); + printf("Test_TC_S_2_4\n"); + printf("TestActivatedCarbonFilterMonitoring\n"); + printf("TestHepaFilterMonitoring\n"); + printf("Test_TC_ACFREMON_1_1\n"); + printf("Test_TC_ACFREMON_2_1\n"); + printf("Test_TC_HEPAFREMON_1_1\n"); + printf("Test_TC_HEPAFREMON_2_1\n"); + + return CHIP_NO_ERROR; + } +}; + +class ManualTestList : public Command { +public: + ManualTestList() + : Command("list-manual") {}; + CHIP_ERROR Run() override + { + + return CHIP_NO_ERROR; + } +}; + +class TestAccessControlCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestAccessControlCluster() + : TestCommandBridge("TestAccessControlCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestAccessControlCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestAccessControlCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestAccessControlCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for commissionee\n"); + err = TestWaitForCommissionee_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Write entries\n"); + err = TestWriteEntries_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Verify\n"); + err = TestVerify_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Write entries empty lists\n"); + err = TestWriteEntriesEmptyLists_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Verify\n"); + err = TestVerify_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Write entry invalid privilege\n"); + err = TestWriteEntryInvalidPrivilege_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Verify\n"); + err = TestVerify_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Write entry invalid auth mode\n"); + err = TestWriteEntryInvalidAuthMode_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Verify\n"); + err = TestVerify_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Write entry invalid subject\n"); + err = TestWriteEntryInvalidSubject_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Verify\n"); + err = TestVerify_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Write entry invalid target\n"); + err = TestWriteEntryInvalidTarget_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Verify\n"); + err = TestVerify_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Write entry too many subjects\n"); + err = TestWriteEntryTooManySubjects_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Verify\n"); + err = TestVerify_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Write entry too many targets\n"); + err = TestWriteEntryTooManyTargets_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Verify\n"); + err = TestVerify_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Write too many entries\n"); + err = TestWriteTooManyEntries_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Verify\n"); + err = TestVerify_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Restore ACL\n"); + err = TestRestoreAcl_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Verify\n"); + err = TestVerify_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Validate resource minima (SubjectsPerAccessControlEntry)\n"); + err = TestValidateResourceMinimaSubjectsPerAccessControlEntry_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Validate resource minima (TargetsPerAccessControlEntry)\n"); + err = TestValidateResourceMinimaTargetsPerAccessControlEntry_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Validate resource minima (AccessControlEntriesPerFabric)\n"); + err = TestValidateResourceMinimaAccessControlEntriesPerFabric_23(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 24; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForCommissionee_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestWriteEntries_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = + [NSNumber numberWithUnsignedInt:1UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; + + temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = + [NSNumber numberWithUnsignedInt:2UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = + [NSNumber numberWithUnsignedShort:3U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:4ULL]; + temp_3[1] = + [NSNumber numberWithUnsignedLongLong:5ULL]; + temp_3[2] = + [NSNumber numberWithUnsignedLongLong:6ULL]; + temp_3[3] = + [NSNumber numberWithUnsignedLongLong:7ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:8U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = + [NSNumber numberWithUnsignedInt:9UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; + + temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = + [NSNumber numberWithUnsignedInt:10UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = + [NSNumber numberWithUnsignedShort:11U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[2] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).authMode = + [NSNumber numberWithUnsignedChar:3U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:12ULL]; + temp_3[1] = + [NSNumber numberWithUnsignedLongLong:13ULL]; + temp_3[2] = + [NSNumber numberWithUnsignedLongLong:14ULL]; + temp_3[3] = + [NSNumber numberWithUnsignedLongLong:15ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:16U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = + [NSNumber numberWithUnsignedInt:17UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; + + temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = + [NSNumber numberWithUnsignedInt:18UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = + [NSNumber numberWithUnsignedShort:19U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[3] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:20ULL]; + temp_3[1] = + [NSNumber numberWithUnsignedLongLong:21ULL]; + temp_3[2] = + [NSNumber numberWithUnsignedLongLong:22ULL]; + temp_3[3] = + [NSNumber numberWithUnsignedLongLong:23ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:24U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = + [NSNumber numberWithUnsignedInt:25UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; + + temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = + [NSNumber numberWithUnsignedInt:26UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = + [NSNumber numberWithUnsignedShort:27U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write entries: Error: %@", err); + } else { + NSLog(@"Write entries: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerify_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify: Error: %@", err); + } else { + NSLog(@"Verify: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets count], static_cast(3))); + VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).cluster)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint, 0U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster, 1UL)); + VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).endpoint)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster, 2UL)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint, 3U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).deviceType)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); + VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); + VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects count], static_cast(4))); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[0], 4ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[1], 5ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[2], 6ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[3], 7ULL)); + VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); + VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets count], static_cast(3))); + VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).cluster)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint, 8U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster, 9UL)); + VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).endpoint)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster, 10UL)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint, 11U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).deviceType)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).privilege, 3U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).authMode, 3U)); + VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects)); + VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects count], static_cast(4))); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[0], 12ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[1], 13ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[2], 14ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[3], 15ULL)); + VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets)); + VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets count], static_cast(3))); + VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).cluster)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint, 16U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster, 17UL)); + VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).endpoint)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster, 18UL)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint, 19U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).deviceType)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).privilege, 3U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).authMode, 2U)); + VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects)); + VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects count], static_cast(4))); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[0], 20ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[1], 21ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[2], 22ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[3], 23ULL)); + VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets)); + VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets count], static_cast(3))); + VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).cluster)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint, 24U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster, 25UL)); + VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).endpoint)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster, 26UL)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint, 27U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).deviceType)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteEntriesEmptyLists_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write entries empty lists: Error: %@", err); + } else { + NSLog(@"Write entries empty lists: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerify_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify: Error: %@", err); + } else { + NSLog(@"Verify: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); + VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteEntryInvalidPrivilege_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write entry invalid privilege: Error: %@", err); + } else { + NSLog(@"Write entry invalid privilege: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerify_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify: Error: %@", err); + } else { + NSLog(@"Verify: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteEntryInvalidAuthMode_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write entry invalid auth mode: Error: %@", err); + } else { + NSLog(@"Write entry invalid auth mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerify_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify: Error: %@", err); + } else { + NSLog(@"Verify: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteEntryInvalidSubject_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write entry invalid subject: Error: %@", err); + } else { + NSLog(@"Write entry invalid subject: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerify_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify: Error: %@", err); + } else { + NSLog(@"Verify: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteEntryInvalidTarget_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write entry invalid target: Error: %@", err); + } else { + NSLog(@"Write entry invalid target: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerify_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify: Error: %@", err); + } else { + NSLog(@"Verify: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteEntryTooManySubjects_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:1ULL]; + temp_3[1] = + [NSNumber numberWithUnsignedLongLong:2ULL]; + temp_3[2] = + [NSNumber numberWithUnsignedLongLong:3ULL]; + temp_3[3] = + [NSNumber numberWithUnsignedLongLong:4ULL]; + temp_3[4] = + [NSNumber numberWithUnsignedLongLong:5ULL]; + temp_3[5] = + [NSNumber numberWithUnsignedLongLong:6ULL]; + temp_3[6] = + [NSNumber numberWithUnsignedLongLong:7ULL]; + temp_3[7] = + [NSNumber numberWithUnsignedLongLong:8ULL]; + temp_3[8] = + [NSNumber numberWithUnsignedLongLong:9ULL]; + temp_3[9] = + [NSNumber numberWithUnsignedLongLong:10ULL]; + temp_3[10] = + [NSNumber numberWithUnsignedLongLong:11ULL]; + temp_3[11] = + [NSNumber numberWithUnsignedLongLong:12ULL]; + temp_3[12] = + [NSNumber numberWithUnsignedLongLong:13ULL]; + temp_3[13] = + [NSNumber numberWithUnsignedLongLong:14ULL]; + temp_3[14] = + [NSNumber numberWithUnsignedLongLong:15ULL]; + temp_3[15] = + [NSNumber numberWithUnsignedLongLong:16ULL]; + temp_3[16] = + [NSNumber numberWithUnsignedLongLong:17ULL]; + temp_3[17] = + [NSNumber numberWithUnsignedLongLong:18ULL]; + temp_3[18] = + [NSNumber numberWithUnsignedLongLong:19ULL]; + temp_3[19] = + [NSNumber numberWithUnsignedLongLong:20ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write entry too many subjects: Error: %@", err); + } else { + NSLog(@"Write entry too many subjects: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerify_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify: Error: %@", err); + } else { + NSLog(@"Verify: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteEntryTooManyTargets_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:1U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = + [NSNumber numberWithUnsignedShort:2U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; + + temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = + [NSNumber numberWithUnsignedShort:3U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; + + temp_3[3] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).endpoint = + [NSNumber numberWithUnsignedShort:4U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[3]).deviceType = nil; + + temp_3[4] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).endpoint = + [NSNumber numberWithUnsignedShort:5U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[4]).deviceType = nil; + + temp_3[5] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).endpoint = + [NSNumber numberWithUnsignedShort:6U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[5]).deviceType = nil; + + temp_3[6] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).endpoint = + [NSNumber numberWithUnsignedShort:7U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[6]).deviceType = nil; + + temp_3[7] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).endpoint = + [NSNumber numberWithUnsignedShort:8U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[7]).deviceType = nil; + + temp_3[8] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).endpoint = + [NSNumber numberWithUnsignedShort:9U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[8]).deviceType = nil; + + temp_3[9] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).endpoint = + [NSNumber numberWithUnsignedShort:10U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[9]).deviceType = nil; + + temp_3[10] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).endpoint = + [NSNumber numberWithUnsignedShort:11U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[10]).deviceType = nil; + + temp_3[11] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).endpoint = + [NSNumber numberWithUnsignedShort:12U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[11]).deviceType = nil; + + temp_3[12] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).endpoint = + [NSNumber numberWithUnsignedShort:13U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[12]).deviceType = nil; + + temp_3[13] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).endpoint = + [NSNumber numberWithUnsignedShort:14U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[13]).deviceType = nil; + + temp_3[14] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).endpoint = + [NSNumber numberWithUnsignedShort:15U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[14]).deviceType = nil; + + temp_3[15] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).endpoint = + [NSNumber numberWithUnsignedShort:16U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[15]).deviceType = nil; + + temp_3[16] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).endpoint = + [NSNumber numberWithUnsignedShort:17U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[16]).deviceType = nil; + + temp_3[17] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).endpoint = + [NSNumber numberWithUnsignedShort:18U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[17]).deviceType = nil; + + temp_3[18] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).endpoint = + [NSNumber numberWithUnsignedShort:19U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[18]).deviceType = nil; + + temp_3[19] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).endpoint = + [NSNumber numberWithUnsignedShort:20U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[19]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write entry too many targets: Error: %@", err); + } else { + NSLog(@"Write entry too many targets: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerify_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify: Error: %@", err); + } else { + NSLog(@"Verify: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteTooManyEntries_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = + [NSNumber numberWithUnsignedInt:1UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; + + temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = + [NSNumber numberWithUnsignedInt:2UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = + [NSNumber numberWithUnsignedShort:3U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:4ULL]; + temp_3[1] = + [NSNumber numberWithUnsignedLongLong:5ULL]; + temp_3[2] = + [NSNumber numberWithUnsignedLongLong:6ULL]; + temp_3[3] = + [NSNumber numberWithUnsignedLongLong:7ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:8U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = + [NSNumber numberWithUnsignedInt:9UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; + + temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = + [NSNumber numberWithUnsignedInt:10UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = + [NSNumber numberWithUnsignedShort:11U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[2] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).authMode = + [NSNumber numberWithUnsignedChar:3U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:12ULL]; + temp_3[1] = + [NSNumber numberWithUnsignedLongLong:13ULL]; + temp_3[2] = + [NSNumber numberWithUnsignedLongLong:14ULL]; + temp_3[3] = + [NSNumber numberWithUnsignedLongLong:15ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:16U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = + [NSNumber numberWithUnsignedInt:17UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; + + temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = + [NSNumber numberWithUnsignedInt:18UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = + [NSNumber numberWithUnsignedShort:19U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[2]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[3] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:20ULL]; + temp_3[1] = + [NSNumber numberWithUnsignedLongLong:21ULL]; + temp_3[2] = + [NSNumber numberWithUnsignedLongLong:22ULL]; + temp_3[3] = + [NSNumber numberWithUnsignedLongLong:23ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:24U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = + [NSNumber numberWithUnsignedInt:25UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; + + temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = + [NSNumber numberWithUnsignedInt:26UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = + [NSNumber numberWithUnsignedShort:27U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[3]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[4] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:28ULL]; + temp_3[1] = + [NSNumber numberWithUnsignedLongLong:29ULL]; + temp_3[2] = + [NSNumber numberWithUnsignedLongLong:30ULL]; + temp_3[3] = + [NSNumber numberWithUnsignedLongLong:31ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:32U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + temp_3[1] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).cluster = + [NSNumber numberWithUnsignedInt:33UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[1]).deviceType = nil; + + temp_3[2] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).cluster = + [NSNumber numberWithUnsignedInt:34UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).endpoint = + [NSNumber numberWithUnsignedShort:35U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[2]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[4]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write too many entries: Error: %@", err); + } else { + NSLog(@"Write too many entries: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerify_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify: Error: %@", err); + } else { + NSLog(@"Verify: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets count], static_cast(3))); + VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).cluster)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).endpoint, 0U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[0]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).cluster, 1UL)); + VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).endpoint)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[1]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).cluster, 2UL)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).endpoint, 3U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets[2]).deviceType)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).privilege, 1U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).authMode, 2U)); + VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects)); + VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects count], static_cast(4))); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[0], 4ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[1], 5ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[2], 6ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).subjects[3], 7ULL)); + VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets)); + VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets count], static_cast(3))); + VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).cluster)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).endpoint, 8U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[0]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).cluster, 9UL)); + VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).endpoint)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[1]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).cluster, 10UL)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).endpoint, 11U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).targets[2]).deviceType)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[1]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).privilege, 3U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).authMode, 3U)); + VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects)); + VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects count], static_cast(4))); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[0], 12ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[1], 13ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[2], 14ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).subjects[3], 15ULL)); + VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets)); + VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets count], static_cast(3))); + VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).cluster)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).endpoint, 16U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[0]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).cluster, 17UL)); + VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).endpoint)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[1]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).cluster, 18UL)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).endpoint, 19U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).targets[2]).deviceType)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[2]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).privilege, 1U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).authMode, 2U)); + VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects)); + VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects count], static_cast(4))); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[0], 20ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[1], 21ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[2], 22ULL)); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).subjects[3], 23ULL)); + VerifyOrReturn(CheckValueNonNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets)); + VerifyOrReturn(CheckValue("Targets", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets count], static_cast(3))); + VerifyOrReturn(CheckValueNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).cluster)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).endpoint, 24U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[0]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).cluster, 25UL)); + VerifyOrReturn(CheckValueNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).endpoint)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[1]).deviceType)); + VerifyOrReturn(CheckValueNonNull("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster)); + VerifyOrReturn(CheckValue("Cluster", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).cluster, 26UL)); + VerifyOrReturn(CheckValueNonNull("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).endpoint, 27U)); + VerifyOrReturn(CheckValueNull("DeviceType", ((MTRAccessControlClusterAccessControlTargetStruct *) ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).targets[2]).deviceType)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[3]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRestoreAcl_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Restore ACL: Error: %@", err); + } else { + NSLog(@"Restore ACL: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerify_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify: Error: %@", err); + } else { + NSLog(@"Verify: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestValidateResourceMinimaSubjectsPerAccessControlEntry_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSubjectsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Validate resource minima (SubjectsPerAccessControlEntry): Error: %@", err); + } else { + NSLog(@"Validate resource minima (SubjectsPerAccessControlEntry): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestValidateResourceMinimaTargetsPerAccessControlEntry_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Validate resource minima (TargetsPerAccessControlEntry): Error: %@", err); + } else { + NSLog(@"Validate resource minima (TargetsPerAccessControlEntry): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("targetsPerAccessControlEntry", [value unsignedShortValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestValidateResourceMinimaAccessControlEntriesPerFabric_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAccessControlEntriesPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Validate resource minima (AccessControlEntriesPerFabric): Error: %@", err); + } else { + NSLog(@"Validate resource minima (AccessControlEntriesPerFabric): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("accessControlEntriesPerFabric", [value unsignedShortValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ACL_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ACL_1_1() + : TestCommandBridge("Test_TC_ACL_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ACL_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from DUT\n"); + err = TestStep2ThReadsClusterRevisionAttributeFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from DUT\n"); + err = TestStep3ThReadsFeatureMapAttributeFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList attribute from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList attribute from DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute (Extension) in AttributeList\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep4bThReadsOptionalAttributeExtensionInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads EventList attribute from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); + err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); + err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsOptionalAttributeExtensionInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads optional attribute (Extension) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads optional attribute (Extension) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ACL_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ACL_2_1() + : TestCommandBridge("Test_TC_ACL_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ACL_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads SubjectsPerAccessControlEntry attribute from DUT\n"); + if (ShouldSkip("ACL.S.A0002")) { + NextTest(); + return; + } + err = TestStep2ThReadsSubjectsPerAccessControlEntryAttributeFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads TargetsPerAccessControlEntry attribute from DUT\n"); + if (ShouldSkip("ACL.S.A0003")) { + NextTest(); + return; + } + err = TestStep3ThReadsTargetsPerAccessControlEntryAttributeFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads AccessControlEntriesPerFabric attribute from DUT\n"); + if (ShouldSkip("ACL.S.A0004")) { + NextTest(); + return; + } + err = TestStep4ThReadsAccessControlEntriesPerFabricAttributeFromDut_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsSubjectsPerAccessControlEntryAttributeFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSubjectsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads SubjectsPerAccessControlEntry attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads SubjectsPerAccessControlEntry attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("subjectsPerAccessControlEntry", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 4U)); + VerifyOrReturn(CheckConstraintMaxValue("subjectsPerAccessControlEntry", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTargetsPerAccessControlEntryAttributeFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetsPerAccessControlEntryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads TargetsPerAccessControlEntry attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads TargetsPerAccessControlEntry attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("targetsPerAccessControlEntry", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("targetsPerAccessControlEntry", [value unsignedShortValue], 3U)); + VerifyOrReturn(CheckConstraintMaxValue("targetsPerAccessControlEntry", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsAccessControlEntriesPerFabricAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAccessControlEntriesPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads AccessControlEntriesPerFabric attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads AccessControlEntriesPerFabric attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("accessControlEntriesPerFabric", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("accessControlEntriesPerFabric", [value unsignedShortValue], 3U)); + VerifyOrReturn(CheckConstraintMaxValue("accessControlEntriesPerFabric", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ACL_2_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ACL_2_3() + : TestCommandBridge("Test_TC_ACL_2_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("D_OK_EMPTY", &mDOkEmpty); + AddArgument("D_OK_SINGLE", &mDOkSingle); + AddArgument("D_OK_FULL", &mDOkFull); + AddArgument("D_BAD_LENGTH", &mDBadLength); + AddArgument("D_BAD_STRUCT", &mDBadStruct); + AddArgument("D_BAD_LIST", &mDBadList); + AddArgument("D_BAD_ELEM", &mDBadElem); + AddArgument("D_BAD_OVERFLOW", &mDBadOverflow); + AddArgument("D_BAD_UNDERFLOW", &mDBadUnderflow); + AddArgument("D_BAD_NONE", &mDBadNone); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ACL_2_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACL_2_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACL_2_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute\n"); + err = TestStep2Th1ReadsDutEndpoint0OperationalCredentialsClusterCurrentFabricIndexAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep3Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep4Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDOkEmpty1718_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep5Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep6Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep7Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep8Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkFull17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003148656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e0018_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep9Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep10Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadLength17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003248656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e2e0018_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep11Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadStruct1518_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep12Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadList3701d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep13Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadElem17103d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep14Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadOverflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018ff_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep15Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadUnderflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep16Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadNone_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep17Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining2ElementsValueIsListOfAccessControlExtensionStructContaining2ElementsFirstElementContainsDataFieldDOkEmpty1718SecondElementContainsDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep18Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep19Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsAnEmptyList_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute\n"); + if (ShouldSkip("ACL.S.A0001")) { + NextTest(); + return; + } + err = TestStep20Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_19(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 20; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mDOkEmpty; + chip::Optional mDOkSingle; + chip::Optional mDOkFull; + chip::Optional mDBadLength; + chip::Optional mDBadStruct; + chip::Optional mDBadList; + chip::Optional mDBadElem; + chip::Optional mDBadOverflow; + chip::Optional mDBadUnderflow; + chip::Optional mDBadNone; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull CurrentFabricIndexValue; + + CHIP_ERROR TestStep2Th1ReadsDutEndpoint0OperationalCredentialsClusterCurrentFabricIndexAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH1 reads DUT Endpoint 0 OperationalCredentials cluster CurrentFabricIndex attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + CurrentFabricIndexValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(0))); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDOkEmpty1718_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = + [CurrentFabricIndexValue copy]; + + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718: Error: %@", err); + } else { + NSLog(@"Step 4: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct: Data field: D_OK_EMPTY : 1718: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); + } else { + NSLog(@"Step 5: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2] + + )); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = + [CurrentFabricIndexValue copy]; + + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); + } else { + NSLog(@"Step 6: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_SINGLE :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71] + + )); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDOkFull17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003148656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e0018_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkFull.HasValue() ? [NSData dataWithBytes:mDOkFull.Value().data() length:mDOkFull.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x31\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:128]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = + [CurrentFabricIndexValue copy]; + + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018: Error: %@", err); + } else { + NSLog(@"Step 8: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_OK_FULL :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003148656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E0018: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); + } else { + NSLog(@"Step 9: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkFull.HasValue() ? [NSData dataWithBytes:mDOkFull.Value().data() length:mDOkFull.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x31\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:128] + + )); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadLength17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700d00000f1ff02003248656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e7420616761696e2e2e2e2e2e2e0018_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadLength.HasValue() ? [NSData dataWithBytes:mDBadLength.Value().data() length:mDBadLength.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\xD0\x00\x00\xF1\xFF\x02\x00\x32\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x61\x67\x61\x69\x6E\x2E\x2E\x2E\x2E\x2E\x2E\x00\x18" length:129]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = + [CurrentFabricIndexValue copy]; + + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018: Error: %@", err); + } else { + NSLog(@"Step 10: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_LENGTH :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700D00000F1FF02003248656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E7420616761696E2E2E2E2E2E2E0018: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadStruct1518_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadStruct.HasValue() ? [NSData dataWithBytes:mDBadStruct.Value().data() length:mDBadStruct.Value().size()] : [[NSData alloc] initWithBytes:"\x15\x18" length:2]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = + [CurrentFabricIndexValue copy]; + + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518: Error: %@", err); + } else { + NSLog(@"Step 11: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_STRUCT : 1518: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadList3701d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadList.HasValue() ? [NSData dataWithBytes:mDBadList.Value().data() length:mDBadList.Value().size()] : [[NSData alloc] initWithBytes:"\x37\x01\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:72]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = + [CurrentFabricIndexValue copy]; + + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); + } else { + NSLog(@"Step 12: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_LIST :3701D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadElem17103d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadElem.HasValue() ? [NSData dataWithBytes:mDBadElem.Value().data() length:mDBadElem.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x10\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:65]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = + [CurrentFabricIndexValue copy]; + + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); + } else { + NSLog(@"Step 13: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_ELEM :17103D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep14Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadOverflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018ff_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadOverflow.HasValue() ? [NSData dataWithBytes:mDBadOverflow.Value().data() length:mDBadOverflow.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18\xFF" length:72]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = + [CurrentFabricIndexValue copy]; + + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF: Error: %@", err); + } else { + NSLog(@"Step 14: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1 .struct Data field: D_BAD_OVERFLOW : 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018FF: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep15Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1StructDataFieldDBadUnderflow17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e6700_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadUnderflow.HasValue() ? [NSData dataWithBytes:mDBadUnderflow.Value().data() length:mDBadUnderflow.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00" length:70]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = + [CurrentFabricIndexValue copy]; + + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700: Error: %@", err); + } else { + NSLog(@"Step 15: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1. struct Data field: D_BAD_UNDERFLOW :17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E6700: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining1Element1structDataFieldDBadNone_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDBadNone.HasValue() ? [NSData dataWithBytes:mDBadNone.Value().data() length:mDBadNone.Value().size()] : [[NSData alloc] initWithBytes:"" length:0]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = + [CurrentFabricIndexValue copy]; + + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE: Error: %@", err); + } else { + NSLog(@"Step 16: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 1 element 1.struct Data field: D_BAD_NONE: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep17Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsListOfAccessControlExtensionStructContaining2ElementsValueIsListOfAccessControlExtensionStructContaining2ElementsFirstElementContainsDataFieldDOkEmpty1718SecondElementContainsDataFieldDOkSingle17d00000f1ff01003d48656c6c6f20576f726c642e205468697320697320612073696e676c6520656c656d656e74206c6976696e6720617320612063686172737472696e670018_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).data = mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[0]).fabricIndex = + [CurrentFabricIndexValue copy]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlExtensionStruct alloc] init]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[1]).data = mDOkSingle.HasValue() ? [NSData dataWithBytes:mDOkSingle.Value().data() length:mDOkSingle.Value().size()] : [[NSData alloc] initWithBytes:"\x17\xD0\x00\x00\xF1\xFF\x01\x00\x3D\x48\x65\x6C\x6C\x6F\x20\x57\x6F\x72\x6C\x64\x2E\x20\x54\x68\x69\x73\x20\x69\x73\x20\x61\x20\x73\x69\x6E\x67\x6C\x65\x20\x65\x6C\x65\x6D\x65\x6E\x74\x20\x6C\x69\x76\x69\x6E\x67\x20\x61\x73\x20\x61\x20\x63\x68\x61\x72\x73\x74\x72\x69\x6E\x67\x00\x18" length:71]; + ((MTRAccessControlClusterAccessControlExtensionStruct *) temp_0[1]).fabricIndex = + [CurrentFabricIndexValue copy]; + + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Error: %@", err); + } else { + NSLog(@"Step 17: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is list of AccessControlExtensionStruct containing 2 elements . value is list of AccessControlExtensionStruct containing 2 elements . first element contains Data field: D_OK_EMPTY 1718 . second element contains Data field: D_OK_SINGLE 17D00000F1FF01003D48656C6C6F20576F726C642E205468697320697320612073696E676C6520656C656D656E74206C6976696E6720617320612063686172737472696E670018: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep18Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); + } else { + NSLog(@"Step 18: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValueAsString("Data", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).data, mDOkEmpty.HasValue() ? [NSData dataWithBytes:mDOkEmpty.Value().data() length:mDOkEmpty.Value().size()] : [[NSData alloc] initWithBytes:"\x17\x18" length:2] + + )); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlExtensionStruct *) actualValue[0]).fabricIndex, CurrentFabricIndexValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep19Th1WritesDutEndpoint0AccessControlClusterExtensionAttributeValueIsAnEmptyList_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id extensionArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + extensionArgument = temp_0; + } + [cluster writeAttributeExtensionWithValue:extensionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list: Error: %@", err); + } else { + NSLog(@"Step 19: TH1 writes DUT Endpoint 0 AccessControl cluster Extension attribute, value is an empty list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep20Th1ReadsDutEndpoint0AccessControlClusterExtensionAttribute_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeExtensionWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Error: %@", err); + } else { + NSLog(@"Step 20: TH1 reads DUT Endpoint 0 AccessControl cluster Extension attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Extension", [actualValue count], static_cast(0))); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ACE_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ACE_1_1() + : TestCommandBridge("Test_TC_ACE_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ACE_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACE_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACE_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); + err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read the commissioner node ID\n"); + err = TestReadTheCommissionerNodeId_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]\n"); + err = TestStep2ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining1ElementsGrantingItselfAdministerPrivilegesOnAllOfEndpoint0StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterNullEndpoint0DeviceTypeNull_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege)\n"); + err = TestStep3ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricScopedReadRequiresAdministerPrivilege_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); + err = TestStep4ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); + err = TestStep5ThSendsTheUpdateFabricLabelCommandToTheNodeOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); + err = TestStep6ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.\n"); + err = TestStep7ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilegeNoteThatThisWillCauseAnErrorToBeReturnedBecauseTheEnableKeyIsInvalidButStillIndicatesThatTheThPassedTheAclCheck_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); + err = TestStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); + err = TestStep9ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndManagePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldManage4CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); + err = TestStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); + err = TestStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); + err = TestStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 13a: Write NodeLabel attribute (Basic - requires manage)\n"); + err = TestStep13aWriteNodeLabelAttributeBasicRequiresManage_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 13b: Send TestEventTrigger (General Diagnostics - requires manage)\n"); + err = TestStep13bSendTestEventTriggerGeneralDiagnosticsRequiresManage_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 13c: Tead the VendorID attribute (Basic - requires view)\n"); + err = TestStep13cTeadTheVendorIDAttributeBasicRequiresView_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); + err = TestStep14ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndOperatePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldOperate3CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); + err = TestStep15aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesStep10PThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); + err = TestStep15bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) \n"); + err = TestStep15cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); + err = TestStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); + err = TestStep17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); + err = TestStep18RepeatStep8ToConfirmThatTheThStillHasViewPrivilegesStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]\n"); + err = TestStep19Th1WritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndViewPrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege)\n"); + err = TestStep20aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); + err = TestStep20bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); + err = TestStep20cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) \n"); + err = TestStep21aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); + err = TestStep21bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 22: Tead the VendorID attribute (Basic - requires view)\n"); + err = TestStep22TeadTheVendorIDAttributeBasicRequiresView_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]\n"); + err = TestStep23ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementGrantingAdministerPrivilegeOnOnlyTheAccessControlClusterAndNoOtherAccess1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint0_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) \n"); + err = TestStep24aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege)\n"); + err = TestTStep24bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege)\n"); + err = TestStep24cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege)\n"); + err = TestStep25aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege)\n"); + err = TestStep25bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege)\n"); + err = TestStep26ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null\n"); + err = TestStep27ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementRestoringFullAccessToTheNodeStructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_37(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 38; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull commissionerNodeId; + + CHIP_ERROR TestReadTheCommissionerNodeId_1() + { + + chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; + return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { + { + commissionerNodeId = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; + } + NextTest(); + }); + } + + CHIP_ERROR TestStep2ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining1ElementsGrantingItselfAdministerPrivilegesOnAllOfEndpoint0StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterNullEndpoint0DeviceTypeNull_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeId copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]: Error: %@", err); + } else { + NSLog(@"Step 2: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 1 elements, granting itself administer privileges on all of Endpoint 0 : struct a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: null, Endpoint: 0, DeviceType: null}]: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricScopedReadRequiresAdministerPrivilege_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-scoped read (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinLength("NOCs", value, 1)); + VerifyOrReturn(CheckConstraintMaxLength("NOCs", value, 1)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id locationArgument; + locationArgument = @"XX"; + [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 4: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThSendsTheUpdateFabricLabelCommandToTheNodeOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; + params.label = @"TestFabric"; + [cluster updateFabricLabelWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 5: TH sends the UpdateFabricLabel command to the Node Operational Credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nodeLabelArgument; + nodeLabelArgument = @"TestNode"; + [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); + } else { + NSLog(@"Step 6: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilegeNoteThatThisWillCauseAnErrorToBeReturnedBecauseTheEnableKeyIsInvalidButStillIndicatesThatTheThPassedTheAclCheck_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; + params.enableKey = + [[NSData alloc] initWithBytes:"0" length:1]; + params.eventTrigger = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster testEventTriggerWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.: Error: %@", err); + } else { + NSLog(@"Step 7: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0 (requires manage privilege). Note that this will cause an error to be returned because the EnableKey is invalid, but still indicates that the TH passed the ACL check.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); + } else { + NSLog(@"Step 8: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndManagePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldManage4CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeId copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = + [NSNumber numberWithUnsignedInt:31UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:4U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeId copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); + } else { + NSLog(@"Step 9: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and manage privilege on everything else on EP0 : 1.Struct : a)Fabric Index:1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Manage (4) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 10: TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id locationArgument; + locationArgument = @"XX"; + [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 11: TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; + params.label = @"TestFabric"; + [cluster updateFabricLabelWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 12: TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13aWriteNodeLabelAttributeBasicRequiresManage_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nodeLabelArgument; + nodeLabelArgument = @"TestNode"; + [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13a: Write NodeLabel attribute (Basic - requires manage): Error: %@", err); + } else { + NSLog(@"Step 13a: Write NodeLabel attribute (Basic - requires manage): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13bSendTestEventTriggerGeneralDiagnosticsRequiresManage_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; + params.enableKey = + [[NSData alloc] initWithBytes:"0" length:1]; + params.eventTrigger = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster testEventTriggerWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13b: Send TestEventTrigger (General Diagnostics - requires manage): Error: %@", err); + } else { + NSLog(@"Step 13b: Send TestEventTrigger (General Diagnostics - requires manage): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13cTeadTheVendorIDAttributeBasicRequiresView_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13c: Tead the VendorID attribute (Basic - requires view): Error: %@", err); + } else { + NSLog(@"Step 13c: Tead the VendorID attribute (Basic - requires view): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep14ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndOperatePrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldOperate3CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeId copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = + [NSNumber numberWithUnsignedInt:31UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeId copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); + } else { + NSLog(@"Step 14: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and operate privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: Operate (3) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep15aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesStep10PThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 15a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges step:10 p- TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep15bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id locationArgument; + locationArgument = @"XX"; + [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 15b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep15cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; + params.label = @"TestFabric"; + [cluster updateFabricLabelWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) : Error: %@", err); + } else { + NSLog(@"Step 15c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege) : Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nodeLabelArgument; + nodeLabelArgument = @"TestNode"; + [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); + } else { + NSLog(@"Step 16: TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; + params.enableKey = + [[NSData alloc] initWithBytes:"0" length:1]; + params.eventTrigger = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster testEventTriggerWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); + } else { + NSLog(@"Step 17: TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep18RepeatStep8ToConfirmThatTheThStillHasViewPrivilegesStep8ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); + } else { + NSLog(@"Step 18: Repeat step 8 to confirm that the TH still has view privileges : Step 8 - TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep19Th1WritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContaining2ElementsGivingItselfAdministerPrivilegeOnlyOnTheAccessControlClusterAndViewPrivilegeOnEverythingElseOnEp01StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldEndpoint0_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeId copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = + [NSNumber numberWithUnsignedInt:31UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeId copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Error: %@", err); + } else { + NSLog(@"Step 19: TH1 writes the ACL attribute with a list of AccessControlEntryStruct entries containing 2 elements, giving itself administer privilege only on the Access Control cluster and view privilege on everything else on EP0. 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Endpoint: 0}]: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep20aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 20a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep20bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id locationArgument; + locationArgument = @"XX"; + [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 20b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep20cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; + params.label = @"TestFabric"; + [cluster updateFabricLabelWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 20c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep21aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nodeLabelArgument; + nodeLabelArgument = @"TestNode"; + [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) : Error: %@", err); + } else { + NSLog(@"Step 21a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege) : Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep21bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; + params.enableKey = + [[NSData alloc] initWithBytes:"0" length:1]; + params.eventTrigger = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster testEventTriggerWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); + } else { + NSLog(@"Step 21b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep22TeadTheVendorIDAttributeBasicRequiresView_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 22: Tead the VendorID attribute (Basic - requires view): Error: %@", err); + } else { + NSLog(@"Step 22: Tead the VendorID attribute (Basic - requires view): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep23ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementGrantingAdministerPrivilegeOnOnlyTheAccessControlClusterAndNoOtherAccess1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldCluster0x001FEndpoint0_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeId copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = + [NSNumber numberWithUnsignedInt:31UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]: Error: %@", err); + } else { + NSLog(@"Step 23: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, granting Administer privilege on only the Access Control cluster and no other access : 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: [{Cluster: 0x001F, Endpoint: 0}]: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep24aRepeatSteps10To12ToConfirmThatThStillDoesNotHaveAdministerPrivilegesRepeatStep10ThReadsTheNOCsAttributeFromTheNodeOperationalCredentialsClusterUsingAFabricFilteredReadRequiresAdministerPrivilege_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeNOCsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) : Error: %@", err); + } else { + NSLog(@"Step 24a: Repeat steps 10 to 12 to confirm that TH still does not have administer privileges. Repeat step:10 - TH reads the NOCs attribute from the Node Operational Credentials cluster using a fabric-filtered read (requires administer privilege) : Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTStep24bRepeatStep11ThWritesTheLocationAttributeInTheBasicInformationClusterWithxxRequiresAdministerPrivilege_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id locationArgument; + locationArgument = @"XX"; + [cluster writeAttributeLocationWithValue:locationArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Error: %@", err); + } else { + NSLog(@"TStep 24b: Repeat step:11 - TH writes the Location attribute in the Basic Information cluster with 'XX' (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep24cRepeatStep12ThSendsTheUpdateFabricLabelCommandToTheOperationalCredentialsClusterWithTheLabelFieldSetToTestFabricRequiresAdministerPrivilege_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; + params.label = @"TestFabric"; + [cluster updateFabricLabelWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Error: %@", err); + } else { + NSLog(@"Step 24c: Repeat step:12 - TH sends the UpdateFabricLabel command to the operational credentials cluster with the Label field set to 'TestFabric' (requires administer privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep25aRepeatSteps16To17ToConfirmThatThStillDoesNotHaveManagePrivilegesStep16ThWritesTheNodeLabelAttributeInTheBasicInformationClusterWithTheStringTestNodeRequiresManagePrivilege_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nodeLabelArgument; + nodeLabelArgument = @"TestNode"; + [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Error: %@", err); + } else { + NSLog(@"Step 25a: Repeat steps 16 to 17 to confirm that TH still does not have manage privileges. Step 16 : TH writes the NodeLabel attribute in the Basic Information cluster with the string 'TestNode' (requires manage privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep25bRepeatSteps17ThSendsTheTestEventTriggerCommandToTheGeneralDiagnosticsClusterWithTheEnableKeySetTo0AndTheEventTriggerSetTo0RequiresManagePrivilege_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralDiagnosticsClusterTestEventTriggerParams alloc] init]; + params.enableKey = + [[NSData alloc] initWithBytes:"0" length:1]; + params.eventTrigger = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster testEventTriggerWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Error: %@", err); + } else { + NSLog(@"Step 25b: Repeat steps 17 : TH sends the TestEventTrigger command to the General Diagnostics cluster with the EnableKey set to 0 and the EventTrigger set to 0. (requires manage privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep26ThReadsTheVendorIDAttributeFromTheBasicInformationClusterRequiresViewPrivilege_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Error: %@", err); + } else { + NSLog(@"Step 26: TH reads the VendorID attribute from the Basic Information cluster (requires view privilege): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep27ThWritesTheAclAttributeWithAListOfAccessControlEntryStructEntriesContainingASingleElementRestoringFullAccessToTheNodeStructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeId copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Error: %@", err); + } else { + NSLog(@"Step 27: TH writes the ACL attribute with a list of AccessControlEntryStruct entries containing a single element, restoring full access to the node. Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ACE_1_5 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ACE_1_5() + : TestCommandBridge("Test_TC_ACE_1_5") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("payload", &mPayload); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("waitAfterCommissioning", 0, UINT16_MAX, &mWaitAfterCommissioning); + AddArgument("PakeVerifier", &mPakeVerifier); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ACE_1_5() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACE_1_5\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACE_1_5\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TH1 commissions DUT using admin node ID N1\n"); + err = TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : TH1 reads the fabric index\n"); + err = TestTh1ReadsTheFabricIndex_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2 & 3: TH1 puts DUT into commissioning mode, TH2 commissions DUT using admin node ID N2\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep23Th1PutsDutIntoCommissioningModeTh2CommissionsDutUsingAdminNodeIdN2_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH1 opens the commissioning window on the DUT\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep2Th1OpensTheCommissioningWindowOnTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Waiting after opening commissioning window\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestWaitingAfterOpeningCommissioningWindow_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH2 commissions DUT using admin node ID N2\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep3Th2CommissionsDutUsingAdminNodeIdN2_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved for TH2\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep4Th2ReadsItsFabricIndexFromTheOperationalCredentialsClusterCurrentFabricIndexAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH2 reads the fabric index\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep4Th2ReadsTheFabricIndex_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Read the commissioner node ID from the alpha fabric\n"); + err = TestReadTheCommissionerNodeIdFromTheAlphaFabric_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]\n"); + err = TestStep5Th1WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterAccessControl0x001fEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldNullETargetsFieldClusterDescriptor0x001dEndpoint0_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Read the commissioner node ID from the beta fabric\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestReadTheCommissionerNodeIdFromTheBetaFabric_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep6Th2WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndexTh2FabricIndexBPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn2ETargetsFieldClusterAccessControl0x001fEndpoint0_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH2 writes ACL giving view privilge for basic cluster\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep6Th2WritesAclGivingViewPrivilgeForBasicCluster_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute\n"); + err = TestStep7Th1ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute\n"); + err = TestStep8Th1ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep9Th2ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 9: TH2 reads descriptor cluster - expect UNSUPPORTED_ACCESS\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep9Th2ReadsDescriptorClusterExpectUnsupportedAccess_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute - expect SUCCESS\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttributeExpectSuccess_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null\n"); + err = TestStep11Th1ResetsTheACLsToTheDefaultValueBywritingDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining1Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandToTheDutWithTheFabricIndexSetToTh2FabricIndex_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric commandto the DUT with the FabricIndex set to th2FabricIndex\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandtoTheDutWithTheFabricIndexSetToTh2FabricIndex_22(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 23; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mPayload; + chip::Optional mDiscriminator; + chip::Optional mWaitAfterCommissioning; + chip::Optional mPakeVerifier; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1Th1CommissionsDutUsingAdminNodeIdN1_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull th1FabricIndex; + + CHIP_ERROR TestTh1ReadsTheFabricIndex_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH1 reads the fabric index: Error: %@", err); + } else { + NSLog(@"TH1 reads the fabric index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + th1FabricIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep23Th1PutsDutIntoCommissioningModeTh2CommissionsDutUsingAdminNodeIdN2_2() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2Th1OpensTheCommissioningWindowOnTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + params.pakePasscodeVerifier = mPakeVerifier.HasValue() ? [NSData dataWithBytes:mPakeVerifier.Value().data() length:mPakeVerifier.Value().size()] : [[NSData alloc] initWithBytes:"\xb9\x61\x70\xaa\xe8\x03\x34\x68\x84\x72\x4f\xe9\xa3\xb2\x87\xc3\x03\x30\xc2\xa6\x60\x37\x5d\x17\xbb\x20\x5a\x8c\xf1\xae\xcb\x35\x04\x57\xf8\xab\x79\xee\x25\x3a\xb6\xa8\xe4\x6b\xb0\x9e\x54\x3a\xe4\x22\x73\x6d\xe5\x01\xe3\xdb\x37\xd4\x41\xfe\x34\x49\x20\xd0\x95\x48\xe4\xc1\x82\x40\x63\x0c\x4f\xf4\x91\x3c\x53\x51\x38\x39\xb7\xc0\x7f\xcc\x06\x27\xa1\xb8\x57\x3a\x14\x9f\xcd\x1f\xa4\x66\xcf" length:97]; + params.discriminator = mDiscriminator.HasValue() ? [NSNumber numberWithUnsignedShort:mDiscriminator.Value()] : [NSNumber numberWithUnsignedShort:3840U]; + params.iterations = + [NSNumber numberWithUnsignedInt:1000UL]; + params.salt = + [[NSData alloc] initWithBytes:"SPAKE2P Key Salt" length:16]; + [cluster openCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH1 opens the commissioning window on the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH1 opens the commissioning window on the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitingAfterOpeningCommissioningWindow_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mWaitAfterCommissioning.HasValue() ? mWaitAfterCommissioning.Value() : 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3Th2CommissionsDutUsingAdminNodeIdN2_5() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("beta", value); + } + NSNumber * _Nonnull th2FabricIndex; + + CHIP_ERROR TestStep4Th2ReadsItsFabricIndexFromTheOperationalCredentialsClusterCurrentFabricIndexAttribute_7() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH2 reads its fabric index from the Operational Credentials cluster CurrentFabricIndex attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + th2FabricIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4Th2ReadsTheFabricIndex_8() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + NSNumber * _Nonnull commissionerNodeIdAlpha; + + CHIP_ERROR TestReadTheCommissionerNodeIdFromTheAlphaFabric_9() + { + + chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; + return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { + { + commissionerNodeIdAlpha = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; + } + NextTest(); + }); + } + + CHIP_ERROR TestStep5Th1WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldClusterAccessControl0x001fEndpoint02structAFabricIndex1BPrivilegeFieldView1CAuthModeFieldCase2DSubjectsFieldNullETargetsFieldClusterDescriptor0x001dEndpoint0_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeIdAlpha copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = + [NSNumber numberWithUnsignedInt:31UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [th1FabricIndex copy]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = + [NSNumber numberWithUnsignedInt:29UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [th1FabricIndex copy]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]: Error: %@", err); + } else { + NSLog(@"Step 5: TH1 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field:[{Cluster: AccessControl (0x001f), Endpoint: 0}] 2.struct : a)Fabric Index: 1 b)Privilege field: View (1) c)AuthMode field: CASE (2) d)Subjects field: null e)Targets field: [{Cluster: Descriptor (0x001d), Endpoint: 0}]: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull commissionerNodeIdBeta; + + CHIP_ERROR TestReadTheCommissionerNodeIdFromTheBetaFabric_11() + { + + chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; + return GetCommissionerNodeId("beta", value, ^(const chip::GetCommissionerNodeIdResponse & values) { + { + commissionerNodeIdBeta = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; + } + NextTest(); + }); + } + + CHIP_ERROR TestStep6Th2WritesDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining2Elements1StructAFabricIndexTh2FabricIndexBPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn2ETargetsFieldClusterAccessControl0x001fEndpoint0_12() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeIdBeta copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = + [NSNumber numberWithUnsignedInt:31UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [th2FabricIndex copy]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = + [NSNumber numberWithUnsignedInt:40UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [th2FabricIndex copy]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]: Error: %@", err); + } else { + NSLog(@"Step 6: TH2 writes DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 2 elements 1.Struct : a)Fabric Index: th2FabricIndex b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N2] e)Targets field: [{Cluster: AccessControl (0x001f), Endpoint: 0}]: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6Th2WritesAclGivingViewPrivilgeForBasicCluster_13() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep7Th1ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH1 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8Th1ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Error: %@", err); + } else { + NSLog(@"Step 8: TH1 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9Th2ReadsDutEndpoint0DescriptorClusterDeviceTypeListAttribute_16() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Error: %@", err); + } else { + NSLog(@"Step 9: TH2 reads DUT Endpoint 0 Descriptor cluster DeviceTypeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ACCESS)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9Th2ReadsDescriptorClusterExpectUnsupportedAccess_17() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttribute_18() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Error: %@", err); + } else { + NSLog(@"Step 10: TH2 reads DUT Endpoint 0 Basic Information cluster VendorID attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10Th2ReadsDutEndpoint0BasicInformationClusterVendorIDAttributeExpectSuccess_19() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep11Th1ResetsTheACLsToTheDefaultValueBywritingDutEndpoint0AccessControlClusterAclAttributevalueIsListOfAccessControlEntryStructContaining1Elements1StructAFabricIndex1BPrivilegeFieldAdminister5CAuthModeFieldCase2DSubjectsFieldn1ETargetsFieldNull_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeIdAlpha copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Error: %@", err); + } else { + NSLog(@"Step 11: TH1 resets the ACLs to the default value bywriting DUT Endpoint 0 AccessControl cluster ACL attribute,value is list of AccessControlEntryStruct containing 1 elements 1.Struct : a)Fabric Index: 1 b)Privilege field: Administer (5) c)AuthMode field: CASE (2) d)Subjects field: [N1] e)Targets field: null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandToTheDutWithTheFabricIndexSetToTh2FabricIndex_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; + params.fabricIndex = + [th2FabricIndex copy]; + [cluster removeFabricWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex: Error: %@", err); + } else { + NSLog(@"Step 12: TH1 removes the TH2 fabric by sending the RemoveFabric command to the DUT with the FabricIndex set to th2FabricIndex: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12Th1RemovesTheTh2FabricBySendingTheRemoveFabricCommandtoTheDutWithTheFabricIndexSetToTh2FabricIndex_22() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } +}; + +class Test_TC_AIRQUAL_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_AIRQUAL_1_1() + : TestCommandBridge("Test_TC_AIRQUAL_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_AIRQUAL_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_AIRQUAL_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AIRQUAL_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip("!AIRQUAL.S.F00 && !AIRQUAL.S.F01 && !AIRQUAL.S.F02 && !AIRQUAL.S.F03")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("AIRQUAL.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenAIRQUALSF00FairEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("AIRQUAL.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenAIRQUALSF01ModerateEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("AIRQUAL.S.F02")) { + NextTest(); + return; + } + err = TestStep3dGivenAIRQUALSF02VeryPoorEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("AIRQUAL.S.F03")) { + NextTest(); + return; + } + err = TestStep3eGivenAIRQUALSF03ExtremelyPoorEnsureFeaturemapHasTheCorrectBitSet_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenAIRQUALSF00FairEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given AIRQUAL.S.F00(Fair) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenAIRQUALSF01ModerateEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given AIRQUAL.S.F01(Moderate) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenAIRQUALSF02VeryPoorEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given AIRQUAL.S.F02(VeryPoor) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenAIRQUALSF03ExtremelyPoorEnsureFeaturemapHasTheCorrectBitSet_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3e: Given AIRQUAL.S.F03(ExtremelyPoor) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_AIRQUAL_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_AIRQUAL_2_1() + : TestCommandBridge("Test_TC_AIRQUAL_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_AIRQUAL_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_AIRQUAL_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AIRQUAL_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the AirQuality attribute.\n"); + if (ShouldSkip("AIRQUAL.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheAirQualityAttribute_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheAirQualityAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAirQuality alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAirQualityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the AirQuality attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the AirQuality attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("airQuality", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("airQuality", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("airQuality", [value unsignedCharValue], 6U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_BOOL_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_BOOL_1_1() + : TestCommandBridge("Test_TC_BOOL_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_BOOL_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_BOOL_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BOOL_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Read the global attribute: FeatureMap\n"); + err = TestStep3ReadTheGlobalAttributeFeatureMap_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ReadTheGlobalAttributeAttributeList_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ReadTheGlobalAttributeAttributeList_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: Read the global attribute: EventList\n"); + if (ShouldSkip("BOOL.S.E00 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: Read the global attribute: EventList\n"); + if (ShouldSkip(" !BOOL.S.E00 && PICS_EVENT_LIST_ENABLED ")) { + NextTest(); + return; + } + NextTest(); + return; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: Read the global attribute: AcceptedCommandList\n"); + err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: Read the global attribute: GeneratedCommandList\n"); + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ReadTheGlobalAttributeFeatureMap_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: Read the global attribute: FeatureMap: Error: %@", err); + } else { + NSLog(@"Step 3: Read the global attribute: FeatureMap: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_BOOL_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_BOOL_2_1() + : TestCommandBridge("Test_TC_BOOL_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_BOOL_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_BOOL_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BOOL_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the StateValue attribute from the DUT\n"); + if (ShouldSkip("BOOL.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsTheStateValueAttributeFromTheDut_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheStateValueAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBooleanState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStateValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the StateValue attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the StateValue attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("stateValue", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_BRBINFO_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_BRBINFO_1_1() + : TestCommandBridge("Test_TC_BRBINFO_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_BRBINFO_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_BRBINFO_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BRBINFO_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); + err = TestStep2ThReadsTheClusterRevisionFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); + err = TestStep3ThReadsTheFeatureMapFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(VendorName) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A0001")) { + NextTest(); + return; + } + err = TestStep4bThReadsOptionalAttributeVendorNameInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(VendorID) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A0002")) { + NextTest(); + return; + } + err = TestStep4cThReadsOptionalAttributeVendorIDInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(ProductName) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A0003")) { + NextTest(); + return; + } + err = TestStep4dThReadsOptionalAttributeProductNameInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(NodeLabel) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A0005")) { + NextTest(); + return; + } + err = TestStep4eThReadsOptionalAttributeNodeLabelInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A0007")) { + NextTest(); + return; + } + err = TestStep4fThReadsOptionalAttributeHardwareVersionInAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A0008")) { + NextTest(); + return; + } + err = TestStep4gThReadsOptionalAttributeHardwareVersionStringInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A0009")) { + NextTest(); + return; + } + err = TestStep4hThReadsOptionalAttributeSoftwareVersionInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A000a")) { + NextTest(); + return; + } + err = TestStep4iThReadsOptionalAttributeSoftwareVersionStringInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A000b")) { + NextTest(); + return; + } + err = TestStep4jThReadsOptionalAttributeManufacturingDateInAttributeList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4k: TH reads optional attribute(PartNumber) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A000c")) { + NextTest(); + return; + } + err = TestStep4kThReadsOptionalAttributePartNumberInAttributeList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4l: TH reads optional attribute(ProductURL) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A000d")) { + NextTest(); + return; + } + err = TestStep4lThReadsOptionalAttributeProductURLInAttributeList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4m: TH reads optional attribute(ProductLabel) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A000e")) { + NextTest(); + return; + } + err = TestStep4mThReadsOptionalAttributeProductLabelInAttributeList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4n: TH reads optional attribute(SerialNumber) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A000f")) { + NextTest(); + return; + } + err = TestStep4nThReadsOptionalAttributeSerialNumberInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4o: TH reads optional attribute(UniqueID) in AttributeList\n"); + if (ShouldSkip("BRBINFO.S.A0012")) { + NextTest(); + return; + } + err = TestStep4oThReadsOptionalAttributeUniqueIDInAttributeList_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5a: TH reads optional event(StartUp) in EventList\n"); + if (ShouldSkip("BRBINFO.S.E00 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5b: TH reads optional attribute(ShutDown) in EventList\n"); + if (ShouldSkip("BRBINFO.S.E01 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5c: TH reads optional attribute(Leave) in EventList\n"); + if (ShouldSkip("BRBINFO.S.E02 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 6: TH reads AcceptedCommandList from DUT\n"); + err = TestStep6ThReadsAcceptedCommandListFromDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 7: TH1 reads GeneratedCommandList from DUT\n"); + err = TestStep7Th1ReadsGeneratedCommandListFromDut_23(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 24; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsOptionalAttributeVendorNameInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads optional attribute(VendorName) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads optional attribute(VendorName) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsOptionalAttributeVendorIDInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads optional attribute(VendorID) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads optional attribute(VendorID) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsOptionalAttributeProductNameInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads optional attribute(ProductName) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads optional attribute(ProductName) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsOptionalAttributeNodeLabelInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads optional attribute(NodeLabel) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads optional attribute(NodeLabel) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsOptionalAttributeHardwareVersionInAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads optional attribute(HardwareVersion) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThReadsOptionalAttributeHardwareVersionStringInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4g: TH reads optional attribute(HardwareVersionString) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsOptionalAttributeSoftwareVersionInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads optional attribute(SoftwareVersion) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThReadsOptionalAttributeSoftwareVersionStringInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads optional attribute(SoftwareVersionString) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsOptionalAttributeManufacturingDateInAttributeList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads optional attribute(ManufacturingDate) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kThReadsOptionalAttributePartNumberInAttributeList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: TH reads optional attribute(PartNumber) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4k: TH reads optional attribute(PartNumber) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4lThReadsOptionalAttributeProductURLInAttributeList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4l: TH reads optional attribute(ProductURL) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4l: TH reads optional attribute(ProductURL) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4mThReadsOptionalAttributeProductLabelInAttributeList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4m: TH reads optional attribute(ProductLabel) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4m: TH reads optional attribute(ProductLabel) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4nThReadsOptionalAttributeSerialNumberInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4n: TH reads optional attribute(SerialNumber) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4n: TH reads optional attribute(SerialNumber) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4oThReadsOptionalAttributeUniqueIDInAttributeList_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4o: TH reads optional attribute(UniqueID) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4o: TH reads optional attribute(UniqueID) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7Th1ReadsGeneratedCommandListFromDut_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBridgedDeviceBasicInformation alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH1 reads GeneratedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH1 reads GeneratedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ACT_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ACT_1_1() + : TestCommandBridge("Test_TC_ACT_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ACT_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACT_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACT_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Read the global attribute: FeatureMap\n"); + err = TestStep3ReadTheGlobalAttributeFeatureMap_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: Read the optional attribute(SetupURL) in AttributeList\n"); + if (ShouldSkip("ACT.S.A0002")) { + NextTest(); + return; + } + err = TestStep4bReadTheOptionalAttributeSetupURLInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads EventList attribute from DUT\n"); + if (ShouldSkip("PICS_USER_PROMPT && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep5ThReadsEventListAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: Read the global attribute: AcceptedCommandList\n"); + err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: Read the global attribute: GeneratedCommandList\n"); + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ReadTheGlobalAttributeFeatureMap_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: Read the global attribute: FeatureMap: Error: %@", err); + } else { + NSLog(@"Step 3: Read the global attribute: FeatureMap: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheOptionalAttributeSetupURLInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the optional attribute(SetupURL) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the optional attribute(SetupURL) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsEventListAttributeFromDut_6() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintMaxLength("acceptedCommandList", value, 11)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActions alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_BIND_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_BIND_1_1() + : TestCommandBridge("Test_TC_BIND_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_BIND_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_BIND_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BIND_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); + err = TestStep2ThReadsTheClusterRevisionFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); + err = TestStep3ThReadsTheFeatureMapFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads AttributeList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsAttributeListFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads AttributeList from DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsAttributeListFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads EventList attribute from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); + err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); + err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsAttributeListFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsAttributeListFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_1_1() + : TestCommandBridge("Test_TC_CC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); + err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); + if (ShouldSkip("( !CC.S.F00 && !CC.S.F01 && !CC.S.F02 && !CC.S.F03 && !CC.S.F04 )")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenCcsf00hsEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenCCSF01EHueEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CC.S.F02")) { + NextTest(); + return; + } + err = TestStep3dGivenCcsf02clEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestStep3eGivenCcsf03xyEnsureFeaturemapHasTheCorrectBitSet_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CC.S.F04")) { + NextTest(); + return; + } + err = TestStep3fGivenCcsf04ctEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep4bThReadsFeatureDependentAttributeCurrentHueInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep4cThReadsFeatureDependentAttributeCurrentSaturationInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList\n"); + if (ShouldSkip("CC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheOptionalAttributeRemainingTimeInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003")) { + NextTest(); + return; + } + err = TestStep4eThReadsFeatureDependentAttributeCurrentXInAttributeList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004")) { + NextTest(); + return; + } + err = TestStep4fThReadsFeatureDependentAttributeCurrentYInAttributeList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList\n"); + if (ShouldSkip("CC.S.A0005")) { + NextTest(); + return; + } + err = TestStep4gThReadsTheOptionalAttributeDriftCompensationInAttributeList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4h: TH reads the optional attribute(CompensationText) in AttributeList\n"); + if (ShouldSkip("CC.S.A0006")) { + NextTest(); + return; + } + err = TestStep4hThReadsTheOptionalAttributeCompensationTextInAttributeList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { + NextTest(); + return; + } + err = TestStep4iThReadsFeatureDependentAttributeColorTemperatureMiredsInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4j: TH reads the Primary1X attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0011")) { + NextTest(); + return; + } + err = TestStep4jThReadsThePrimary1XAttributeInAttributeList_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4k: TH reads the Primary1Y attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0012")) { + NextTest(); + return; + } + err = TestStep4kThReadsThePrimary1YAttributeInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4l: TH reads the Primary1Intensity attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0013")) { + NextTest(); + return; + } + err = TestStep4lThReadsThePrimary1IntensityAttributeInAttributeList_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4m: TH reads the Primary2X attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0015")) { + NextTest(); + return; + } + err = TestStep4mThReadsThePrimary2XAttributeInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4n: TH reads the Primary2Y attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0016")) { + NextTest(); + return; + } + err = TestStep4nThReadsThePrimary2YAttributeInAttributeList_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4o: TH reads the Primary2Intensity attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0017")) { + NextTest(); + return; + } + err = TestStep4oThReadsThePrimary2IntensityAttributeInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4p: TH reads the Primary3X attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0019")) { + NextTest(); + return; + } + err = TestStep4pThReadsThePrimary3XAttributeInAttributeList_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4q: TH reads the Primary3Y attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A001a")) { + NextTest(); + return; + } + err = TestStep4qThReadsThePrimary3YAttributeInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4r: TH reads the Primary3Intensity attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A001b")) { + NextTest(); + return; + } + err = TestStep4rThReadsThePrimary3IntensityAttributeInAttributeList_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4s: TH reads the Primary4X attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0020")) { + NextTest(); + return; + } + err = TestStep4sThReadsThePrimary4XAttributeInAttributeList_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4t: TH reads the Primary4Y attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0021")) { + NextTest(); + return; + } + err = TestStep4tThReadsThePrimary4YAttributeInAttributeList_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4u: TH reads the Primary4Intensity attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0022")) { + NextTest(); + return; + } + err = TestStep4uThReadsThePrimary4IntensityAttributeInAttributeList_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4v: TH reads the Primary5X attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0024")) { + NextTest(); + return; + } + err = TestStep4vThReadsThePrimary5XAttributeInAttributeList_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4w: TH reads the Primary5Y attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0025")) { + NextTest(); + return; + } + err = TestStep4wThReadsThePrimary5YAttributeInAttributeList_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4x: TH reads the Primary5Intensity attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0026")) { + NextTest(); + return; + } + err = TestStep4xThReadsThePrimary5IntensityAttributeInAttributeList_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4y: TH reads the Primary6X attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0028")) { + NextTest(); + return; + } + err = TestStep4yThReadsThePrimary6XAttributeInAttributeList_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4z: TH reads the Primary6Y attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A0029")) { + NextTest(); + return; + } + err = TestStep4zThReadsThePrimary6YAttributeInAttributeList_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4a1: TH reads the Primary6Intensity attribute in AttributeList\n"); + if (ShouldSkip("CC.S.A002a")) { + NextTest(); + return; + } + err = TestStep4a1ThReadsThePrimary6IntensityAttributeInAttributeList_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList\n"); + if (ShouldSkip("CC.S.A0030")) { + NextTest(); + return; + } + err = TestStep4a2ThReadsTheOptionalAttributeWhitePointXInAttributeList_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList\n"); + if (ShouldSkip("CC.S.A0031")) { + NextTest(); + return; + } + err = TestStep4a3ThReadsTheOptionalAttributeWhitePointYInAttributeList_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList\n"); + if (ShouldSkip("CC.S.A0032")) { + NextTest(); + return; + } + err = TestStep4a4ThReadsTheOptionalAttributeColorPointRXInAttributeList_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList\n"); + if (ShouldSkip("CC.S.A0033")) { + NextTest(); + return; + } + err = TestStep4a5ThReadsTheOptionalAttributeColorPointRYInAttributeList_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList\n"); + if (ShouldSkip("CC.S.A0034")) { + NextTest(); + return; + } + err = TestStep4a6ThReadsTheOptionalAttributeColorPointRIntensityInAttributeList_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList\n"); + if (ShouldSkip("CC.S.A0036")) { + NextTest(); + return; + } + err = TestStep4a7ThReadsTheOptionalAttributeColorPointGXInAttributeList_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList\n"); + if (ShouldSkip("CC.S.A0037")) { + NextTest(); + return; + } + err = TestStep4a8ThReadsTheOptionalAttributeColorPointGYInAttributeList_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList\n"); + if (ShouldSkip("CC.S.A0038")) { + NextTest(); + return; + } + err = TestStep4a9ThReadsTheOptionalAttributeColorPointGIntensityInAttributeList_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList\n"); + if (ShouldSkip("CC.S.A003a")) { + NextTest(); + return; + } + err = TestStep4a10ThReadsTheOptionalAttributeColorPointBXInAttributeList_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList\n"); + if (ShouldSkip("CC.S.A003b")) { + NextTest(); + return; + } + err = TestStep4a11ThReadsTheOptionalAttributeColorPointBYInAttributeList_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList\n"); + if (ShouldSkip("CC.S.A003c")) { + NextTest(); + return; + } + err = TestStep4a12ThReadsTheOptionalAttributeColorPointBIntensityInAttributeList_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { + NextTest(); + return; + } + err = TestStep4a13ThReadsFeatureDependentAttributeEnhancedCurrentHueInAttributeList_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList\n"); + if (ShouldSkip("CC.S.F02 && CC.S.A4002")) { + NextTest(); + return; + } + err = TestStep4a14ThReadsFeatureDependentAttributeColorLoopActiveInAttributeList_48(); + break; + case 49: + ChipLogProgress(chipTool, " ***** Test Step 49 : Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList\n"); + if (ShouldSkip("CC.S.F02 && CC.S.A4003")) { + NextTest(); + return; + } + err = TestStep4a15ThReadsFeatureDependentAttributeColorLoopDirectionInAttributeList_49(); + break; + case 50: + ChipLogProgress(chipTool, " ***** Test Step 50 : Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList\n"); + if (ShouldSkip("CC.S.F02 && CC.S.A4004")) { + NextTest(); + return; + } + err = TestStep4a16ThReadsFeatureDependentAttributeColorLoopTimeInAttributeList_50(); + break; + case 51: + ChipLogProgress(chipTool, " ***** Test Step 51 : Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList\n"); + if (ShouldSkip("CC.S.F02 && CC.S.A4005")) { + NextTest(); + return; + } + err = TestStep4a17ThReadsFeatureDependentAttributeColorLoopStartEnhancedHueInAttributeList_51(); + break; + case 52: + ChipLogProgress(chipTool, " ***** Test Step 52 : Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList\n"); + if (ShouldSkip("CC.S.F02 && CC.S.A4006")) { + NextTest(); + return; + } + err = TestStep4a18ThReadsFeatureDependentAttributeColorLoopStoredEnhancedHueInAttributeList_52(); + break; + case 53: + ChipLogProgress(chipTool, " ***** Test Step 53 : Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { + NextTest(); + return; + } + err = TestStep4a19ThReadsFeatureDependentAttributeColorTempPhysicalMinMiredsInAttributeList_53(); + break; + case 54: + ChipLogProgress(chipTool, " ***** Test Step 54 : Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { + NextTest(); + return; + } + err = TestStep4a20ThReadsFeatureDependentAttributeColorTempPhysicalMaxMiredsInAttributeList_54(); + break; + case 55: + ChipLogProgress(chipTool, " ***** Test Step 55 : Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A400d")) { + NextTest(); + return; + } + err = TestStep4a21THReadsFeatureDependentAttributeCoupleColorTempToLevelMinMiredsInAttributeList_55(); + break; + case 56: + ChipLogProgress(chipTool, " ***** Test Step 56 : Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A4010")) { + NextTest(); + return; + } + err = TestStep4a22ThReadsFeatureDependentAttributeStartUpColorTemperatureMiredsInAttributeList_56(); + break; + case 57: + ChipLogProgress(chipTool, " ***** Test Step 57 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 58: + ChipLogProgress(chipTool, " ***** Test Step 58 : Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6aThReadsFeatureDependentCommandMoveToHueInAcceptedCommandList_58(); + break; + case 59: + ChipLogProgress(chipTool, " ***** Test Step 59 : Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep6bThReadsFeatureDependentCommandMoveHueInAcceptedCommandList_59(); + break; + case 60: + ChipLogProgress(chipTool, " ***** Test Step 60 : Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep6cThReadsFeatureDependentCommandStepHueInAcceptedCommandList_60(); + break; + case 61: + ChipLogProgress(chipTool, " ***** Test Step 61 : Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep6dThReadsFeatureDependentCommandMoveToSaturationInAcceptedCommandList_61(); + break; + case 62: + ChipLogProgress(chipTool, " ***** Test Step 62 : Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep6eThReadsFeatureDependentCommandMoveSaturationInAcceptedCommandList_62(); + break; + case 63: + ChipLogProgress(chipTool, " ***** Test Step 63 : Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep6fThReadsFeatureDependentCommandStepSaturationInAcceptedCommandList_63(); + break; + case 64: + ChipLogProgress(chipTool, " ***** Test Step 64 : Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep6gThReadsFeatureDependentCommandMoveToHueAndSaturationInAcceptedCommandList_64(); + break; + case 65: + ChipLogProgress(chipTool, " ***** Test Step 65 : Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep6hThReadsFeatureDependentCommandMoveToColorInAcceptedCommandList_65(); + break; + case 66: + ChipLogProgress(chipTool, " ***** Test Step 66 : Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep6iThReadsFeatureDependentCommandMoveColorInAcceptedCommandList_66(); + break; + case 67: + ChipLogProgress(chipTool, " ***** Test Step 67 : Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C09.Rsp")) { + NextTest(); + return; + } + err = TestStep6jThReadsFeatureDependentCommandStepColorInAcceptedCommandList_67(); + break; + case 68: + ChipLogProgress(chipTool, " ***** Test Step 68 : Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { + NextTest(); + return; + } + err = TestStep6kThReadsFeatureDependentCommandMoveToColorTemperatureInAcceptedCommandList_68(); + break; + case 69: + ChipLogProgress(chipTool, " ***** Test Step 69 : Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep6lThReadsFeatureDependentCommandEnhancedMoveToHueInAcceptedCommandList_69(); + break; + case 70: + ChipLogProgress(chipTool, " ***** Test Step 70 : Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F01 && CC.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep6mThReadsFeatureDependentCommandEnhancedMoveHueInAcceptedCommandList_70(); + break; + case 71: + ChipLogProgress(chipTool, " ***** Test Step 71 : Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { + NextTest(); + return; + } + err = TestStep6nThReadsFeatureDependentCommandEnhancedStepHueInAcceptedCommandList_71(); + break; + case 72: + ChipLogProgress(chipTool, " ***** Test Step 72 : Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { + NextTest(); + return; + } + err = TestStep6oTHReadsFeatureDependentCommandEnhancedMoveToHueAndSaturationInAcceptedCommandList_72(); + break; + case 73: + ChipLogProgress(chipTool, " ***** Test Step 73 : Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F02 && CC.S.C44.Rsp")) { + NextTest(); + return; + } + err = TestStep6pThReadsFeatureDependentCommandColorLoopSetInAcceptedCommandList_73(); + break; + case 74: + ChipLogProgress(chipTool, " ***** Test Step 74 : Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F00 && CC.S.F03 && CC.S.F04 && CC.S.C47.Rsp")) { + NextTest(); + return; + } + err = TestStep6qThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_74(); + break; + case 75: + ChipLogProgress(chipTool, " ***** Test Step 75 : Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F04 && CC.S.C4b.Rsp")) { + NextTest(); + return; + } + err = TestStep6rThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_75(); + break; + case 76: + ChipLogProgress(chipTool, " ***** Test Step 76 : Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList\n"); + if (ShouldSkip("CC.S.F04 && CC.S.C4c.Rsp")) { + NextTest(); + return; + } + err = TestStep6sThReadsFeatureDependentCommandStepColorTemperatureInAcceptedCommandList_76(); + break; + case 77: + ChipLogProgress(chipTool, " ***** Test Step 77 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); + err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_77(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 49: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 50: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 51: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 52: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 53: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 54: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 55: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 56: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 57: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 58: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 59: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 60: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 61: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 62: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 63: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 64: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 65: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 66: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 67: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 68: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 69: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 70: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 71: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 72: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 73: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 74: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 75: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 76: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 77: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 78; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 6U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenCcsf00hsEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given CC.S.F00(HS) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenCCSF01EHueEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given CC.S.F01(EHue) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenCcsf02clEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given CC.S.F02(CL) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenCcsf03xyEnsureFeaturemapHasTheCorrectBitSet_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3e: Given CC.S.F03(XY) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenCcsf04ctEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given CC.S.F04(CT) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16394UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16394UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeCurrentHueInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads feature dependent attribute (CurrentHue) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeCurrentSaturationInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads feature dependent attribute (CurrentSaturation) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheOptionalAttributeRemainingTimeInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the optional attribute(RemainingTime) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsFeatureDependentAttributeCurrentXInAttributeList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads feature dependent attribute (CurrentX) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsFeatureDependentAttributeCurrentYInAttributeList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads feature dependent attribute (CurrentY) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThReadsTheOptionalAttributeDriftCompensationInAttributeList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4g: TH reads the optional attribute(DriftCompensation) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsTheOptionalAttributeCompensationTextInAttributeList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads the optional attribute(CompensationText) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads the optional attribute(CompensationText) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThReadsFeatureDependentAttributeColorTemperatureMiredsInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads feature dependent attribute (ColorTemperatureMireds) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsThePrimary1XAttributeInAttributeList_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads the Primary1X attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads the Primary1X attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kThReadsThePrimary1YAttributeInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: TH reads the Primary1Y attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4k: TH reads the Primary1Y attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4lThReadsThePrimary1IntensityAttributeInAttributeList_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4l: TH reads the Primary1Intensity attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4l: TH reads the Primary1Intensity attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4mThReadsThePrimary2XAttributeInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4m: TH reads the Primary2X attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4m: TH reads the Primary2X attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4nThReadsThePrimary2YAttributeInAttributeList_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4n: TH reads the Primary2Y attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4n: TH reads the Primary2Y attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4oThReadsThePrimary2IntensityAttributeInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4o: TH reads the Primary2Intensity attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4o: TH reads the Primary2Intensity attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4pThReadsThePrimary3XAttributeInAttributeList_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4p: TH reads the Primary3X attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4p: TH reads the Primary3X attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4qThReadsThePrimary3YAttributeInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4q: TH reads the Primary3Y attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4q: TH reads the Primary3Y attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4rThReadsThePrimary3IntensityAttributeInAttributeList_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4r: TH reads the Primary3Intensity attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4r: TH reads the Primary3Intensity attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4sThReadsThePrimary4XAttributeInAttributeList_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4s: TH reads the Primary4X attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4s: TH reads the Primary4X attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4tThReadsThePrimary4YAttributeInAttributeList_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4t: TH reads the Primary4Y attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4t: TH reads the Primary4Y attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4uThReadsThePrimary4IntensityAttributeInAttributeList_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4u: TH reads the Primary4Intensity attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4u: TH reads the Primary4Intensity attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4vThReadsThePrimary5XAttributeInAttributeList_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4v: TH reads the Primary5X attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4v: TH reads the Primary5X attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4wThReadsThePrimary5YAttributeInAttributeList_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4w: TH reads the Primary5Y attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4w: TH reads the Primary5Y attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4xThReadsThePrimary5IntensityAttributeInAttributeList_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4x: TH reads the Primary5Intensity attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4x: TH reads the Primary5Intensity attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4yThReadsThePrimary6XAttributeInAttributeList_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4y: TH reads the Primary6X attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4y: TH reads the Primary6X attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4zThReadsThePrimary6YAttributeInAttributeList_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4z: TH reads the Primary6Y attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4z: TH reads the Primary6Y attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a1ThReadsThePrimary6IntensityAttributeInAttributeList_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a1: TH reads the Primary6Intensity attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a1: TH reads the Primary6Intensity attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a2ThReadsTheOptionalAttributeWhitePointXInAttributeList_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a2: TH reads the optional attribute(WhitePointX) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a3ThReadsTheOptionalAttributeWhitePointYInAttributeList_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a3: TH reads the optional attribute(WhitePointY) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a4ThReadsTheOptionalAttributeColorPointRXInAttributeList_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a4: TH reads the optional attribute(ColorPointRX) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a5ThReadsTheOptionalAttributeColorPointRYInAttributeList_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a5: TH reads the optional attribute(ColorPointRY) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a6ThReadsTheOptionalAttributeColorPointRIntensityInAttributeList_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a6: TH reads the optional attribute(ColorPointRIntensity) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a7ThReadsTheOptionalAttributeColorPointGXInAttributeList_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a7: TH reads the optional attribute(ColorPointGX) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a8ThReadsTheOptionalAttributeColorPointGYInAttributeList_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a8: TH reads the optional attribute(ColorPointGY) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a9ThReadsTheOptionalAttributeColorPointGIntensityInAttributeList_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a9: TH reads the optional attribute(ColorPointGIntensity) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a10ThReadsTheOptionalAttributeColorPointBXInAttributeList_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a10: TH reads the optional attribute(ColorPointBX) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a11ThReadsTheOptionalAttributeColorPointBYInAttributeList_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a11: TH reads the optional attribute(ColorPointBY) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a12ThReadsTheOptionalAttributeColorPointBIntensityInAttributeList_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a12: TH reads the optional attribute(ColorPointBIntensity) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a13ThReadsFeatureDependentAttributeEnhancedCurrentHueInAttributeList_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a13: TH reads feature dependent attribute (EnhancedCurrentHue) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a14ThReadsFeatureDependentAttributeColorLoopActiveInAttributeList_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a14: TH reads feature dependent attribute (ColorLoopActive) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16386UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a15ThReadsFeatureDependentAttributeColorLoopDirectionInAttributeList_49() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a15: TH reads feature dependent attribute (ColorLoopDirection) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16387UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a16ThReadsFeatureDependentAttributeColorLoopTimeInAttributeList_50() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a16: TH reads feature dependent attribute (ColorLoopTime) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16388UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a17ThReadsFeatureDependentAttributeColorLoopStartEnhancedHueInAttributeList_51() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a17: TH reads feature dependent attribute (ColorLoopStartEnhancedHue) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16389UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a18ThReadsFeatureDependentAttributeColorLoopStoredEnhancedHueInAttributeList_52() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a18: TH reads feature dependent attribute (ColorLoopStoredEnhancedHue) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16390UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a19ThReadsFeatureDependentAttributeColorTempPhysicalMinMiredsInAttributeList_53() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a19: TH reads feature dependent attribute (ColorTempPhysicalMinMireds) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16395UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a20ThReadsFeatureDependentAttributeColorTempPhysicalMaxMiredsInAttributeList_54() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a20: TH reads feature dependent attribute (ColorTempPhysicalMaxMireds) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16396UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a21THReadsFeatureDependentAttributeCoupleColorTempToLevelMinMiredsInAttributeList_55() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a21:TH reads feature dependent attribute (CoupleColorTempToLevelMinMireds) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16397UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a22ThReadsFeatureDependentAttributeStartUpColorTemperatureMiredsInAttributeList_56() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a22: TH reads feature dependent attribute (StartUpColorTemperatureMireds) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16400UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsFeatureDependentCommandMoveToHueInAcceptedCommandList_58() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads feature dependent command(MoveToHue) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsFeatureDependentCommandMoveHueInAcceptedCommandList_59() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads feature dependent command(MoveHue) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cThReadsFeatureDependentCommandStepHueInAcceptedCommandList_60() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6c: TH reads feature dependent command(StepHue) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6dThReadsFeatureDependentCommandMoveToSaturationInAcceptedCommandList_61() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6d: TH reads feature dependent command(MoveToSaturation) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6eThReadsFeatureDependentCommandMoveSaturationInAcceptedCommandList_62() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6e: TH reads feature dependent command(MoveSaturation) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6fThReadsFeatureDependentCommandStepSaturationInAcceptedCommandList_63() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6f: TH reads feature dependent command(StepSaturation) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6gThReadsFeatureDependentCommandMoveToHueAndSaturationInAcceptedCommandList_64() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6g: TH reads feature dependent command(MoveToHueAndSaturation) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6hThReadsFeatureDependentCommandMoveToColorInAcceptedCommandList_65() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6h: TH reads feature dependent command(MoveToColor) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6iThReadsFeatureDependentCommandMoveColorInAcceptedCommandList_66() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6i: TH reads feature dependent command(MoveColor) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6jThReadsFeatureDependentCommandStepColorInAcceptedCommandList_67() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6j: TH reads feature dependent command(StepColor) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6kThReadsFeatureDependentCommandMoveToColorTemperatureInAcceptedCommandList_68() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6k: TH reads feature dependent command(MoveToColorTemperature) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6lThReadsFeatureDependentCommandEnhancedMoveToHueInAcceptedCommandList_69() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6l: TH reads feature dependent command(EnhancedMoveToHue) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6mThReadsFeatureDependentCommandEnhancedMoveHueInAcceptedCommandList_70() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6m: TH reads feature dependent command(EnhancedMoveHue) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 65UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6nThReadsFeatureDependentCommandEnhancedStepHueInAcceptedCommandList_71() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6n: TH reads feature dependent command(EnhancedStepHue) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 66UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6oTHReadsFeatureDependentCommandEnhancedMoveToHueAndSaturationInAcceptedCommandList_72() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6o:TH reads feature dependent command(EnhancedMoveToHueAndSaturation) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 67UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6pThReadsFeatureDependentCommandColorLoopSetInAcceptedCommandList_73() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6p: TH reads feature dependent command(ColorLoopSet) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 68UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6qThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_74() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6q: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 71UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6rThReadsFeatureDependentCommandStopMoveStepInAcceptedCommandList_75() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6r: TH reads feature dependent command(StopMoveStep) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 75UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6sThReadsFeatureDependentCommandStepColorTemperatureInAcceptedCommandList_76() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6s: TH reads feature dependent command(StepColorTemperature) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 76UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_77() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_2_1() + : TestCommandBridge("Test_TC_CC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute\n"); + if (ShouldSkip("CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutThe0x0000CurrentHueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute\n"); + if (ShouldSkip("CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutThe0x0001CurrentSaturationAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute\n"); + if (ShouldSkip("CC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutThe0x0002RemainingTimeAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the (0x0003) CurrentX attribute\n"); + if (ShouldSkip("CC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThe0x0003CurrentXAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the (0x0004) CurrentY attribute\n"); + if (ShouldSkip("CC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThe0x0004CurrentYAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute\n"); + if (ShouldSkip("CC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutThe0x0005DriftCompensationAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the (0x0006) CompensationText attribute\n"); + if (ShouldSkip("CC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutThe0x0006CompensationTextAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute\n"); + if (ShouldSkip("CC.S.A0007")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutThe0x0007ColorTemperatureMiredsAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the (0x0008) ColorMode attribute\n"); + if (ShouldSkip("CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutThe0x0008ColorModeAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the (0x000f) Options attribute\n"); + if (ShouldSkip("CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutThe0x000fOptionsAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute\n"); + if (ShouldSkip("CC.S.A4000")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutThe0x4000EnhancedCurrentHueAttribute_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute\n"); + if (ShouldSkip("CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep13ThReadsFromTheDutThe0x4001EnhancedColorModeAttribute_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute\n"); + if (ShouldSkip("CC.S.A4002")) { + NextTest(); + return; + } + err = TestStep14thReadsFromTheDutThe0x4002ColorLoopActiveAttribute_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute\n"); + if (ShouldSkip("CC.S.A4003")) { + NextTest(); + return; + } + err = TestStep15ThReadsFromTheDutThe0x4003ColorLoopDirectionAttribute_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute\n"); + if (ShouldSkip("CC.S.A4004")) { + NextTest(); + return; + } + err = TestStep16ThReadsFromTheDutThe0x4004ColorLoopTimeAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute\n"); + if (ShouldSkip("CC.S.A4005")) { + NextTest(); + return; + } + err = TestStep17ThReadsFromTheDutThe0x4005ColorLoopStartEnhancedHueAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT\n"); + if (ShouldSkip("CC.S.A4006")) { + NextTest(); + return; + } + err = TestStep18ThReadsFromTheDutThe0x4006ColorLoopStoredEnhancedHueAttributeT_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT\n"); + err = TestStep18aSavingForComparisionInStep19ReadsFeatureMapAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute\n"); + if (ShouldSkip("CC.S.A400a")) { + NextTest(); + return; + } + err = TestStep19ThReadsFromTheDutThe0x400aColorCapabilitiesAttribute_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute\n"); + if (ShouldSkip("CC.S.A400b")) { + NextTest(); + return; + } + err = TestStep20ThReadsFromTheDutThe0x400bColorTempPhysicalMinMiredsAttribute_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute\n"); + if (ShouldSkip("CC.S.A400c")) { + NextTest(); + return; + } + err = TestStep21ThReadsFromTheDutThe0x400cColorTempPhysicalMaxMiredsAttribute_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute\n"); + if (ShouldSkip("CC.S.A400d")) { + NextTest(); + return; + } + err = TestStep22ThReadsFromTheDutThe0x400dCoupleColorTempToLevelMinMiredsAttribute_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute\n"); + if (ShouldSkip("CC.S.A4010")) { + NextTest(); + return; + } + err = TestStep23ThReadsFromTheDutThe0x4010StartUpColorTemperatureMiredsAttribute_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute\n"); + if (ShouldSkip("CC.S.A0010")) { + NextTest(); + return; + } + err = TestStep24ThReadsFromTheDutThe0x0010NumberOfPrimariesAttribute_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 25: TH reads Primary1X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 1 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0011")) { + NextTest(); + return; + } + err = TestStep25ThReadsPrimary1XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 26: TH reads Primary1Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 1 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0012")) { + NextTest(); + return; + } + err = TestStep26ThReadsPrimary1YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 27: TH reads Primary1Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 1 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0013")) { + NextTest(); + return; + } + err = TestStep27ThReadsPrimary1IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs1OrMore_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 28: TH reads Primary2X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 2 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0015")) { + NextTest(); + return; + } + err = TestStep28ThReadsPrimary2XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 29: TH reads Primary2Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 2 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0016")) { + NextTest(); + return; + } + err = TestStep29ThReadsPrimary2YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Step 30: TH reads Primary2Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 2 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0017")) { + NextTest(); + return; + } + err = TestStep30ThReadsPrimary2IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs2OrMore_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 31: TH reads Primary3X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 3 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0019")) { + NextTest(); + return; + } + err = TestStep31ThReadsPrimary3XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Step 32: TH reads Primary3Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 3 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A001a")) { + NextTest(); + return; + } + err = TestStep32ThReadsPrimary3YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Step 33: TH reads Primary3Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 3 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A001b")) { + NextTest(); + return; + } + err = TestStep33ThReadsPrimary3IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs3OrMore_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Step 34: TH reads Primary4X attribute from DUT Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 4 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0020")) { + NextTest(); + return; + } + err = TestStep34ThReadsPrimary4XAttributeFromDutVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Step 35: TH reads Primary4Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 4 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0021")) { + NextTest(); + return; + } + err = TestStep35ThReadsPrimary4YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Step 36: TH reads Primary4Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 4 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0022")) { + NextTest(); + return; + } + err = TestStep36ThReadsPrimary4IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs4OrMore_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Step 37: TH reads Primary5X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 5 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0024")) { + NextTest(); + return; + } + err = TestStep37ThReadsPrimary5XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Step 38: TH reads Primary5Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 5 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0025")) { + NextTest(); + return; + } + err = TestStep38ThReadsPrimary5YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Step 39: TH reads Primary5Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 5 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0026")) { + NextTest(); + return; + } + err = TestStep39ThReadsPrimary5IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs5OrMore_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Step 40: TH reads Primary6X attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 6 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0028")) { + NextTest(); + return; + } + err = TestStep40ThReadsPrimary6XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Step 41: TH reads Primary6Y attribute from DUT and Verify that the DUT response contains an uint16 [Min:0 Max:0xfeff] if NumberOfPrimaries is 6 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A0029")) { + NextTest(); + return; + } + err = TestStep41ThReadsPrimary6YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Step 42: TH reads Primary6Intensity attribute from DUT and Verify that the DUT response contains an uint8 if NumberOfPrimaries is 6 or more\n"); + if (ShouldSkip("PICS_USER_PROMPT && CC.S.A002a")) { + NextTest(); + return; + } + err = TestStep42ThReadsPrimary6IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs6OrMore_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute\n"); + if (ShouldSkip("CC.S.A0030")) { + NextTest(); + return; + } + err = TestStep43ThReadsFromTheDutThe0x0030WhitePointXAttribute_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute\n"); + if (ShouldSkip("CC.S.A0031")) { + NextTest(); + return; + } + err = TestStep44ThReadsFromTheDutThe0x0031WhitePointYAttribute_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute\n"); + if (ShouldSkip("CC.S.A0032")) { + NextTest(); + return; + } + err = TestStep45ThReadsFromTheDutThe0x0032ColorPointRXAttribute_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute\n"); + if (ShouldSkip("CC.S.A0033")) { + NextTest(); + return; + } + err = TestStep46ThReadsFromTheDutThe0x0033ColorPointRYAttribute_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute\n"); + if (ShouldSkip("CC.S.A0034")) { + NextTest(); + return; + } + err = TestStep47ThReadsFromTheDutThe0x0034ColorPointRIntensityAttribute_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute\n"); + if (ShouldSkip("CC.S.A0036")) { + NextTest(); + return; + } + err = TestStep48ThReadsFromTheDutThe0x0036ColorPointGXAttribute_48(); + break; + case 49: + ChipLogProgress(chipTool, " ***** Test Step 49 : Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute\n"); + if (ShouldSkip("CC.S.A0037")) { + NextTest(); + return; + } + err = TestStep49ThReadsFromTheDutThe0x0037ColorPointGYAttribute_49(); + break; + case 50: + ChipLogProgress(chipTool, " ***** Test Step 50 : Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute\n"); + if (ShouldSkip("CC.S.A0038")) { + NextTest(); + return; + } + err = TestStep50ThReadsFromTheDutThe0x0038ColorPointGIntensityAttribute_50(); + break; + case 51: + ChipLogProgress(chipTool, " ***** Test Step 51 : Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute\n"); + if (ShouldSkip("CC.S.A003a")) { + NextTest(); + return; + } + err = TestStep51ThReadsFromTheDutThe0x003aColorPointBXAttribute_51(); + break; + case 52: + ChipLogProgress(chipTool, " ***** Test Step 52 : Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute\n"); + if (ShouldSkip("CC.S.A003b")) { + NextTest(); + return; + } + err = TestStep52ThReadsFromTheDutThe0x003bColorPointBYAttribute_52(); + break; + case 53: + ChipLogProgress(chipTool, " ***** Test Step 53 : Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute\n"); + if (ShouldSkip("CC.S.A003c")) { + NextTest(); + return; + } + err = TestStep53ThReadsFromTheDutThe0x003cColorPointBIntensityAttribute_53(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 49: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 50: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 51: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 52: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 53: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 54; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutThe0x0000CurrentHueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the (0x0000) CurrentHue attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentHue", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutThe0x0001CurrentSaturationAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the (0x0001) CurrentSaturation attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentSaturation", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutThe0x0002RemainingTimeAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRemainingTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the (0x0002) RemainingTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("remainingTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("remainingTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("remainingTime", [value unsignedShortValue], 65534U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThe0x0003CurrentXAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the (0x0003) CurrentX attribute: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the (0x0003) CurrentX attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentX", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThe0x0004CurrentYAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the (0x0004) CurrentY attribute: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the (0x0004) CurrentY attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentY", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutThe0x0005DriftCompensationAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDriftCompensationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the (0x0005) DriftCompensation attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("driftCompensation", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("driftCompensation", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("driftCompensation", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutThe0x0006CompensationTextAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCompensationTextWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the (0x0006) CompensationText attribute: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the (0x0006) CompensationText attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("compensationText", "char_string", "char_string")); + VerifyOrReturn(CheckConstraintMaxLength("compensationText", value, 254)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutThe0x0007ColorTemperatureMiredsAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the (0x0007) ColorTemperatureMireds attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutThe0x0008ColorModeAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the (0x0008) ColorMode attribute: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the (0x0008) ColorMode attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorMode", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutThe0x000fOptionsAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the (0x000f) Options attribute: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the (0x000f) Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("options", "bitmap8", "bitmap8")); + VerifyOrReturn(CheckConstraintMinValue("options", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("options", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutThe0x4000EnhancedCurrentHueAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the (0x4000) EnhancedCurrentHue attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13ThReadsFromTheDutThe0x4001EnhancedColorModeAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute: Error: %@", err); + } else { + NSLog(@"Step 13: TH reads from the DUT the (0x4001) EnhancedColorMode attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedColorMode", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep14thReadsFromTheDutThe0x4002ColorLoopActiveAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute: Error: %@", err); + } else { + NSLog(@"Step 14:TH reads from the DUT the (0x4002) ColorLoopActive attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorLoopActive", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("colorLoopActive", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorLoopActive", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep15ThReadsFromTheDutThe0x4003ColorLoopDirectionAttribute_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute: Error: %@", err); + } else { + NSLog(@"Step 15: TH reads from the DUT the (0x4003) ColorLoopDirection attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorLoopDirection", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("colorLoopDirection", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorLoopDirection", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16ThReadsFromTheDutThe0x4004ColorLoopTimeAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute: Error: %@", err); + } else { + NSLog(@"Step 16: TH reads from the DUT the (0x4004) ColorLoopTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorLoopTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorLoopTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorLoopTime", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep17ThReadsFromTheDutThe0x4005ColorLoopStartEnhancedHueAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute: Error: %@", err); + } else { + NSLog(@"Step 17: TH reads from the DUT the (0x4005) ColorLoopStartEnhancedHue attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorLoopStartEnhancedHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorLoopStartEnhancedHue", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorLoopStartEnhancedHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep18ThReadsFromTheDutThe0x4006ColorLoopStoredEnhancedHueAttributeT_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT: Error: %@", err); + } else { + NSLog(@"Step 18: TH reads from the DUT the (0x4006) ColorLoopStoredEnhancedHue attributeT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorLoopStoredEnhancedHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorLoopStoredEnhancedHue", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorLoopStoredEnhancedHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull FeatureMapValue; + + CHIP_ERROR TestStep18aSavingForComparisionInStep19ReadsFeatureMapAttributeFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 18a: Saving for comparision in step 19 reads FeatureMap attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + FeatureMapValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep19ThReadsFromTheDutThe0x400aColorCapabilitiesAttribute_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorCapabilitiesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute: Error: %@", err); + } else { + NSLog(@"Step 19: TH reads from the DUT the (0x400a) ColorCapabilities attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorCapabilities", actualValue, FeatureMapValue)); + } + + VerifyOrReturn(CheckConstraintType("colorCapabilities", "bitmap16", "bitmap16")); + VerifyOrReturn(CheckConstraintMinValue("colorCapabilities", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorCapabilities", [value unsignedShortValue], 31U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep20ThReadsFromTheDutThe0x400bColorTempPhysicalMinMiredsAttribute_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute: Error: %@", err); + } else { + NSLog(@"Step 20: TH reads from the DUT the (0x400b) ColorTempPhysicalMinMireds attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep21ThReadsFromTheDutThe0x400cColorTempPhysicalMaxMiredsAttribute_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute: Error: %@", err); + } else { + NSLog(@"Step 21: TH reads from the DUT the (0x400c) ColorTempPhysicalMaxMireds attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep22ThReadsFromTheDutThe0x400dCoupleColorTempToLevelMinMiredsAttribute_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCoupleColorTempToLevelMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute: Error: %@", err); + } else { + NSLog(@"Step 22: TH reads from the DUT the (0x400d) CoupleColorTempToLevelMinMireds attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("coupleColorTempToLevelMinMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("coupleColorTempToLevelMinMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("coupleColorTempToLevelMinMireds", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep23ThReadsFromTheDutThe0x4010StartUpColorTemperatureMiredsAttribute_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute: Error: %@", err); + } else { + NSLog(@"Step 23: TH reads from the DUT the (0x4010) StartUpColorTemperatureMireds attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep24ThReadsFromTheDutThe0x0010NumberOfPrimariesAttribute_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfPrimariesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute: Error: %@", err); + } else { + NSLog(@"Step 24: TH reads from the DUT the (0x0010) NumberOfPrimaries attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("numberOfPrimaries", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("numberOfPrimaries", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfPrimaries", [value unsignedCharValue], 6U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep25ThReadsPrimary1XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_25() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep26ThReadsPrimary1YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs1OrMore_26() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep27ThReadsPrimary1IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs1OrMore_27() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep28ThReadsPrimary2XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_28() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep29ThReadsPrimary2YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs2OrMore_29() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep30ThReadsPrimary2IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs2OrMore_30() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep31ThReadsPrimary3XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_31() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep32ThReadsPrimary3YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs3OrMore_32() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep33ThReadsPrimary3IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs3OrMore_33() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep34ThReadsPrimary4XAttributeFromDutVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_34() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep35ThReadsPrimary4YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs4OrMore_35() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep36ThReadsPrimary4IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs4OrMore_36() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep37ThReadsPrimary5XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_37() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep38ThReadsPrimary5YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs5OrMore_38() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep39ThReadsPrimary5IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs5OrMore_39() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep40ThReadsPrimary6XAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_40() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep41ThReadsPrimary6YAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint16Min0Max0xfeffIfNumberOfPrimariesIs6OrMore_41() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep42ThReadsPrimary6IntensityAttributeFromDutAndVerifyThatTheDutResponseContainsAnUint8IfNumberOfPrimariesIs6OrMore_42() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep43ThReadsFromTheDutThe0x0030WhitePointXAttribute_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWhitePointXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute: Error: %@", err); + } else { + NSLog(@"Step 43: TH reads from the DUT the (0x0030) WhitePointX attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("whitePointX", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("whitePointX", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("whitePointX", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep44ThReadsFromTheDutThe0x0031WhitePointYAttribute_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWhitePointYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute: Error: %@", err); + } else { + NSLog(@"Step 44: TH reads from the DUT the (0x0031) WhitePointY attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("whitePointY", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("whitePointY", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("whitePointY", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep45ThReadsFromTheDutThe0x0032ColorPointRXAttribute_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorPointRXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute: Error: %@", err); + } else { + NSLog(@"Step 45: TH reads from the DUT the (0x0032) ColorPointRX attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorPointRX", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorPointRX", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorPointRX", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep46ThReadsFromTheDutThe0x0033ColorPointRYAttribute_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorPointRYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute: Error: %@", err); + } else { + NSLog(@"Step 46: TH reads from the DUT the (0x0033) ColorPointRY attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorPointRY", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorPointRY", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorPointRY", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep47ThReadsFromTheDutThe0x0034ColorPointRIntensityAttribute_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorPointRIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute: Error: %@", err); + } else { + NSLog(@"Step 47: TH reads from the DUT the (0x0034) ColorPointRIntensity attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("colorPointRIntensity", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("colorPointRIntensity", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorPointRIntensity", [value unsignedCharValue], 255U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep48ThReadsFromTheDutThe0x0036ColorPointGXAttribute_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorPointGXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute: Error: %@", err); + } else { + NSLog(@"Step 48: TH reads from the DUT the (0x0036) ColorPointGX attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorPointGX", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorPointGX", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorPointGX", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep49ThReadsFromTheDutThe0x0037ColorPointGYAttribute_49() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorPointGYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute: Error: %@", err); + } else { + NSLog(@"Step 49: TH reads from the DUT the (0x0037) ColorPointGY attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorPointGY", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorPointGY", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorPointGY", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep50ThReadsFromTheDutThe0x0038ColorPointGIntensityAttribute_50() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorPointGIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute: Error: %@", err); + } else { + NSLog(@"Step 50: TH reads from the DUT the (0x0038) ColorPointGIntensity attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("colorPointGIntensity", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("colorPointGIntensity", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorPointGIntensity", [value unsignedCharValue], 255U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep51ThReadsFromTheDutThe0x003aColorPointBXAttribute_51() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorPointBXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute: Error: %@", err); + } else { + NSLog(@"Step 51: TH reads from the DUT the (0x003a) ColorPointBX attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorPointBX", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorPointBX", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorPointBX", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep52ThReadsFromTheDutThe0x003bColorPointBYAttribute_52() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorPointBYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute: Error: %@", err); + } else { + NSLog(@"Step 52: TH reads from the DUT the (0x003b) ColorPointBY attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorPointBY", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorPointBY", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorPointBY", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep53ThReadsFromTheDutThe0x003cColorPointBIntensityAttribute_53() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorPointBIntensityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute: Error: %@", err); + } else { + NSLog(@"Step 53: TH reads from the DUT the (0x003c) ColorPointBIntensity attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("colorPointBIntensity", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("colorPointBIntensity", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorPointBIntensity", [value unsignedCharValue], 255U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_3_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_3_2() + : TestCommandBridge("Test_TC_CC_3_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_3_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_3_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_3_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsMoveHueCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep2cThReadsCurrentHueAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2dThReadsCurrentHueAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2fThReadsCurrentHueAttributeFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 2s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait2s_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2g: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2gThReadsCurrentHueAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsMoveToHueCommandToDutWithHue60Direction0x00ShortestDistanceAndTransitionTime0Immediately_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait100ms_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThSendsMoveHueCommandToDutWithMoveMode0x03DownAndRate5UnitsS_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3c: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep3cThReadsCurrentHueAttributeFromDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep3dThReadsCurrentHueAttributeFromDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep3eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3f: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep3fThReadsCurrentHueAttributeFromDut_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Wait 2s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait2s_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3g: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep3gThReadsCurrentHueAttributeFromDut_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep4aThReadsColorModeAttributeFromDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 31; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; + params.hue = + [NSNumber numberWithUnsignedChar:200U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bThSendsMoveHueCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:1U]; + params.rate = + [NSNumber numberWithUnsignedChar:5U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends MoveHue command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThReadsCurrentHueAttributeFromDut_7() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWait10s_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2dThReadsCurrentHueAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 38U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 52U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_10() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:0U]; + params.rate = + [NSNumber numberWithUnsignedChar:5U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); + } else { + NSLog(@"Step 2e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2fThReadsCurrentHueAttributeFromDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2f: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 80U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 110U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait2s_13() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 2000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2gThReadsCurrentHueAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2g: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2g: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 80U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 110U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsMoveToHueCommandToDutWithHue60Direction0x00ShortestDistanceAndTransitionTime0Immediately_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; + params.hue = + [NSNumber numberWithUnsignedChar:60U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=60, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_16() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThSendsMoveHueCommandToDutWithMoveMode0x03DownAndRate5UnitsS_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:3U]; + params.rate = + [NSNumber numberWithUnsignedChar:5U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Error: %@", err); + } else { + NSLog(@"Step 3b: TH sends MoveHue command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_18() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 4U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 16U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_20() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 183U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 247U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_22() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3eThSendsMoveHueCommandToDutWithMoveMode0x00StopAndRate5UnitsS_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveHueParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:0U]; + params.rate = + [NSNumber numberWithUnsignedChar:5U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); + } else { + NSLog(@"Step 3e: TH sends MoveHue command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fThReadsCurrentHueAttributeFromDut_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3f: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 140U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 190U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait2s_25() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 2000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3gThReadsCurrentHueAttributeFromDut_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3g: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 140U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 190U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_3_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_3_3() + : TestCommandBridge("Test_TC_CC_3_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_3_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_3_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_3_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsStepHueCommandToDutWithStepMode0x01UpStepSize60AndTransitionTime20020s_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2cThReadsCurrentHueAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep2dThReadsCurrentHueAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait5s_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000 PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep2eThReadsCurrentHueAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsMoveToHueCommandToDutWithHue50Direction0x00ShortestDistanceAndTransitionTime0Immediately_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait100ms_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThSendsStepHueCommandToDutWithStepMode0x03DownStepSize60AndTransitionTime20020s_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3c: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep3cThReadsCurrentHueAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep3dThReadsCurrentHueAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 5s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait5s_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep3eThReadsCurrentHueAttributeFromDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep4aThReadsColorModeAttributeFromDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Turn off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_24(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 25; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsMoveToHueCommandToDutWithHue200Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; + params.hue = + [NSNumber numberWithUnsignedChar:200U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends MoveToHue command to DUT with Hue=200, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bThSendsStepHueCommandToDutWithStepMode0x01UpStepSize60AndTransitionTime20020s_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterStepHueParams alloc] init]; + params.stepMode = + [NSNumber numberWithUnsignedChar:1U]; + params.stepSize = + [NSNumber numberWithUnsignedChar:60U]; + params.transitionTime = + [NSNumber numberWithUnsignedChar:200U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stepHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s): Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends StepHue command to DUT with StepMode=0x01 (up), StepSize=60 and TransitionTime=200 (20s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThReadsCurrentHueAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 195U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2dThReadsCurrentHueAttributeFromDut_9() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWait5s_10() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2eThReadsCurrentHueAttributeFromDut_11() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3aThSendsMoveToHueCommandToDutWithHue50Direction0x00ShortestDistanceAndTransitionTime0Immediately_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToHueParams alloc] init]; + params.hue = + [NSNumber numberWithUnsignedChar:50U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends MoveToHue command to DUT with Hue=50, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_13() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThSendsStepHueCommandToDutWithStepMode0x03DownStepSize60AndTransitionTime20020s_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterStepHueParams alloc] init]; + params.stepMode = + [NSNumber numberWithUnsignedChar:3U]; + params.stepSize = + [NSNumber numberWithUnsignedChar:60U]; + params.transitionTime = + [NSNumber numberWithUnsignedChar:200U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stepHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s): Error: %@", err); + } else { + NSLog(@"Step 3b: TH sends StepHue command to DUT with StepMode=0x03 (down), StepSize=60 and TransitionTime=200 (20s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_15() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 17U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 23U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_17() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 208U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 255U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_19() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3eThReadsCurrentHueAttributeFromDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3e: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 208U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 255U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_4_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_4_1() + : TestCommandBridge("Test_TC_CC_4_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("SaturationConfigValue", 0, UINT8_MAX, &mSaturationConfigValue); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_4_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation60AndTransitionTime0Immediately_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime30030s_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait5s_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2f: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2fThReadsCurrentSaturationAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep3aThReadsColorModeAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep3bThReadsEnhancedColorModeAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Turn off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 18; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mSaturationConfigValue; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation60AndTransitionTime0Immediately_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; + params.saturation = + [NSNumber numberWithUnsignedChar:60U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=60 and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime30030s_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; + params.saturation = + [NSNumber numberWithUnsignedChar:120U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:300U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s): Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=300 (30s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 80U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 115U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_10() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 102U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 138U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2fThReadsCurrentSaturationAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2f: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 102U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 138U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsColorModeAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsEnhancedColorModeAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_4_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_4_2() + : TestCommandBridge("Test_TC_CC_4_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_4_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait5s_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime0Immediately_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait100ms_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThSendsMoveSaturationCommandToDutWithMoveMode0x03DownAndRate5UnitsS_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3c: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3cThReadsCurrentSaturationAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3dThReadsCurrentSaturationAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3eThReadsCurrentSaturationAttributeFromDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait100ms_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep4bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4c: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep4cThReadsCurrentSaturationAttributeFromDut_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep4dThSendsMoveSaturationCommandToDutWithMoveMode0x00StopAndRate5UnitsS_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4e: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep4eThReadsCurrentSaturationAttributeFromDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Wait 2s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait2s_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4f: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep4fThReadsCurrentSaturationAttributeFromDut_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep5aThReadsColorModeAttributeFromDut_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep5bThReadsEnhancedColorModeAttributeFromDut_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Turn off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_33(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 34; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; + params.saturation = + [NSNumber numberWithUnsignedChar:150U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:1U]; + params.rate = + [NSNumber numberWithUnsignedChar:5U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_10() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation120AndTransitionTime0Immediately_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; + params.saturation = + [NSNumber numberWithUnsignedChar:120U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=120 and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_13() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThSendsMoveSaturationCommandToDutWithMoveMode0x03DownAndRate5UnitsS_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:3U]; + params.rate = + [NSNumber numberWithUnsignedChar:5U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Error: %@", err); + } else { + NSLog(@"Step 3b: TH sends MoveSaturation command to DUT with MoveMode=0x03 (down) and Rate=5 (units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_15() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3cThReadsCurrentSaturationAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 59U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 81U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_17() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 5U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 35U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_19() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3eThReadsCurrentSaturationAttributeFromDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 10U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsMoveToSaturationCommandToDutWithSaturation150AndTransitionTime0Immediately_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; + params.saturation = + [NSNumber numberWithUnsignedChar:150U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends MoveToSaturation command to DUT with Saturation=150 and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_22() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4bThSendsMoveSaturationCommandToDutWithMoveMode0x01UpAndRate5UnitsS_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:1U]; + params.rate = + [NSNumber numberWithUnsignedChar:5U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Error: %@", err); + } else { + NSLog(@"Step 4b: TH sends MoveSaturation command to DUT with MoveMode=0x01 (up) and Rate=5 (units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_24() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4cThReadsCurrentSaturationAttributeFromDut_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThSendsMoveSaturationCommandToDutWithMoveMode0x00StopAndRate5UnitsS_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveSaturationParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:0U]; + params.rate = + [NSNumber numberWithUnsignedChar:5U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Error: %@", err); + } else { + NSLog(@"Step 4d: TH sends MoveSaturation command to DUT with MoveMode=0x00 (stop) and Rate=5 (units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsCurrentSaturationAttributeFromDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait2s_28() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 2000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4fThReadsCurrentSaturationAttributeFromDut_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 170U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 230U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThReadsColorModeAttributeFromDut_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bThReadsEnhancedColorModeAttributeFromDut_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_4_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_4_3() + : TestCommandBridge("Test_TC_CC_4_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_4_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation200AndTransitionTime0Immediately_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize40AndTransitionTime20020s_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2cThReadsCurrentSaturationAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2dThReadsCurrentSaturationAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait5s_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2eThReadsCurrentSaturationAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep2fThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize20AndTransitionTime10010s_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2g: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2gThReadsCurrentSaturationAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation50AndTransitionTime0Immediately_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait100ms_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize40AndTransitionTime20020s_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3c: H reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3cHReadsCurrentSaturationAttributeFromDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3dThReadsCurrentSaturationAttributeFromDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 5s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait5s_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3e: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3eThReadsCurrentSaturationAttributeFromDut_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep3fThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize20AndTransitionTime10010S_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3g: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3gThReadsCurrentSaturationAttributeFromDut_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep4aThReadsColorModeAttributeFromDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4b: H reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep4bHReadsEnhancedColorModeAttributeFromDut_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 31; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsMoveToSaturationCommandToDutWithSaturation200AndTransitionTime0Immediately_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; + params.saturation = + [NSNumber numberWithUnsignedChar:200U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends MoveToSaturation command to DUT with Saturation=200 and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize40AndTransitionTime20020s_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; + params.stepMode = + [NSNumber numberWithUnsignedChar:1U]; + params.stepSize = + [NSNumber numberWithUnsignedChar:40U]; + params.transitionTime = + [NSNumber numberWithUnsignedChar:200U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stepSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s): Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=40 and TransitionTime=200 (20s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThReadsCurrentSaturationAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 187U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 253U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2dThReadsCurrentSaturationAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 204U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_10() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2eThReadsCurrentSaturationAttributeFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2e: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 204U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2fThSendsStepSaturationCommandToDutWithStepMode0x01UpStepSize20AndTransitionTime10010s_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; + params.stepMode = + [NSNumber numberWithUnsignedChar:1U]; + params.stepSize = + [NSNumber numberWithUnsignedChar:20U]; + params.transitionTime = + [NSNumber numberWithUnsignedChar:100U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stepSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s): Error: %@", err); + } else { + NSLog(@"Step 2f: TH sends StepSaturation command to DUT with StepMode=0x01 (up), StepSize=20 and TransitionTime=100 (10s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_13() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2gThReadsCurrentSaturationAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2g: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2g: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 216U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsMoveToSaturationCommandToDutWithSaturation50AndTransitionTime0Immediately_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToSaturationParams alloc] init]; + params.saturation = + [NSNumber numberWithUnsignedChar:50U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends MoveToSaturation command to DUT with Saturation=50 and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_16() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize40AndTransitionTime20020s_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; + params.stepMode = + [NSNumber numberWithUnsignedChar:3U]; + params.stepSize = + [NSNumber numberWithUnsignedChar:40U]; + params.transitionTime = + [NSNumber numberWithUnsignedChar:200U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stepSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s): Error: %@", err); + } else { + NSLog(@"Step 3b: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=40 and TransitionTime=200 (20s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_18() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3cHReadsCurrentSaturationAttributeFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: H reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: H reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 25U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 35U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_20() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 8U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 12U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_22() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3eThReadsCurrentSaturationAttributeFromDut_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3e: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 8U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 12U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fThSendsStepSaturationCommandToDutWithStepMode0x03DownStepSize20AndTransitionTime10010S_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterStepSaturationParams alloc] init]; + params.stepMode = + [NSNumber numberWithUnsignedChar:3U]; + params.stepSize = + [NSNumber numberWithUnsignedChar:20U]; + params.transitionTime = + [NSNumber numberWithUnsignedChar:100U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stepSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s): Error: %@", err); + } else { + NSLog(@"Step 3f: TH sends StepSaturation command to DUT with StepMode=0x03 (down), StepSize=20 and TransitionTime=100 (10 s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_25() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3gThReadsCurrentSaturationAttributeFromDut_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3g: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentSaturation", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bHReadsEnhancedColorModeAttributeFromDut_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: H reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: H reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_4_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_4_4() + : TestCommandBridge("Test_TC_CC_4_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_4_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_4_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_4_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsMoveToHueAndSaturationCommandToDutWithHue200Saturation50AndTransitionTime0Immediately_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentHue attribute from DUT.\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000 && CC.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThReadsCurrentHueAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b1: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2b1ThReadsCurrentSaturationAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s)\n"); + if (ShouldSkip("CC.S.F00 && CC.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsMoveToHueAndSaturationCommandToDutWithHue160Saturation80AndTransitionTime20020s_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep3bThReadsCurrentHueAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b1: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3b1ThReadsCurrentSaturationAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait10s_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep3cThReadsCurrentHueAttributeFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c1: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3c1ThReadsCurrentSaturationAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); + if (ShouldSkip("CC.S.F00")) { + NextTest(); + return; + } + err = TestWait5s_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads CurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0000")) { + NextTest(); + return; + } + err = TestStep3dThReadsCurrentHueAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d1: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3d1ThReadsCurrentSaturationAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep4aThReadsColorModeAttributeFromDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F00 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Turn off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 21; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsMoveToHueAndSaturationCommandToDutWithHue200Saturation50AndTransitionTime0Immediately_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToHueAndSaturationParams alloc] init]; + params.hue = + [NSNumber numberWithUnsignedChar:200U]; + params.saturation = + [NSNumber numberWithUnsignedChar:50U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToHueAndSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends MoveToHueAndSaturation command to DUT with Hue=200, Saturation=50 and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bThReadsCurrentHueAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads CurrentHue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads CurrentHue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 170U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 230U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2b1ThReadsCurrentSaturationAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b1: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 42U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 58U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsMoveToHueAndSaturationCommandToDutWithHue160Saturation80AndTransitionTime20020s_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToHueAndSaturationParams alloc] init]; + params.hue = + [NSNumber numberWithUnsignedChar:160U]; + params.saturation = + [NSNumber numberWithUnsignedChar:80U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:200U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToHueAndSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s): Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends MoveToHueAndSaturation command to DUT with Hue=160, Saturation=80 and TransitionTime=200 (20s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThReadsCurrentHueAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 160U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 200U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3b1ThReadsCurrentSaturationAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b1: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 50U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 80U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_11() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3cThReadsCurrentHueAttributeFromDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 135U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 185U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3c1ThReadsCurrentSaturationAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c1: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentSaturation", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_14() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3dThReadsCurrentHueAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads CurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentHue", [value unsignedCharValue], 135U)); + VerifyOrReturn(CheckConstraintMaxValue("currentHue", [value unsignedCharValue], 185U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3d1ThReadsCurrentSaturationAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d1: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d1: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_5_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_5_1() + : TestCommandBridge("Test_TC_CC_5_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_5_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003")) { + NextTest(); + return; + } + err = TestStep2bThReadsCurrentXAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b1: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004")) { + NextTest(); + return; + } + err = TestStep2b1ThReadsCurrentYAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime20020s_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait10s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThReadsCurrentXAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThReadsCurrentYAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait10s_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep3cThReadsCurrentXAttributeFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep3cThReadsCurrentYAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait5s_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep3dThReadsCurrentXAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep3dThReadsCurrentYAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep4aThWrites0ToTheOptionsAttribute_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH read Options attribute\n"); + if (ShouldSkip("CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep4bThReadOptionsAttribute_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4c: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep4cThSendsOnCommandToDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4dThSendsAMoveToColorCommandToTheDutWithColorX327680x8000X05PurpleColorY196600x4CCCY03TransitionTime0Immediate_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait100ms_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4e: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4eThReadsCurrentXAttributeFromDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4e: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4eThReadsCurrentYAttributeFromDut_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4f: TH sends Off command to DUT\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep4fThSendsOffCommandToDut_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait100ms_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4h: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4hThReadsCurrentXAttributeFromDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4h: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4hThReadsCurrentYAttributeFromDut_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait100ms_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4j: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4jThReadsCurrentXAttributeFromDut_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4j: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4jThReadsCurrentYAttributeFromDut_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait100ms_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4i: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4iThReadsCurrentXAttributeFromDut_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4i: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4iThReadsCurrentYAttributeFromDut_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5a: TH writes 1 to the Options attribute\n"); + if (ShouldSkip("CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep5aThWrites1ToTheOptionsAttribute_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Step 5b: TH read Options attribute\n"); + if (ShouldSkip("CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep5bThReadOptionsAttribute_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Step 5c: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep5cThSendsOnCommandToDut_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5dThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait100ms_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Step 5e: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5eThReadsCurrentXAttributeFromDut_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Step 5e: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5eThReadsCurrentYAttributeFromDut_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Step 5f: TH sends Off command to DUT\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep5fThSendsOffCommandToDut_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait100ms_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Step 5h: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5hThReadsCurrentXAttributeFromDut_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Step 5h: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5hThReadsCurrentYAttributeFromDut_48(); + break; + case 49: + ChipLogProgress(chipTool, " ***** Test Step 49 : Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_49(); + break; + case 50: + ChipLogProgress(chipTool, " ***** Test Step 50 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait100ms_50(); + break; + case 51: + ChipLogProgress(chipTool, " ***** Test Step 51 : Step 5j: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5jThReadsCurrentXAttributeFromDut_51(); + break; + case 52: + ChipLogProgress(chipTool, " ***** Test Step 52 : Step 5j: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5jThReadsCurrentYAttributeFromDut_52(); + break; + case 53: + ChipLogProgress(chipTool, " ***** Test Step 53 : Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_53(); + break; + case 54: + ChipLogProgress(chipTool, " ***** Test Step 54 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait100ms_54(); + break; + case 55: + ChipLogProgress(chipTool, " ***** Test Step 55 : Step 5l: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5lThReadsCurrentXAttributeFromDut_55(); + break; + case 56: + ChipLogProgress(chipTool, " ***** Test Step 56 : Step 5l: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5lThReadsCurrentYAttributeFromDut_56(); + break; + case 57: + ChipLogProgress(chipTool, " ***** Test Step 57 : Step 6a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep6aThReadsColorModeAttributeFromDut_57(); + break; + case 58: + ChipLogProgress(chipTool, " ***** Test Step 58 : Step 6b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep6bThReadsEnhancedColorModeAttributeFromDut_58(); + break; + case 59: + ChipLogProgress(chipTool, " ***** Test Step 59 : Turn off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_59(); + break; + case 60: + ChipLogProgress(chipTool, " ***** Test Step 60 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_60(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 49: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 50: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 51: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 52: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 53: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 54: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 55: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 56: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 57: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 58: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 59: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 60: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 61; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:32768U]; + params.colorY = + [NSNumber numberWithUnsignedShort:19660U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bThReadsCurrentXAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2b1ThReadsCurrentYAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b1: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b1: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime20020s_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:13107U]; + params.colorY = + [NSNumber numberWithUnsignedShort:13107U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:200U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s): Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 200 (20s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 13107U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 32768U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 13107U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 19660U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_11() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3cThReadsCurrentXAttributeFromDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsCurrentYAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_14() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3dThReadsCurrentXAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThReadsCurrentYAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThWrites0ToTheOptionsAttribute_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadOptionsAttribute_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH read Options attribute: Error: %@", err); + } else { + NSLog(@"Step 4b: TH read Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Options", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThSendsOnCommandToDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThSendsAMoveToColorCommandToTheDutWithColorX327680x8000X05PurpleColorY196600x4CCCY03TransitionTime0Immediate_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:32768U]; + params.colorY = + [NSNumber numberWithUnsignedShort:19660U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 4d: TH sends a MoveToColor command to the DUT with ColorX = 32768/0x8000 (x=0.5) (purple) ColorY = 19660/0x4CCC (y=0.3) TransitionTime = 0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_21() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4eThReadsCurrentXAttributeFromDut_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsCurrentYAttributeFromDut_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThSendsOffCommandToDut_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH sends Off command to DUT: Error: %@", err); + } else { + NSLog(@"Step 4f: TH sends Off command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:13107U]; + params.colorY = + [NSNumber numberWithUnsignedShort:13107U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 4g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_26() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4hThReadsCurrentXAttributeFromDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentX", actualValue, 32768U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsCurrentYAttributeFromDut_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentY", actualValue, 19660U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:13107U]; + params.colorY = + [NSNumber numberWithUnsignedShort:32768U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:1U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 4i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_30() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4jThReadsCurrentXAttributeFromDut_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentX", actualValue, 32768U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsCurrentYAttributeFromDut_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentY", actualValue, 19660U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:26214U]; + params.colorY = + [NSNumber numberWithUnsignedShort:32768U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:1U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:1U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 4k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_34() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4iThReadsCurrentXAttributeFromDut_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 22282U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 30146U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThReadsCurrentYAttributeFromDut_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 27853U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 37683U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThWrites1ToTheOptionsAttribute_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH writes 1 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 5a: TH writes 1 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bThReadOptionsAttribute_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH read Options attribute: Error: %@", err); + } else { + NSLog(@"Step 5b: TH read Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Options", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5cThSendsOnCommandToDut_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5c: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 5c: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5dThSendsMoveToColorCommandToDutWithColorX327680x8000ColorY196600x4CCCTransitionTime0Immediate_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:32768U]; + params.colorY = + [NSNumber numberWithUnsignedShort:19660U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 5d: TH sends MoveToColor command to DUT, with ColorX = 32768/0x8000 ColorY = 19660/0x4CCC TransitionTime = 0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_41() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5eThReadsCurrentXAttributeFromDut_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5e: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5e: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27853U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 37683U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5eThReadsCurrentYAttributeFromDut_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5e: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5e: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 16711U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 22609U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5fThSendsOffCommandToDut_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5f: TH sends Off command to DUT: Error: %@", err); + } else { + NSLog(@"Step 5f: TH sends Off command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5gThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY131070x3333TransitionTime0Immediate_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:13107U]; + params.colorY = + [NSNumber numberWithUnsignedShort:13107U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 5g: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 13107/0x3333 TransitionTime = 0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_46() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5hThReadsCurrentXAttributeFromDut_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5h: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5h: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11141U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 15073U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5hThReadsCurrentYAttributeFromDut_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5h: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5h: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11141U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 15073U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5iThSendsMoveToColorCommandToDutWithColorX131070x3333ColorY327680x8000TransitionTime0Immediate_49() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:13107U]; + params.colorY = + [NSNumber numberWithUnsignedShort:32768U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:1U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 5i: TH sends MoveToColor command to DUT, with ColorX = 13107/0x3333 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_50() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5jThReadsCurrentXAttributeFromDut_51() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5j: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5j: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentX", actualValue, 13107U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5jThReadsCurrentYAttributeFromDut_52() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5j: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5j: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentY", actualValue, 13107U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5kThSendsMoveToColorCommandToDutWithColorX262140x6666ColorY327680x8000TransitionTime0Immediate_53() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:26214U]; + params.colorY = + [NSNumber numberWithUnsignedShort:32768U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:1U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:1U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 5k: TH sends MoveToColor command to DUT, with ColorX = 26214/0x6666 ColorY = 32768/0x8000 TransitionTime = 0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_54() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5lThReadsCurrentXAttributeFromDut_55() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5l: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5l: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 22282U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 30146U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5lThReadsCurrentYAttributeFromDut_56() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5l: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5l: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 27853U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 37683U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsColorModeAttributeFromDut_57() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsEnhancedColorModeAttributeFromDut_58() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_59() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_60() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_5_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_5_2() + : TestCommandBridge("Test_TC_CC_5_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_5_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep0aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep0bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep1aThSendsMoveToColorCommandToDutWithColorX33000ColorY26000TransitionTime0Immediate_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH sends MoveColor command to DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsMoveColorCommandToDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait10s_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThReadsCurrentXAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThReadsCurrentYAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait10s_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep2cThReadsCurrentXAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep2cThReadsCurrentYAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 10s\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait10s_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2d: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep2dThReadsCurrentXAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2d: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep2dThReadsCurrentYAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH sends StopMoveStep command to DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C47.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsStopMoveStepCommandToDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3b: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThReadsCurrentXAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3b: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThReadsCurrentYAttributeFromDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep4aThReadsColorModeAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Turn off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 22; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 0b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1aThSendsMoveToColorCommandToDutWithColorX33000ColorY26000TransitionTime0Immediate_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:33000U]; + params.colorY = + [NSNumber numberWithUnsignedShort:26000U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 1a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 26000 TransitionTime = 0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2aThSendsMoveColorCommandToDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveColorParams alloc] init]; + params.rateX = + [NSNumber numberWithShort:-100]; + params.rateY = + [NSNumber numberWithShort:100]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends MoveColor command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends MoveColor command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bThReadsCurrentXAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 27200U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 36800U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThReadsCurrentYAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 22900U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 31100U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_9() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThReadsCurrentXAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 26350U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 35650U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cThReadsCurrentYAttributeFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 23800U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 32200U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + NSNumber * _Nonnull CurrentXValue; + + CHIP_ERROR TestStep2dThReadsCurrentXAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 25500U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 34500U)); + { + CurrentXValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull CurrentYValue; + + CHIP_ERROR TestStep2dThReadsCurrentYAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 24650U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 33350U)); + { + CurrentYValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsStopMoveStepCommandToDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterStopMoveStepParams alloc] init]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stopMoveStepWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends StopMoveStep command to DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends StopMoveStep command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 25500U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 34500U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 24650U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 33350U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_5_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_5_3() + : TestCommandBridge("Test_TC_CC_5_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_5_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_5_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_5_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsMoveToColorCommandToDutWithColorX33000ColorY20000TransitionTime0Immediate_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s)\n"); + if (ShouldSkip("CC.S.F03 && CC.S.C09.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsStepColorCommandToDutWithStepX20000StepY6000TransitionTime20020s_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait10s_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThReadsCurrentXAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThReadsCurrentYAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait10s_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3c: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep3cThReadsCurrentXAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3c: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep3cThReadsCurrentYAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); + if (ShouldSkip("CC.S.F03")) { + NextTest(); + return; + } + err = TestWait5s_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3d: TH reads CurrentX attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0003 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep3dThReadsCurrentXAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: TH reads CurrentY attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0004 && CC.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep3dThReadsCurrentYAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep4aThReadsColorModeAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F03 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Turn off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_18(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 19; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsMoveToColorCommandToDutWithColorX33000ColorY20000TransitionTime0Immediate_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorParams alloc] init]; + params.colorX = + [NSNumber numberWithUnsignedShort:33000U]; + params.colorY = + [NSNumber numberWithUnsignedShort:20000U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends MoveToColor command to DUT, with ColorX = 33000 ColorY = 20000 TransitionTime = 0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3aThSendsStepColorCommandToDutWithStepX20000StepY6000TransitionTime20020s_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterStepColorParams alloc] init]; + params.stepX = + [NSNumber numberWithShort:-20000]; + params.stepY = + [NSNumber numberWithShort:-6000]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:200U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stepColorWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s): Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends StepColor command to DUT, with StepX = -20000, StepY = -6000, TransitionTime = 200 (20s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThReadsCurrentXAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 13000U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 33000U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsCurrentYAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 14000U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 20000U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_9() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3cThReadsCurrentXAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11050U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 14950U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsCurrentYAttributeFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11900U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 16100U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3dThReadsCurrentXAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentXWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads CurrentX attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentX", [value unsignedShortValue], 11050U)); + VerifyOrReturn(CheckConstraintMaxValue("currentX", [value unsignedShortValue], 14950U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThReadsCurrentYAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentYWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads CurrentY attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentY", [value unsignedShortValue], 11900U)); + VerifyOrReturn(CheckConstraintMaxValue("currentY", [value unsignedShortValue], 16100U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_6_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_6_1() + : TestCommandBridge("Test_TC_CC_6_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("ConfigWait", 0, UINT16_MAX, &mConfigWait); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_6_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_6_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_6_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep0aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep0bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { + NextTest(); + return; + } + err = TestStep1aThReadsColorTempPhysicalMinMiredsAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { + NextTest(); + return; + } + err = TestStep1bThReadsColorTempPhysicalMaxMiredsAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1c: TH reads ColorTemperatureMireds attribute from DUT.\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { + NextTest(); + return; + } + err = TestStep1cThReadsColorTemperatureMiredsAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).\n"); + if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsMoveToColorTemperatureCommandToDutWithColorTemperatureMireds310AndTransitionTime0Immediately_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F04")) { + NextTest(); + return; + } + err = TestWait100ms_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).\n"); + if (ShouldSkip("CC.S.F04 && CC.S.C0a.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsMoveToColorTemperaturCommandToDutWithColorTemperatureMireds250AndTransitionTime30030s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 10s\n"); + if (ShouldSkip("CC.S.F04")) { + NextTest(); + return; + } + err = TestWait10s_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH reads ColorTemperatureMireds attribute from DUT.\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { + NextTest(); + return; + } + err = TestStep2cThReadsColorTemperatureMiredsAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); + if (ShouldSkip("CC.S.F04")) { + NextTest(); + return; + } + err = TestWait10s_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: TH reads ColorTemperatureMireds attribute from DUT.\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { + NextTest(); + return; + } + err = TestStep2dThReadsColorTemperatureMiredsAttributeFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 10s\n"); + if (ShouldSkip("CC.S.F04")) { + NextTest(); + return; + } + err = TestWait10s_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2e: TH reads ColorTemperatureMireds attribute from DUT.\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { + NextTest(); + return; + } + err = TestStep2eThReadsColorTemperatureMiredsAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 5s\n"); + if (ShouldSkip("CC.S.F04")) { + NextTest(); + return; + } + err = TestWait5s_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 2f: TH reads ColorTemperatureMireds attribute from DUT.\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A0007 && CC.S.C0a.Rsp")) { + NextTest(); + return; + } + err = TestStep2fThReadsColorTemperatureMiredsAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep3aThReadsColorModeAttributeFromDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep3bThReadsEnhancedColorModeAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Turn Off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Wait to turn Off light\n"); + err = TestWaitToTurnOffLight_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 22; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mConfigWait; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 0b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull ColorTempPhysicalMinMiredsValue; + + CHIP_ERROR TestStep1aThReadsColorTempPhysicalMinMiredsAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1a: TH reads ColorTempPhysicalMinMireds attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); + { + ColorTempPhysicalMinMiredsValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull ColorTempPhysicalMaxMiredsValue; + + CHIP_ERROR TestStep1bThReadsColorTempPhysicalMaxMiredsAttributeFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 1b: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); + { + ColorTempPhysicalMaxMiredsValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1cThReadsColorTemperatureMiredsAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 1c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], ColorTempPhysicalMinMiredsValue)); + VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], ColorTempPhysicalMaxMiredsValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsMoveToColorTemperatureCommandToDutWithColorTemperatureMireds310AndTransitionTime0Immediately_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorTemperatureParams alloc] init]; + params.colorTemperatureMireds = + [NSNumber numberWithUnsignedShort:310U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorTemperatureWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends MoveToColorTemperature command to DUT with ColorTemperatureMireds=310 and TransitionTime=0 (immediately).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_7() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bThSendsMoveToColorTemperaturCommandToDutWithColorTemperatureMireds250AndTransitionTime30030s_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterMoveToColorTemperatureParams alloc] init]; + params.colorTemperatureMireds = + [NSNumber numberWithUnsignedShort:250U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:300U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToColorTemperatureWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).: Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends MoveToColorTemperatur command to DUT with ColorTemperatureMireds=250 and TransitionTime=300 (30s).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_9() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThReadsColorTemperatureMiredsAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 246U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 334U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_11() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2dThReadsColorTemperatureMiredsAttributeFromDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads ColorTemperatureMireds attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 230U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 310U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_13() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2eThReadsColorTemperatureMiredsAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 2e: TH reads ColorTemperatureMireds attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 212U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 288U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_15() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2fThReadsColorTemperatureMiredsAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 2f: TH reads ColorTemperatureMireds attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 212U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 288U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsColorModeAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsEnhancedColorModeAttributeFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn Off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn Off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitToTurnOffLight_20() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mConfigWait.HasValue() ? mConfigWait.Value() : 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_6_5 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_6_5() + : TestCommandBridge("Test_TC_CC_6_5") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("ConfigWait", 0, UINT16_MAX, &mConfigWait); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_6_5() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_6_5\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_6_5\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep0aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp && CC.S.F04")) { + NextTest(); + return; + } + err = TestStep0bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0c: TH reads ColorTemperatureMireds attribute from DUT.\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { + NextTest(); + return; + } + err = TestStep0cThReadsColorTemperatureMiredsAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A400b")) { + NextTest(); + return; + } + err = TestStep0dThReadsColorTempPhysicalMinMiredsAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A400c")) { + NextTest(); + return; + } + err = TestStep0eThReadsColorTempPhysicalMaxMiredsAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute\n"); + if (ShouldSkip("CC.S.A4010 && CC.S.F04")) { + NextTest(); + return; + } + err = TestStep1ThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH writes to StartUpColorTemperatureMireds attribute with value StartUpColorTemperatureMireds\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && CC.S.A4010 && CC.S.F04")) { + NextTest(); + return; + } + err = TestStep2aThWritesToStartUpColorTemperatureMiredsAttributeWithValueStartUpColorTemperatureMireds_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT\n"); + if (ShouldSkip("CC.S.A4010 && CC.S.F04")) { + NextTest(); + return; + } + err = TestStep2bThReadsStartUpColorTemperatureMiredsAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2b: Verify that the DUT response contains StartUpColorTemperatureMireds that matches the StartUpColorTemperatureMireds set in Step 2a\n"); + if (ShouldSkip("CC.S.A4010 && CC.S.F04 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep2bVerifyThatTheDutResponseContainsStartUpColorTemperatureMiredsThatMatchesTheStartUpColorTemperatureMiredsSetInStep2a_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: Reboot target device\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep3aRebootTargetDevice_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: Reboot target device(DUT)\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep3bRebootTargetDeviceDUT_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A4010")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4b: TH reads ColorTemperatureMireds attribute from DUT.\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A0007")) { + NextTest(); + return; + } + err = TestStep4bThReadsColorTemperatureMiredsAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep5aThReadsColorModeAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F04 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep5bThReadsEnhancedColorModeAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Turn Off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Wait to turn Off light\n"); + err = TestWaitToTurnOffLight_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_19(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 20; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mConfigWait; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 0b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0cThReadsColorTemperatureMiredsAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0c: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 0c: TH reads ColorTemperatureMireds attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorTemperatureMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorTemperatureMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTemperatureMireds", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0dThReadsColorTempPhysicalMinMiredsAttributeFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTempPhysicalMinMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 0d: TH reads ColorTempPhysicalMinMireds attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorTempPhysicalMinMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMinMireds", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0eThReadsColorTempPhysicalMaxMiredsAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTempPhysicalMaxMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 0e: TH reads ColorTempPhysicalMaxMireds attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("colorTempPhysicalMaxMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorTempPhysicalMaxMireds", [value unsignedShortValue], 65279U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1ThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThWritesToStartUpColorTemperatureMiredsAttributeWithValueStartUpColorTemperatureMireds_7() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + NSNumber * _Nullable StartUpColorTemperatureMiredsValue; + + CHIP_ERROR TestStep2bThReadsStartUpColorTemperatureMiredsAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads StartUpColorTemperatureMireds attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("startUpColorTemperatureMireds", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("startUpColorTemperatureMireds", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("startUpColorTemperatureMireds", [value unsignedShortValue], 65279U)); + } + { + StartUpColorTemperatureMiredsValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bVerifyThatTheDutResponseContainsStartUpColorTemperatureMiredsThatMatchesTheStartUpColorTemperatureMiredsSetInStep2a_9() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3aRebootTargetDevice_10() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestStep3bRebootTargetDeviceDUT_11() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheStartUpColorTemperatureMiredsAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartUpColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the StartUpColorTemperatureMireds attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (StartUpColorTemperatureMiredsValue == nil) { + VerifyOrReturn(CheckValueNull("StartUpColorTemperatureMireds", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("StartUpColorTemperatureMireds", actualValue)); + VerifyOrReturn(CheckValue("StartUpColorTemperatureMireds", actualValue, StartUpColorTemperatureMiredsValue)); + } + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsColorTemperatureMiredsAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorTemperatureMiredsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads ColorTemperatureMireds attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads ColorTemperatureMireds attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorTemperatureMireds", actualValue, StartUpColorTemperatureMiredsValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThReadsColorModeAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bThReadsEnhancedColorModeAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn Off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn Off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitToTurnOffLight_18() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mConfigWait.HasValue() ? mConfigWait.Value() : 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_7_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_7_3() + : TestCommandBridge("Test_TC_CC_7_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_7_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_7_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_7_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep0aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep0bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); + if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue6000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).\n"); + if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsEnhancedStepHueCommandToDutWithStepMode0x01UpStepSize6000AndTransitionTime30030s_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait 10s\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait10s_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep2cThReadsEnhancedCurrentHueAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait10s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 10s\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait10s_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5s\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait5s_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2f: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); + if (ShouldSkip("CC.S.F01 && CC.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep5aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue12000Direction0x00ShortestDistanceAndTransitionTime0Immediately_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait100ms_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s)\n"); + if (ShouldSkip("CC.S.F01 && CC.S.C42.Rsp")) { + NextTest(); + return; + } + err = TestStep5bThSendsEnhancedStepHueCommandToDutWithStepMode0x03DownStepSize6000AndTransitionTime30030s_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Wait 10s\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait10s_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5c: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep5cThReadsEnhancedCurrentHueAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Wait 10s\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait10s_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 2d: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 10s\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait10s_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 2e: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Wait 5s\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait5s_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 2f: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000 && CC.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 6a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep6aThReadsColorModeAttributeFromDut_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 6b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep6bThReadsEnhancedColorModeAttributeFromDut_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Turn Off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_28(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 29; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep0aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 0a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 0b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue6000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; + params.enhancedHue = + [NSNumber numberWithUnsignedShort:6000U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster enhancedMoveToHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=6000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bThSendsEnhancedStepHueCommandToDutWithStepMode0x01UpStepSize6000AndTransitionTime30030s_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterEnhancedStepHueParams alloc] init]; + params.stepMode = + [NSNumber numberWithUnsignedChar:1U]; + params.stepSize = + [NSNumber numberWithUnsignedShort:6000U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:300U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster enhancedStepHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).: Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends EnhancedStepHue command to DUT with StepMode=0x01 (up), StepSize=6000 and TransitionTime=300 (30s).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThReadsEnhancedCurrentHueAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 6800U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 9200U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 8500U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 11500U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_10() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 10200U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 13800U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 10200U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 13800U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue12000Direction0x00ShortestDistanceAndTransitionTime0Immediately_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; + params.enhancedHue = + [NSNumber numberWithUnsignedShort:12000U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster enhancedMoveToHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); + } else { + NSLog(@"Step 5a: TH sends EnhancedMoveToHue command to DUT with EnhancedHue=12000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_15() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5bThSendsEnhancedStepHueCommandToDutWithStepMode0x03DownStepSize6000AndTransitionTime30030s_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterEnhancedStepHueParams alloc] init]; + params.stepMode = + [NSNumber numberWithUnsignedChar:3U]; + params.stepSize = + [NSNumber numberWithUnsignedShort:6000U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:300U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster enhancedStepHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s): Error: %@", err); + } else { + NSLog(@"Step 5b: TH sends EnhancedStepHue command to DUT with StepMode=0x03 (down), StepSize=6000 and TransitionTime=300 (30s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_17() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5cThReadsEnhancedCurrentHueAttributeFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5c: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 8500U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 11500U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_19() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2dThReadsEnhancedCurrentHueAttributeFromDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 6800U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 9200U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_21() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2eThReadsEnhancedCurrentHueAttributeFromDut_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2e: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 5100U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 6900U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_23() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2fThReadsEnhancedCurrentHueAttributeFromDut_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2f: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 5100U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 6900U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsColorModeAttributeFromDut_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsEnhancedColorModeAttributeFromDut_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn Off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn Off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CC_7_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CC_7_4() + : TestCommandBridge("Test_TC_CC_7_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CC_7_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CC_7_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CC_7_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1bThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately)\n"); + if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue20000Saturation50AndTransitionTime0Immediately_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 100ms\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { + NextTest(); + return; + } + err = TestStep2bThReadsEnhancedCurrentHueAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestThReadsCurrentSaturationAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s)\n"); + if (ShouldSkip("CC.S.F01 && CC.S.C43.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue16000Saturation80AndTransitionTime20020s_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 10s\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait10s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { + NextTest(); + return; + } + err = TestStep3bThReadsEnhancedCurrentHueAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3bThReadsCurrentSaturationAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 10s\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait10s_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { + NextTest(); + return; + } + err = TestStep3cThReadsEnhancedCurrentHueAttributeFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3cThReadsCurrentSaturationAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 5s\n"); + if (ShouldSkip("CC.S.F01")) { + NextTest(); + return; + } + err = TestWait5s_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH reads EnhancedCurrentHue attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4000")) { + NextTest(); + return; + } + err = TestStep3dThReadsEnhancedCurrentHueAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3d: TH reads CurrentSaturation attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3dThReadsCurrentSaturationAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a: TH reads ColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A0008")) { + NextTest(); + return; + } + err = TestStep4aThReadsColorModeAttributeFromDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: TH reads EnhancedColorMode attribute from DUT\n"); + if (ShouldSkip("CC.S.F01 && CC.S.A4001")) { + NextTest(); + return; + } + err = TestStep4bThReadsEnhancedColorModeAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Turn Off light that we turned on\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestTurnOffLightThatWeTurnedOn_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 21; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue20000Saturation50AndTransitionTime0Immediately_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueAndSaturationParams alloc] init]; + params.enhancedHue = + [NSNumber numberWithUnsignedShort:20000U]; + params.saturation = + [NSNumber numberWithUnsignedChar:50U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster enhancedMoveToHueAndSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately): Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=20000, Saturation=50 and TransitionTime=0 (immediately): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bThReadsEnhancedCurrentHueAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 17000U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 23000U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThReadsCurrentSaturationAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 42U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 58U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsEnhancedMoveToHueAndSaturationCommandToDutWithEnhancedHue16000Saturation80AndTransitionTime20020s_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueAndSaturationParams alloc] init]; + params.enhancedHue = + [NSNumber numberWithUnsignedShort:16000U]; + params.saturation = + [NSNumber numberWithUnsignedChar:80U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:200U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster enhancedMoveToHueAndSaturationWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s): Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends EnhancedMoveToHueAndSaturation command to DUT with EnhancedHue=16000, Saturation=80 and TransitionTime=200 (20s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThReadsEnhancedCurrentHueAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 16000U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 20000U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsCurrentSaturationAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 50U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 80U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_11() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3cThReadsEnhancedCurrentHueAttributeFromDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], 13600U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 18400U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsCurrentSaturationAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("currentSaturation", [value unsignedCharValue], 68U)); + VerifyOrReturn(CheckConstraintMaxValue("currentSaturation", [value unsignedCharValue], 92U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_14() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3dThReadsEnhancedCurrentHueAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, 16000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThReadsCurrentSaturationAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSaturationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads CurrentSaturation attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentSaturation", actualValue, 80U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsColorModeAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads ColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorMode", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintMinValue("colorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("colorMode", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsEnhancedColorModeAttributeFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedColorModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads EnhancedColorMode attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedColorMode", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintMinValue("enhancedColorMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedColorMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightThatWeTurnedOn_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn Off light that we turned on: Error: %@", err); + } else { + NSLog(@"Turn Off light that we turned on: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestColorControl_9_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestColorControl_9_1() + : TestCommandBridge("TestColorControl_9_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestColorControl_9_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestColorControl_9_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestColorControl_9_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : TH writes 0 to the Options attribute\n"); + err = TestThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : TH sends On command to DUT\n"); + err = TestThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); + err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 100ms\n"); + err = TestWaitFor100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read ColorLoopActive attribute from DUT\n"); + err = TestReadColorLoopActiveAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Read ColorLoopDirection attribute from DUT\n"); + err = TestReadColorLoopDirectionAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x4UpdateTimeAndTimeAttributeTo55sForOneLoopToDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Read ColorLoopTime attribute from DUT\n"); + err = TestReadColorLoopTimeAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x8UpdateStartHueAndStartHueAttributeTo0x00A0ToDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Read ColorLoopStartEnhancedHue attribute from DUT\n"); + err = TestReadColorLoopStartEnhancedHueAttributeFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Read ColorLoopActive attribute from DUT\n"); + err = TestReadColorLoopActiveAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); + err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Wait for 5S\n"); + err = TestWaitFor5s_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT\n"); + err = TestSavingValueForComparisonInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Wait for 5S\n"); + err = TestWaitFor5s_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Read ColorLoopActive attribute from DUT\n"); + err = TestReadColorLoopActiveAttributeFromDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.\n"); + err = TestSavingValueForComparisonInStep6cReadColorLoopStoredEnhancedHueAttributeFromDut_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Read ColorLoopDirection attribute from DUT\n"); + err = TestReadColorLoopDirectionAttributeFromDut_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Read ColorLoopActive attribute from DUT\n"); + err = TestReadColorLoopActiveAttributeFromDut_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); + err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for 5S\n"); + err = TestWaitFor5s_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT\n"); + err = TestSavingValueForComparisionInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Wait for 5S\n"); + err = TestWaitFor5s_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Read ColorLoopActive attribute from DUT\n"); + err = TestReadColorLoopActiveAttributeFromDut_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT\n"); + err = TestSavingValueForComparisionInStep9cReadColorLoopStoredEnhancedHueAttributeFromDut_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); + err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Wait 10ms\n"); + err = TestWait10ms_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Read ColorLoopDirection attribute from DUT\n"); + err = TestReadColorLoopDirectionAttributeFromDut_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Read ColorLoopActive attribute from DUT\n"); + err = TestReadColorLoopActiveAttributeFromDut_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); + err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Wait for 5S\n"); + err = TestWaitFor5s_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT\n"); + err = TestSavingValueForComparisionInStep12dReadColorLoopStartEnhancedHueAttributeFromDut_48(); + break; + case 49: + ChipLogProgress(chipTool, " ***** Test Step 49 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_49(); + break; + case 50: + ChipLogProgress(chipTool, " ***** Test Step 50 : Wait for 5S\n"); + err = TestWaitFor5s_50(); + break; + case 51: + ChipLogProgress(chipTool, " ***** Test Step 51 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_51(); + break; + case 52: + ChipLogProgress(chipTool, " ***** Test Step 52 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_52(); + break; + case 53: + ChipLogProgress(chipTool, " ***** Test Step 53 : Read ColorLoopActive attribute from DUT\n"); + err = TestReadColorLoopActiveAttributeFromDut_53(); + break; + case 54: + ChipLogProgress(chipTool, " ***** Test Step 54 : Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.\n"); + err = TestSavingValueForComparisionInStep13cReadColorLoopStoredEnhancedHueAttributeFromDut_54(); + break; + case 55: + ChipLogProgress(chipTool, " ***** Test Step 55 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_55(); + break; + case 56: + ChipLogProgress(chipTool, " ***** Test Step 56 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_56(); + break; + case 57: + ChipLogProgress(chipTool, " ***** Test Step 57 : Read ColorLoopDirection attribute from DUT\n"); + err = TestReadColorLoopDirectionAttributeFromDut_57(); + break; + case 58: + ChipLogProgress(chipTool, " ***** Test Step 58 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_58(); + break; + case 59: + ChipLogProgress(chipTool, " ***** Test Step 59 : Read ColorLoopActive attribute from DUT\n"); + err = TestReadColorLoopActiveAttributeFromDut_59(); + break; + case 60: + ChipLogProgress(chipTool, " ***** Test Step 60 : Read ColorLoopStoredEnhancedHue attribute from DUT\n"); + err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_60(); + break; + case 61: + ChipLogProgress(chipTool, " ***** Test Step 61 : Wait for 5S\n"); + err = TestWaitFor5s_61(); + break; + case 62: + ChipLogProgress(chipTool, " ***** Test Step 62 : Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT\n"); + err = TestSavingValueForComparisionInStep15dReadColorLoopStartEnhancedHueAttributeFromDut_62(); + break; + case 63: + ChipLogProgress(chipTool, " ***** Test Step 63 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_63(); + break; + case 64: + ChipLogProgress(chipTool, " ***** Test Step 64 : Wait for 5S\n"); + err = TestWaitFor5s_64(); + break; + case 65: + ChipLogProgress(chipTool, " ***** Test Step 65 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_65(); + break; + case 66: + ChipLogProgress(chipTool, " ***** Test Step 66 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_66(); + break; + case 67: + ChipLogProgress(chipTool, " ***** Test Step 67 : Read ColorLoopActive attribute from DUT\n"); + err = TestReadColorLoopActiveAttributeFromDut_67(); + break; + case 68: + ChipLogProgress(chipTool, " ***** Test Step 68 : Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.\n"); + err = TestSavingValueForComparisionInStep16bReadColorLoopStoredEnhancedHueAttributeFromDut_68(); + break; + case 69: + ChipLogProgress(chipTool, " ***** Test Step 69 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_69(); + break; + case 70: + ChipLogProgress(chipTool, " ***** Test Step 70 : Turn Off light for color control tests\n"); + err = TestTurnOffLightForColorControlTests_70(); + break; + case 71: + ChipLogProgress(chipTool, " ***** Test Step 71 : Check on/off attribute value is false after off command\n"); + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_71(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 49: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 50: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 51: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 52: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 53: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 54: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 55: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 56: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 57: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 58: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 59: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 60: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 61: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 62: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 63: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 64: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 65: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 66: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 67: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 68: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 69: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 70: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 71: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(400)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 72; + + chip::Optional mNodeId; + chip::Optional mTimeout; + chip::Optional mCluster; + chip::Optional mEndpoint; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; + params.enhancedHue = + [NSNumber numberWithUnsignedShort:16384U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster enhancedMoveToHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); + } else { + NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:1U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:2U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x4UpdateTimeAndTimeAttributeTo55sForOneLoopToDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:4U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:5U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x4 (UpdateTime) and Time attribute to 5 (5s for one loop) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopTimeAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopTime attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopTime attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopTime", actualValue, 5U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x8UpdateStartHueAndStartHueAttributeTo0x00A0ToDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:8U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:160U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x8 (UpdateStartHue) and StartHue attribute to 0x00A0 to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopStartEnhancedHueAttributeFromDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopStartEnhancedHue", actualValue, 160U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:1U]; + params.action = + [NSNumber numberWithUnsignedChar:1U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_16() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + NSNumber * _Nonnull ColorLoopStartEnhancedHueStep5d; + + CHIP_ERROR TestSavingValueForComparisonInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Saving value for comparison in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ColorLoopStartEnhancedHueStep5d = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep5d)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_19() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep5d)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:1U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep6c; + + CHIP_ERROR TestSavingValueForComparisonInStep6cReadColorLoopStoredEnhancedHueAttributeFromDut_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Saving value for comparison in step 6c read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ColorLoopStoredEnhancedHueStep6c = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep6c)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:2U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:1U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:1U]; + params.action = + [NSNumber numberWithUnsignedChar:1U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_30() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + NSNumber * _Nonnull ColorLoopStartEnhancedHueStep8d; + + CHIP_ERROR TestSavingValueForComparisionInStep8dReadColorLoopStartEnhancedHueAttributeFromDut_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Saving value for comparision in step 8d read ColorLoopStartEnhancedHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ColorLoopStartEnhancedHueStep8d = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep8d)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_33() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep8d)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:1U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep9c; + + CHIP_ERROR TestSavingValueForComparisionInStep9cReadColorLoopStoredEnhancedHueAttributeFromDut_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Saving value for comparision in step 9c read ColorLoopStoredEnhancedHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ColorLoopStoredEnhancedHueStep9c = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep9c)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; + params.enhancedHue = + [NSNumber numberWithUnsignedShort:16384U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster enhancedMoveToHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); + } else { + NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10ms_40() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, 16384U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x0DecrementHueToDut_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:2U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x0 (decrement hue) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:1U]; + params.action = + [NSNumber numberWithUnsignedChar:2U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_47() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + NSNumber * _Nonnull ColorLoopStartEnhancedHueStep12d; + + CHIP_ERROR TestSavingValueForComparisionInStep12dReadColorLoopStartEnhancedHueAttributeFromDut_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Saving value for comparision in step 12d read ColorLoopStartEnhancedHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ColorLoopStartEnhancedHueStep12d = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_49() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep12d)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_50() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_51() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep12d)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_52() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:1U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_53() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep13c; + + CHIP_ERROR TestSavingValueForComparisionInStep13cReadColorLoopStoredEnhancedHueAttributeFromDut_54() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Saving value for comparision in step 13c read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ColorLoopStoredEnhancedHueStep13c = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_55() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep13c)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_56() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:2U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:1U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_57() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopDirection attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopDirection attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x2StartFromEnhancedCurrentHueToDut_58() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:1U]; + params.action = + [NSNumber numberWithUnsignedChar:2U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x2 (start from EnhancedCurrentHue) to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_59() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_60() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_61() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + NSNumber * _Nonnull ColorLoopStartEnhancedHueStep15d; + + CHIP_ERROR TestSavingValueForComparisionInStep15dReadColorLoopStartEnhancedHueAttributeFromDut_62() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Saving value for comparision in step 15d read ColorLoopStartEnhancedHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ColorLoopStartEnhancedHueStep15d = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_63() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep15d)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_64() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_65() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueStep15d)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_66() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:1U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_67() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull ColorLoopStoredEnhancedHueStep16b; + + CHIP_ERROR TestSavingValueForComparisionInStep16bReadColorLoopStoredEnhancedHueAttributeFromDut_68() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Saving value for comparision in step 16b read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ColorLoopStoredEnhancedHueStep16b = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_69() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueStep16b)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightForColorControlTests_70() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn Off light for color control tests: Error: %@", err); + } else { + NSLog(@"Turn Off light for color control tests: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_71() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestColorControl_9_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestColorControl_9_2() + : TestCommandBridge("TestColorControl_9_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestColorControl_9_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestColorControl_9_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestColorControl_9_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : TH writes 0 to the Options attribute\n"); + err = TestThWrites0ToTheOptionsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : TH sends On command to DUT\n"); + err = TestThSendsOnCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).\n"); + err = TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 100ms\n"); + err = TestWaitFor100ms_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0xFActionAttributeTo0x0DeActivateDirectionAttributeTo0x0DecrementHueTimeAttributeTo30AndStartHueAttributeTo0x00A0ToDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read ColorLoopActive attribute from DUT\n"); + err = TestReadColorLoopActiveAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Read ColorLoopDirection attribute from DUT.\n"); + err = TestReadColorLoopDirectionAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Read ColorLoopTime attribute from DUT.\n"); + err = TestReadColorLoopTimeAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Read ColorLoopStartEnhancedHue attribute from DUT.\n"); + err = TestReadColorLoopStartEnhancedHueAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Read ColorLoopActive attribute from DUT.\n"); + err = TestReadColorLoopActiveAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Read ColorLoopStoredEnhancedHue attribute from DUT.\n"); + err = TestReadColorLoopStoredEnhancedHueAttributeFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for 5S\n"); + err = TestWaitFor5s_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.\n"); + err = TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Wait for 5S\n"); + err = TestWaitFor5s_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Read ColorLoopDirection attribute from DUT.\n"); + err = TestReadColorLoopDirectionAttributeFromDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Wait for 5S\n"); + err = TestWaitFor5s_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.\n"); + err = TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Wait for 5S\n"); + err = TestWaitFor5s_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Read EnhancedCurrentHue attribute from DUT\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.\n"); + err = TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Read ColorLoopActive attribute from DUT\n"); + err = TestReadColorLoopActiveAttributeFromDut_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.\n"); + err = TestSavingValueForComparisionReadColorLoopStoredEnhancedHueAttributeFromDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Read EnhancedCurrentHue attribute from DUT.\n"); + err = TestReadEnhancedCurrentHueAttributeFromDut_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Turn off light for color control tests\n"); + err = TestTurnOffLightForColorControlTests_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(400)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 31; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestThWrites0ToTheOptionsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsOnCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsEnhancedMoveToHueCommandToDutWithEnhancedHue0x4000Direction0x00ShortestDistanceAndTransitionTime0Immediately_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterEnhancedMoveToHueParams alloc] init]; + params.enhancedHue = + [NSNumber numberWithUnsignedShort:16384U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster enhancedMoveToHueWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Error: %@", err); + } else { + NSLog(@"TH sends EnhancedMoveToHue command to DUT with EnhancedHue=0x4000, Direction=0x00 (shortest distance) and TransitionTime=0 (immediately).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor100ms_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0xFActionAttributeTo0x0DeActivateDirectionAttributeTo0x0DecrementHueTimeAttributeTo30AndStartHueAttributeTo0x00A0ToDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:15U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:5U]; + params.startHue = + [NSNumber numberWithUnsignedShort:160U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0xF, Action attribute to 0x0 (De-activate), Direction attribute to 0x0 (decrement hue), Time attribute to 30, and StartHue attribute to 0x00A0 to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopDirection attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Read ColorLoopDirection attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopTimeAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopTime attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Read ColorLoopTime attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopTime", actualValue, 5U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopStartEnhancedHueAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Read ColorLoopStartEnhancedHue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopStartEnhancedHue", actualValue, 160U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x1StartFromColorLoopStartEnhancedHueToDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:1U]; + params.action = + [NSNumber numberWithUnsignedChar:1U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x1 (start from ColorLoopStartEnhancedHue) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopStoredEnhancedHueAttributeFromDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopStoredEnhancedHue", actualValue, 16384U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_13() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + NSNumber * _Nonnull ColorLoopStartEnhancedHueValue; + + CHIP_ERROR TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ColorLoopStartEnhancedHueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_16() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x2UpdateDirectionAndDirectionAttributeTo0x1IncrementHueToDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:2U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:1U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x2 (UpdateDirection) and Direction attribute to 0x1 (increment hue) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopDirectionAttributeFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopDirection attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Read ColorLoopDirection attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopDirection", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_20() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + NSNumber * _Nonnull ColorLoopStartEnhancedHueValue2; + + CHIP_ERROR TestSavingValueForComparisionReadColorLoopStartEnhancedHueAttributeFromDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStartEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Saving value for comparision read ColorLoopStartEnhancedHue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ColorLoopStartEnhancedHueValue2 = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue2)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_23() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("enhancedCurrentHue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("enhancedCurrentHue", [value unsignedShortValue], ColorLoopStartEnhancedHueValue2)); + VerifyOrReturn(CheckConstraintMaxValue("enhancedCurrentHue", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsColorLoopSetCommandToWithUpdateFlagAttributeTo0x1UpdateActionAndActionAttributeTo0x0DeActivateToDut_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRColorControlClusterColorLoopSetParams alloc] init]; + params.updateFlags = + [NSNumber numberWithUnsignedChar:1U]; + params.action = + [NSNumber numberWithUnsignedChar:0U]; + params.direction = + [NSNumber numberWithUnsignedChar:0U]; + params.time = + [NSNumber numberWithUnsignedShort:0U]; + params.startHue = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster colorLoopSetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Error: %@", err); + } else { + NSLog(@"TH sends ColorLoopSet command to with UpdateFlag attribute to 0x1 (UpdateAction) and Action attribute to 0x0 (De-activate) to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadColorLoopActiveAttributeFromDut_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopActiveWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read ColorLoopActive attribute from DUT: Error: %@", err); + } else { + NSLog(@"Read ColorLoopActive attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ColorLoopActive", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull ColorLoopStoredEnhancedHueValue3; + + CHIP_ERROR TestSavingValueForComparisionReadColorLoopStoredEnhancedHueAttributeFromDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeColorLoopStoredEnhancedHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Saving value for comparision read ColorLoopStoredEnhancedHue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ColorLoopStoredEnhancedHueValue3 = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEnhancedCurrentHueAttributeFromDut_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterColorControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnhancedCurrentHueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read EnhancedCurrentHue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Read EnhancedCurrentHue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EnhancedCurrentHue", actualValue, ColorLoopStoredEnhancedHueValue3)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffLightForColorControlTests_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn off light for color control tests: Error: %@", err); + } else { + NSLog(@"Turn off light for color control tests: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CDOCONC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CDOCONC_1_1() + : TestCommandBridge("Test_TC_CDOCONC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CDOCONC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CDOCONC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CDOCONC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); + err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenCdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CDOCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3cGivenCdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CDOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3dGivenCdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CDOCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3eGivenCdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CDOCONC.S.F02 && CDOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3fGivenCdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CDOCONC.S.F02 && !CDOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3gGivenCdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("CDOCONC.S.F03 && CDOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3hGivenCdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CDOCONC.S.F03 && !CDOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3iGivenCdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("CDOCONC.S.F04 && CDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3jGivenCdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CDOCONC.S.F04 && !CDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3kGivenCdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("CDOCONC.S.F05 && CDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3lGivenCdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CDOCONC.S.F05 && !CDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3mGivenCdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); + if (ShouldSkip("CDOCONC.S.A0007 && CDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set\n"); + if (ShouldSkip(" !CDOCONC.S.A0007 ")) { + NextTest(); + return; + } + err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCdoconcsa0007IsNotSet_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); + if (ShouldSkip("CDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set\n"); + if (ShouldSkip(" !CDOCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCdoconcsf00MeaIsNotSet_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("CDOCONC.S.F04")) { + NextTest(); + return; + } + err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set\n"); + if (ShouldSkip(" !CDOCONC.S.F04 ")) { + NextTest(); + return; + } + err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf04PeaIsNotSet_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("CDOCONC.S.F05")) { + NextTest(); + return; + } + err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set\n"); + if (ShouldSkip(" !CDOCONC.S.F05 ")) { + NextTest(); + return; + } + err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf05AvgIsNotSet_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); + if (ShouldSkip("CDOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set\n"); + if (ShouldSkip(" !CDOCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCdoconcsf01LevIsNotSet_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); + err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 30; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenCdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given CDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenCdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3c: Given CDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenCdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given CDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenCdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3e: Given CDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenCdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given CDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenCdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3g: Given CDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenCdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given CDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iGivenCdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3i: Given CDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3jGivenCdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3j: Given CDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kGivenCdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3k: Given CDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3lGivenCdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3l: Given CDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3mGivenCdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3m: Given CDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCdoconcsa0007IsNotSet_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set: Error: %@", err); + } else { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CDOCONC.S.A0007 is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCdoconcsf00MeaIsNotSet_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CDOCONC.S.F00 (MEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf04PeaIsNotSet_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F04 (PEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCdoconcsf05AvgIsNotSet_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set: Error: %@", err); + } else { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CDOCONC.S.F05 (AVG) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCdoconcsf01LevIsNotSet_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set: Error: %@", err); + } else { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CDOCONC.S.F01 (LEV) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CDOCONC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CDOCONC_2_1() + : TestCommandBridge("Test_TC_CDOCONC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CDOCONC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CDOCONC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CDOCONC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); + if (ShouldSkip("CDOCONC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); + if (ShouldSkip("CDOCONC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); + if (ShouldSkip("CDOCONC.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); + if (ShouldSkip("CDOCONC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); + if (ShouldSkip("CDOCONC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); + if (ShouldSkip("CDOCONC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); + if (ShouldSkip("CDOCONC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); + if (ShouldSkip("CDOCONC.S.A0008")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); + if (ShouldSkip("CDOCONC.S.A0009")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); + if (ShouldSkip("CDOCONC.S.A000a")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); + if (ShouldSkip("CDOCONC.S.A0007")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CMOCONC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CMOCONC_1_1() + : TestCommandBridge("Test_TC_CMOCONC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CMOCONC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CMOCONC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CMOCONC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); + err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CMOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenCmoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CMOCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3cGivenCmoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CMOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3dGivenCmoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CMOCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3eGivenCmoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CMOCONC.S.F02 && CMOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3fGivenCmoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CMOCONC.S.F02 && !CMOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3gGivenCmoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("CMOCONC.S.F03 && CMOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3hGivenCmoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CMOCONC.S.F03 && !CMOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3iGivenCmoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("CMOCONC.S.F04 && CMOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3jGivenCmoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CMOCONC.S.F04 && !CMOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3kGivenCmoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("CMOCONC.S.F05 && CMOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3lGivenCmoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !CMOCONC.S.F05 && !CMOCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3mGivenCmoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); + if (ShouldSkip("CMOCONC.S.A0007 && CMOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set\n"); + if (ShouldSkip(" !CMOCONC.S.A0007 ")) { + NextTest(); + return; + } + err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCmoconcsa0007IsNotSet_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); + if (ShouldSkip("CMOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set\n"); + if (ShouldSkip(" !CMOCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCmoconcsf00MeaIsNotSet_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("CMOCONC.S.F04")) { + NextTest(); + return; + } + err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set\n"); + if (ShouldSkip(" !CMOCONC.S.F04 ")) { + NextTest(); + return; + } + err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf04PeaIsNotSet_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("CMOCONC.S.F05")) { + NextTest(); + return; + } + err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set\n"); + if (ShouldSkip(" !CMOCONC.S.F05 ")) { + NextTest(); + return; + } + err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf05AvgIsNotSet_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); + if (ShouldSkip("CMOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set\n"); + if (ShouldSkip(" !CMOCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCmoconcsf01LevIsNotSet_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); + err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 30; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenCmoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given CMOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenCmoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3c: Given CMOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenCmoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given CMOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenCmoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3e: Given CMOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenCmoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given CMOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenCmoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3g: Given CMOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenCmoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given CMOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iGivenCmoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3i: Given CMOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3jGivenCmoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3j: Given CMOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kGivenCmoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3k: Given CMOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3lGivenCmoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3l: Given CMOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3mGivenCmoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3m: Given CMOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenCmoconcsa0007IsNotSet_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set: Error: %@", err); + } else { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when CMOCONC.S.A0007 is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenCmoconcsf00MeaIsNotSet_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when CMOCONC.S.F00 (MEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf04PeaIsNotSet_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F04 (PEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenCmoconcsf05AvgIsNotSet_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set: Error: %@", err); + } else { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when CMOCONC.S.F05 (AVG) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenCmoconcsf01LevIsNotSet_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set: Error: %@", err); + } else { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when CMOCONC.S.F01 (LEV) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CMOCONC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CMOCONC_2_1() + : TestCommandBridge("Test_TC_CMOCONC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CMOCONC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CMOCONC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CMOCONC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); + if (ShouldSkip("CMOCONC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); + if (ShouldSkip("CMOCONC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); + if (ShouldSkip("CMOCONC.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); + if (ShouldSkip("CMOCONC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); + if (ShouldSkip("CMOCONC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); + if (ShouldSkip("CMOCONC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); + if (ShouldSkip("CMOCONC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); + if (ShouldSkip("CMOCONC.S.A0008")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); + if (ShouldSkip("CMOCONC.S.A0009")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); + if (ShouldSkip("CMOCONC.S.A000a")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); + if (ShouldSkip("CMOCONC.S.A0007")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterCarbonMonoxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FLDCONC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FLDCONC_1_1() + : TestCommandBridge("Test_TC_FLDCONC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FLDCONC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLDCONC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLDCONC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set\n"); + err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("FLDCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenFldconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !FLDCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3cGivenFldconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("FLDCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3dGivenFldconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !FLDCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3eGivenFldconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("FLDCONC.S.F02 && FLDCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3fGivenFldconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !FLDCONC.S.F02 && !FLDCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3gGivenFldconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("FLDCONC.S.F03 && FLDCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3hGivenFldconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !FLDCONC.S.F03 && !FLDCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3iGivenFldconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("FLDCONC.S.F04 && FLDCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3jGivenFldconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !FLDCONC.S.F04 && !FLDCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3kGivenFldconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("FLDCONC.S.F05 && FLDCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3lGivenFldconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !FLDCONC.S.F05 && !FLDCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3mGivenFldconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); + if (ShouldSkip("FLDCONC.S.A0007 && FLDCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set\n"); + if (ShouldSkip(" !FLDCONC.S.A0007 ")) { + NextTest(); + return; + } + err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenFldconcsa0007IsNotSet_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); + if (ShouldSkip("FLDCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set\n"); + if (ShouldSkip(" !FLDCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenFldconcsf00MeaIsNotSet_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("FLDCONC.S.F04")) { + NextTest(); + return; + } + err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set\n"); + if (ShouldSkip(" !FLDCONC.S.F04 ")) { + NextTest(); + return; + } + err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf04PeaIsNotSet_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("FLDCONC.S.F05")) { + NextTest(); + return; + } + err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set\n"); + if (ShouldSkip(" !FLDCONC.S.F05 ")) { + NextTest(); + return; + } + err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf05AvgIsNotSet_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); + if (ShouldSkip("FLDCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set\n"); + if (ShouldSkip(" !FLDCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenFldconcsf01LevIsNotSet_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 30; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenFldconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given FLDCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenFldconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3c: Given FLDCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenFldconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given FLDCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenFldconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3e: Given FLDCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenFldconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given FLDCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenFldconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3g: Given FLDCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenFldconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given FLDCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iGivenFldconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3i: Given FLDCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3jGivenFldconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3j: Given FLDCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kGivenFldconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3k: Given FLDCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3lGivenFldconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3l: Given FLDCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3mGivenFldconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3m: Given FLDCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenFldconcsa0007IsNotSet_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set: Error: %@", err); + } else { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when FLDCONC.S.A0007 is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenFldconcsf00MeaIsNotSet_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when FLDCONC.S.F00 (MEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf04PeaIsNotSet_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F04 (PEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenFldconcsf05AvgIsNotSet_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set: Error: %@", err); + } else { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when FLDCONC.S.F05 (AVG) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenFldconcsf01LevIsNotSet_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set: Error: %@", err); + } else { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when FLDCONC.S.F01 (LEV) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FLDCONC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FLDCONC_2_1() + : TestCommandBridge("Test_TC_FLDCONC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FLDCONC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLDCONC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLDCONC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); + if (ShouldSkip("FLDCONC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); + if (ShouldSkip("FLDCONC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); + if (ShouldSkip("FLDCONC.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); + if (ShouldSkip("FLDCONC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); + if (ShouldSkip("FLDCONC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); + if (ShouldSkip("FLDCONC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); + if (ShouldSkip("FLDCONC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); + if (ShouldSkip("FLDCONC.S.A0008")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); + if (ShouldSkip("FLDCONC.S.A0009")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); + if (ShouldSkip("FLDCONC.S.A000a")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); + if (ShouldSkip("FLDCONC.S.A0007")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFormaldehydeConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_NDOCONC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_NDOCONC_1_1() + : TestCommandBridge("Test_TC_NDOCONC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_NDOCONC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_NDOCONC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_NDOCONC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set\n"); + err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("NDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenNdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !NDOCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3cGivenNdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("NDOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3dGivenNdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !NDOCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3eGivenNdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("NDOCONC.S.F02 && NDOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3fGivenNdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !NDOCONC.S.F02 && !NDOCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3gGivenNdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("NDOCONC.S.F03 && NDOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3hGivenNdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !NDOCONC.S.F03 && !NDOCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3iGivenNdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("NDOCONC.S.F04 && NDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3jGivenNdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !NDOCONC.S.F04 && NDOCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3kGivenNdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("NDOCONC.S.F05 && NDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3lGivenNdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !NDOCONC.S.F05 && !NDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3mGivenNdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); + if (ShouldSkip("NDOCONC.S.A0007 && NDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set\n"); + if (ShouldSkip(" !NDOCONC.S.A0007 ")) { + NextTest(); + return; + } + err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenNdoconcsa0007IsNotSet_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); + if (ShouldSkip("NDOCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set\n"); + if (ShouldSkip(" !NDOCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenNdoconcsf00MeaIsNotSet_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("NDOCONC.S.F04")) { + NextTest(); + return; + } + err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set\n"); + if (ShouldSkip(" !NDOCONC.S.F04 ")) { + NextTest(); + return; + } + err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf04PeaIsNotSet_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("NDOCONC.S.F05")) { + NextTest(); + return; + } + err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set\n"); + if (ShouldSkip(" !NDOCONC.S.F05 ")) { + NextTest(); + return; + } + err = TestStep4iThReadsThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf05AvgIsNotSet_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); + if (ShouldSkip("NDOCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set\n"); + if (ShouldSkip(" !NDOCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenNdoconcsf01LevIsNotSet_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 30; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute. and check for either bit 0 or 1 set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenNdoconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given NDOCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenNdoconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3c: Given NDOCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenNdoconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given NDOCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenNdoconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3e: Given NDOCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenNdoconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given NDOCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenNdoconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3g: Given NDOCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenNdoconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given NDOCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iGivenNdoconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3i: Given NDOCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3jGivenNdoconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3j: Given NDOCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kGivenNdoconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3k: Given NDOCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3lGivenNdoconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3l: Given NDOCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3mGivenNdoconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3m: Given NDOCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenNdoconcsa0007IsNotSet_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set: Error: %@", err); + } else { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when NDOCONC.S.A0007 is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenNdoconcsf00MeaIsNotSet_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when NDOCONC.S.F00 (MEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf04PeaIsNotSet_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F04 (PEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThReadsThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenNdoconcsf05AvgIsNotSet_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set: Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when NDOCONC.S.F05 (AVG) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenNdoconcsf01LevIsNotSet_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set: Error: %@", err); + } else { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when NDOCONC.S.F01 (LEV) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_NDOCONC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_NDOCONC_2_1() + : TestCommandBridge("Test_TC_NDOCONC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_NDOCONC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_NDOCONC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_NDOCONC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); + if (ShouldSkip("NDOCONC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); + if (ShouldSkip("NDOCONC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); + if (ShouldSkip("NDOCONC.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); + if (ShouldSkip("NDOCONC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); + if (ShouldSkip("NDOCONC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); + if (ShouldSkip("NDOCONC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); + if (ShouldSkip("NDOCONC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); + if (ShouldSkip("NDOCONC.S.A0008")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); + if (ShouldSkip("NDOCONC.S.A0009")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); + if (ShouldSkip("NDOCONC.S.A000a")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); + if (ShouldSkip("NDOCONC.S.A0007")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNitrogenDioxideConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OZCONC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OZCONC_1_1() + : TestCommandBridge("Test_TC_OZCONC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OZCONC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OZCONC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OZCONC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); + err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("OZCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenOzconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !OZCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3cGivenOzconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("OZCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3dGivenOzconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !OZCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3eGivenOzconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("OZCONC.S.F02 && OZCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3fGivenOzconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !OZCONC.S.F02 && !OZCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3gGivenOzconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("OZCONC.S.F03 && OZCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3hGivenOzconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !OZCONC.S.F03 && !OZCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3iGivenOzconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("OZCONC.S.F04 && OZCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3jGivenOzconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !OZCONC.S.F04 && !OZCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3kGivenOzconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("OZCONC.S.F05 && OZCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3lGivenOzconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !OZCONC.S.F05 && !OZCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3mGivenOzconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); + if (ShouldSkip("OZCONC.S.A0007 && OZCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set\n"); + if (ShouldSkip(" !OZCONC.S.A0007 ")) { + NextTest(); + return; + } + err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenOzconcsa0007IsNotSet_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); + if (ShouldSkip("OZCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set\n"); + if (ShouldSkip(" !OZCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenOzconcsf00MeaIsNotSet_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("OZCONC.S.F04")) { + NextTest(); + return; + } + err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set\n"); + if (ShouldSkip(" !OZCONC.S.F04 ")) { + NextTest(); + return; + } + err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf04PeaIsNotSet_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("OZCONC.S.F05")) { + NextTest(); + return; + } + err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set\n"); + if (ShouldSkip(" !OZCONC.S.F05 ")) { + NextTest(); + return; + } + err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf05AvgIsNotSet_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); + if (ShouldSkip("OZCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set\n"); + if (ShouldSkip(" !OZCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenOzconcsf01LevIsNotSet_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 30; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenOzconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given OZCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenOzconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3c: Given OZCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenOzconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given OZCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenOzconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3e: Given OZCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenOzconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given OZCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenOzconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3g: Given OZCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenOzconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given OZCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iGivenOzconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3i: Given OZCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3jGivenOzconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3j: Given OZCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kGivenOzconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3k: Given OZCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3lGivenOzconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3l: Given OZCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3mGivenOzconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3m: Given OZCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenOzconcsa0007IsNotSet_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set: Error: %@", err); + } else { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when OZCONC.S.A0007 is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenOzconcsf00MeaIsNotSet_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when OZCONC.S.F00 (MEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf04PeaIsNotSet_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F04 (PEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenOzconcsf05AvgIsNotSet_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set: Error: %@", err); + } else { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when OZCONC.S.F05 (AVG) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenOzconcsf01LevIsNotSet_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set: Error: %@", err); + } else { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when OZCONC.S.F01 (LEV) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OZCONC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OZCONC_2_1() + : TestCommandBridge("Test_TC_OZCONC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OZCONC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OZCONC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OZCONC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); + if (ShouldSkip("OZCONC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); + if (ShouldSkip("OZCONC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); + if (ShouldSkip("OZCONC.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); + if (ShouldSkip("OZCONC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); + if (ShouldSkip("OZCONC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); + if (ShouldSkip("OZCONC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); + if (ShouldSkip("OZCONC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); + if (ShouldSkip("OZCONC.S.A0008")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); + if (ShouldSkip("OZCONC.S.A0009")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); + if (ShouldSkip("OZCONC.S.A000a")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); + if (ShouldSkip("OZCONC.S.A0007")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOzoneConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PMHCONC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PMHCONC_1_1() + : TestCommandBridge("Test_TC_PMHCONC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PMHCONC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMHCONC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMHCONC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); + err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PMHCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenPmhconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMHCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3cGivenPmhconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PMHCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3dGivenPmhconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMHCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3eGivenPmhconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PMHCONC.S.F02 && PMHCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3fGivenPmhconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMHCONC.S.F02 && !PMHCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3gGivenPmhconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("PMHCONC.S.F03 && PMHCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3hGivenPmhconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMHCONC.S.F03 && !PMHCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3iGivenPmhconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("PMHCONC.S.F04 && PMHCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3jGivenPmhconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMHCONC.S.F04 && PMHCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3kGivenPmhconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("PMHCONC.S.F05 && PMHCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3lGivenPmhconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMHCONC.S.F05 && !PMHCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3mGivenPmhconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); + if (ShouldSkip("PMHCONC.S.A0007 && PMHCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set\n"); + if (ShouldSkip(" !PMHCONC.S.A0007 ")) { + NextTest(); + return; + } + err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmhconcsa0007IsNotSet_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); + if (ShouldSkip("PMHCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set\n"); + if (ShouldSkip(" !PMHCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmhconcsf00MeaIsNotSet_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("PMHCONC.S.F04")) { + NextTest(); + return; + } + err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set\n"); + if (ShouldSkip(" !PMHCONC.S.F04 ")) { + NextTest(); + return; + } + err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf04PeaIsNotSet_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("PMHCONC.S.F05")) { + NextTest(); + return; + } + err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set\n"); + if (ShouldSkip(" !PMHCONC.S.F05 ")) { + NextTest(); + return; + } + err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf05AvgIsNotSet_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); + if (ShouldSkip("PMHCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set\n"); + if (ShouldSkip(" !PMHCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmhconcsf01LevIsNotSet_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); + err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 30; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenPmhconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given PMHCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenPmhconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3c: Given PMHCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenPmhconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given PMHCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenPmhconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3e: Given PMHCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenPmhconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given PMHCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenPmhconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3g: Given PMHCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenPmhconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given PMHCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iGivenPmhconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3i: Given PMHCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3jGivenPmhconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3j: Given PMHCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kGivenPmhconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3k: Given PMHCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3lGivenPmhconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3l: Given PMHCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3mGivenPmhconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3m: Given PMHCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmhconcsa0007IsNotSet_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set: Error: %@", err); + } else { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMHCONC.S.A0007 is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmhconcsf00MeaIsNotSet_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMHCONC.S.F00 (MEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf04PeaIsNotSet_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F04 (PEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmhconcsf05AvgIsNotSet_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set: Error: %@", err); + } else { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMHCONC.S.F05 (AVG) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmhconcsf01LevIsNotSet_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set: Error: %@", err); + } else { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMHCONC.S.F01 (LEV) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PMHCONC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PMHCONC_2_1() + : TestCommandBridge("Test_TC_PMHCONC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PMHCONC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMHCONC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMHCONC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); + if (ShouldSkip("PMHCONC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); + if (ShouldSkip("PMHCONC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); + if (ShouldSkip("PMHCONC.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); + if (ShouldSkip("PMHCONC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); + if (ShouldSkip("PMHCONC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); + if (ShouldSkip("PMHCONC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); + if (ShouldSkip("PMHCONC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); + if (ShouldSkip("PMHCONC.S.A0008")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); + if (ShouldSkip("PMHCONC.S.A0009")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); + if (ShouldSkip("PMHCONC.S.A000a")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); + if (ShouldSkip("PMHCONC.S.A0007")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM1ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PMICONC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PMICONC_1_1() + : TestCommandBridge("Test_TC_PMICONC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PMICONC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMICONC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMICONC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); + err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PMICONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenPmiconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMICONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3cGivenPmiconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PMICONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3dGivenPmiconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMICONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3eGivenPmiconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PMICONC.S.F02 && PMICONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3fGivenPmiconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMICONC.S.F02 && !PMICONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3gGivenPmiconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("PMICONC.S.F03 && PMICONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3hGivenPmiconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMICONC.S.F03 && !PMICONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3iGivenPmiconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("PMICONC.S.F04 && PMICONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3jGivenPmiconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMICONC.S.F04 && !PMICONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3kGivenPmiconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("PMICONC.S.F05 && PMICONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3lGivenPmiconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMICONC.S.F05 && !PMICONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3mGivenPmiconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); + if (ShouldSkip("PMICONC.S.A0007 && PMICONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set\n"); + if (ShouldSkip(" !PMICONC.S.A0007 ")) { + NextTest(); + return; + } + err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmiconcsa0007IsNotSet_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); + if (ShouldSkip("PMICONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set\n"); + if (ShouldSkip(" !PMICONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmiconcsf00MeaIsNotSet_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("PMICONC.S.F04")) { + NextTest(); + return; + } + err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set\n"); + if (ShouldSkip(" !PMICONC.S.F04 ")) { + NextTest(); + return; + } + err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf04PeaIsNotSet_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("PMICONC.S.F05")) { + NextTest(); + return; + } + err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set\n"); + if (ShouldSkip(" !PMICONC.S.F05 ")) { + NextTest(); + return; + } + err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf05AvgIsNotSet_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); + if (ShouldSkip("PMICONC.S.F01")) { + NextTest(); + return; + } + err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set\n"); + if (ShouldSkip(" !PMICONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmiconcsf01LevIsNotSet_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); + err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 30; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenPmiconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given PMICONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenPmiconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3c: Given PMICONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenPmiconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given PMICONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenPmiconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3e: Given PMICONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenPmiconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given PMICONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenPmiconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3g: Given PMICONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenPmiconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given PMICONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iGivenPmiconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3i: Given PMICONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3jGivenPmiconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3j: Given PMICONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kGivenPmiconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3k: Given PMICONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3lGivenPmiconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3l: Given PMICONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3mGivenPmiconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3m: Given PMICONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmiconcsa0007IsNotSet_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set: Error: %@", err); + } else { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMICONC.S.A0007 is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmiconcsf00MeaIsNotSet_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMICONC.S.F00 (MEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf04PeaIsNotSet_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F04 (PEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmiconcsf05AvgIsNotSet_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set: Error: %@", err); + } else { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMICONC.S.F05 (AVG) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmiconcsf01LevIsNotSet_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set: Error: %@", err); + } else { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMICONC.S.F01 (LEV) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PMICONC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PMICONC_2_1() + : TestCommandBridge("Test_TC_PMICONC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PMICONC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMICONC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMICONC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); + if (ShouldSkip("PMICONC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); + if (ShouldSkip("PMICONC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); + if (ShouldSkip("PMICONC.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); + if (ShouldSkip("PMICONC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); + if (ShouldSkip("PMICONC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); + if (ShouldSkip("PMICONC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); + if (ShouldSkip("PMICONC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); + if (ShouldSkip("PMICONC.S.A0008")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); + if (ShouldSkip("PMICONC.S.A0009")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); + if (ShouldSkip("PMICONC.S.A000a")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); + if (ShouldSkip("PMICONC.S.A0007")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM25ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PMKCONC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PMKCONC_1_1() + : TestCommandBridge("Test_TC_PMKCONC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PMKCONC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMKCONC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMKCONC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set\n"); + err = TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PMKCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenPmkconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMKCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3cGivenPmkconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PMKCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3dGivenPmkconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMKCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3eGivenPmkconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PMKCONC.S.F02 && PMKCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3fGivenPmkconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMKCONC.S.F02 && !PMKCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3gGivenPmkconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("PMKCONC.S.F03 && PMKCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3hGivenPmkconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMKCONC.S.F03 && !PMKCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3iGivenPmkconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("PMKCONC.S.F04 && PMKCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3jGivenPmkconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMKCONC.S.F04 && !PMKCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3kGivenPmkconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("PMKCONC.S.F05 && PMKCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3lGivenPmkconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !PMKCONC.S.F05 && !PMKCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3mGivenPmkconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: Read the optional attribute Uncertainty in AttributeList\n"); + if (ShouldSkip("PMKCONC.S.A0007 && PMKCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set\n"); + if (ShouldSkip(" !PMKCONC.S.A0007 ")) { + NextTest(); + return; + } + err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmkconcsa0007IsNotSet_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); + if (ShouldSkip("PMKCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set\n"); + if (ShouldSkip(" !PMKCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmkconcsf00MeaIsNotSet_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("PMKCONC.S.F04")) { + NextTest(); + return; + } + err = TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set\n"); + if (ShouldSkip(" !PMKCONC.S.F04 ")) { + NextTest(); + return; + } + err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf04PeaIsNotSet_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("PMKCONC.S.F05")) { + NextTest(); + return; + } + err = TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set\n"); + if (ShouldSkip(" !PMKCONC.S.F05 ")) { + NextTest(); + return; + } + err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf05AvgIsNotSet_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList\n"); + if (ShouldSkip("PMKCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set\n"); + if (ShouldSkip(" !PMKCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmkconcsf01LevIsNotSet_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: Read the global attribute: AcceptedCommandList\n"); + err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: Read the global attribute: GeneratedCommandList\n"); + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_29(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 30; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMapAndCheckForEitherBit0Or1Set_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: FeatureMap and check for either bit 0 or 1 set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenPmkconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given PMKCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenPmkconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3c: Given PMKCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenPmkconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given PMKCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenPmkconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3e: Given PMKCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenPmkconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given PMKCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenPmkconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3g: Given PMKCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenPmkconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given PMKCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iGivenPmkconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3i: Given PMKCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3jGivenPmkconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3j: Given PMKCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kGivenPmkconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3k: Given PMKCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3lGivenPmkconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3l: Given PMKCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3mGivenPmkconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3m: Given PMKCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheOptionalAttributeUncertaintyInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the optional attribute Uncertainty in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenPmkconcsa0007IsNotSet_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set: Error: %@", err); + } else { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when PMKCONC.S.A0007 is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dReadTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: Read the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenPmkconcsf00MeaIsNotSet_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when PMKCONC.S.F00 (MEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fReadTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: Read the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf04PeaIsNotSet_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F04 (PEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hReadTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: Read the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenPmkconcsf05AvgIsNotSet_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set: Error: %@", err); + } else { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when PMKCONC.S.F05 (AVG) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jReadTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: Read the optional, feature dependent attribute LevelValue in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenPmkconcsf01LevIsNotSet_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set: Error: %@", err); + } else { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when PMKCONC.S.F01 (LEV) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PMKCONC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PMKCONC_2_1() + : TestCommandBridge("Test_TC_PMKCONC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PMKCONC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PMKCONC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PMKCONC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); + if (ShouldSkip("PMKCONC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); + if (ShouldSkip("PMKCONC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); + if (ShouldSkip("PMKCONC.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); + if (ShouldSkip("PMKCONC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); + if (ShouldSkip("PMKCONC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); + if (ShouldSkip("PMKCONC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); + if (ShouldSkip("PMKCONC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); + if (ShouldSkip("PMKCONC.S.A0008")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); + if (ShouldSkip("PMKCONC.S.A0009")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); + if (ShouldSkip("PMKCONC.S.A000a")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); + if (ShouldSkip("PMKCONC.S.A0007")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPM10ConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_RNCONC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_RNCONC_1_1() + : TestCommandBridge("Test_TC_RNCONC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_RNCONC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_RNCONC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RNCONC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); + err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("RNCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenRnconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !RNCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3cGivenRnconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("RNCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3dGivenRnconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !RNCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3eGivenRnconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("RNCONC.S.F02 && RNCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3fGivenRnconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !RNCONC.S.F02 && !RNCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3gGivenRnconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("RNCONC.S.F03 && RNCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3hGivenRnconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !RNCONC.S.F03 && !RNCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3iGivenRnconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("RNCONC.S.F04 && RNCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3jGivenRnconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !RNCONC.S.F04 && RNCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3kGivenRnconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("RNCONC.S.F05 && RNCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3lGivenRnconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !RNCONC.S.F05 && !RNCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3mGivenRnconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); + if (ShouldSkip("RNCONC.S.A0007 && RNCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set\n"); + if (ShouldSkip(" !RNCONC.S.A0007 ")) { + NextTest(); + return; + } + err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenRnconcsa0007IsNotSet_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); + if (ShouldSkip("RNCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set\n"); + if (ShouldSkip(" !RNCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenRnconcsf00MeaIsNotSet_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("RNCONC.S.F04")) { + NextTest(); + return; + } + err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set\n"); + if (ShouldSkip(" !RNCONC.S.F04 ")) { + NextTest(); + return; + } + err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf04PeaIsNotSet_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("RNCONC.S.F05")) { + NextTest(); + return; + } + err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set\n"); + if (ShouldSkip(" !RNCONC.S.F05 ")) { + NextTest(); + return; + } + err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf05AvgIsNotSet_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); + if (ShouldSkip("RNCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set\n"); + if (ShouldSkip(" !RNCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenRnconcsf01LevIsNotSet_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 30; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenRnconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given RNCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenRnconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3c: Given RNCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenRnconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given RNCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenRnconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3e: Given RNCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenRnconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given RNCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenRnconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3g: Given RNCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenRnconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given RNCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iGivenRnconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3i: Given RNCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3jGivenRnconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3j: Given RNCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kGivenRnconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3k: Given RNCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3lGivenRnconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3l: Given RNCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3mGivenRnconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3m: Given RNCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenRnconcsa0007IsNotSet_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set: Error: %@", err); + } else { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when RNCONC.S.A0007 is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenRnconcsf00MeaIsNotSet_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when RNCONC.S.F00 (MEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf04PeaIsNotSet_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F04 (PEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenRnconcsf05AvgIsNotSet_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set: Error: %@", err); + } else { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when RNCONC.S.F05 (AVG) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenRnconcsf01LevIsNotSet_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set: Error: %@", err); + } else { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when RNCONC.S.F01 (LEV) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_RNCONC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_RNCONC_2_1() + : TestCommandBridge("Test_TC_RNCONC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_RNCONC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_RNCONC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RNCONC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); + if (ShouldSkip("RNCONC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); + if (ShouldSkip("RNCONC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); + if (ShouldSkip("RNCONC.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); + if (ShouldSkip("RNCONC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); + if (ShouldSkip("RNCONC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: H reads from the DUT the AverageMeasuredValue attribute.\n"); + if (ShouldSkip("RNCONC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7HReadsFromTheDutTheAverageMeasuredValueAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); + if (ShouldSkip("RNCONC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); + if (ShouldSkip("RNCONC.S.A0008")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); + if (ShouldSkip("RNCONC.S.A0009")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); + if (ShouldSkip("RNCONC.S.A000a")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); + if (ShouldSkip("RNCONC.S.A0007")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7HReadsFromTheDutTheAverageMeasuredValueAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: H reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: H reads from the DUT the AverageMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRadonConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TVOCCONC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TVOCCONC_1_1() + : TestCommandBridge("Test_TC_TVOCCONC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TVOCCONC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TVOCCONC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TVOCCONC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set\n"); + err = TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TVOCCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenTvocconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !TVOCCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3cGivenTvocconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TVOCCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3dGivenTvocconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !TVOCCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3eGivenTvocconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TVOCCONC.S.F02 && TVOCCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3fGivenTvocconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !TVOCCONC.S.F02 && !TVOCCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep3gGivenTvocconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("TVOCCONC.S.F03 && TVOCCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3hGivenTvocconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !TVOCCONC.S.F03 && !TVOCCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep3iGivenTvocconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("TVOCCONC.S.F04 && TVOCCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3jGivenTvocconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !TVOCCONC.S.F04 && !TVOCCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3kGivenTvocconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set\n"); + if (ShouldSkip("TVOCCONC.S.F05 && TVOCCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep3lGivenTvocconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear\n"); + if (ShouldSkip(" !TVOCCONC.S.F05 && !TVOCCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3mGivenTvocconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the optional attribute Uncertainty in AttributeList\n"); + if (ShouldSkip("TVOCCONC.S.A0007 && TVOCCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set\n"); + if (ShouldSkip(" !TVOCCONC.S.A0007 ")) { + NextTest(); + return; + } + err = TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenTvocconcsa0007IsNotSet_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList\n"); + if (ShouldSkip("TVOCCONC.S.F00")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set\n"); + if (ShouldSkip(" !TVOCCONC.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenTvocconcsf00MeaIsNotSet_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("TVOCCONC.S.F04")) { + NextTest(); + return; + } + err = TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set\n"); + if (ShouldSkip(" !TVOCCONC.S.F04 ")) { + NextTest(); + return; + } + err = TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf04PeaIsNotSet_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList\n"); + if (ShouldSkip("TVOCCONC.S.F05")) { + NextTest(); + return; + } + err = TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set\n"); + if (ShouldSkip(" !TVOCCONC.S.F05 ")) { + NextTest(); + return; + } + err = TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf05AvgIsNotSet_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList\n"); + if (ShouldSkip("TVOCCONC.S.F01")) { + NextTest(); + return; + } + err = TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set\n"); + if (ShouldSkip(" !TVOCCONC.S.F01 ")) { + NextTest(); + return; + } + err = TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenTvocconcsf01LevIsNotSet_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5: TH reads from the DUT the EventList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 30; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttributeAndCheckForEitherBit0Or1Set_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute and check for either bit 0 or 1 set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenTvocconcsf00meaEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given TVOCCONC.S.F00(MEA) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenTvocconcsf00meaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3c: Given TVOCCONC.S.F00(MEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenTvocconcsf01levEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given TVOCCONC.S.F01(LEV) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenTvocconcsf01levIsNotSetEnsureFeaturemapHasTheCorrectBitClear_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3e: Given TVOCCONC.S.F01(LEV) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenTvocconcsf02medEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given TVOCCONC.S.F02(MED) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenTvocconcsf02medIsNotSetEnsureFeaturemapHasTheCorrectBitClear_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3g: Given TVOCCONC.S.F02(MED) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenTvocconcsf03criEnsureFeaturemapHasTheCorrectBitsSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given TVOCCONC.S.F03(CRI) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iGivenTvocconcsf03criIsNotSetEnsureFeaturemapHasTheCorrectBitClear_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3i: Given TVOCCONC.S.F03(CRI) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3jGivenTvocconcsf04peaEnsureFeaturemapHasTheCorrectBitsSet_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3j: Given TVOCCONC.S.F04(PEA) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kGivenTvocconcsf04peaIsNotSetEnsureFeaturemapHasTheCorrectBitClear_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3k: Given TVOCCONC.S.F04(PEA) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3lGivenTvocconcsf05avgEnsureFeaturemapHasTheCorrectBitsSet_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set: Error: %@", err); + } else { + NSLog(@"Step 3l: Given TVOCCONC.S.F05(AVG) ensure featuremap has the correct bits set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3mGivenTvocconcsf05avgIsNotSetEnsureFeaturemapHasTheCorrectBitClear_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3m: Given TVOCCONC.S.F05(AVG) is not set, ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeUncertaintyInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute Uncertainty in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cCheckTheOptionalAttributeUncertaintyIsExcludedFromAttributeListWhenTvocconcsa0007IsNotSet_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set: Error: %@", err); + } else { + NSLog(@"Step 4c: Check the optional attribute Uncertainty is excluded from AttributeList when TVOCCONC.S.A0007 is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheOptionalFeatureDependentAttributesMeasuredValueMinMeasuredValueMaxMeasuredValueAndMeasurementUnitInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the optional, feature dependent attributes MeasuredValue, MinMeasuredValue, MaxMeasuredValue and Measurement Unit in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eCheckThatMeasuredValueMinMeasuredValueMaxMeasuredValueMeasurementUnitAndUncertaintyAreExcludedFromAttributeListWhenTvocconcsf00MeaIsNotSet_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4e: Check that MeasuredValue, MinMeasuredValue, MaxMeasuredValue, Measurement Unit and Uncertainty are excluded from AttributeList when TVOCCONC.S.F00 (MEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsTheOptionalFeatureDependentAttributesPeakMeasuredValuePeakMeasuredValueWindowInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads the optional, feature dependent attributes PeakMeasuredValue & PeakMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gCheckThatPeakMeasuredValuePeakMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf04PeaIsNotSet_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set: Error: %@", err); + } else { + NSLog(@"Step 4g: Check that PeakMeasuredValue & PeakMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F04 (PEA) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsTheOptionalFeatureDependentAttributesAverageMeasuredValueAverageMeasuredValueWindowInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads the optional, feature dependent attributes AverageMeasuredValue AverageMeasuredValueWindow in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iCheckThatAverageMeasuredValueAndAverageMeasuredValueWindowAreExcludedFromAttributeListWhenTvocconcsf05AvgIsNotSet_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set: Error: %@", err); + } else { + NSLog(@"Step 4i: Check that AverageMeasuredValue and AverageMeasuredValueWindow are excluded from AttributeList when TVOCCONC.S.F05 (AVG) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsTheOptionalFeatureDependentAttributeLevelValueInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads the optional, feature dependent attribute LevelValue in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kCheckThatLevelValueIsExcludedFromAttributeListWhenTvocconcsf01LevIsNotSet_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set: Error: %@", err); + } else { + NSLog(@"Step 4k: Check that LevelValue is excluded from AttributeList when TVOCCONC.S.F01 (LEV) is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TVOCCONC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TVOCCONC_2_1() + : TestCommandBridge("Test_TC_TVOCCONC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TVOCCONC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TVOCCONC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TVOCCONC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); + if (ShouldSkip("TVOCCONC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); + if (ShouldSkip("TVOCCONC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); + if (ShouldSkip("TVOCCONC.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the PeakMeasuredValue attribute.\n"); + if (ShouldSkip("TVOCCONC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.\n"); + if (ShouldSkip("TVOCCONC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the AverageMeasuredValue attribute.\n"); + if (ShouldSkip("TVOCCONC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.\n"); + if (ShouldSkip("TVOCCONC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MeasurementUnit attribute.\n"); + if (ShouldSkip("TVOCCONC.S.A0008")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MeasurementMedium attribute.\n"); + if (ShouldSkip("TVOCCONC.S.A0009")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the LevelValue attribute.\n"); + if (ShouldSkip("TVOCCONC.S.A000a")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheLevelValueAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the Uncertainty attribute.\n"); + if (ShouldSkip("TVOCCONC.S.A0007")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value floatValue], 0.0f)); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value floatValue], MinMeasuredValueValue)); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThePeakMeasuredValueAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the PeakMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("peakMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThePeakMeasuredValueWindowAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePeakMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the PeakMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("peakMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("peakMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("peakMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheAverageMeasuredValueAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the AverageMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("averageMeasuredValue", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValue", [value floatValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValue", [value floatValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheAverageMeasuredValueWindowAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAverageMeasuredValueWindowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the AverageMeasuredValueWindow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("averageMeasuredValueWindow", "elapsed_s", "elapsed_s")); + VerifyOrReturn(CheckConstraintMinValue("averageMeasuredValueWindow", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("averageMeasuredValueWindow", [value unsignedIntValue], 604800UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheMeasurementUnitAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the MeasurementUnit attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementUnit", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementUnit", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementUnit", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheMeasurementMediumAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasurementMediumWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the MeasurementMedium attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("measurementMedium", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("measurementMedium", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measurementMedium", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheLevelValueAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLevelValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the LevelValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("levelValue", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("levelValue", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("levelValue", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheUncertaintyAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTotalVolatileOrganicCompoundsConcentrationMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUncertaintyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the Uncertainty attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("uncertainty", "single", "single")); + VerifyOrReturn(CheckConstraintMinValue("uncertainty", [value floatValue], 0.0f)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OPCREDS_1_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OPCREDS_1_2() + : TestCommandBridge("Test_TC_OPCREDS_1_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OPCREDS_1_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OPCREDS_1_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OPCREDS_1_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 10UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_BINFO_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_BINFO_1_1() + : TestCommandBridge("Test_TC_BINFO_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_BINFO_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_BINFO_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_BINFO_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); + err = TestStep2ThReadsTheClusterRevisionFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); + err = TestStep3ThReadsTheFeatureMapFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList\n"); + if (ShouldSkip("BINFO.S.A000b")) { + NextTest(); + return; + } + err = TestStep4bThReadsOptionalAttributeManufacturingDateInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(PartNumber) in attributeList\n"); + if (ShouldSkip("BINFO.S.A000c")) { + NextTest(); + return; + } + err = TestStep4cThReadsOptionalAttributePartNumberInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(ProductURL) in attributeList\n"); + if (ShouldSkip("BINFO.S.A000d")) { + NextTest(); + return; + } + err = TestStep4dThReadsOptionalAttributeProductURLInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(ProductLabel) in attributeList\n"); + if (ShouldSkip("BINFO.S.A000e")) { + NextTest(); + return; + } + err = TestStep4eThReadsOptionalAttributeProductLabelInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(SerialNumber) in attributeList\n"); + if (ShouldSkip("BINFO.S.A000f")) { + NextTest(); + return; + } + err = TestStep4fThReadsOptionalAttributeSerialNumberInAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList\n"); + if (ShouldSkip("BINFO.S.A0010")) { + NextTest(); + return; + } + err = TestStep4gThReadsOptionalAttributeLocalConfigDisabledInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(Reachable) in attributeList\n"); + if (ShouldSkip("BINFO.S.A0011")) { + NextTest(); + return; + } + err = TestStep4hThReadsOptionalAttributeReachableInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads optional attribute(UniqueID) in attributeList\n"); + if (ShouldSkip("BINFO.S.A0012")) { + NextTest(); + return; + } + err = TestStep4iThReadsOptionalAttributeUniqueIDInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: TH reads EventList from DUT\n"); + if (ShouldSkip(" !BINFO.S.E00 && !BINFO.S.E01 && !BINFO.S.E02 && !BINFO.S.A0011 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: Read BINFO.S.E00(StartUp) event in EventList\n"); + if (ShouldSkip("BINFO.S.E00 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5c: Read BINFO.S.E01(ShutDown) event in EventList\n"); + if (ShouldSkip("BINFO.S.E01 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5d: Read BINFO.S.E02(Leave) event in EventList\n"); + if (ShouldSkip("BINFO.S.E02 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5e: Read (ReachableChanged) event in EventList\n"); + if (ShouldSkip("BINFO.S.A0011 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 20; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsOptionalAttributeManufacturingDateInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads optional attribute(ManufacturingDate) in attributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsOptionalAttributePartNumberInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads optional attribute(PartNumber) in attributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads optional attribute(PartNumber) in attributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsOptionalAttributeProductURLInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads optional attribute(ProductURL) in attributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads optional attribute(ProductURL) in attributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsOptionalAttributeProductLabelInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads optional attribute(ProductLabel) in attributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads optional attribute(ProductLabel) in attributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsOptionalAttributeSerialNumberInAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads optional attribute(SerialNumber) in attributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads optional attribute(SerialNumber) in attributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThReadsOptionalAttributeLocalConfigDisabledInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList: Error: %@", err); + } else { + NSLog(@"Step 4g: TH reads optional attribute(LocalConfigDisabled) in attributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsOptionalAttributeReachableInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads optional attribute(Reachable) in attributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads optional attribute(Reachable) in attributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThReadsOptionalAttributeUniqueIDInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads optional attribute(UniqueID) in attributeList: Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads optional attribute(UniqueID) in attributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CNET_1_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CNET_1_3() + : TestCommandBridge("Test_TC_CNET_1_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CNET_1_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CNET_1_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CNET_1_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap\n"); + if (ShouldSkip(" !CNET.S.F00 && !CNET.S.F01 && !CNET.S.F02 ")) { + NextTest(); + return; + } + err = TestStep3aReadTheGlobalAttributeFeatureMap_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Read the global attribute: FeatureMap when CNET.S.F00 is set\n"); + if (ShouldSkip("CNET.S.F00")) { + NextTest(); + return; + } + err = TestStep3bReadTheGlobalAttributeFeatureMapWhenCnetsf00IsSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Read the global attribute: FeatureMap when CNET.S.F01 is set\n"); + if (ShouldSkip("CNET.S.F01")) { + NextTest(); + return; + } + err = TestStep3cReadTheGlobalAttributeFeatureMapWhenCnetsf01IsSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Read the global attribute: FeatureMap when CNET.S.F02 is set\n"); + if (ShouldSkip("CNET.S.F02")) { + NextTest(); + return; + } + err = TestStep3dReadTheGlobalAttributeFeatureMapWhenCnetsf02IsSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: Read mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true\n"); + if (ShouldSkip("CNET.S.F00 || CNET.S.F01 || CNET.S.F02")) { + NextTest(); + return; + } + err = TestStep4bReadMandatoryAttributesInAttributeListIfCnetsf00wiCnetsf01thCnetsf02etIsTrue_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: Read the optional attribute(ScanMaxTimeSeconds): AttributeList\n"); + if (ShouldSkip("CNET.S.A0002")) { + NextTest(); + return; + } + err = TestStep4cReadTheOptionalAttributeScanMaxTimeSecondsAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: Reading optional attribute(ConnectMaxTimeSeconds) in AttributeList\n"); + if (ShouldSkip("CNET.S.A0003")) { + NextTest(); + return; + } + err = TestStep4dReadingOptionalAttributeConnectMaxTimeSecondsInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6a: Read AcceptedCommandList If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH)\n"); + if (ShouldSkip("( CNET.S.F00 || CNET.S.F01 )")) { + NextTest(); + return; + } + err = TestStep6aReadAcceptedCommandListIfDutSupportsWiFiThreadRelatedFeaturesCnetsf00wicnetsf01th_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6b: Read AcceptedCommandList If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true)\n"); + if (ShouldSkip("CNET.S.F00")) { + NextTest(); + return; + } + err = TestStep6bReadAcceptedCommandListIfDutSupportsWiFiRelatedFeaturesCnetsf00wiIsTrue_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6c: Read AcceptedCommandList If DUT supports Thread related features(CNET.S.F01(TH) is true)\n"); + if (ShouldSkip("CNET.S.F01")) { + NextTest(); + return; + } + err = TestStep6cReadAcceptedCommandListIfDutSupportsThreadRelatedFeaturesCNETSF01THIsTrue_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6d: Read AcceptedCommandList If DUT supports Ethernet related features(CNET.S.F02(TH) is true)\n"); + if (ShouldSkip("CNET.S.F02")) { + NextTest(); + return; + } + err = TestStep6dReadAcceptedCommandListIfDutSupportsEthernetRelatedFeaturesCNETSF02THIsTrue_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7a: Read the GeneratedCommandList If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true)\n"); + if (ShouldSkip("( CNET.S.F00 || CNET.S.F01 )")) { + NextTest(); + return; + } + err = TestStep7aReadTheGeneratedCommandListIfDutSupportsWiFiThreadRelatedFeaturesCNETSF00WIOrCnetsf01thIsTrue_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 7b: Read the GeneratedCommandList If DUT supports Ethernet related features(CNET.S.F02(ET) must be true)\n"); + if (ShouldSkip("CNET.S.F02")) { + NextTest(); + return; + } + err = TestStep7bReadTheGeneratedCommandListIfDutSupportsEthernetRelatedFeaturesCNETSF02ETMustBeTrue_17(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 18; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMap_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: FeatureMap: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: FeatureMap: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bReadTheGlobalAttributeFeatureMapWhenCnetsf00IsSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Read the global attribute: FeatureMap when CNET.S.F00 is set: Error: %@", err); + } else { + NSLog(@"Step 3b: Read the global attribute: FeatureMap when CNET.S.F00 is set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cReadTheGlobalAttributeFeatureMapWhenCnetsf01IsSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Read the global attribute: FeatureMap when CNET.S.F01 is set: Error: %@", err); + } else { + NSLog(@"Step 3c: Read the global attribute: FeatureMap when CNET.S.F01 is set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 2UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dReadTheGlobalAttributeFeatureMapWhenCnetsf02IsSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Read the global attribute: FeatureMap when CNET.S.F02 is set: Error: %@", err); + } else { + NSLog(@"Step 3d: Read the global attribute: FeatureMap when CNET.S.F02 is set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 4UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadMandatoryAttributesInAttributeListIfCnetsf00wiCnetsf01thCnetsf02etIsTrue_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true: Error: %@", err); + } else { + NSLog(@"Step 4b: Read mandatory attributes in AttributeList if CNET.S.F00(WI)/CNET.S.F01(TH)/CNET.S.F02(ET) is true: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cReadTheOptionalAttributeScanMaxTimeSecondsAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Read the optional attribute(ScanMaxTimeSeconds): AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: Read the optional attribute(ScanMaxTimeSeconds): AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dReadingOptionalAttributeConnectMaxTimeSecondsInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: Reading optional attribute(ConnectMaxTimeSeconds) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: Reading optional attribute(ConnectMaxTimeSeconds) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aReadAcceptedCommandListIfDutSupportsWiFiThreadRelatedFeaturesCnetsf00wicnetsf01th_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: Read AcceptedCommandList If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH): Error: %@", err); + } else { + NSLog(@"Step 6a: Read AcceptedCommandList If DUT supports Wi-Fi/Thread related features CNET.S.F00(WI),CNET.S.F01(TH): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bReadAcceptedCommandListIfDutSupportsWiFiRelatedFeaturesCnetsf00wiIsTrue_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: Read AcceptedCommandList If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true): Error: %@", err); + } else { + NSLog(@"Step 6b: Read AcceptedCommandList If DUT supports Wi-Fi related features (CNET.S.F00(WI) is true): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cReadAcceptedCommandListIfDutSupportsThreadRelatedFeaturesCNETSF01THIsTrue_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: Read AcceptedCommandList If DUT supports Thread related features(CNET.S.F01(TH) is true): Error: %@", err); + } else { + NSLog(@"Step 6c: Read AcceptedCommandList If DUT supports Thread related features(CNET.S.F01(TH) is true): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6dReadAcceptedCommandListIfDutSupportsEthernetRelatedFeaturesCNETSF02THIsTrue_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: Read AcceptedCommandList If DUT supports Ethernet related features(CNET.S.F02(TH) is true): Error: %@", err); + } else { + NSLog(@"Step 6d: Read AcceptedCommandList If DUT supports Ethernet related features(CNET.S.F02(TH) is true): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7aReadTheGeneratedCommandListIfDutSupportsWiFiThreadRelatedFeaturesCNETSF00WIOrCnetsf01thIsTrue_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7a: Read the GeneratedCommandList If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true): Error: %@", err); + } else { + NSLog(@"Step 7a: Read the GeneratedCommandList If DUT supports Wi-Fi/Thread related features(CNET.S.F00(WI) or CNET.S.F01(TH) is true): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7bReadTheGeneratedCommandListIfDutSupportsEthernetRelatedFeaturesCNETSF02ETMustBeTrue_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterNetworkCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7b: Read the GeneratedCommandList If DUT supports Ethernet related features(CNET.S.F02(ET) must be true): Error: %@", err); + } else { + NSLog(@"Step 7b: Read the GeneratedCommandList If DUT supports Ethernet related features(CNET.S.F02(ET) must be true): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DESC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DESC_1_1() + : TestCommandBridge("Test_TC_DESC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DESC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DESC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DESC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip("!DESC.S.F00")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList)\n"); + if (ShouldSkip("DESC.S.F00")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute0x0001ShallBeIncludedIfAndOnlyIfDESCSF00TagList_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00\n"); + if (ShouldSkip("DESC.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0004ShallBeIncludedIfAndOnlyIfDescsf00_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads AcceptedCommandList attribute from DUT\n"); + err = TestStep6ThReadsAcceptedCommandListAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); + err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute0x0001ShallBeIncludedIfAndOnlyIfDESCSF00TagList_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList): Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. 0x0001: SHALL be included if and only if DESC.S.F00(TagList): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0004ShallBeIncludedIfAndOnlyIfDescsf00_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0004: SHALL be included if and only if DESC.S.F00: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsAcceptedCommandListAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads AcceptedCommandList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DLOG_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DLOG_1_1() + : TestCommandBridge("Test_TC_DLOG_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DLOG_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DLOG_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DLOG_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); + err = TestStep2ThReadsTheClusterRevisionFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap from DUT\n"); + err = TestStep3ThReadsTheFeatureMapFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads AttributeList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsAttributeListFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads AttributeList from DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsAttributeListFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads EventList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads AcceptedCommandList from DUT\n"); + err = TestStep6ThReadsAcceptedCommandListFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads GeneratedCommandList from DUT\n"); + err = TestStep7ThReadsGeneratedCommandListFromDut_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheFeatureMapFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the FeatureMap from DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the FeatureMap from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsAttributeListFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsAttributeListFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDiagnosticLogs alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DGETH_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DGETH_1_1() + : TestCommandBridge("Test_TC_DGETH_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DGETH_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); + err = TestStep2ThReadsTheClusterRevisionFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); + if (ShouldSkip(" !DGETH.S.F00 && !DGETH.S.F01")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheFeatureMapFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DGETH.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenDgethsf00EnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DGETH.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenDgethsf01EnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads optional attribute(PHYRate) in AttributeList\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep4bThReadsOptionalAttributePHYRateInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads optional attribute(FullDuplex) in AttributeList\n"); + if (ShouldSkip("DGETH.S.A0001")) { + NextTest(); + return; + } + err = TestStep4cThReadsOptionalAttributeFullDuplexInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList\n"); + if (ShouldSkip("DGETH.S.A0002")) { + NextTest(); + return; + } + err = TestStep4dThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList\n"); + if (ShouldSkip("DGETH.S.A0003")) { + NextTest(); + return; + } + err = TestStep4eThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); + if (ShouldSkip("DGETH.S.A0004")) { + NextTest(); + return; + } + err = TestStep4fThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); + if (ShouldSkip("DGETH.S.A0005")) { + NextTest(); + return; + } + err = TestStep4gThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList\n"); + if (ShouldSkip("DGETH.S.A0006")) { + NextTest(); + return; + } + err = TestStep4hThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList\n"); + if (ShouldSkip("DGETH.S.A0007")) { + NextTest(); + return; + } + err = TestStep4iThReadsOptionalAttributeCarrierDetectInAttributeList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList\n"); + if (ShouldSkip("DGETH.S.A0008")) { + NextTest(); + return; + } + err = TestStep4jThReadsOptionalAttributeTimeSinceResetInAttributeList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5: TH reads EventList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6: TH reads AcceptedCommandList from DUT\n"); + if (ShouldSkip("( DGETH.S.F00 || DGETH.S.F01 )")) { + NextTest(); + return; + } + err = TestStep6ThReadsAcceptedCommandListFromDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads AcceptedCommandList from DUT\n"); + if (ShouldSkip(" !DGETH.S.F00 && !DGETH.S.F01 ")) { + NextTest(); + return; + } + err = TestStep6ThReadsAcceptedCommandListFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: TH reads GeneratedCommandList from DUT\n"); + err = TestStep7ThReadsGeneratedCommandListFromDut_19(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 20; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenDgethsf00EnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given DGETH.S.F00 ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenDgethsf01EnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given DGETH.S.F01 ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsOptionalAttributePHYRateInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads optional attribute(PHYRate) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads optional attribute(PHYRate) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsOptionalAttributeFullDuplexInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads optional attribute(FullDuplex) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads optional attribute(FullDuplex) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF00PKTCNTInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F00(PKTCNT)) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4g: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsOptionalAttributePacketRxCountAndFeatureDependentDGETHSF01ERRCNTInAttributeList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads optional attribute(PacketRxCount) and Feature dependent(DGETH.S.F01(ERRCNT)) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThReadsOptionalAttributeCarrierDetectInAttributeList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads optional attribute(CarrierDetect) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsOptionalAttributeTimeSinceResetInAttributeList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads optional attribute(TimeSinceReset) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DGETH_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DGETH_2_1() + : TestCommandBridge("Test_TC_DGETH_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DGETH_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads PHYRate attribute constraints\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsPHYRateAttributeConstraints_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FullDuplex attribute constraints\n"); + if (ShouldSkip("DGETH.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFullDuplexAttributeConstraints_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads PacketRxCount attribute constraints\n"); + if (ShouldSkip("DGETH.S.A0002")) { + NextTest(); + return; + } + err = TestStep4aThReadsPacketRxCountAttributeConstraints_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4b: Reboot target device\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep4bRebootTargetDevice_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4c: Reboot target device(DUT)\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep4cRebootTargetDeviceDUT_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: Upon a node reboot, PacketRxCount attribute value will be reset to 0\n"); + if (ShouldSkip("PICS_USER_PROMPT && DGETH.S.A0002")) { + NextTest(); + return; + } + err = TestStep4dUponANodeRebootPacketRxCountAttributeValueWillBeResetTo0_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5a: TH reads PacketTxCount attribute constraints\n"); + if (ShouldSkip("DGETH.S.A0003")) { + NextTest(); + return; + } + err = TestStep5aThReadsPacketTxCountAttributeConstraints_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5b: TH reads PacketTxCount attribute constraints, Upon a node reboot, the value will be reset to 0\n"); + if (ShouldSkip("PICS_USER_PROMPT && DGETH.S.A0003")) { + NextTest(); + return; + } + err = TestStep5bThReadsPacketTxCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0\n"); + if (ShouldSkip("DGETH.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsTxErrCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0\n"); + if (ShouldSkip("DGETH.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsCollisionCountAttributeUponANodeRebootTheValueWillBeResetTo0_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 8: TH reads OverrunCount attribute constraints\n"); + if (ShouldSkip("DGETH.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsOverrunCountAttributeConstraints_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 9: TH reads CarrierDetect attribute constraints\n"); + if (ShouldSkip("DGETH.S.A0007")) { + NextTest(); + return; + } + err = TestStep9ThReadsCarrierDetectAttributeConstraints_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 10: TH reads TimeSinceReset attribute constraints\n"); + if (ShouldSkip("DGETH.S.A0008")) { + NextTest(); + return; + } + err = TestStep10ThReadsTimeSinceResetAttributeConstraints_14(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 15; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsPHYRateAttributeConstraints_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads PHYRate attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads PHYRate attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFullDuplexAttributeConstraints_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFullDuplexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads FullDuplex attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads FullDuplex attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("fullDuplex", "boolean", "boolean")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsPacketRxCountAttributeConstraints_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads PacketRxCount attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads PacketRxCount attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("packetRxCount", "int64u", "int64u")); + VerifyOrReturn(CheckConstraintMinValue("packetRxCount", [value unsignedLongLongValue], 0ULL)); + VerifyOrReturn(CheckConstraintMaxValue("packetRxCount", [value unsignedLongLongValue], 18446744073709551615ULL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bRebootTargetDevice_4() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestStep4cRebootTargetDeviceDUT_5() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep4dUponANodeRebootPacketRxCountAttributeValueWillBeResetTo0_7() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep5aThReadsPacketTxCountAttributeConstraints_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH reads PacketTxCount attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 5a: TH reads PacketTxCount attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("packetTxCount", "int64u", "int64u")); + VerifyOrReturn(CheckConstraintMinValue("packetTxCount", [value unsignedLongLongValue], 0ULL)); + VerifyOrReturn(CheckConstraintMaxValue("packetTxCount", [value unsignedLongLongValue], 18446744073709551615ULL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bThReadsPacketTxCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_9() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep6ThReadsTxErrCountAttributeConstraintsUponANodeRebootTheValueWillBeResetTo0_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads TxErrCount attribute constraints, Upon a node reboot, the value will be reset to 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TxErrCount", actualValue, 0ULL)); + } + + VerifyOrReturn(CheckConstraintType("txErrCount", "int64u", "int64u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsCollisionCountAttributeUponANodeRebootTheValueWillBeResetTo0_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads CollisionCount attribute , Upon a node reboot, the value will be reset to 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CollisionCount", actualValue, 0ULL)); + } + + VerifyOrReturn(CheckConstraintType("collisionCount", "int64u", "int64u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsOverrunCountAttributeConstraints_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads OverrunCount attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads OverrunCount attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OverrunCount", actualValue, 0ULL)); + } + + VerifyOrReturn(CheckConstraintType("overrunCount", "int64u", "int64u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsCarrierDetectAttributeConstraints_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCarrierDetectWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads CarrierDetect attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads CarrierDetect attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("carrierDetect", "boolean", "boolean")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsTimeSinceResetAttributeConstraints_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTimeSinceResetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads TimeSinceReset attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads TimeSinceReset attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("timeSinceReset", "int64u", "int64u")); + VerifyOrReturn(CheckConstraintMinValue("timeSinceReset", [value unsignedLongLongValue], 0ULL)); + VerifyOrReturn(CheckConstraintMaxValue("timeSinceReset", [value unsignedLongLongValue], 18446744073709551615ULL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DGETH_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DGETH_2_2() + : TestCommandBridge("Test_TC_DGETH_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DGETH_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGETH_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGETH_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a.1: TH reads PHYRate attribute from DUT\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep2a1ThReadsPHYRateAttributeFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a.2: TH reads PHYRate attribute from DUT\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep2a2ThReadsPHYRateAttributeFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a.3: TH reads PHYRate attribute from DUT\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep2a3ThReadsPHYRateAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a.4: TH reads PHYRate attribute from DUT\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep2a4ThReadsPHYRateAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a.5: TH reads PHYRate attribute from DUT\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep2a5ThReadsPHYRateAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a.6: TH reads PHYRate attribute from DUT\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep2a6ThReadsPHYRateAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a.7: TH reads PHYRate attribute from DUT\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep2a7ThReadsPHYRateAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2a.8: TH reads PHYRate attribute from DUT\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep2a8ThReadsPHYRateAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a.9: TH reads PHYRate attribute from DUT\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep2a9ThReadsPHYRateAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2a.10: TH reads PHYRate attribute from DUT\n"); + if (ShouldSkip("DGETH.S.A0000")) { + NextTest(); + return; + } + err = TestStep2a10ThReadsPHYRateAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2b: TH reads PacketRxCount attribute value from DUT\n"); + if (ShouldSkip("DGETH.S.A0002")) { + NextTest(); + return; + } + err = TestStep2bThReadsPacketRxCountAttributeValueFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2c: TH reads PacketTxCount attribute value from DUT\n"); + if (ShouldSkip("DGETH.S.A0003")) { + NextTest(); + return; + } + err = TestStep2cThReadsPacketTxCountAttributeValueFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2d: TH reads TxErrCount attribute value from DUT\n"); + if (ShouldSkip("DGETH.S.A0004")) { + NextTest(); + return; + } + err = TestStep2dThReadsTxErrCountAttributeValueFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2e: TH reads CollisionCount attribute value from DUT\n"); + if (ShouldSkip("DGETH.S.A0005")) { + NextTest(); + return; + } + err = TestStep2eThReadsCollisionCountAttributeValueFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 2f: TH reads OverrunCount attribute value from DUT\n"); + if (ShouldSkip("DGETH.S.A0006")) { + NextTest(); + return; + } + err = TestStep2fThReadsOverrunCountAttributeValueFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 2g: Sends ResetCounts command\n"); + if (ShouldSkip("DGETH.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2gSendsResetCountsCommand_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 2h: TH reads PacketRxCount attribute value from DUT\n"); + if (ShouldSkip("DGETH.S.A0002 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep2hThReadsPacketRxCountAttributeValueFromDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 2i: TH reads PacketTxCount attribute value from DUT\n"); + if (ShouldSkip("DGETH.S.A0003 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep2iThReadsPacketTxCountAttributeValueFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 2j: TH reads TxErrCount attribute value from DUT\n"); + if (ShouldSkip("DGETH.S.A0004")) { + NextTest(); + return; + } + err = TestStep2jThReadsTxErrCountAttributeValueFromDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 2k: TH reads CollisionCount attribute value from DUT\n"); + if (ShouldSkip("DGETH.S.A0005")) { + NextTest(); + return; + } + err = TestStep2kThReadsCollisionCountAttributeValueFromDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 2l: TH reads OverrunCount attribute value from DUT\n"); + if (ShouldSkip("DGETH.S.A0006")) { + NextTest(); + return; + } + err = TestStep2lThReadsOverrunCountAttributeValueFromDut_21(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 22; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2a1ThReadsPHYRateAttributeFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a.1: TH reads PHYRate attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a.1: TH reads PHYRate attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2a2ThReadsPHYRateAttributeFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a.2: TH reads PHYRate attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a.2: TH reads PHYRate attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2a3ThReadsPHYRateAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a.3: TH reads PHYRate attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a.3: TH reads PHYRate attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2a4ThReadsPHYRateAttributeFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a.4: TH reads PHYRate attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a.4: TH reads PHYRate attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2a5ThReadsPHYRateAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a.5: TH reads PHYRate attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a.5: TH reads PHYRate attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2a6ThReadsPHYRateAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a.6: TH reads PHYRate attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a.6: TH reads PHYRate attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2a7ThReadsPHYRateAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a.7: TH reads PHYRate attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a.7: TH reads PHYRate attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2a8ThReadsPHYRateAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a.8: TH reads PHYRate attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a.8: TH reads PHYRate attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2a9ThReadsPHYRateAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a.9: TH reads PHYRate attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a.9: TH reads PHYRate attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2a10ThReadsPHYRateAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePHYRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a.10: TH reads PHYRate attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a.10: TH reads PHYRate attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("PHYRate", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("PHYRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PHYRate", [value unsignedCharValue], 9U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull PacketRxCountValue; + + CHIP_ERROR TestStep2bThReadsPacketRxCountAttributeValueFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads PacketRxCount attribute value from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads PacketRxCount attribute value from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + PacketRxCountValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull PacketTxCountValue; + + CHIP_ERROR TestStep2cThReadsPacketTxCountAttributeValueFromDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads PacketTxCount attribute value from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads PacketTxCount attribute value from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + PacketTxCountValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull TxErrCountValue; + + CHIP_ERROR TestStep2dThReadsTxErrCountAttributeValueFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads TxErrCount attribute value from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads TxErrCount attribute value from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + TxErrCountValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull CollisionCountValue; + + CHIP_ERROR TestStep2eThReadsCollisionCountAttributeValueFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH reads CollisionCount attribute value from DUT: Error: %@", err); + } else { + NSLog(@"Step 2e: TH reads CollisionCount attribute value from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + CollisionCountValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull OverrunCountValue; + + CHIP_ERROR TestStep2fThReadsOverrunCountAttributeValueFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH reads OverrunCount attribute value from DUT: Error: %@", err); + } else { + NSLog(@"Step 2f: TH reads OverrunCount attribute value from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + OverrunCountValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2gSendsResetCountsCommand_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster resetCountsWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2g: Sends ResetCounts command: Error: %@", err); + } else { + NSLog(@"Step 2g: Sends ResetCounts command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2hThReadsPacketRxCountAttributeValueFromDut_17() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2iThReadsPacketTxCountAttributeValueFromDut_18() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2jThReadsTxErrCountAttributeValueFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTxErrCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2j: TH reads TxErrCount attribute value from DUT: Error: %@", err); + } else { + NSLog(@"Step 2j: TH reads TxErrCount attribute value from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMaxValue("txErrCount", [value unsignedLongLongValue], TxErrCountValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2kThReadsCollisionCountAttributeValueFromDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCollisionCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2k: TH reads CollisionCount attribute value from DUT: Error: %@", err); + } else { + NSLog(@"Step 2k: TH reads CollisionCount attribute value from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMaxValue("collisionCount", [value unsignedLongLongValue], CollisionCountValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2lThReadsOverrunCountAttributeValueFromDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterEthernetNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2l: TH reads OverrunCount attribute value from DUT: Error: %@", err); + } else { + NSLog(@"Step 2l: TH reads OverrunCount attribute value from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMaxValue("overrunCount", [value unsignedLongLongValue], OverrunCountValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FLW_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FLW_1_1() + : TestCommandBridge("Test_TC_FLW_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FLW_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLW_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLW_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); + if (ShouldSkip("FLW.S.A0003")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFlowMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FLABEL_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FLABEL_1_1() + : TestCommandBridge("Test_TC_FLABEL_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FLABEL_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FLABEL_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FLABEL_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFixedLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FAN_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FAN_1_1() + : TestCommandBridge("Test_TC_FAN_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FAN_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip(" !FAN.S.F00 && !FAN.S.F01 && !FAN.S.F02 && !FAN.S.F03 && !FAN.S.F04 && !FAN.S.F05 ")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("FAN.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenFansf00spdEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("FAN.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenFansf01autEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("FAN.S.F02")) { + NextTest(); + return; + } + err = TestStep3dGivenFansf02rckEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("FAN.S.F03")) { + NextTest(); + return; + } + err = TestStep3eGivenFansf03wndEnsureFeaturemapHasTheCorrectBitSet_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("FAN.S.F04")) { + NextTest(); + return; + } + err = TestStep3fGivenFansf04stepEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("FAN.S.F05")) { + NextTest(); + return; + } + err = TestStep3gGivenFansf05dirEnsureFeaturemapHasTheCorrectBitSet_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList\n"); + if (ShouldSkip("FAN.S.F00")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheFeatureDependentFansf00SpdAttributeInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList\n"); + if (ShouldSkip("FAN.S.F02")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheFeatureDependentFansf02rckAttributeInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList\n"); + if (ShouldSkip("FAN.S.F03")) { + NextTest(); + return; + } + err = TestStep4eThReadsTheFeatureDependentFansf03wndAttributeInAttributeList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList\n"); + if (ShouldSkip("FAN.S.F05")) { + NextTest(); + return; + } + err = TestStep4fThReadsTheFeatureDependentFansf05dirAttributeInAttributeList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5: TH reads EventList attribute from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6:TH reads from the DUT the AcceptedCommandList attribute.\n"); + if (ShouldSkip(" !FAN.S.C00.Rsp ")) { + NextTest(); + return; + } + err = TestStep6thReadsFromTheDutTheAcceptedCommandListAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6: TH Reads the optional command (Step) in AcceptedCommandList\n"); + if (ShouldSkip("FAN.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6ThReadsTheOptionalCommandStepInAcceptedCommandList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_18(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 19; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenFansf00spdEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given FAN.S.F00(SPD) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenFansf01autEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given FAN.S.F01(AUT) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenFansf02rckEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given FAN.S.F02(RCK) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenFansf03wndEnsureFeaturemapHasTheCorrectBitSet_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3e: Given FAN.S.F03(WND) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenFansf04stepEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given FAN.S.F04(STEP) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenFansf05dirEnsureFeaturemapHasTheCorrectBitSet_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3g: Given FAN.S.F05(DIR) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheFeatureDependentFansf00SpdAttributeInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH Reads the feature dependent FAN.S.F00 (SPD) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheFeatureDependentFansf02rckAttributeInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH Reads the feature dependent FAN.S.F02(RCK) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsTheFeatureDependentFansf03wndAttributeInAttributeList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH Reads the feature dependent FAN.S.F03(WND) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsTheFeatureDependentFansf05dirAttributeInAttributeList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH Reads the feature dependent FAN.S.F05(DIR) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6thReadsFromTheDutTheAcceptedCommandListAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6:TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6:TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsTheOptionalCommandStepInAcceptedCommandList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH Reads the optional command (Step) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: TH Reads the optional command (Step) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FAN_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FAN_2_1() + : TestCommandBridge("Test_TC_FAN_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FAN_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the FanMode attribute\n"); + if (ShouldSkip("FAN.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheTheFanModeAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the FanModeSequence attribute\n"); + if (ShouldSkip("FAN.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheTheFanModeSequenceAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the the PercentSetting attribute\n"); + if (ShouldSkip("FAN.S.A0002")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheThePercentSettingAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the the PercentCurrent attribute\n"); + if (ShouldSkip("FAN.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutTheThePercentCurrentAttribute_4(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheTheFanModeAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the the FanMode attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the the FanMode attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("fanMode", "enum8", "enum8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheTheFanModeSequenceAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFanModeSequenceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the the FanModeSequence attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the the FanModeSequence attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("fanModeSequence", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("fanModeSequence", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("fanModeSequence", [value unsignedCharValue], 5U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheThePercentSettingAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the the PercentSetting attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the the PercentSetting attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("percentSetting", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("percentSetting", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("percentSetting", [value unsignedCharValue], 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheThePercentCurrentAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the the PercentCurrent attribute: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the the PercentCurrent attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("percentCurrent", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("percentCurrent", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("percentCurrent", [value unsignedCharValue], 100U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FAN_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FAN_2_2() + : TestCommandBridge("Test_TC_FAN_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FAN_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the SpeedMax attribute\n"); + if (ShouldSkip("FAN.S.A0004")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheTheSpeedMaxAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SpeedSetting attribute\n"); + if (ShouldSkip("FAN.S.A0005 && FAN.S.A0004")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheTheSpeedSettingAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the the SpeedCurrent attribute\n"); + if (ShouldSkip("FAN.S.A0006 && FAN.S.A0004")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheTheSpeedCurrentAttribute_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull SpeedMaxValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheTheSpeedMaxAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedMaxWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the the SpeedMax attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the the SpeedMax attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("speedMax", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("speedMax", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("speedMax", [value unsignedCharValue], 100U)); + { + SpeedMaxValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSpeedSettingAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the the SpeedSetting attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the the SpeedSetting attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("speedSetting", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("speedSetting", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("speedSetting", [value unsignedCharValue], SpeedMaxValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheTheSpeedCurrentAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the the SpeedCurrent attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the the SpeedCurrent attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("speedCurrent", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("speedCurrent", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("speedCurrent", [value unsignedCharValue], SpeedMaxValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FAN_2_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FAN_2_3() + : TestCommandBridge("Test_TC_FAN_2_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FAN_2_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the RockSupport attribute\n"); + if (ShouldSkip("FAN.S.A0007")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheTheRockSupportAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the RockSetting attribute\n"); + if (ShouldSkip("FAN.S.A0008")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheTheRockSettingAttribute_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheTheRockSupportAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRockSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the the RockSupport attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the the RockSupport attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("rockSupport", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheTheRockSettingAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRockSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the the RockSetting attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the the RockSetting attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("rockSetting", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FAN_2_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FAN_2_4() + : TestCommandBridge("Test_TC_FAN_2_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FAN_2_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_2_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_2_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the WindSupport attribute\n"); + if (ShouldSkip("FAN.S.A0009")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheTheWindSupportAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the WindSetting attribute\n"); + if (ShouldSkip("FAN.S.A000A")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheTheWindSettingAttribute_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheTheWindSupportAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWindSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the the WindSupport attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the the WindSupport attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("windSupport", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheTheWindSettingAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWindSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the the WindSetting attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the the WindSetting attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("windSetting", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FAN_3_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FAN_3_1() + : TestCommandBridge("Test_TC_FAN_3_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("ConfigPercentSetting", 0, UINT8_MAX, &mConfigPercentSetting); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FAN_3_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_3_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_3_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH writes a supported FanMode attribute that is other than off to DUT\n"); + if (ShouldSkip("FAN.S.A0000")) { + NextTest(); + return; + } + err = TestStep2aThWritesASupportedFanModeAttributeThatIsOtherThanOffToDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 1000ms\n"); + if (ShouldSkip("FAN.S.A0000")) { + NextTest(); + return; + } + err = TestWait1000ms_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: after a few seconds, TH reads from the DUT the the FanMode attribute\n"); + if (ShouldSkip("FAN.S.A0000")) { + NextTest(); + return; + } + err = TestStep2bAfterAFewSecondsThReadsFromTheDutTheTheFanModeAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2.1a: TH writes the Off value of FanMode attribute to DUT\n"); + if (ShouldSkip("FAN.S.A0000")) { + NextTest(); + return; + } + err = TestStep21aThWritesTheOffValueOfFanModeAttributeToDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 1000ms\n"); + if (ShouldSkip("FAN.S.A0000")) { + NextTest(); + return; + } + err = TestWait1000ms_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2.1b: TH reads from the DUT the PercentSetting attribute\n"); + if (ShouldSkip("FAN.S.A0002")) { + NextTest(); + return; + } + err = TestStep21bThReadsFromTheDutThePercentSettingAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2.1c: TH reads from the DUT the PercentCurrent attribute\n"); + if (ShouldSkip("FAN.S.A0003")) { + NextTest(); + return; + } + err = TestStep21cThReadsFromTheDutThePercentCurrentAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3a: TH writes PercentSetting attribute a non-zero value to DUT\n"); + if (ShouldSkip("FAN.S.A0002")) { + NextTest(); + return; + } + err = TestStep3aThWritesPercentSettingAttributeANonZeroValueToDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Wait 1000ms\n"); + if (ShouldSkip("FAN.S.A0002")) { + NextTest(); + return; + } + err = TestWait1000ms_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3b: TH reads from the DUT the PercentCurrent attribute\n"); + if (ShouldSkip("FAN.S.A0003")) { + NextTest(); + return; + } + err = TestStep3bThReadsFromTheDutThePercentCurrentAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3c: TH reads from the DUT the PercentSetting attribute\n"); + if (ShouldSkip("FAN.S.A0002")) { + NextTest(); + return; + } + err = TestStep3cThReadsFromTheDutThePercentSettingAttribute_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3.1a: TH writes PercentSetting attribute a zero value to DUT\n"); + if (ShouldSkip("FAN.S.A0002")) { + NextTest(); + return; + } + err = TestStep31aThWritesPercentSettingAttributeAZeroValueToDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait 1000ms\n"); + if (ShouldSkip("FAN.S.A0002")) { + NextTest(); + return; + } + err = TestWait1000ms_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3.1b: after a few seconds, TH reads from the DUT the the FanMode attribute\n"); + if (ShouldSkip("FAN.S.A0000")) { + NextTest(); + return; + } + err = TestStep31bAfterAFewSecondsThReadsFromTheDutTheTheFanModeAttribute_14(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 15; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mConfigPercentSetting; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2aThWritesASupportedFanModeAttributeThatIsOtherThanOffToDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id fanModeArgument; + fanModeArgument = + [NSNumber numberWithUnsignedChar:3U]; + [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH writes a supported FanMode attribute that is other than off to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH writes a supported FanMode attribute that is other than off to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait1000ms_2() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2bAfterAFewSecondsThReadsFromTheDutTheTheFanModeAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: after a few seconds, TH reads from the DUT the the FanMode attribute: Error: %@", err); + } else { + NSLog(@"Step 2b: after a few seconds, TH reads from the DUT the the FanMode attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FanMode", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep21aThWritesTheOffValueOfFanModeAttributeToDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id fanModeArgument; + fanModeArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2.1a: TH writes the Off value of FanMode attribute to DUT: Error: %@", err); + } else { + NSLog(@"Step 2.1a: TH writes the Off value of FanMode attribute to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait1000ms_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep21bThReadsFromTheDutThePercentSettingAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2.1b: TH reads from the DUT the PercentSetting attribute: Error: %@", err); + } else { + NSLog(@"Step 2.1b: TH reads from the DUT the PercentSetting attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); + VerifyOrReturn(CheckValue("PercentSetting", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep21cThReadsFromTheDutThePercentCurrentAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2.1c: TH reads from the DUT the PercentCurrent attribute: Error: %@", err); + } else { + NSLog(@"Step 2.1c: TH reads from the DUT the PercentCurrent attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PercentCurrent", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThWritesPercentSettingAttributeANonZeroValueToDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id percentSettingArgument; + percentSettingArgument = mConfigPercentSetting.HasValue() ? [NSNumber numberWithUnsignedChar:mConfigPercentSetting.Value()] : [NSNumber numberWithUnsignedChar:30U]; + [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH writes PercentSetting attribute a non-zero value to DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH writes PercentSetting attribute a non-zero value to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait1000ms_9() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThReadsFromTheDutThePercentCurrentAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads from the DUT the PercentCurrent attribute: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads from the DUT the PercentCurrent attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PercentCurrent", actualValue, mConfigPercentSetting.HasValue() ? mConfigPercentSetting.Value() : 30U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsFromTheDutThePercentSettingAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads from the DUT the PercentSetting attribute: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads from the DUT the PercentSetting attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); + VerifyOrReturn(CheckValue("PercentSetting", actualValue, mConfigPercentSetting.HasValue() ? mConfigPercentSetting.Value() : 30U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep31aThWritesPercentSettingAttributeAZeroValueToDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id percentSettingArgument; + percentSettingArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3.1a: TH writes PercentSetting attribute a zero value to DUT: Error: %@", err); + } else { + NSLog(@"Step 3.1a: TH writes PercentSetting attribute a zero value to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait1000ms_13() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep31bAfterAFewSecondsThReadsFromTheDutTheTheFanModeAttribute_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3.1b: after a few seconds, TH reads from the DUT the the FanMode attribute: Error: %@", err); + } else { + NSLog(@"Step 3.1b: after a few seconds, TH reads from the DUT the the FanMode attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FanMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FAN_3_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FAN_3_2() + : TestCommandBridge("Test_TC_FAN_3_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FAN_3_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_3_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_3_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SpeedMax attribute\n"); + if (ShouldSkip("FAN.S.A0004")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheSpeedMaxAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH writes to the DUT the a value less than or equal to the value read in step 2\n"); + if (ShouldSkip("FAN.S.A0005")) { + NextTest(); + return; + } + err = TestStep3ThWritesToTheDutTheAValueLessThanOrEqualToTheValueReadInStep2_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Wait 1000ms\n"); + if (ShouldSkip("FAN.S.A0005")) { + NextTest(); + return; + } + err = TestWait1000ms_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: After a few seconds, TH reads from the DUT the SpeedSetting attribute\n"); + if (ShouldSkip("FAN.S.A0005")) { + NextTest(); + return; + } + err = TestStep4AfterAFewSecondsThReadsFromTheDutTheSpeedSettingAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the SpeedCurrent attribute\n"); + if (ShouldSkip("FAN.S.A0006")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutTheSpeedCurrentAttribute_5(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 6; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull rSpeedMax; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheSpeedMaxAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedMaxWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the SpeedMax attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the SpeedMax attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + rSpeedMax = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThWritesToTheDutTheAValueLessThanOrEqualToTheValueReadInStep2_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id speedSettingArgument; + speedSettingArgument = + [rSpeedMax copy]; + [cluster writeAttributeSpeedSettingWithValue:speedSettingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH writes to the DUT the a value less than or equal to the value read in step 2: Error: %@", err); + } else { + NSLog(@"Step 3: TH writes to the DUT the a value less than or equal to the value read in step 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait1000ms_3() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4AfterAFewSecondsThReadsFromTheDutTheSpeedSettingAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: After a few seconds, TH reads from the DUT the SpeedSetting attribute: Error: %@", err); + } else { + NSLog(@"Step 4: After a few seconds, TH reads from the DUT the SpeedSetting attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (rSpeedMax == nil) { + VerifyOrReturn(CheckValueNull("SpeedSetting", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); + VerifyOrReturn(CheckValue("SpeedSetting", actualValue, rSpeedMax)); + } + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheSpeedCurrentAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the SpeedCurrent attribute: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the SpeedCurrent attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("SpeedCurrent", actualValue, rSpeedMax)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_FAN_3_6 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_FAN_3_6() + : TestCommandBridge("Test_TC_FAN_3_6") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_FAN_3_6() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_FAN_3_6\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_FAN_3_6\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH writes a value of Forward to the DUT\n"); + if (ShouldSkip("FAN.S.A000B")) { + NextTest(); + return; + } + err = TestStep2ThWritesAValueOfForwardToTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 1000ms\n"); + if (ShouldSkip("FAN.S.A000B")) { + NextTest(); + return; + } + err = TestWait1000ms_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute\n"); + if (ShouldSkip("FAN.S.A000B")) { + NextTest(); + return; + } + err = TestStep3AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes a value of Reverse to the DUT\n"); + if (ShouldSkip("FAN.S.A000B")) { + NextTest(); + return; + } + err = TestStep4ThWritesAValueOfReverseToTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 1000ms\n"); + if (ShouldSkip("FAN.S.A000B")) { + NextTest(); + return; + } + err = TestWait1000ms_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute\n"); + if (ShouldSkip("FAN.S.A000B")) { + NextTest(); + return; + } + err = TestStep5AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_6(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 7; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThWritesAValueOfForwardToTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id airflowDirectionArgument; + airflowDirectionArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeAirflowDirectionWithValue:airflowDirectionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH writes a value of Forward to the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH writes a value of Forward to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait1000ms_2() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAirflowDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Error: %@", err); + } else { + NSLog(@"Step 3: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AirflowDirection", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThWritesAValueOfReverseToTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id airflowDirectionArgument; + airflowDirectionArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeAirflowDirectionWithValue:airflowDirectionArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH writes a value of Reverse to the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH writes a value of Reverse to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait1000ms_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheAirflowDirectionAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAirflowDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Error: %@", err); + } else { + NSLog(@"Step 5: after a few seconds, TH reads from the DUT the AirflowDirection attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AirflowDirection", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CGEN_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CGEN_1_1() + : TestCommandBridge("Test_TC_CGEN_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CGEN_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CGEN_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CGEN_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Read the global attribute: FeatureMap\n"); + err = TestStep3ReadTheGlobalAttributeFeatureMap_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ReadTheGlobalAttributeAttributeList_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ReadTheGlobalAttributeAttributeList_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: Read the global attribute: AcceptedCommandList\n"); + err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: Read the global attribute: GeneratedCommandList\n"); + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ReadTheGlobalAttributeFeatureMap_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: Read the global attribute: FeatureMap: Error: %@", err); + } else { + NSLog(@"Step 3: Read the global attribute: FeatureMap: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CGEN_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CGEN_2_1() + : TestCommandBridge("Test_TC_CGEN_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CGEN_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CGEN_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CGEN_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH1 reads the BreadCrumb Attribute from the DUT\n"); + if (ShouldSkip("CGEN.S.A0000")) { + NextTest(); + return; + } + err = TestStep1Th1ReadsTheBreadCrumbAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT\n"); + if (ShouldSkip("CGEN.S.A0000")) { + NextTest(); + return; + } + err = TestStep2Th1WritesTheBreadCrumbAttributeAs1ToTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH1 reads the BreadCrumb attribute from the DUT\n"); + if (ShouldSkip("CGEN.S.A0000")) { + NextTest(); + return; + } + err = TestStep3Th1ReadsTheBreadCrumbAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH1 reads the RegulatoryConfig attribute from the DUT\n"); + if (ShouldSkip("CGEN.S.A0002")) { + NextTest(); + return; + } + err = TestStep4Th1ReadsTheRegulatoryConfigAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH1 reads the LocationCapability attribute from the DUT\n"); + if (ShouldSkip("CGEN.S.A0003")) { + NextTest(); + return; + } + err = TestStep5Th1ReadsTheLocationCapabilityAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535\n"); + if (ShouldSkip("CGEN.S.A0001")) { + NextTest(); + return; + } + err = TestStep6Th1ReadsBasicCommissioningInfoAttributeFromDutAndVerifyThatTheBasicCommissioningInfoAttributeHasTheFollowingFieldFailSafeExpiryLengthSecondsFieldValueIsWithinADurationRangeOf0To65535_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT\n"); + if (ShouldSkip("CGEN.S.A0004")) { + NextTest(); + return; + } + err = TestStep7Th1ReadsSupportsConcurrentConnectionAttributeFromTheDut_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1Th1ReadsTheBreadCrumbAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH1 reads the BreadCrumb Attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH1 reads the BreadCrumb Attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("breadcrumb", "int64u", "int64u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2Th1WritesTheBreadCrumbAttributeAs1ToTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id breadcrumbArgument; + breadcrumbArgument = + [NSNumber numberWithUnsignedLongLong:1ULL]; + [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH1 writes the BreadCrumb attribute as 1 to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3Th1ReadsTheBreadCrumbAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH1 reads the BreadCrumb attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH1 reads the BreadCrumb attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4Th1ReadsTheRegulatoryConfigAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRegulatoryConfigWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH1 reads the RegulatoryConfig attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH1 reads the RegulatoryConfig attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("regulatoryConfig", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("regulatoryConfig", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5Th1ReadsTheLocationCapabilityAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLocationCapabilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH1 reads the LocationCapability attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH1 reads the LocationCapability attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("locationCapability", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("locationCapability", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6Th1ReadsBasicCommissioningInfoAttributeFromDutAndVerifyThatTheBasicCommissioningInfoAttributeHasTheFollowingFieldFailSafeExpiryLengthSecondsFieldValueIsWithinADurationRangeOf0To65535_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBasicCommissioningInfoWithCompletion:^(MTRGeneralCommissioningClusterBasicCommissioningInfo * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535: Error: %@", err); + } else { + NSLog(@"Step 6: TH1 reads BasicCommissioningInfo attribute from DUT and Verify that the BasicCommissioningInfo attribute has the following field: FailSafeExpiryLengthSeconds field value is within a duration range of 0 to 65535: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7Th1ReadsSupportsConcurrentConnectionAttributeFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportsConcurrentConnectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH1 reads SupportsConcurrentConnection attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("supportsConcurrentConnection", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DGGEN_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DGGEN_1_1() + : TestCommandBridge("Test_TC_DGGEN_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DGGEN_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGGEN_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGGEN_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Read the global attribute: FeatureMap\n"); + err = TestStep3ReadTheGlobalAttributeFeatureMap_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList\n"); + err = TestStep4bValidatePresenceOfMandatoryAttributeUpTimeInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: Read optional attribute(TotalOperationalHours) in AttributeList\n"); + if (ShouldSkip("DGGEN.S.A0003")) { + NextTest(); + return; + } + err = TestStep4cReadOptionalAttributeTotalOperationalHoursInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: Read optional attribute(BootReason) in AttributeList\n"); + if (ShouldSkip("DGGEN.S.A0004")) { + NextTest(); + return; + } + err = TestStep4dReadOptionalAttributeBootReasonInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: Read optional attribute(ActiveHardwareFaults) in AttributeList\n"); + if (ShouldSkip("DGGEN.S.A0005")) { + NextTest(); + return; + } + err = TestStep4eReadOptionalAttributeActiveHardwareFaultsInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: Read optional attribute(ActiveRadioFaults) in AttributeList\n"); + if (ShouldSkip("DGGEN.S.A0006")) { + NextTest(); + return; + } + err = TestStep4fReadOptionalAttributeActiveRadioFaultsInAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: Read optional attribute(ActiveNetworkFaults) in AttributeList\n"); + if (ShouldSkip("DGGEN.S.A0007")) { + NextTest(); + return; + } + err = TestStep4gReadOptionalAttributeActiveNetworkFaultsInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5a: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5b: Read optional event(HardwareFaultChange) in EventList\n"); + if (ShouldSkip("DGGEN.S.E00 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5c: Read optional event(RadioFaultChange) in EventList\n"); + if (ShouldSkip("DGGEN.S.E01 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5d: Read optional event(NetworkFaultChange) in EventList\n"); + if (ShouldSkip("DGGEN.S.E02 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: Read the global attribute: AcceptedCommandList\n"); + err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads GeneratedCommandList from DUT\n"); + err = TestStep7ThReadsGeneratedCommandListFromDut_16(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 17; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ReadTheGlobalAttributeFeatureMap_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: Read the global attribute: FeatureMap: Error: %@", err); + } else { + NSLog(@"Step 3: Read the global attribute: FeatureMap: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bValidatePresenceOfMandatoryAttributeUpTimeInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Validate presence of mandatory attribute(UpTime) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cReadOptionalAttributeTotalOperationalHoursInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Read optional attribute(TotalOperationalHours) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: Read optional attribute(TotalOperationalHours) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dReadOptionalAttributeBootReasonInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: Read optional attribute(BootReason) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: Read optional attribute(BootReason) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eReadOptionalAttributeActiveHardwareFaultsInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Read optional attribute(ActiveHardwareFaults) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: Read optional attribute(ActiveHardwareFaults) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fReadOptionalAttributeActiveRadioFaultsInAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: Read optional attribute(ActiveRadioFaults) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: Read optional attribute(ActiveRadioFaults) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gReadOptionalAttributeActiveNetworkFaultsInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Read optional attribute(ActiveNetworkFaults) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4g: Read optional attribute(ActiveNetworkFaults) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 2UL)); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_GRPKEY_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_GRPKEY_1_1() + : TestCommandBridge("Test_TC_GRPKEY_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_GRPKEY_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_GRPKEY_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_GRPKEY_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip(" !GRPKEY.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("GRPKEY.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenGrpkeysf00csEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip(" !PICS_EVENT_LIST_ENABLED ")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenGrpkeysf00csEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given GRPKEY.S.F00(CS) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_GRPKEY_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_GRPKEY_2_2() + : TestCommandBridge("Test_TC_GRPKEY_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_GRPKEY_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_GRPKEY_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_GRPKEY_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.\n"); + if (ShouldSkip("GRPKEY.S.A0003")) { + NextTest(); + return; + } + err = TestStep1ThReadsMaxGroupKeysPerFabricAttributeFromGroupKeyManagementClusterOnDutUsingAFabricFilteredReadSaveTheValueAsMaxGrpKeyForFutureUse_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a\n"); + if (ShouldSkip("GRPKEY.S.C01.Rsp && GRPKEY.S.C02.Tx")) { + NextTest(); + return; + } + err = TestStep3ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1null7EpochKey2Null8EpochStartTime2null_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime2null_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithCommandFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0Null4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep7ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0Null5EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep8ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep9ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep10ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep11ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0184467440737095516135EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime117EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep12ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614NoteEpochKey1AndEpochStartTime1AreNullWhenEpochKey2AndEpochStartTime2AreNotNull_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep13ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime218446744073709551614NoteEpochKey2IsSetToNullAndEpochStartTime2IsNotNull_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep14ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime2NullNoteEpochKey2IsNotNullAndEpochStartTime2IsNull_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep15ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime016EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf7EpochStartTime1184467440737095516138EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf9EpochStartTime21NoteEpochStartTime2IsEarlierThanEpochStartTime1_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes)\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep16ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D04EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime21Note1RepeatTheStepBySendingEpochKey1AndEpochKey2With1ByteValue16Bytes_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes)\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep16RepeatTheStepBySendingEpochKey1With1ByteValue16Bytes_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes)\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep16NoteRepeatTheStepBySendingEpochKey2With1ByteValue16Bytes_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte)\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep16aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having15BytesValue16Byte_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte)\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey1Having15BytesValue16Byte_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte)\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey2Having15BytesValue16Byte_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes)\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep16bThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having17BytesValue16Bytes_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes)\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey1Having17BytesValue16Bytes_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes)\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey2Having17BytesValue16Bytes_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep17ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D3d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D4d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1174467440737095516137EpochKey2D5d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime217446744073709551614NoteKeySetWriteCommandIsSentWithDifferentEpochKeysEpochStartTime1AndEpochStartTime2Values_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a\n"); + if (ShouldSkip("GRPKEY.S.C01.Rsp && GRPKEY.S.C02.Tx")) { + NextTest(); + return; + } + err = TestStep18ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.\n"); + if (ShouldSkip("GRPKEY.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep19ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.\n"); + if (ShouldSkip("GRPKEY.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep20ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 21: TH sends KeySetWrite command to DUT until size of list for TH’s fabric in GroupKeyMap attribute contains Max_GrpKey entries, starting with GroupKeySetID 1 and incrementing by 1 each time.\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep21ThSendsKeySetWriteCommandToDutUntilSizeOfListForTHsFabricInGroupKeyMapAttributeContainsMaxGrpKeyEntriesStartingWithGroupKeySetID1AndIncrementingBy1EachTime_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.\n"); + if (ShouldSkip("GRPKEY.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep22ThAgainSendsKeySetWriteCommandToDutWithAnyOtherGroupKeySetIDNotUsedYet_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 23: TH sends KeySetReadAllIndices command to DUT.\n"); + if (ShouldSkip("GRPKEY.S.C04.Rsp && GRPKEY.S.C05.Tx && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep23ThSendsKeySetReadAllIndicesCommandToDut_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0\n"); + if (ShouldSkip("GRPKEY.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep24ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x0_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.\n"); + if (ShouldSkip("GRPKEY.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep25ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_33(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_NOT_FOUND)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 34; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull Max_GrpKey; + + CHIP_ERROR TestStep1ThReadsMaxGroupKeysPerFabricAttributeFromGroupKeyManagementClusterOnDutUsingAFabricFilteredReadSaveTheValueAsMaxGrpKeyForFutureUse_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxGroupKeysPerFabricWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads MaxGroupKeysPerFabric attribute from GroupKeyManagement cluster on DUT using a fabric-filtered read. Save the value as Max_GrpKey for future use.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + Max_GrpKey = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; + params.groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + [cluster keySetReadWithParams:params completion: + ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Error: %@", err); + } else { + NSLog(@"Step 3: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.groupKeySet; + VerifyOrReturn(CheckValue("GroupKeySetID", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySetID, 26U)); + VerifyOrReturn(CheckValue("GroupKeySecurityPolicy", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySecurityPolicy, 0U)); + VerifyOrReturn(CheckValueNull("EpochKey0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey0)); + VerifyOrReturn(CheckValueNonNull("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0)); + VerifyOrReturn(CheckValue("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0, 1ULL)); + VerifyOrReturn(CheckValueNull("EpochKey1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey1)); + VerifyOrReturn(CheckValueNonNull("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1)); + VerifyOrReturn(CheckValue("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1, 18446744073709551613ULL)); + VerifyOrReturn(CheckValueNull("EpochKey2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey2)); + VerifyOrReturn(CheckValueNonNull("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2)); + VerifyOrReturn(CheckValue("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2, 18446744073709551614ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1null7EpochKey2Null8EpochStartTime2null_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null: Error: %@", err); + } else { + NSLog(@"Step 4: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1:null 7)EpochKey2: null 8)EpochStartTime2:null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime2null_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null: Error: %@", err); + } else { + NSLog(@"Step 5: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: null 8)EpochStartTime2:null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithCommandFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0Null4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = nil; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); + } else { + NSLog(@"Step 6: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with command fields as follows:1)GroupKeySetID: 0x01a 2) GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: null 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1:18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0Null5EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = nil; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Error: %@", err); + } else { + NSLog(@"Step 7: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: null 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); + } else { + NSLog(@"Step 8: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 0 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); + } else { + NSLog(@"Step 9: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Error: %@", err); + } else { + NSLog(@"Step 10: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2:18446744073709551614: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime0184467440737095516135EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime117EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Error: %@", err); + } else { + NSLog(@"Step 11: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 18446744073709551613 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 1 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1Null6EpochStartTime1Null7EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime218446744073709551614NoteEpochKey1AndEpochStartTime1AreNullWhenEpochKey2AndEpochStartTime2AreNotNull_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = nil; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = nil; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null: Error: %@", err); + } else { + NSLog(@"Step 12: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: null 6)EpochStartTime1: null 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 18446744073709551614 Note: EpochKey1 and EpochStartTime1 are null when EpochKey2 and EpochStartTime2 are not null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2Null8EpochStartTime218446744073709551614NoteEpochKey2IsSetToNullAndEpochStartTime2IsNotNull_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = nil; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null: Error: %@", err); + } else { + NSLog(@"Step 13: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: null 8)EpochStartTime2: 18446744073709551614 Note: EpochKey2 is set to null and EpochStartTime2 is not null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep14ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime2NullNoteEpochKey2IsNotNullAndEpochStartTime2IsNull_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = nil; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null: Error: %@", err); + } else { + NSLog(@"Step 14: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: null Note: EpochKey2 is not null and EpochStartTime2 is null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep15ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime016EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf7EpochStartTime1184467440737095516138EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf9EpochStartTime21NoteEpochStartTime2IsEarlierThanEpochStartTime1_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1: Error: %@", err); + } else { + NSLog(@"Step 15: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 6)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 7)EpochStartTime1: 18446744073709551613 8)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 9)EpochStartTime2: 1 Note: EpochStartTime2 is earlier than EpochStartTime1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D04EpochStartTime015EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1184467440737095516137EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime21Note1RepeatTheStepBySendingEpochKey1AndEpochKey2With1ByteValue16Bytes_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0" length:1]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes): Error: %@", err); + } else { + NSLog(@"Step 16: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0 4)EpochStartTime0: 1 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 18446744073709551613 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 1 Note1: Repeat the step by sending EpochKey1 and EpochKey2 with 1 byte value (< 16 bytes): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16RepeatTheStepBySendingEpochKey1With1ByteValue16Bytes_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1" length:1]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes): Error: %@", err); + } else { + NSLog(@"Step 16: Repeat the step by sending EpochKey1 with 1 byte value (< 16 bytes): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16NoteRepeatTheStepBySendingEpochKey2With1ByteValue16Bytes_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2" length:1]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes): Error: %@", err); + } else { + NSLog(@"Step 16: Note: Repeat the step by sending EpochKey2 with 1 byte value (< 16 bytes): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having15BytesValue16Byte_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte): Error: %@", err); + } else { + NSLog(@"Step 16a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 15 bytes value (< 16 byte): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey1Having15BytesValue16Byte_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte): Error: %@", err); + } else { + NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey1 having 15 bytes value (< 16 byte): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16aRepeatStep16aBySendingKeySetWriteCommandWithEpochKey2Having15BytesValue16Byte_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde" length:15]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte): Error: %@", err); + } else { + NSLog(@"Step 16a: Repeat step 16a by sending KeySetWrite Command with EpochKey2 having 15 bytes value (< 16 byte): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16bThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutNoteRepeatStep16BySendingKeySetWriteCommandWithEpochKey0EpochKey1AndEpochKey2Having17BytesValue16Bytes_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes): Error: %@", err); + } else { + NSLog(@"Step 16b: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT. Note: Repeat step 16 by sending KeySetWrite Command with EpochKey0, EpochKey1 and EpochKey2 having 17 bytes value (> 16 bytes): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey1Having17BytesValue16Bytes_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes): Error: %@", err); + } else { + NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey1 having 17 bytes value (> 16 bytes): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16bRepeatStep16BySendingKeySetWriteCommandWithEpochKey2Having17BytesValue16Bytes_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf\xde" length:17]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes): Error: %@", err); + } else { + NSLog(@"Step 16b: Repeat step 16 by sending KeySetWrite Command with EpochKey2 having 17 bytes value (> 16 bytes): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep17ThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutOnEp0WithGroupKeySetFieldsAsFollows1GroupKeySetID0x01a2GroupKeySecurityPolicyTrustFirst03EpochKey0D3d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime015EpochKey1D4d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime1174467440737095516137EpochKey2D5d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime217446744073709551614NoteKeySetWriteCommandIsSentWithDifferentEpochKeysEpochStartTime1AndEpochStartTime2Values_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd3\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd4\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:17446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd5\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:17446744073709551614ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values: Error: %@", err); + } else { + NSLog(@"Step 17: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT on EP0 with GroupKeySet fields as follows: 1)GroupKeySetID: 0x01a 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d3d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 1 5)EpochKey1: d4d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 17446744073709551613 7)EpochKey2: d5d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 17446744073709551614 Note: KeySetWrite command is sent with different EpochKeys,EpochStartTime1 and EpochStartTime2 values: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep18ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01a_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; + params.groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + [cluster keySetReadWithParams:params completion: + ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Error: %@", err); + } else { + NSLog(@"Step 18: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01a: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.groupKeySet; + VerifyOrReturn(CheckValue("GroupKeySetID", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySetID, 26U)); + VerifyOrReturn(CheckValue("GroupKeySecurityPolicy", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).groupKeySecurityPolicy, 0U)); + VerifyOrReturn(CheckValueNull("EpochKey0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey0)); + VerifyOrReturn(CheckValueNonNull("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0)); + VerifyOrReturn(CheckValue("EpochStartTime0", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime0, 1ULL)); + VerifyOrReturn(CheckValueNull("EpochKey1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey1)); + VerifyOrReturn(CheckValueNonNull("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1)); + VerifyOrReturn(CheckValue("EpochStartTime1", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime1, 17446744073709551613ULL)); + VerifyOrReturn(CheckValueNull("EpochKey2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochKey2)); + VerifyOrReturn(CheckValueNonNull("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2)); + VerifyOrReturn(CheckValue("EpochStartTime2", ((MTRGroupKeyManagementClusterGroupKeySetStruct *) actualValue).epochStartTime2, 17446744073709551614ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep19ThSendsKeySetReadCommandToGroupKeyManagementClusterWithGroupKeySetIDAs0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetReadParams alloc] init]; + params.groupKeySetID = + [NSNumber numberWithUnsignedShort:27U]; + [cluster keySetReadWithParams:params completion: + ^(MTRGroupKeyManagementClusterKeySetReadResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.: Error: %@", err); + } else { + NSLog(@"Step 19: TH sends KeySetRead command to GroupKeyManagement cluster with GroupKeySetID as 0x01b that does not exist in the GroupKeyMap attribute list.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_NOT_FOUND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep20ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; + params.groupKeySetID = + [NSNumber numberWithUnsignedShort:26U]; + [cluster keySetRemoveWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.: Error: %@", err); + } else { + NSLog(@"Step 20: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep21ThSendsKeySetWriteCommandToDutUntilSizeOfListForTHsFabricInGroupKeyMapAttributeContainsMaxGrpKeyEntriesStartingWithGroupKeySetID1AndIncrementingBy1EachTime_29() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep22ThAgainSendsKeySetWriteCommandToDutWithAnyOtherGroupKeySetIDNotUsedYet_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:3U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\xd0\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\xd1\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:18446744073709551613ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\xd2\xd1\xd2\xd3\xd4\xd5\xd6\xd7\xd8\xd9\xda\xdb\xdc\xdd\xde\xdf" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.: Error: %@", err); + } else { + NSLog(@"Step 22: TH again sends KeySetWrite command to DUT with any other GroupKeySetID not used yet.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep23ThSendsKeySetReadAllIndicesCommandToDut_31() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep24ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x0_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; + params.groupKeySetID = + [NSNumber numberWithUnsignedShort:0U]; + [cluster keySetRemoveWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0: Error: %@", err); + } else { + NSLog(@"Step 24: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep25ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01bThatDoesNotExistInTheGroupKeyMapAttributeList_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; + params.groupKeySetID = + [NSNumber numberWithUnsignedShort:27U]; + [cluster keySetRemoveWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.: Error: %@", err); + } else { + NSLog(@"Step 25: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01b that does not exist in the GroupKeyMap attribute list.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_NOT_FOUND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ICDM_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ICDM_1_1() + : TestCommandBridge("Test_TC_ICDM_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ICDM_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ICDM_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ICDM_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from DUT\n"); + err = TestStep2ThReadsClusterRevisionAttributeFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from DUT\n"); + if (ShouldSkip("ICDM.S.F00")) { + NextTest(); + return; + } + err = TestStep3ThReadsFeatureMapAttributeFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads FeatureMap attribute from DUT\n"); + if (ShouldSkip(" !ICDM.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3ThReadsFeatureMapAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList attribute from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList attribute from DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: Read the optional attribute(RegisteredClients) in AttributeList\n"); + if (ShouldSkip("ICDM.S.A0003")) { + NextTest(); + return; + } + err = TestStep4bReadTheOptionalAttributeRegisteredClientsInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: Read the optional attribute(IcdCounter) in AttributeList\n"); + if (ShouldSkip("ICDM.S.A0004")) { + NextTest(); + return; + } + err = TestStep4cReadTheOptionalAttributeIcdCounterInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList\n"); + if (ShouldSkip("ICDM.S.A0005")) { + NextTest(); + return; + } + err = TestStep4dReadTheOptionalAttributeClientsSupportedPerFabricInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6a: TH reads AcceptedCommandList attribute from DUT\n"); + if (ShouldSkip(" !ICDM.S.F00 && !ICDM.S.C03.Rsp ")) { + NextTest(); + return; + } + err = TestStep6aThReadsAcceptedCommandListAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true\n"); + if (ShouldSkip("ICDM.S.F00")) { + NextTest(); + return; + } + err = TestStep6bThReadsAcceptedCommandListAttributeFromDutIfIcdmsf00IsTrue_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6c: Read the optional command (StayActiveRequest) in AttributeList\n"); + if (ShouldSkip("ICDM.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep6cReadTheOptionalCommandStayActiveRequestInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); + if (ShouldSkip(" !ICDM.S.F00 ")) { + NextTest(); + return; + } + err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH reads GeneratedCommandList attribute from DUT\n"); + if (ShouldSkip("ICDM.S.F00")) { + NextTest(); + return; + } + err = TestStep7ThReadsGeneratedCommandListAttributeFromDut_14(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 15; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads ClusterRevision attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads FeatureMap attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheOptionalAttributeRegisteredClientsInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the optional attribute(RegisteredClients) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the optional attribute(RegisteredClients) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cReadTheOptionalAttributeIcdCounterInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Read the optional attribute(IcdCounter) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: Read the optional attribute(IcdCounter) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dReadTheOptionalAttributeClientsSupportedPerFabricInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: Read the optional attribute(ClientsSupportedPerFabric) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsAcceptedCommandListAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads AcceptedCommandList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsAcceptedCommandListAttributeFromDutIfIcdmsf00IsTrue_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads AcceptedCommandList attribute from DUT if ICDM.S.F00 is true: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cReadTheOptionalCommandStayActiveRequestInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: Read the optional command (StayActiveRequest) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 6c: Read the optional command (StayActiveRequest) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsGeneratedCommandListAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterICDManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads GeneratedCommandList attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_I_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_I_1_1() + : TestCommandBridge("Test_TC_I_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_I_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList\n"); + if (ShouldSkip("I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep6ThReadsTheOptionalCommandTriggerEffectInAcceptedCommandList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsTheOptionalCommandTriggerEffectInAcceptedCommandList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads the optional command(TriggerEffect) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_I_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_I_2_1() + : TestCommandBridge("Test_TC_I_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_I_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the IdentifyTime attribute from the DUT\n"); + if (ShouldSkip("I.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsTheIdentifyTimeAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the IdentifyType attribute from the DUT\n"); + if (ShouldSkip("I.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheIdentifyTypeAttributeFromTheDut_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheIdentifyTimeAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the IdentifyTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the IdentifyTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("identifyTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheIdentifyTypeAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeIdentifyTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the IdentifyType attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the IdentifyType attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("identifyType", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("identifyType", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("identifyType", [value unsignedCharValue], 5U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_I_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_I_2_2() + : TestCommandBridge("Test_TC_I_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_I_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1a: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1aCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1b: TH reads the IdentifyType attribute from the DUT.\n"); + if (ShouldSkip("I.S.A0001")) { + NextTest(); + return; + } + err = TestStep1bThReadsTheIdentifyTypeAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that the device enters its identification state using the IdentifyType from Step 1b, in order to indicate to an observer which of several nodes and/or endpoints it is.\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.A0001")) { + NextTest(); + return; + } + err = TestVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).\n"); + if (ShouldSkip("I.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x003c60s_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH reads immediately IdentifyTime attribute from DUT\n"); + if (ShouldSkip("I.S.A0000")) { + NextTest(); + return; + } + err = TestStep2bThReadsImmediatelyIdentifyTimeAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 10000ms\n"); + err = TestWait10000ms_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT\n"); + if (ShouldSkip("I.S.A0000")) { + NextTest(); + return; + } + err = TestStep2cAfter10SecondsTheThReadsIdentifyTimeAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).\n"); + if (ShouldSkip("I.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep4aBefore60SecondsExpireThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x0000StopIdentifying_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads immediately IdentifyTime attribute from DUT\n"); + if (ShouldSkip("I.S.A0000")) { + NextTest(); + return; + } + err = TestStep4bThReadsImmediatelyIdentifyTimeAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT\n"); + if (ShouldSkip("I.S.A0000")) { + NextTest(); + return; + } + err = TestStep6aThWritesAValueOf0x000f15sToIdentifyTimeAttributeOfDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 15000ms\n"); + err = TestWait15000ms_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT\n"); + if (ShouldSkip("I.S.A0000")) { + NextTest(); + return; + } + err = TestStep6bAfter15SecondsTheThReadsIdentifyTimeAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Verify that the device enters its identification state using the IdentifyType from Step 1b, in order to indicate to an observer which of several nodes and/or endpoints it is.\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.A0001")) { + NextTest(); + return; + } + err = TestVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_12(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 13; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1aCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull IdentifyTypeValue; + + CHIP_ERROR TestStep1bThReadsTheIdentifyTypeAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeIdentifyTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH reads the IdentifyType attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 1b: TH reads the IdentifyType attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("identifyType", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("identifyType", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("identifyType", [value unsignedCharValue], 5U)); + { + IdentifyTypeValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_2() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2aThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x003c60s_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; + params.identifyTime = + [NSNumber numberWithUnsignedShort:60U]; + [cluster identifyWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends Identify command to DUT, with the IdentifyTime field set to 0x003c (60s).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThReadsImmediatelyIdentifyTimeAttributeFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads immediately IdentifyTime attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads immediately IdentifyTime attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 51U)); + VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 69U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10000ms_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cAfter10SecondsTheThReadsIdentifyTimeAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: After 10 seconds, the TH reads IdentifyTime attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 42U)); + VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 58U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aBefore60SecondsExpireThSendsIdentifyCommandToDutWithTheIdentifyTimeFieldSetTo0x0000StopIdentifying_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; + params.identifyTime = + [NSNumber numberWithUnsignedShort:0U]; + [cluster identifyWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).: Error: %@", err); + } else { + NSLog(@"Step 4a: Before 60 seconds expire, TH sends Identify command to DUT, with the identify time field set to 0x0000 (stop identifying).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsImmediatelyIdentifyTimeAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads immediately IdentifyTime attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads immediately IdentifyTime attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("IdentifyTime", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThWritesAValueOf0x000f15sToIdentifyTimeAttributeOfDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id identifyTimeArgument; + identifyTimeArgument = + [NSNumber numberWithUnsignedShort:15U]; + [cluster writeAttributeIdentifyTimeWithValue:identifyTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 6a: TH writes a value of 0x000f (15s) to IdentifyTime attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait15000ms_10() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 15000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep6bAfter15SecondsTheThReadsIdentifyTimeAttributeFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeIdentifyTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6b: After 15 seconds, the TH reads IdentifyTime attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("identifyTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("identifyTime", [value unsignedShortValue], 5U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheDeviceEntersItsIdentificationStateUsingTheIdentifyTypeFromStep1bInOrderToIndicateToAnObserverWhichOfSeveralNodesAndOrEndpointsItIs_12() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } +}; + +class Test_TC_I_2_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_I_2_3() + : TestCommandBridge("Test_TC_I_2_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_I_2_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_I_2_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_I_2_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x00 default\n"); + if (ShouldSkip("I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x00Default_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : DUT executes a blink effect\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestDutExecutesABlinkEffect_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default\n"); + if (ShouldSkip("I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : DUT executes a breathe effect\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestDutExecutesABreatheEffect_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x02 okay and the effect variant field set to 0x00 default\n"); + if (ShouldSkip("I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep2cThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x02OkayAndTheEffectVariantFieldSetTo0x00Default_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : DUT executes an okay effect\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestDutExecutesAnOkayEffect_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2d: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x0b channel change and the effect variant field set to 0x00 default\n"); + if (ShouldSkip("I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep2dThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x0bChannelChangeAndTheEffectVariantFieldSetTo0x00Default_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : DUT executes a channel change effect\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestDutExecutesAChannelChangeEffect_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2e: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default\n"); + if (ShouldSkip("I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep2eThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : DUT executes a breathe effect\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestDutExecutesABreatheEffect_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2f: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xfe finish effect and the effect variant field set to 0x00 default\n"); + if (ShouldSkip("I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep2fThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xfeFinishEffectAndTheEffectVariantFieldSetTo0x00Default_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : DUT stops the breathe effect after the current effect sequence\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestDutStopsTheBreatheEffectAfterTheCurrentEffectSequence_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2g: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default\n"); + if (ShouldSkip("I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep2gThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : DUT executes a breathe effect\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestDutExecutesABreatheEffect_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 2h: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default\n"); + if (ShouldSkip("I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep2hThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : DUT stops the breathe effect as soon as possible.\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestDutStopsTheBreatheEffectAsSoonAsPossible_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x42 unknown\n"); + if (ShouldSkip("I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x42Unknown_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Check DUT executes a blink effect.\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestCheckDutExecutesABlinkEffect_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default\n"); + if (ShouldSkip("I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : DUT stops any effect that may be still running as soon as possible\n"); + if (ShouldSkip("PICS_USER_PROMPT && I.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestDutStopsAnyEffectThatMayBeStillRunningAsSoonAsPossible_20(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 21; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x00Default_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; + params.effectIdentifier = + [NSNumber numberWithUnsignedChar:0U]; + params.effectVariant = + [NSNumber numberWithUnsignedChar:0U]; + [cluster triggerEffectWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x00 default: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x00 default: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestDutExecutesABlinkEffect_2() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; + params.effectIdentifier = + [NSNumber numberWithUnsignedChar:1U]; + params.effectVariant = + [NSNumber numberWithUnsignedChar:0U]; + [cluster triggerEffectWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestDutExecutesABreatheEffect_4() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2cThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x02OkayAndTheEffectVariantFieldSetTo0x00Default_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; + params.effectIdentifier = + [NSNumber numberWithUnsignedChar:2U]; + params.effectVariant = + [NSNumber numberWithUnsignedChar:0U]; + [cluster triggerEffectWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x02 okay and the effect variant field set to 0x00 default: Error: %@", err); + } else { + NSLog(@"Step 2c: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x02 okay and the effect variant field set to 0x00 default: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestDutExecutesAnOkayEffect_6() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2dThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x0bChannelChangeAndTheEffectVariantFieldSetTo0x00Default_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; + params.effectIdentifier = + [NSNumber numberWithUnsignedChar:11U]; + params.effectVariant = + [NSNumber numberWithUnsignedChar:0U]; + [cluster triggerEffectWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x0b channel change and the effect variant field set to 0x00 default: Error: %@", err); + } else { + NSLog(@"Step 2d: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x0b channel change and the effect variant field set to 0x00 default: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestDutExecutesAChannelChangeEffect_8() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2eThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; + params.effectIdentifier = + [NSNumber numberWithUnsignedChar:1U]; + params.effectVariant = + [NSNumber numberWithUnsignedChar:0U]; + [cluster triggerEffectWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Error: %@", err); + } else { + NSLog(@"Step 2e: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestDutExecutesABreatheEffect_10() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2fThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xfeFinishEffectAndTheEffectVariantFieldSetTo0x00Default_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; + params.effectIdentifier = + [NSNumber numberWithUnsignedChar:254U]; + params.effectVariant = + [NSNumber numberWithUnsignedChar:0U]; + [cluster triggerEffectWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xfe finish effect and the effect variant field set to 0x00 default: Error: %@", err); + } else { + NSLog(@"Step 2f: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xfe finish effect and the effect variant field set to 0x00 default: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestDutStopsTheBreatheEffectAfterTheCurrentEffectSequence_12() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2gThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x01BreatheAndTheEffectVariantFieldSetTo0x00Default_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; + params.effectIdentifier = + [NSNumber numberWithUnsignedChar:1U]; + params.effectVariant = + [NSNumber numberWithUnsignedChar:0U]; + [cluster triggerEffectWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2g: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Error: %@", err); + } else { + NSLog(@"Step 2g: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x01 breathe and the effect variant field set to 0x00 default: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestDutExecutesABreatheEffect_14() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2hThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; + params.effectIdentifier = + [NSNumber numberWithUnsignedChar:255U]; + params.effectVariant = + [NSNumber numberWithUnsignedChar:0U]; + [cluster triggerEffectWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2h: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default: Error: %@", err); + } else { + NSLog(@"Step 2h: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestDutStopsTheBreatheEffectAsSoonAsPossible_16() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3aThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0x00BlinkAndTheEffectVariantFieldSetTo0x42Unknown_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; + params.effectIdentifier = + [NSNumber numberWithUnsignedChar:0U]; + params.effectVariant = + [NSNumber numberWithUnsignedChar:66U]; + [cluster triggerEffectWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x42 unknown: Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends TriggerEffect command to DUT with the effect identifier field set to 0x00 blink and the effect variant field set to 0x42 unknown: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckDutExecutesABlinkEffect_18() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3bThSendsTriggerEffectCommandToDutWithTheEffectIdentifierFieldSetTo0xffStopEffectAndTheEffectVariantFieldSetTo0x00Default_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterTriggerEffectParams alloc] init]; + params.effectIdentifier = + [NSNumber numberWithUnsignedChar:255U]; + params.effectVariant = + [NSNumber numberWithUnsignedChar:0U]; + [cluster triggerEffectWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default: Error: %@", err); + } else { + NSLog(@"Step 3b: TH sends TriggerEffect command to DUT with the effect identifier field set to 0xff stop effect and the effect variant field set to 0x00 default: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestDutStopsAnyEffectThatMayBeStillRunningAsSoonAsPossible_20() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } +}; + +class Test_TC_ILL_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ILL_1_1() + : TestCommandBridge("Test_TC_ILL_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ILL_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT.\n"); + err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap attribute from the DUT.\n"); + err = TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); + if (ShouldSkip("ILL.S.A0003")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList\n"); + if (ShouldSkip("ILL.S.A0004")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheOptionalAttributeLightSensorTypeInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the EventList attribute from the DUT.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the AcceptedCommandList attribute from the DUT.\n"); + err = TestStep6ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads the GeneratedCommandList attribute from the DUT.\n"); + err = TestStep7ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheOptionalAttributeLightSensorTypeInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the optional attribute(LightSensorType) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsTheAcceptedCommandListAttributeFromTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads the AcceptedCommandList attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads the AcceptedCommandList attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsTheGeneratedCommandListAttributeFromTheDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads the GeneratedCommandList attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads the GeneratedCommandList attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ILL_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ILL_2_1() + : TestCommandBridge("Test_TC_ILL_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ILL_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.\n"); + if (ShouldSkip("ILL.S.A0001")) { + NextTest(); + return; + } + err = TestStep2TestHarnessClientReadsMinMeasuredValueAttributeFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.\n"); + if (ShouldSkip("ILL.S.A0002")) { + NextTest(); + return; + } + err = TestStep3TestHarnessClientReadsMaxMeasuredValueAttributeFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Test Harness Client reads MeasuredValue attribute from DUT.\n"); + if (ShouldSkip("ILL.S.A0000")) { + NextTest(); + return; + } + err = TestStep4TestHarnessClientReadsMeasuredValueAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the Tolerance attribute from the DUT.\n"); + if (ShouldSkip("ILL.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsTheToleranceAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads the LightSensorType attribute from the DUT\n"); + if (ShouldSkip("ILL.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsTheLightSensorTypeAttributeFromTheDut_5(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 6; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2TestHarnessClientReadsMinMeasuredValueAttributeFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 2: Test Harness Client reads MinMeasuredValue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value unsignedShortValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value unsignedShortValue], 65533U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3TestHarnessClientReadsMaxMeasuredValueAttributeFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 3: Test Harness Client reads MaxMeasuredValue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value unsignedShortValue], 2U)); + VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value unsignedShortValue], 65534U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4TestHarnessClientReadsMeasuredValueAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: Test Harness Client reads MeasuredValue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 4: Test Harness Client reads MeasuredValue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value unsignedShortValue], 65534U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheToleranceAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsTheLightSensorTypeAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLightSensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads the LightSensorType attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads the LightSensorType attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("lightSensorType", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("lightSensorType", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("lightSensorType", [value unsignedCharValue], 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ILL_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ILL_2_2() + : TestCommandBridge("Test_TC_ILL_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ILL_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ILL_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ILL_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH reads MinMeasuredValue attribute from DUT\n"); + if (ShouldSkip("ILL.S.A0001")) { + NextTest(); + return; + } + err = TestStep2aThReadsMinMeasuredValueAttributeFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads MaxMeasuredValue attribute from DUT\n"); + if (ShouldSkip("ILL.S.A0002")) { + NextTest(); + return; + } + err = TestStep2bThReadsMaxMeasuredValueAttributeFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Cover the sensor or darken the room\n"); + if (ShouldSkip("PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep3CoverTheSensorOrDarkenTheRoom_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 1s\n"); + err = TestWait1s_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.\n"); + if (ShouldSkip("ILL.S.A0000 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep4AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: Expose the sensor again to light\n"); + if (ShouldSkip("PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep5ExposeTheSensorAgainToLight_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 1s\n"); + err = TestWait1s_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.\n"); + if (ShouldSkip("ILL.S.A0000 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep6AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2aThReadsMinMeasuredValueAttributeFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH reads MinMeasuredValue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH reads MinMeasuredValue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16u", "int16u")); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep2bThReadsMaxMeasuredValueAttributeFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads MaxMeasuredValue attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads MaxMeasuredValue attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16u", "int16u")); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3CoverTheSensorOrDarkenTheRoom_3() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for Successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWait1s_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 4: After a few seconds, TH reads MeasuredValue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value unsignedShortValue], 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ExposeTheSensorAgainToLight_6() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for Successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWait1s_7() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep6AfterAFewSecondsThReadsMeasuredValueAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIlluminanceMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.: Error: %@", err); + } else { + NSLog(@"Step 6: After a few seconds, TH reads MeasuredValue attribute from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value unsignedShortValue], 65534U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LVL_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LVL_1_1() + : TestCommandBridge("Test_TC_LVL_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LVL_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: Read the global attribute: ClusterRevision\n"); + err = TestStep1ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: Read the global attribute: FeatureMap\n"); + if (ShouldSkip(" !LVL.S.F00 && !LVL.S.F01 && !LVL.S.F02 ")) { + NextTest(); + return; + } + err = TestStep2aReadTheGlobalAttributeFeatureMap_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("LVL.S.F00")) { + NextTest(); + return; + } + err = TestStep2bGivenLvlsf00ooEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("LVL.S.F01")) { + NextTest(); + return; + } + err = TestStep2cGivenLvlsf01ltEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("LVL.S.F02")) { + NextTest(); + return; + } + err = TestStep2dGivenLvlsf02fqEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aReadTheGlobalAttributeAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aReadTheGlobalAttributeAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: Read the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList\n"); + if (ShouldSkip("LVL.S.F01")) { + NextTest(); + return; + } + err = TestStep3bReadTheOptionalAttributeStartUpCurrentLevelAndRemainingTimeInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: Read the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList\n"); + if (ShouldSkip("LVL.S.F02")) { + NextTest(); + return; + } + err = TestStep3cReadTheOptionalAttributeCurrentFrequencyMinFrequencyAndMinFrequencyInAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3d: Read the optional attribute(MinLevel) in AttributeList\n"); + if (ShouldSkip("LVL.S.A0002")) { + NextTest(); + return; + } + err = TestStep3dReadTheOptionalAttributeMinLevelInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3e: Read the optional attribute(MaxLevel) in AttributeList\n"); + if (ShouldSkip("LVL.S.A0003")) { + NextTest(); + return; + } + err = TestStep3eReadTheOptionalAttributeMaxLevelInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3f: Read the optional attribute(OnOffTransitionTime) in AttributeList\n"); + if (ShouldSkip("LVL.S.A0010")) { + NextTest(); + return; + } + err = TestStep3fReadTheOptionalAttributeOnOffTransitionTimeInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3g: Read the optional attribute(OnTransitionTime) in AttributeList\n"); + if (ShouldSkip("LVL.S.A0012")) { + NextTest(); + return; + } + err = TestStep3gReadTheOptionalAttributeOnTransitionTimeInAttributeList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3h: Read the optional attribute(OffTransitionTime) in AttributeList\n"); + if (ShouldSkip("LVL.S.A0013")) { + NextTest(); + return; + } + err = TestStep3hReadTheOptionalAttributeOffTransitionTimeInAttributeList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3i: Read the optional attribute(DefaultMoveRate) in AttributeList\n"); + if (ShouldSkip("LVL.S.A0014")) { + NextTest(); + return; + } + err = TestStep3iReadTheOptionalAttributeDefaultMoveRateInAttributeList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: Read the global attribute: AcceptedCommandList\n"); + err = TestStep4aReadTheGlobalAttributeAcceptedCommandList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4a.1: Read the Feature-dependent(LVL.S.F02) command in AcceptedCommandList\n"); + if (ShouldSkip("LVL.S.F02")) { + NextTest(); + return; + } + err = TestStep4a1ReadTheFeatureDependentLVLSF02CommandInAcceptedCommandList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4b: Read the global attribute: GeneratedCommandList\n"); + err = TestStep4bReadTheGlobalAttributeGeneratedCommandList_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 20; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 1: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aReadTheGlobalAttributeFeatureMap_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: Read the global attribute: FeatureMap: Error: %@", err); + } else { + NSLog(@"Step 2a: Read the global attribute: FeatureMap: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bGivenLvlsf00ooEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2b: Given LVL.S.F00(OO) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cGivenLvlsf01ltEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2c: Given LVL.S.F01(LT) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dGivenLvlsf02fqEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2d: Given LVL.S.F02(FQ) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bReadTheOptionalAttributeStartUpCurrentLevelAndRemainingTimeInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Read the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3b: Read the optional attribute(StartUpCurrentLevel and RemainingTime) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cReadTheOptionalAttributeCurrentFrequencyMinFrequencyAndMinFrequencyInAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Read the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3c: Read the optional attribute(CurrentFrequency, MinFrequency and MinFrequency) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dReadTheOptionalAttributeMinLevelInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Read the optional attribute(MinLevel) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3d: Read the optional attribute(MinLevel) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eReadTheOptionalAttributeMaxLevelInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Read the optional attribute(MaxLevel) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3e: Read the optional attribute(MaxLevel) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fReadTheOptionalAttributeOnOffTransitionTimeInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Read the optional attribute(OnOffTransitionTime) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3f: Read the optional attribute(OnOffTransitionTime) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gReadTheOptionalAttributeOnTransitionTimeInAttributeList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Read the optional attribute(OnTransitionTime) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3g: Read the optional attribute(OnTransitionTime) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hReadTheOptionalAttributeOffTransitionTimeInAttributeList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Read the optional attribute(OffTransitionTime) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3h: Read the optional attribute(OffTransitionTime) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iReadTheOptionalAttributeDefaultMoveRateInAttributeList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Read the optional attribute(DefaultMoveRate) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3i: Read the optional attribute(DefaultMoveRate) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAcceptedCommandList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a1ReadTheFeatureDependentLVLSF02CommandInAcceptedCommandList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a.1: Read the Feature-dependent(LVL.S.F02) command in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4a.1: Read the Feature-dependent(LVL.S.F02) command in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheGlobalAttributeGeneratedCommandList_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LVL_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LVL_2_1() + : TestCommandBridge("Test_TC_LVL_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LVL_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the CurrentLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheCurrentLevelAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the RemainingTime attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsTheRemainingTimeAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the MinLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0002 && LVL.S.F01")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheMinLevelAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads the MinLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0002 && !LVL.S.F01")) { + NextTest(); + return; + } + err = TestStep3bThReadsTheMinLevelAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the MaxLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0003 && LVL.S.F01")) { + NextTest(); + return; + } + err = TestStep4ThReadsTheMaxLevelAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads the MaxLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0003 && !LVL.S.F01")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheMaxLevelAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b & 4C TH reads the CurrentLevel attribute\n"); + if (ShouldSkip("LVL.S.F01 && LVL.S.A0002 && LVL.S.A0003")) { + NextTest(); + return; + } + err = TestStep4b4cThReadsTheCurrentLevelAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b & 4C TH reads the CurrentLevel attribute\n"); + if (ShouldSkip("LVL.S.A0002 && LVL.S.A0003 && !LVL.S.F01")) { + NextTest(); + return; + } + err = TestStep4b4cThReadsTheCurrentLevelAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the CurrentFrequency attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0004")) { + NextTest(); + return; + } + err = TestStep5ThReadsTheCurrentFrequencyAttributeFromTheDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the MinFrequency attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0005")) { + NextTest(); + return; + } + err = TestStep6ThReadsTheMinFrequencyAttributeFromTheDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads the MaxFrequency attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0006")) { + NextTest(); + return; + } + err = TestStep7ThReadsTheMaxFrequencyAttributeFromTheDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b & 7C TH reads the CurrentFrequency attribute\n"); + if (ShouldSkip("LVL.S.A0004 && LVL.S.A0005 && LVL.S.A0006")) { + NextTest(); + return; + } + err = TestStep7b7cThReadsTheCurrentFrequencyAttribute_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 8: TH reads the OnOffTransitionTime attribute\n"); + if (ShouldSkip("LVL.S.A0010")) { + NextTest(); + return; + } + err = TestStep8ThReadsTheOnOffTransitionTimeAttribute_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 9a: TH reads the OnLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.F01 && LVL.S.A0011")) { + NextTest(); + return; + } + err = TestStep9aThReadsTheOnLevelAttributeFromTheDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 9b: TH reads the OnLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0011 && !LVL.S.F01")) { + NextTest(); + return; + } + err = TestStep9bThReadsTheOnLevelAttributeFromTheDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 10: TH reads the OnTransitionTime attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0012")) { + NextTest(); + return; + } + err = TestStep10ThReadsTheOnTransitionTimeAttributeFromTheDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 11: TH reads the OffTransitionTime attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0013")) { + NextTest(); + return; + } + err = TestStep11ThReadsTheOffTransitionTimeAttributeFromTheDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 12: TH reads the DefaultMoveRate attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0014")) { + NextTest(); + return; + } + err = TestStep12ThReadsTheDefaultMoveRateAttributeFromTheDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 13: TH reads the Options attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A000f")) { + NextTest(); + return; + } + err = TestStep13ThReadsTheOptionsAttributeFromTheDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 14: TH reads the StartUpCurrentLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A4000")) { + NextTest(); + return; + } + err = TestStep14ThReadsTheStartUpCurrentLevelAttributeFromTheDut_20(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 21; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable CurrentLevelValue; + + CHIP_ERROR TestStep1ThReadsTheCurrentLevelAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the CurrentLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the CurrentLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 254U)); + } + { + CurrentLevelValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsTheRemainingTimeAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRemainingTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the RemainingTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the RemainingTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("remainingTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("remainingTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("remainingTime", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull MinLevelValue; + + CHIP_ERROR TestStep3aThReadsTheMinLevelAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the MinLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the MinLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("MinLevel", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); + { + MinLevelValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull MinLevelFeatureMapNotSupportedValue; + + CHIP_ERROR TestStep3bThReadsTheMinLevelAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads the MinLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads the MinLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("minLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("minLevel", [value unsignedCharValue], 254U)); + { + MinLevelFeatureMapNotSupportedValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull MaxLevelValue; + + CHIP_ERROR TestStep4ThReadsTheMaxLevelAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the MaxLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the MaxLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("MaxLevel", actualValue, 254U)); + } + + VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], MinLevelValue)); + { + MaxLevelValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull MaxLevelFeatureMapNotSupportedValue; + + CHIP_ERROR TestStep4aThReadsTheMaxLevelAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the MaxLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the MaxLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); + VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); + { + MaxLevelFeatureMapNotSupportedValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4b4cThReadsTheCurrentLevelAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Error: %@", err); + } else { + NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], MinLevelValue)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], MaxLevelValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4b4cThReadsTheCurrentLevelAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Error: %@", err); + } else { + NSLog(@"Step 4b & 4C TH reads the CurrentLevel attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], MaxLevelFeatureMapNotSupportedValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheCurrentFrequencyAttributeFromTheDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the CurrentFrequency attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the CurrentFrequency attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull MinFrequencyValue; + + CHIP_ERROR TestStep6ThReadsTheMinFrequencyAttributeFromTheDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads the MinFrequency attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads the MinFrequency attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("minFrequency", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("minFrequency", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("minFrequency", [value unsignedShortValue], 65535U)); + { + MinFrequencyValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull MaxFrequencyValue; + + CHIP_ERROR TestStep7ThReadsTheMaxFrequencyAttributeFromTheDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads the MaxFrequency attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads the MaxFrequency attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("maxFrequency", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("maxFrequency", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("maxFrequency", [value unsignedShortValue], 65535U)); + { + MaxFrequencyValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7b7cThReadsTheCurrentFrequencyAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7b & 7C TH reads the CurrentFrequency attribute: Error: %@", err); + } else { + NSLog(@"Step 7b & 7C TH reads the CurrentFrequency attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], MinFrequencyValue)); + VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], MaxFrequencyValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsTheOnOffTransitionTimeAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads the OnOffTransitionTime attribute: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads the OnOffTransitionTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("onOffTransitionTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("onOffTransitionTime", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9aThReadsTheOnLevelAttributeFromTheDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9a: TH reads the OnLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 9a: TH reads the OnLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], MinLevelValue)); + VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], MaxLevelValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9bThReadsTheOnLevelAttributeFromTheDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9b: TH reads the OnLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 9b: TH reads the OnLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], MinLevelFeatureMapNotSupportedValue)); + VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], MaxLevelFeatureMapNotSupportedValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsTheOnTransitionTimeAttributeFromTheDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads the OnTransitionTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("onTransitionTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("onTransitionTime", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsTheOffTransitionTimeAttributeFromTheDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads the OffTransitionTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("offTransitionTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("offTransitionTime", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsTheDefaultMoveRateAttributeFromTheDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads the DefaultMoveRate attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("defaultMoveRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("defaultMoveRate", [value unsignedCharValue], 255U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13ThReadsTheOptionsAttributeFromTheDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH reads the Options attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 13: TH reads the Options attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("options", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep14ThReadsTheStartUpCurrentLevelAttributeFromTheDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 14: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("startUpCurrentLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("startUpCurrentLevel", [value unsignedCharValue], 255U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LVL_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LVL_2_2() + : TestCommandBridge("Test_TC_LVL_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("OnOffTransitionTimeConfigValue", 0, UINT16_MAX, &mOnOffTransitionTimeConfigValue); + AddArgument("OnLevelConfigValue", 0, UINT8_MAX, &mOnLevelConfigValue); + AddArgument("OnTransitionTimeConfigValue", 0, UINT16_MAX, &mOnTransitionTimeConfigValue); + AddArgument("OffTransitionTimeConfigValue", 0, UINT16_MAX, &mOffTransitionTimeConfigValue); + AddArgument("DefaultMoveRateConfigValue", 0, UINT8_MAX, &mDefaultMoveRateConfigValue); + AddArgument("StartUpCurrentLevelConfigValue", 0, UINT8_MAX, &mStartUpCurrentLevelConfigValue); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LVL_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads the OnOffTransitionTime attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0010")) { + NextTest(); + return; + } + err = TestStep1aThReadsTheOnOffTransitionTimeAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a\n"); + if (ShouldSkip("LVL.S.A0010")) { + NextTest(); + return; + } + err = TestStep1bThWritesTheOnOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn1a_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads the OnOffTransitionTime attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0010")) { + NextTest(); + return; + } + err = TestStep1cThReadsTheOnOffTransitionTimeAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH reads the OnLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0011")) { + NextTest(); + return; + } + err = TestStep2aThReadsTheOnLevelAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a\n"); + if (ShouldSkip("LVL.S.A0011")) { + NextTest(); + return; + } + err = TestStep2bThWritesTheOnLevelAttributeOnTheDutWithADifferentValueThanThatReadIn2a_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: TH reads the OnLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0011")) { + NextTest(); + return; + } + err = TestStep2cThReadsTheOnLevelAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH reads the OnTransitionTime attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0012")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheOnTransitionTimeAttributeFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a\n"); + if (ShouldSkip("LVL.S.A0012")) { + NextTest(); + return; + } + err = TestStep3bThWritesTheOnTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn3a_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: TH reads the OnTransitionTime attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0012")) { + NextTest(); + return; + } + err = TestStep3cThReadsTheOnTransitionTimeAttributeFromTheDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads the OffTransitionTime attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0013")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheOffTransitionTimeAttributeFromTheDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a\n"); + if (ShouldSkip("LVL.S.A0013")) { + NextTest(); + return; + } + err = TestStep4bThWritesTheOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn4a_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: TH reads the OffTransitionTime attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0013")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheOffTransitionTimeAttributeFromTheDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: TH reads the DefaultMoveRate attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0014")) { + NextTest(); + return; + } + err = TestStep5aThReadsTheDefaultMoveRateAttributeFromTheDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a\n"); + if (ShouldSkip("LVL.S.A0014")) { + NextTest(); + return; + } + err = TestStep5bThWritesTheDefaultMoveRateAttributeOnTheDutWithADifferentValueThanThatReadIn5a_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5c: TH reads the DefaultMoveRate attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0014")) { + NextTest(); + return; + } + err = TestStep5cThReadsTheDefaultMoveRateAttributeFromTheDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A4000")) { + NextTest(); + return; + } + err = TestStep6aThReadsTheStartUpCurrentLevelAttributeFromTheDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a\n"); + if (ShouldSkip("LVL.S.A4000")) { + NextTest(); + return; + } + err = TestStep6bThWritesTheStartUpCurrentLevelAttributeOnTheDutWithADifferentValueThanThatReadIn6a_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A4000")) { + NextTest(); + return; + } + err = TestStep6cThReadsTheStartUpCurrentLevelAttributeFromTheDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : writes back default value of OnOffTransitionTime attribute\n"); + if (ShouldSkip("LVL.S.A0010")) { + NextTest(); + return; + } + err = TestWritesBackDefaultValueOfOnOffTransitionTimeAttribute_19(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 20; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mOnOffTransitionTimeConfigValue; + chip::Optional mOnLevelConfigValue; + chip::Optional mOnTransitionTimeConfigValue; + chip::Optional mOffTransitionTimeConfigValue; + chip::Optional mDefaultMoveRateConfigValue; + chip::Optional mStartUpCurrentLevelConfigValue; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull OnOffTransitionTimeValue; + + CHIP_ERROR TestStep1aThReadsTheOnOffTransitionTimeAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH reads the OnOffTransitionTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1a: TH reads the OnOffTransitionTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("onOffTransitionTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("onOffTransitionTime", [value unsignedShortValue], 65535U)); + { + OnOffTransitionTimeValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThWritesTheOnOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn1a_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onOffTransitionTimeArgument; + onOffTransitionTimeArgument = mOnOffTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOnOffTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:10U]; + [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a: Error: %@", err); + } else { + NSLog(@"Step 1b: TH writes the OnOffTransitionTime attribute on the DUT with a different value than that read in 1a: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1cThReadsTheOnOffTransitionTimeAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: TH reads the OnOffTransitionTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1c: TH reads the OnOffTransitionTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOffTransitionTime", actualValue, mOnOffTransitionTimeConfigValue.HasValue() ? mOnOffTransitionTimeConfigValue.Value() : 10U)); + } + + VerifyOrReturn(CheckConstraintType("onOffTransitionTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintNotValue("onOffTransitionTime", value, OnOffTransitionTimeValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable OnLevelValue; + + CHIP_ERROR TestStep2aThReadsTheOnLevelAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH reads the OnLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH reads the OnLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("onLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("onLevel", [value unsignedCharValue], 254U)); + } + { + OnLevelValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThWritesTheOnLevelAttributeOnTheDutWithADifferentValueThanThatReadIn2a_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onLevelArgument; + onLevelArgument = mOnLevelConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mOnLevelConfigValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; + [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a: Error: %@", err); + } else { + NSLog(@"Step 2b: TH writes the OnLevel attribute on the DUT with a different value than that read in 2a: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cThReadsTheOnLevelAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads the OnLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads the OnLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("OnLevel", actualValue)); + VerifyOrReturn(CheckValue("OnLevel", actualValue, mOnLevelConfigValue.HasValue() ? mOnLevelConfigValue.Value() : 5U)); + } + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("onLevel", "int8u", "int8u")); + } + VerifyOrReturn(CheckConstraintNotValue("onLevel", value, OnLevelValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable OnTransitionTimeValue; + + CHIP_ERROR TestStep3aThReadsTheOnTransitionTimeAttributeFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the OnTransitionTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("onTransitionTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("onTransitionTime", [value unsignedShortValue], 65535U)); + } + { + OnTransitionTimeValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThWritesTheOnTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn3a_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onTransitionTimeArgument; + onTransitionTimeArgument = mOnTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOnTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:5U]; + [cluster writeAttributeOnTransitionTimeWithValue:onTransitionTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a: Error: %@", err); + } else { + NSLog(@"Step 3b: TH writes the OnTransitionTime attribute on the DUT with a different value than that read in 3a: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsTheOnTransitionTimeAttributeFromTheDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads the OnTransitionTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads the OnTransitionTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("OnTransitionTime", actualValue)); + VerifyOrReturn(CheckValue("OnTransitionTime", actualValue, mOnTransitionTimeConfigValue.HasValue() ? mOnTransitionTimeConfigValue.Value() : 5U)); + } + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("onTransitionTime", "int16u", "int16u")); + } + VerifyOrReturn(CheckConstraintNotValue("onTransitionTime", value, OnTransitionTimeValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable OffTransitionTimeValue; + + CHIP_ERROR TestStep4aThReadsTheOffTransitionTimeAttributeFromTheDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the OffTransitionTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("offTransitionTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("offTransitionTime", [value unsignedShortValue], 65535U)); + } + { + OffTransitionTimeValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThWritesTheOffTransitionTimeAttributeOnTheDutWithADifferentValueThanThatReadIn4a_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id offTransitionTimeArgument; + offTransitionTimeArgument = mOffTransitionTimeConfigValue.HasValue() ? [NSNumber numberWithUnsignedShort:mOffTransitionTimeConfigValue.Value()] : [NSNumber numberWithUnsignedShort:10U]; + [cluster writeAttributeOffTransitionTimeWithValue:offTransitionTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a: Error: %@", err); + } else { + NSLog(@"Step 4b: TH writes the OffTransitionTime attribute on the DUT with a different value than that read in 4a: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheOffTransitionTimeAttributeFromTheDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the OffTransitionTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the OffTransitionTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("OffTransitionTime", actualValue)); + VerifyOrReturn(CheckValue("OffTransitionTime", actualValue, mOffTransitionTimeConfigValue.HasValue() ? mOffTransitionTimeConfigValue.Value() : 10U)); + } + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("offTransitionTime", "int16u", "int16u")); + } + VerifyOrReturn(CheckConstraintNotValue("offTransitionTime", value, OffTransitionTimeValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable DefaultMoveRatevalue; + + CHIP_ERROR TestStep5aThReadsTheDefaultMoveRateAttributeFromTheDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5a: TH reads the DefaultMoveRate attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("defaultMoveRate", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("defaultMoveRate", [value unsignedCharValue], 255U)); + } + { + DefaultMoveRatevalue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bThWritesTheDefaultMoveRateAttributeOnTheDutWithADifferentValueThanThatReadIn5a_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id defaultMoveRateArgument; + defaultMoveRateArgument = mDefaultMoveRateConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mDefaultMoveRateConfigValue.Value()] : [NSNumber numberWithUnsignedChar:111U]; + [cluster writeAttributeDefaultMoveRateWithValue:defaultMoveRateArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a: Error: %@", err); + } else { + NSLog(@"Step 5b: TH writes the DefaultMoveRate attribute on the DUT with a different value than that read in 5a: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5cThReadsTheDefaultMoveRateAttributeFromTheDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDefaultMoveRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5c: TH reads the DefaultMoveRate attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5c: TH reads the DefaultMoveRate attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("DefaultMoveRate", actualValue)); + VerifyOrReturn(CheckValue("DefaultMoveRate", actualValue, mDefaultMoveRateConfigValue.HasValue() ? mDefaultMoveRateConfigValue.Value() : 111U)); + } + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("defaultMoveRate", "int8u", "int8u")); + } + VerifyOrReturn(CheckConstraintNotValue("defaultMoveRate", value, DefaultMoveRatevalue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable StartUpCurrentLevelValue; + + CHIP_ERROR TestStep6aThReadsTheStartUpCurrentLevelAttributeFromTheDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("startUpCurrentLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("startUpCurrentLevel", [value unsignedCharValue], 255U)); + } + { + StartUpCurrentLevelValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThWritesTheStartUpCurrentLevelAttributeOnTheDutWithADifferentValueThanThatReadIn6a_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id startUpCurrentLevelArgument; + startUpCurrentLevelArgument = mStartUpCurrentLevelConfigValue.HasValue() ? [NSNumber numberWithUnsignedChar:mStartUpCurrentLevelConfigValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; + [cluster writeAttributeStartUpCurrentLevelWithValue:startUpCurrentLevelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a: Error: %@", err); + } else { + NSLog(@"Step 6b: TH writes the StartUpCurrentLevel attribute on the DUT with a different value than that read in 6a: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cThReadsTheStartUpCurrentLevelAttributeFromTheDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartUpCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6c: TH reads the StartUpCurrentLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("StartUpCurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("StartUpCurrentLevel", actualValue, mStartUpCurrentLevelConfigValue.HasValue() ? mStartUpCurrentLevelConfigValue.Value() : 5U)); + } + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("startUpCurrentLevel", "int8u", "int8u")); + } + VerifyOrReturn(CheckConstraintNotValue("startUpCurrentLevel", value, StartUpCurrentLevelValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWritesBackDefaultValueOfOnOffTransitionTimeAttribute_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onOffTransitionTimeArgument; + onOffTransitionTimeArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"writes back default value of OnOffTransitionTime attribute: Error: %@", err); + } else { + NSLog(@"writes back default value of OnOffTransitionTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LVL_3_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LVL_3_1() + : TestCommandBridge("Test_TC_LVL_3_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LVL_3_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_3_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_3_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestPreconditionSendOnCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); + if (ShouldSkip("LVL.S.A0010")) { + NextTest(); + return; + } + err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("LVL.S.A000f")) { + NextTest(); + return; + } + err = TestStep1ThWrites0ToTheOptionsAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1a: TH writes NULL to the OnLevel attribute\n"); + if (ShouldSkip("LVL.S.A0011")) { + NextTest(); + return; + } + err = TestStep1aThWritesNullToTheOnLevelAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends Off command to DUT\n"); + if (ShouldSkip("LVL.S.C04.Rsp && OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsOffCommandToDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); + if (ShouldSkip("LVL.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsAMoveToLevelWithOnOffCommandToDutWithLevel50AndTransitionTime0Immediate_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); + if (ShouldSkip("OO.S.A0000 && LVL.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C04.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep2dThReadsCurrentLevelAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: TH sends On command to DUT\n"); + if (ShouldSkip("LVL.S.C04.Rsp && OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsOnCommandToDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep3cThReadsCurrentLevelAttributeFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsAMoveToLevelCommandToTheDutWithLevel200AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 10000ms\n"); + err = TestWait10000ms_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { + NextTest(); + return; + } + err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10000ms\n"); + err = TestWait10000ms_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { + NextTest(); + return; + } + err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10000ms\n"); + err = TestWait10000ms_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { + NextTest(); + return; + } + err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 5000ms\n"); + err = TestWait5000ms_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { + NextTest(); + return; + } + err = TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition)\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000 && !LVL.S.M.VarRate")) { + NextTest(); + return; + } + err = TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5a: TH writes 0x00 to the Options attribute\n"); + if (ShouldSkip("LVL.S.A000f")) { + NextTest(); + return; + } + err = TestStep5aThWrites0x00ToTheOptionsAttribute_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 5b: TH reads the Options attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A000f")) { + NextTest(); + return; + } + err = TestStep5bThReadsTheOptionsAttributeFromTheDut_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 5c: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep5cThSendsOnCommandToDut_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep5dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5e: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep5eThReadsCurrentLevelAttributeFromDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5f: TH sends Off command to DUT\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep5fThSendsOffCommandToDut_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep5gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5h: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep5hThReadsCurrentLevelAttributeFromDut_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep5iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Step 5j: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep5jThReadsCurrentLevelAttributeFromDut_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep5kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Step 5l: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep5lThReadsCurrentLevelAttributeFromDut_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Step 6a: TH writes 0x01 to the Options attribute\n"); + if (ShouldSkip("LVL.S.A000f")) { + NextTest(); + return; + } + err = TestStep6aThWrites0x01ToTheOptionsAttribute_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Step 6b: TH reads the Options attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A000f")) { + NextTest(); + return; + } + err = TestStep6bThReadsTheOptionsAttributeFromTheDut_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Step 6c: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep6cThSendsOnCommandToDut_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Step 6e: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep6eThReadsCurrentLevelAttributeFromDut_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Step 6f: TH sends Off command to DUT\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6fThSendsOffCommandToDut_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Step 6h: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep6hThReadsCurrentLevelAttributeFromDut_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Step 6j: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep6jThReadsCurrentLevelAttributeFromDut_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Step 6l: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep6lThReadsCurrentLevelAttributeFromDut_46(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 47; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionSendOnCommand_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition Send On Command: Error: %@", err); + } else { + NSLog(@"Precondition Send On Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is true after on command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onOffTransitionTimeArgument; + onOffTransitionTimeArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); + } else { + NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1ThWrites0ToTheOptionsAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1aThWritesNullToTheOnLevelAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onLevelArgument; + onLevelArgument = nil; + [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes NULL to the OnLevel attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes NULL to the OnLevel attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsOffCommandToDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends Off command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThSendsAMoveToLevelWithOnOffCommandToDutWithLevel50AndTransitionTime0Immediate_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:50U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithOnOffWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends a MoveToLevelWithOnOff command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dThReadsCurrentLevelAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsOnCommandToDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:50U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsCurrentLevelAttributeFromDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsAMoveToLevelCommandToTheDutWithLevel200AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:200U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:300U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s: Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends a MoveToLevel command to the DUT with Level = 200 and TransitionTime = 300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10000ms_14() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10000ms_16() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10000ms_18() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4d:After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5000ms_20() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThWrites0x00ToTheOptionsAttribute_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH writes 0x00 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 5a: TH writes 0x00 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bThReadsTheOptionsAttributeFromTheDut_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH reads the Options attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5b: TH reads the Options attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Options", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5cThSendsOnCommandToDut_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5c: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 5c: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:100U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); + } else { + NSLog(@"Step 5d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5eThReadsCurrentLevelAttributeFromDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5e: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5e: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5fThSendsOffCommandToDut_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5f: TH sends Off command to DUT: Error: %@", err); + } else { + NSLog(@"Step 5f: TH sends Off command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:120U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); + } else { + NSLog(@"Step 5g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5hThReadsCurrentLevelAttributeFromDut_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5h: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5h: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:140U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:1U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Error: %@", err); + } else { + NSLog(@"Step 5i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5jThReadsCurrentLevelAttributeFromDut_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5j: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5j: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:160U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:1U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:1U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Error: %@", err); + } else { + NSLog(@"Step 5k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5lThReadsCurrentLevelAttributeFromDut_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5l: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5l: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 160U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThWrites0x01ToTheOptionsAttribute_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH writes 0x01 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 6a: TH writes 0x01 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsTheOptionsAttributeFromTheDut_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOptionsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads the Options attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads the Options attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Options", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cThSendsOnCommandToDut_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 6c: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6dThSendsAMoveToLevelCommandToTheDutWith1Level1002TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:100U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); + } else { + NSLog(@"Step 6d: TH sends a MoveToLevel command to the DUT with: 1)Level = 100 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6eThReadsCurrentLevelAttributeFromDut_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6e: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6e: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6fThSendsOffCommandToDut_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6f: TH sends Off command to DUT: Error: %@", err); + } else { + NSLog(@"Step 6f: TH sends Off command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6gThSendsAMoveToLevelCommandToTheDutWith1Level1202TransitionTime0Immediate3OptionsMask0x004OptionsOverride0x00_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:120U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Error: %@", err); + } else { + NSLog(@"Step 6g: TH sends a MoveToLevel command to the DUT with: 1)Level = 120 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x00 4)OptionsOverride = 0x00: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6hThReadsCurrentLevelAttributeFromDut_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6h: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6h: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 120U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6iThSendsAMoveToLevelCommandToTheDutWith1Level1402TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x00_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:140U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:1U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Error: %@", err); + } else { + NSLog(@"Step 6i: TH sends a MoveToLevel command to the DUT with: 1)Level = 140 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x00: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6jThReadsCurrentLevelAttributeFromDut_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6j: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6j: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 120U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6kThSendsAMoveToLevelCommandToTheDutWith1Level1602TransitionTime0Immediate3OptionsMask0x014OptionsOverride0x01_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:160U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:1U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:1U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Error: %@", err); + } else { + NSLog(@"Step 6k: TH sends a MoveToLevel command to the DUT with: 1)Level = 160 2)TransitionTime = 0 (immediate) 3)OptionsMask = 0x01 4)OptionsOverride = 0x01: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6lThReadsCurrentLevelAttributeFromDut_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6l: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6l: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 160U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LVL_4_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LVL_4_1() + : TestCommandBridge("Test_TC_LVL_4_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LVL_4_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_4_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_4_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestPreconditionSendOnCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); + if (ShouldSkip("LVL.S.A0010")) { + NextTest(); + return; + } + err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1a: TH writes 0 to the Options attribute\n"); + if (ShouldSkip("LVL.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aThWrites0ToTheOptionsAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1b: TH reads the MaxLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0003")) { + NextTest(); + return; + } + err = TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: TH sends Off command to DUT\n"); + if (ShouldSkip("OO.S.C00.Rsp && LVL.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsOffCommandToDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s)\n"); + if (ShouldSkip("LVL.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsAMoveWithOnOffCommandToDutWithMoveMode0x00UpAndRate10UnitsS_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); + if (ShouldSkip("OO.S.A0000 && LVL.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C05.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep2dThReadsCurrentLevelAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Wait 5000ms\n"); + err = TestWait5000ms_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C05.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep2eAfter5SecondsThReadsCurrentLevelAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsOnCommandToDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3c: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep3cThReadsCurrentLevelAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s)\n"); + if (ShouldSkip("LVL.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsAMoveCommandToTheDutWithMoveMode0x00UpAndRate5UnitsS_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10s\n"); + err = TestWait10s_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 10s\n"); + err = TestWait10s_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 10s\n"); + err = TestWait10s_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Wait 19s\n"); + err = TestWait19s_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep4eAfterAnother19SecondsThReadsCurrentLevelAttributeFromDut_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Precondition send Off Command\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestPreconditionSendOffCommand_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_25(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 26; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionSendOnCommand_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition Send On Command: Error: %@", err); + } else { + NSLog(@"Precondition Send On Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is true after on command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onOffTransitionTimeArgument; + onOffTransitionTimeArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); + } else { + NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1aThWrites0ToTheOptionsAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes 0 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsOffCommandToDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends Off command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThSendsAMoveWithOnOffCommandToDutWithMoveMode0x00UpAndRate10UnitsS_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveWithOnOffParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:0U]; + params.rate = + [NSNumber numberWithUnsignedChar:10U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveWithOnOffWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s): Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends a MoveWithOnOff command to DUT, with MoveMode =0x00 (up) and Rate =10 (units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable CurrentLevelValue; + + CHIP_ERROR TestStep2dThReadsCurrentLevelAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentLevel", "int8u", "int8u")); + } + { + CurrentLevelValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5000ms_10() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2eAfter5SecondsThReadsCurrentLevelAttributeFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2e: After 5 seconds TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsOnCommandToDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:50U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsCurrentLevelAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsAMoveCommandToTheDutWithMoveMode0x00UpAndRate5UnitsS_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:0U]; + params.rate = + [NSNumber numberWithUnsignedChar:5U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s): Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends a Move command to the DUT with MoveMode =0x00 (up) and Rate =5 (units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_16() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_18() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_20() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 230U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait19s_22() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 19000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4eAfterAnother19SecondsThReadsCurrentLevelAttributeFromDut_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4e: After another 19 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreconditionSendOffCommand_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition send Off Command: Error: %@", err); + } else { + NSLog(@"Precondition send Off Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LVL_5_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LVL_5_1() + : TestCommandBridge("Test_TC_LVL_5_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LVL_5_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_5_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_5_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition Send On Command\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestPreconditionSendOnCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Check on/off attribute value is true after on command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Precondition: write default value of OnOffTransitionTime attribute\n"); + if (ShouldSkip("LVL.S.A0010")) { + NextTest(); + return; + } + err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1: TH writes 0x00 to the Options attribute\n"); + if (ShouldSkip("LVL.S.A000f")) { + NextTest(); + return; + } + err = TestStep1ThWrites0x00ToTheOptionsAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH sends Off command to DUT\n"); + if (ShouldSkip("OO.S.C00.Rsp && LVL.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsOffCommandToDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate)\n"); + if (ShouldSkip("LVL.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsAStepWithOnOffCommandToDutWithStepMode0x00UpStepSize50AndTransitionTime0Immediate_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT\n"); + if (ShouldSkip("OO.S.A0000 && LVL.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3a: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsOnCommandToDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3c: Reads current level attribute from DUT\n"); + if (ShouldSkip("LVL.S.A0000 && LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3cReadsCurrentLevelAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.\n"); + if (ShouldSkip("LVL.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsAStepCommandToTheDutWithStepMode0x00UpStepSize150AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 10s\n"); + err = TestWait10s_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { + NextTest(); + return; + } + err = TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 10s\n"); + err = TestWait10s_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { + NextTest(); + return; + } + err = TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Wait 10s\n"); + err = TestWait10s_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { + NextTest(); + return; + } + err = TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Wait 5000ms\n"); + err = TestWait5000ms_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && LVL.S.M.VarRate")) { + NextTest(); + return; + } + err = TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition)\n"); + if (ShouldSkip("LVL.S.C02.Rsp && LVL.S.A0000 && !LVL.S.M.VarRate")) { + NextTest(); + return; + } + err = TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Precondition send Off Command\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestPreconditionSendOffCommand_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 23; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionSendOnCommand_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition Send On Command: Error: %@", err); + } else { + NSLog(@"Precondition Send On Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is true after on command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onOffTransitionTimeArgument; + onOffTransitionTimeArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); + } else { + NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1ThWrites0x00ToTheOptionsAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH writes 0x00 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1: TH writes 0x00 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsOffCommandToDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends Off command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThSendsAStepWithOnOffCommandToDutWithStepMode0x00UpStepSize50AndTransitionTime0Immediate_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterStepWithOnOffParams alloc] init]; + params.stepMode = + [NSNumber numberWithUnsignedChar:0U]; + params.stepSize = + [NSNumber numberWithUnsignedChar:50U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stepWithOnOffWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends a StepWithOnOff command to DUT, with StepMode =0x00 (up), StepSize =50 and TransitionTime =0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cThReadsOnOffAttributeOnOffClusterFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads OnOff attribute (On/Off cluster) from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsOnCommandToDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:50U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 3b: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cReadsCurrentLevelAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Reads current level attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: Reads current level attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsAStepCommandToTheDutWithStepMode0x00UpStepSize150AndTransitionTime30030SThisMeansTheLevelShouldIncreaseBy150UnitsIn30sSo5UnitsS_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterStepParams alloc] init]; + params.stepMode = + [NSNumber numberWithUnsignedChar:0U]; + params.stepSize = + [NSNumber numberWithUnsignedChar:150U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:300U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stepWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends a Step command to the DUT with StepMode_ =0x00 (up), StepSize =150 and TransitionTime =300 (30 s). This means the level should increase by 150 units in 30s, so 5 units/s.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4bAfter10SecondsThReadsCurrentLevelAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: After 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_14() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4cAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 127U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 173U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait10s_16() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4dAfterAnother10SecondsThReadsCurrentLevelAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4d: After another 10 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 170U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5000ms_18() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4eAfterAnother5SecondsThReadsCurrentLevelAttributeFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4e: After another 5 seconds, TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsCurrentLevelAttributeFromDutAfterDutHasFinishedTheTransition_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads CurrentLevel attribute from DUT (after DUT has finished the transition): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreconditionSendOffCommand_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition send Off Command: Error: %@", err); + } else { + NSLog(@"Precondition send Off Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LVL_6_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LVL_6_1() + : TestCommandBridge("Test_TC_LVL_6_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LVL_6_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_6_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_6_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: write default value of OnOffTransitionTime attribute\n"); + if (ShouldSkip("LVL.S.A0010")) { + NextTest(); + return; + } + err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1a: TH writes 0x00 to the Options attribute\n"); + if (ShouldSkip("LVL.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aThWrites0x00ToTheOptionsAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1bThSendsOnCommandToDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate)\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.A0000 && LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThReadsCurrentLevelAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s)\n"); + if (ShouldSkip("LVL.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2cThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2d: Wait 5000ms\n"); + err = TestStep2dWait5000ms_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3: After 5 seconds, TH sends a Stop command to the DUT\n"); + if (ShouldSkip("LVL.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep3After5SecondsThSendsAStopCommandToTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Physically verify that the device has stopped transitioning\n"); + if (ShouldSkip("PICS_USER_PROMPT && LVL.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.C03.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsCurrentLevelAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s)\n"); + if (ShouldSkip("LVL.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 5000ms\n"); + err = TestWait5000ms_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT\n"); + if (ShouldSkip("LVL.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep6After5SecondsThSendsAStopWithOnOffCommandToTheDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Physically verify that the device has stopped transitioning\n"); + if (ShouldSkip("PICS_USER_PROMPT && LVL.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C01.Rsp && LVL.S.C07.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep7ThReadsCurrentLevelAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Precondition send Off Command\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestPreconditionSendOffCommand_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 18; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onOffTransitionTimeArgument; + onOffTransitionTimeArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); + } else { + NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1aThWrites0x00ToTheOptionsAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes 0x00 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes 0x00 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsOnCommandToDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsAMoveToLevelCommandToDutWithLevel50AndTransitionTime0Immediate_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:50U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends a MoveToLevel command to DUT, with Level =50 and TransitionTime =0 (immediate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThReadsCurrentLevelAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 50U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:0U]; + params.rate = + [NSNumber numberWithUnsignedChar:5U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Error: %@", err); + } else { + NSLog(@"Step 2c: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dWait5000ms_7() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3After5SecondsThSendsAStopCommandToTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterStopParams alloc] init]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stopWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: After 5 seconds, TH sends a Stop command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: After 5 seconds, TH sends a Stop command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_9() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep4ThReadsCurrentLevelAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 64U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 86U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThSendsAMoveCommandToTheDutWithTheMoveModeFieldSetTo0x00MoveUpAndTheRateFieldSetTo0x055UnitsS_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveParams alloc] init]; + params.moveMode = + [NSNumber numberWithUnsignedChar:0U]; + params.rate = + [NSNumber numberWithUnsignedChar:5U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Error: %@", err); + } else { + NSLog(@"Step 5: TH sends a Move command to the DUT, with the MoveMode field set to 0x00 (move up) and the Rate field set to 0x05 (5 units/s): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5000ms_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep6After5SecondsThSendsAStopWithOnOffCommandToTheDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterStopWithOnOffParams alloc] init]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster stopWithOnOffWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 6: After 5 seconds, TH sends a StopWithOnOff command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPhysicallyVerifyThatTheDeviceHasStoppedTransitioning_14() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep7ThReadsCurrentLevelAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentLevel", [value unsignedCharValue], 85U)); + VerifyOrReturn(CheckConstraintMaxValue("currentLevel", [value unsignedCharValue], 115U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreconditionSendOffCommand_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition send Off Command: Error: %@", err); + } else { + NSLog(@"Precondition send Off Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LVL_7_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LVL_7_1() + : TestCommandBridge("Test_TC_LVL_7_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("RandomLevelValue", 0, UINT8_MAX, &mRandomLevelValue); + AddArgument("RandomFrequencyValue", 0, UINT16_MAX, &mRandomFrequencyValue); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LVL_7_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LVL_7_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LVL_7_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: write default value of OnOffTransitionTime attribute\n"); + if (ShouldSkip("LVL.S.A0010")) { + NextTest(); + return; + } + err = TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0a: TH writes 0x00 to the Options attribute\n"); + if (ShouldSkip("LVL.S.A000f")) { + NextTest(); + return; + } + err = TestStep0aThWrites0x00ToTheOptionsAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0b: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep0bThSendsOnCommandToDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1a: TH reads the MinLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0002")) { + NextTest(); + return; + } + err = TestStep1aThReadsTheMinLevelAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1b: TH reads the MaxLevel attribute from the DUT\n"); + if (ShouldSkip("LVL.S.A0003")) { + NextTest(); + return; + } + err = TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).\n"); + if (ShouldSkip("LVL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep1cThSendsAMoveToLevelCommandToDutWithTheLevelFieldSetToAValueBetweenTheMinLevelAndMaxLevelValuesIfPresentOtherwiseBetween0x01And0xFEAndTheTransitionTimeFieldSetTo0x0000MoveImmediately_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Wait 100ms\n"); + err = TestWait100ms_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1d: TH reads CurrentLevel attribute from DUT\n"); + if (ShouldSkip("LVL.S.C00.Rsp && LVL.S.A0000")) { + NextTest(); + return; + } + err = TestStep1dThReadsCurrentLevelAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH reads the CurrentFrequency attribute.\n"); + if (ShouldSkip("LVL.S.A0004")) { + NextTest(); + return; + } + err = TestStep2aThReadsTheCurrentFrequencyAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH reads the MinFrequency attribute.\n"); + if (ShouldSkip("LVL.S.A0005")) { + NextTest(); + return; + } + err = TestStep2bThReadsTheMinFrequencyAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.\n"); + if (ShouldSkip("LVL.S.A0006")) { + NextTest(); + return; + } + err = TestStep2cThReadsTheMaxFrequencyAttributeAndCheckIfFmaxFminFailTheTest_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test\n"); + if (ShouldSkip("LVL.S.A0004")) { + NextTest(); + return; + } + err = TestStep2dSanityCheckOnValuesReadInSteps2a2cIfFcFminFailTheTestAndFcFmaxFailTheTest_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax\n"); + if (ShouldSkip("LVL.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToARandomValueFrandChosenSuchThatFminFrandFmax_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Wait 100ms\n"); + err = TestWait100ms_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: TH reads the CurrentFrequency attribute.\n"); + if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004")) { + NextTest(); + return; + } + err = TestStep3bThReadsTheCurrentFrequencyAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to fmax + 1\n"); + if (ShouldSkip("LVL.S.C08.Rsp && PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep4aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmax1_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: TH reads the CurrentFrequency attribute.\n"); + if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004 && PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheCurrentFrequencyAttribute_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to fmin - 1\n"); + if (ShouldSkip("LVL.S.C08.Rsp && PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep5aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmin1_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5b: TH reads the CurrentFrequency attribute.\n"); + if (ShouldSkip("LVL.S.C08.Rsp && LVL.S.A0004 && PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep5bThReadsTheCurrentFrequencyAttribute_19(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 20; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mRandomLevelValue; + chip::Optional mRandomFrequencyValue; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionWriteDefaultValueOfOnOffTransitionTimeAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onOffTransitionTimeArgument; + onOffTransitionTimeArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Error: %@", err); + } else { + NSLog(@"Precondition: write default value of OnOffTransitionTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0aThWrites0x00ToTheOptionsAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id optionsArgument; + optionsArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOptionsWithValue:optionsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0a: TH writes 0x00 to the Options attribute: Error: %@", err); + } else { + NSLog(@"Step 0a: TH writes 0x00 to the Options attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0bThSendsOnCommandToDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0b: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 0b: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull minLevelValue; + + CHIP_ERROR TestStep1aThReadsTheMinLevelAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH reads the MinLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1a: TH reads the MinLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("minLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("minLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("minLevel", [value unsignedCharValue], 254U)); + { + minLevelValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull maxLevelValue; + + CHIP_ERROR TestStep1bThReadsTheMaxLevelAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH reads the MaxLevel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("maxLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("maxLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("maxLevel", [value unsignedCharValue], 254U)); + { + maxLevelValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1cThSendsAMoveToLevelCommandToDutWithTheLevelFieldSetToAValueBetweenTheMinLevelAndMaxLevelValuesIfPresentOtherwiseBetween0x01And0xFEAndTheTransitionTimeFieldSetTo0x0000MoveImmediately_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = mRandomLevelValue.HasValue() ? [NSNumber numberWithUnsignedChar:mRandomLevelValue.Value()] : [NSNumber numberWithUnsignedChar:100U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).: Error: %@", err); + } else { + NSLog(@"Step 1c: TH sends a MoveToLevel command to DUT, with the Level field set to a value between the MinLevel and MaxLevel values (if present, otherwise between 0x01 and 0xFE) and the TransitionTime field set to 0x0000 (move immediately).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_7() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep1dThReadsCurrentLevelAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1d: TH reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1d: TH reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, mRandomLevelValue.HasValue() ? mRandomLevelValue.Value() : 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull CurrentFrequencyValue; + + CHIP_ERROR TestStep2aThReadsTheCurrentFrequencyAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH reads the CurrentFrequency attribute.: Error: %@", err); + } else { + NSLog(@"Step 2a: TH reads the CurrentFrequency attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], 65535U)); + { + CurrentFrequencyValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull MinFrequencyValue; + + CHIP_ERROR TestStep2bThReadsTheMinFrequencyAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads the MinFrequency attribute.: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads the MinFrequency attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("minFrequency", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("minFrequency", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("minFrequency", [value unsignedShortValue], 65535U)); + { + MinFrequencyValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull MaxFrequencyValue; + + CHIP_ERROR TestStep2cThReadsTheMaxFrequencyAttributeAndCheckIfFmaxFminFailTheTest_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads the MaxFrequency attribute and check, if fmax < fmin, FAIL the test.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("maxFrequency", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("maxFrequency", [value unsignedShortValue], MinFrequencyValue)); + VerifyOrReturn(CheckConstraintMaxValue("maxFrequency", [value unsignedShortValue], 65535U)); + { + MaxFrequencyValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dSanityCheckOnValuesReadInSteps2a2cIfFcFminFailTheTestAndFcFmaxFailTheTest_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test: Error: %@", err); + } else { + NSLog(@"Step 2d: sanity check on values read in steps 2a..2c, if fc < fmin, FAIL the test and fc > fmax, FAIL the test: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentFrequency", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("currentFrequency", [value unsignedShortValue], MinFrequencyValue)); + VerifyOrReturn(CheckConstraintMaxValue("currentFrequency", [value unsignedShortValue], MaxFrequencyValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToARandomValueFrandChosenSuchThatFminFrandFmax_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToClosestFrequencyParams alloc] init]; + params.frequency = mRandomFrequencyValue.HasValue() ? [NSNumber numberWithUnsignedShort:mRandomFrequencyValue.Value()] : [NSNumber numberWithUnsignedShort:30000U]; + [cluster moveToClosestFrequencyWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax: Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends a MoveToClosestFrequency command to DUT, with the frequency field set to a random value frand, chosen such that: fmin < frand < fmax: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100ms_14() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThReadsTheCurrentFrequencyAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads the CurrentFrequency attribute.: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads the CurrentFrequency attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmax1_16() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep4bThReadsTheCurrentFrequencyAttribute_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the CurrentFrequency attribute.: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the CurrentFrequency attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThSendsAMoveToClosestFrequencyCommandToDutWithTheFrequencyFieldSetToFmin1_18() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep5bThReadsTheCurrentFrequencyAttribute_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH reads the CurrentFrequency attribute.: Error: %@", err); + } else { + NSLog(@"Step 5b: TH reads the CurrentFrequency attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentFrequency", actualValue, mRandomFrequencyValue.HasValue() ? mRandomFrequencyValue.Value() : 30000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LCFG_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LCFG_1_1() + : TestCommandBridge("Test_TC_LCFG_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LCFG_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LCFG_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LCFG_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLocalizationConfiguration alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LUNIT_1_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LUNIT_1_2() + : TestCommandBridge("Test_TC_LUNIT_1_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LUNIT_1_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LUNIT_1_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LUNIT_1_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip(" !LUNIT.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("LUNIT.S.F00")) { + NextTest(); + return; + } + err = TestStep3GivenLunitsf00tempEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList\n"); + if (ShouldSkip("LUNIT.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsFeatureDependentLUNITSF00AttributeInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3GivenLunitsf00tempEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3: Given LUNIT.S.F00(TEMP) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFeatureDependentLUNITSF00AttributeInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads Feature dependent(LUNIT.S.F00) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LUNIT_3_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LUNIT_3_1() + : TestCommandBridge("Test_TC_LUNIT_3_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LUNIT_3_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LUNIT_3_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LUNIT_3_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads from the DUT the TemperatureUnit\n"); + if (ShouldSkip("LUNIT.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsFromTheDutTheTemperatureUnit_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes 0 to TemperatureUnit\n"); + if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Fahrenheit")) { + NextTest(); + return; + } + err = TestStep2ThWrites0ToTemperatureUnit_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the TemperatureUnit\n"); + if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Fahrenheit")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheTemperatureUnit_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes 1 to TemperatureUnit\n"); + if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Celsius")) { + NextTest(); + return; + } + err = TestStep4ThWrites1ToTemperatureUnit_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the TemperatureUnit\n"); + if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Celsius")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutTheTemperatureUnit_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes 2 to TemperatureUnit\n"); + if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Kelvin")) { + NextTest(); + return; + } + err = TestStep6ThWrites2ToTemperatureUnit_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the TemperatureUnit\n"); + if (ShouldSkip("LUNIT.S.A0000 && LUNIT.S.M.Kelvin")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheTemperatureUnit_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH writes 5 to TemperatureUnit\n"); + if (ShouldSkip("LUNIT.S.A0000")) { + NextTest(); + return; + } + err = TestStep8ThWrites5ToTemperatureUnit_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsFromTheDutTheTemperatureUnit_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads from the DUT the TemperatureUnit: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads from the DUT the TemperatureUnit: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("temperatureUnit", "enum8", "enum8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThWrites0ToTemperatureUnit_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id temperatureUnitArgument; + temperatureUnitArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH writes 0 to TemperatureUnit: Error: %@", err); + } else { + NSLog(@"Step 2: TH writes 0 to TemperatureUnit: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheTemperatureUnit_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the TemperatureUnit: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the TemperatureUnit: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThWrites1ToTemperatureUnit_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id temperatureUnitArgument; + temperatureUnitArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH writes 1 to TemperatureUnit: Error: %@", err); + } else { + NSLog(@"Step 4: TH writes 1 to TemperatureUnit: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheTemperatureUnit_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the TemperatureUnit: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the TemperatureUnit: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThWrites2ToTemperatureUnit_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id temperatureUnitArgument; + temperatureUnitArgument = + [NSNumber numberWithUnsignedChar:2U]; + [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH writes 2 to TemperatureUnit: Error: %@", err); + } else { + NSLog(@"Step 6: TH writes 2 to TemperatureUnit: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheTemperatureUnit_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureUnitWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the TemperatureUnit: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the TemperatureUnit: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TemperatureUnit", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThWrites5ToTemperatureUnit_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id temperatureUnitArgument; + temperatureUnitArgument = + [NSNumber numberWithUnsignedChar:5U]; + [cluster writeAttributeTemperatureUnitWithValue:temperatureUnitArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH writes 5 to TemperatureUnit: Error: %@", err); + } else { + NSLog(@"Step 8: TH writes 5 to TemperatureUnit: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LTIME_1_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LTIME_1_2() + : TestCommandBridge("Test_TC_LTIME_1_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LTIME_1_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LTIME_1_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LTIME_1_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT\n"); + if (ShouldSkip("LTIME.S.F00 && LTIME.S.A0001")) { + NextTest(); + return; + } + err = TestStep4bThReadsFeatureDependentAttributeActiveCalendarTypeInAttributeListFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT\n"); + if (ShouldSkip("LTIME.S.F00 && LTIME.S.A0002")) { + NextTest(); + return; + } + err = TestStep4cThReadsFeatureDependentAttributeSupportedCalendarTypesInAttributeListFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + VerifyOrReturn(CheckConstraintMinValue("featureMap", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("featureMap", [value unsignedIntValue], 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeActiveCalendarTypeInAttributeListFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads Feature dependent attribute(ActiveCalendarType) in AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeSupportedCalendarTypesInAttributeListFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads Feature dependent attribute(SupportedCalendarTypes) in AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LTIME_3_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LTIME_3_1() + : TestCommandBridge("Test_TC_LTIME_3_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LTIME_3_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LTIME_3_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LTIME_3_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads HourFormat attribute from DUT\n"); + if (ShouldSkip("LTIME.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsHourFormatAttributeFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute\n"); + if (ShouldSkip("LTIME.S.M.12HR")) { + NextTest(); + return; + } + err = TestStep2IfLtimesa000012hrThWrites0ToHourFormatAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads HourFormat attribute\n"); + if (ShouldSkip("LTIME.S.A0000")) { + NextTest(); + return; + } + err = TestStep3ThReadsHourFormatAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute\n"); + if (ShouldSkip("LTIME.S.M.24HR")) { + NextTest(); + return; + } + err = TestStep4IfLtimesa000024hrThWrites1ToHourFormatAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads HourFormat attribute\n"); + if (ShouldSkip("LTIME.S.A0000")) { + NextTest(); + return; + } + err = TestStep5ThReadsHourFormatAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads ActiveCalendarType attribute from DUT\n"); + if (ShouldSkip("LTIME.S.A0001")) { + NextTest(); + return; + } + err = TestStep6ThReadsActiveCalendarTypeAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads SupportedCalendarTypes attribute from DUT\n"); + if (ShouldSkip("LTIME.S.A0002")) { + NextTest(); + return; + } + err = TestStep7ThReadsSupportedCalendarTypesAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH writes value in PIXIT.LTIME.SCT to ActiveCalendarType attribute, followed by reading the ActiveCalendarType attribute value\n"); + if (ShouldSkip("LTIME.S.A0001 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep8ThWritesValueInPixitltimesctToActiveCalendarTypeAttributeFollowedByReadingTheActiveCalendarTypeAttributeValue_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: Repeat step 8 for all the values in PIXIT.LTIME.SCT\n"); + if (ShouldSkip("LTIME.S.A0001 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep9RepeatStep8ForAllTheValuesInPixitltimesct_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 10: TH writes 50 to ActiveCalendarType attribute\n"); + if (ShouldSkip("LTIME.S.A0001")) { + NextTest(); + return; + } + err = TestStep10ThWrites50ToActiveCalendarTypeAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 11: TH writes 5 to HourFormat attribute\n"); + if (ShouldSkip("LTIME.S.A0000")) { + NextTest(); + return; + } + err = TestStep11ThWrites5ToHourFormatAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsHourFormatAttributeFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads HourFormat attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads HourFormat attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("hourFormat", "enum8", "enum8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2IfLtimesa000012hrThWrites0ToHourFormatAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id hourFormatArgument; + hourFormatArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute: Error: %@", err); + } else { + NSLog(@"Step 2: If (LTIME.S.A0000.12HR) TH writes 0 to HourFormat attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsHourFormatAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads HourFormat attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads HourFormat attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("HourFormat", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4IfLtimesa000024hrThWrites1ToHourFormatAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id hourFormatArgument; + hourFormatArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute: Error: %@", err); + } else { + NSLog(@"Step 4: If (LTIME.S.A0000.24HR) TH writes 1 to HourFormat attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsHourFormatAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeHourFormatWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads HourFormat attribute: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads HourFormat attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("HourFormat", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsActiveCalendarTypeAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeActiveCalendarTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads ActiveCalendarType attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads ActiveCalendarType attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("activeCalendarType", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("activeCalendarType", [value unsignedCharValue], 11U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsSupportedCalendarTypesAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedCalendarTypesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads SupportedCalendarTypes attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads SupportedCalendarTypes attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMaxLength("supportedCalendarTypes", value, 12)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThWritesValueInPixitltimesctToActiveCalendarTypeAttributeFollowedByReadingTheActiveCalendarTypeAttributeValue_8() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep9RepeatStep8ForAllTheValuesInPixitltimesct_9() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep10ThWrites50ToActiveCalendarTypeAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id activeCalendarTypeArgument; + activeCalendarTypeArgument = + [NSNumber numberWithUnsignedChar:50U]; + [cluster writeAttributeActiveCalendarTypeWithValue:activeCalendarTypeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH writes 50 to ActiveCalendarType attribute: Error: %@", err); + } else { + NSLog(@"Step 10: TH writes 50 to ActiveCalendarType attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThWrites5ToHourFormatAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeFormatLocalization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id hourFormatArgument; + hourFormatArgument = + [NSNumber numberWithUnsignedChar:5U]; + [cluster writeAttributeHourFormatWithValue:hourFormatArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH writes 5 to HourFormat attribute: Error: %@", err); + } else { + NSLog(@"Step 11: TH writes 5 to HourFormat attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LWM_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LWM_1_1() + : TestCommandBridge("Test_TC_LWM_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LWM_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LWM_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LWM_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF)\n"); + if (ShouldSkip("LWM.S.F00")) { + NextTest(); + return; + } + err = TestStep3thReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfLwmsf00deponoff_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip(" !LWM.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList\n"); + if (ShouldSkip("LWM.S.A0002")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList\n"); + if (ShouldSkip("LWM.S.F00")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheFeatureDependentAttributeDEPONOFFInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 11; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3thReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfLwmsf00deponoff_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF): Error: %@", err); + } else { + NSLog(@"Step 3:TH reads from the DUT the FeatureMap attribute., bit 0: SHALL be 1 if and only if LWM.S.F00(DEPONOFF): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheFeatureDependentAttributeDEPONOFFInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the Feature dependent attribute(DEPONOFF) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LWM_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LWM_2_1() + : TestCommandBridge("Test_TC_LWM_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("NewMode_CHANGE_OK", 0, UINT8_MAX, &mNewModeChangeOk); + AddArgument("NewMode_CHANGE_FAIL", 0, UINT8_MAX, &mNewModeChangeFail); + AddArgument("invalid_mode_th", 0, UINT8_MAX, &mInvalidModeTh); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LWM_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LWM_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LWM_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1:Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SupportedModes attribute.\n"); + if (ShouldSkip("LWM.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheSupportedModesAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the CurrentMode attribute.\n"); + if (ShouldSkip("LWM.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheCurrentModeAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th\n"); + if (ShouldSkip("LWM.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThSendsAChangeToModeCommandToTheDutWithNewModeSetToNewModeTh_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: Manually put the device in a state from which it will FAIL to transition to PIXIT.LWM.MODE_CHANGE_FAIL\n"); + if (ShouldSkip("LWM.S.M.CAN_TEST_MODE_FAILURE && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep5ManuallyPutTheDeviceInAStateFromWhichItWillFailToTransitionToPixitlwmmodeChangeFail_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the CurrentMode attribute.\n"); + if (ShouldSkip("LWM.S.A0001")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheCurrentModeAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_FAIL\n"); + if (ShouldSkip("LWM.S.M.CAN_TEST_MODE_FAILURE && LWM.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep7ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeFail_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the CurrentMode attribute.\n"); + if (ShouldSkip("LWM.S.A0001")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheCurrentModeAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: Manually put the device in a state from which it will SUCCESSFULLY transition to PIXIT.LWM.MODE_CHANGE_OK\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep9ManuallyPutTheDeviceInAStateFromWhichItWillSuccessfullyTransitionToPixitlwmmodeChangeOk_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the CurrentMode attribute.\n"); + if (ShouldSkip("LWM.S.A0001")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheCurrentModeAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK\n"); + if (ShouldSkip("LWM.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep11ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeOk_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK\n"); + if (ShouldSkip("LWM.S.A0001")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th\n"); + if (ShouldSkip("LWM.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep13ThSendsAChangeToModeCommandToTheDutWithNewModeSetToInvalidModeTh_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK\n"); + if (ShouldSkip("LWM.S.A0001")) { + NextTest(); + return; + } + err = TestStep14ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_13(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 14; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mNewModeChangeOk; + chip::Optional mNewModeChangeFail; + chip::Optional mInvalidModeTh; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheSupportedModesAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedModesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the SupportedModes attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the SupportedModes attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("supportedModes", "list", "list")); + VerifyOrReturn(CheckConstraintMinLength("supportedModes", value, 2)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull old_current_mode_dut; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheCurrentModeAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the CurrentMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); + { + old_current_mode_dut = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThSendsAChangeToModeCommandToTheDutWithNewModeSetToNewModeTh_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; + params.newMode = + [old_current_mode_dut copy]; + [cluster changeToModeWithParams:params completion: + ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th: Error: %@", err); + } else { + NSLog(@"Step 4: TH sends a ChangeToMode command to the DUT with NewMode set to new_mode_th: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ManuallyPutTheDeviceInAStateFromWhichItWillFailToTransitionToPixitlwmmodeChangeFail_4() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + NSNumber * _Nonnull Step6_current_mode_dut; + + CHIP_ERROR TestStep6ThReadsFromTheDutTheCurrentModeAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the CurrentMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); + { + Step6_current_mode_dut = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeFail_6() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheCurrentModeAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the CurrentMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentMode", actualValue, Step6_current_mode_dut)); + } + + VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ManuallyPutTheDeviceInAStateFromWhichItWillSuccessfullyTransitionToPixitlwmmodeChangeOk_8() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + NSNumber * _Nonnull Step10_current_mode_dut; + + CHIP_ERROR TestStep10ThReadsFromTheDutTheCurrentModeAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the CurrentMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the CurrentMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentMode", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentMode", [value unsignedCharValue], 254U)); + { + Step10_current_mode_dut = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThSendsAChangeToModeCommandToTheDutWithNewModeSetToPixitlwmmodeChangeOk_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; + params.newMode = mNewModeChangeOk.HasValue() ? [NSNumber numberWithUnsignedChar:mNewModeChangeOk.Value()] : [NSNumber numberWithUnsignedChar:2U]; + [cluster changeToModeWithParams:params completion: + ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); + } else { + NSLog(@"Step 11: TH sends a ChangeToMode command to the DUT with NewMode set to PIXIT.LWM.MODE_CHANGE_OK: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentMode", actualValue, mNewModeChangeOk.HasValue() ? mNewModeChangeOk.Value() : 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13ThSendsAChangeToModeCommandToTheDutWithNewModeSetToInvalidModeTh_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLaundryWasherModeClusterChangeToModeParams alloc] init]; + params.newMode = mInvalidModeTh.HasValue() ? [NSNumber numberWithUnsignedChar:mInvalidModeTh.Value()] : [NSNumber numberWithUnsignedChar:5U]; + [cluster changeToModeWithParams:params completion: + ^(MTRLaundryWasherModeClusterChangeToModeResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th: Error: %@", err); + } else { + NSLog(@"Step 13: TH sends a ChangeToMode command to the DUT with NewMode set to invalid_mode_th: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep14ThReadsFromTheDutTheCurrentModeAttributeVerifyThatTheDutResponseContainsAnIntegerValueEqualToPixitlwmmodeChangeOk_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Error: %@", err); + } else { + NSLog(@"Step 14: TH reads from the DUT the CurrentMode attribute. Verify that the DUT response contains an integer value equal to PIXIT.LWM.MODE_CHANGE_OK: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentMode", actualValue, mNewModeChangeOk.HasValue() ? mNewModeChangeOk.Value() : 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WASHERCTRL_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WASHERCTRL_1_1() + : TestCommandBridge("Test_TC_WASHERCTRL_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WASHERCTRL_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH\n"); + err = TestCommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false\n"); + if (ShouldSkip("!WASHERCTRL.S.F00 && !WASHERCTRL.S.F01")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeIfWasherctrlsf00spinWasherctrlsf01rinseAreFalse_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true)\n"); + if (ShouldSkip("WASHERCTRL.S.F00")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0SetTo1IfTheDutIsCapableOfControllingTheWasherUsingTheSpinAttributesWasherctrlsf00spinIsTrue_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true)\n"); + if (ShouldSkip("WASHERCTRL.S.F01")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit1SetTo1IfTheDutSupportsRinseAttributesWasherctrlsf01rinseIsTrue_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.\n"); + if (ShouldSkip("WASHERCTRL.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheFeatureDependentWASHERCTRLSF00AttributesInAttributeListFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.\n"); + if (ShouldSkip("WASHERCTRL.S.F01")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheFeatureDependentWASHERCTRLSF01AttributesInAttributeListFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeIfWasherctrlsf00spinWasherctrlsf01rinseAreFalse_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute. If WASHERCTRL.S.F00(SPIN) & WASHERCTRL.S.F01(RINSE) are false: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0SetTo1IfTheDutIsCapableOfControllingTheWasherUsingTheSpinAttributesWasherctrlsf00spinIsTrue_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true): Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0 set to 1 if the DUT is capable of controlling the washer using the spin attributes (WASHERCTRL.S.F00(SPIN) is true): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit1SetTo1IfTheDutSupportsRinseAttributesWasherctrlsf01rinseIsTrue_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true): Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 1 set to 1 if the DUT supports rinse attributes (WASHERCTRL.S.F01(RINSE) is true): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheFeatureDependentWASHERCTRLSF00AttributesInAttributeListFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the feature dependent(WASHERCTRL.S.F00) attributes in AttributeList from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheFeatureDependentWASHERCTRLSF01AttributesInAttributeListFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the feature dependent(WASHERCTRL.S.F01) attributes in AttributeList from DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WASHERCTRL_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WASHERCTRL_2_1() + : TestCommandBridge("Test_TC_WASHERCTRL_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("SpinSpeedCurrentValue", 0, UINT8_MAX, &mSpinSpeedCurrentValue); + AddArgument("unsupportedSpinSpeedCurrentValue", 0, UINT8_MAX, &mUnsupportedSpinSpeedCurrentValue); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WASHERCTRL_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the SpinSpeeds attribute\n"); + if (ShouldSkip("WASHERCTRL.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheTheSpinSpeedsAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute\n"); + if (ShouldSkip("WASHERCTRL.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheTheSpinSpeedCurrentAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the DUT response contains a uint8 with value between 0 and numSpinSpeeds-1 inclusive.\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && WASHERCTRL.S.A0001")) { + NextTest(); + return; + } + err = TestVerifyThatTheDutResponseContainsAUint8WithValueBetween0AndNumSpinSpeeds1Inclusive_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1)\n"); + if (ShouldSkip("WASHERCTRL.S.A0001")) { + NextTest(); + return; + } + err = TestStep4ThWritesASupportedSpinSpeedCurrentAttributeThatIsAValidIndexIntoTheListOfSpinSpeeds0ToNumSpinSpeeds1_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 2 seconds\n"); + err = TestWait2Seconds_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute\n"); + if (ShouldSkip("WASHERCTRL.S.A0001")) { + NextTest(); + return; + } + err = TestStep5AfterAFewSecondsThReadsFromTheDutTheSpinSpeedCurrentAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT\n"); + if (ShouldSkip("WASHERCTRL.S.A0001")) { + NextTest(); + return; + } + err = TestStep6ThWritesAnUnsupportedSpinSpeedCurrentAttributeThatIsOtherThan0ToDut_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mSpinSpeedCurrentValue; + chip::Optional mUnsupportedSpinSpeedCurrentValue; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheTheSpinSpeedsAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpinSpeedsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the the SpinSpeeds attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the the SpinSpeeds attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("spinSpeeds", "list", "list")); + VerifyOrReturn(CheckConstraintMaxLength("spinSpeeds", value, 16)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSpinSpeedCurrentAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpinSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the the SpinSpeedCurrent attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("spinSpeedCurrent", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("spinSpeedCurrent", [value unsignedCharValue], 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheDutResponseContainsAUint8WithValueBetween0AndNumSpinSpeeds1Inclusive_3() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep4ThWritesASupportedSpinSpeedCurrentAttributeThatIsAValidIndexIntoTheListOfSpinSpeeds0ToNumSpinSpeeds1_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id spinSpeedCurrentArgument; + spinSpeedCurrentArgument = mSpinSpeedCurrentValue.HasValue() ? [NSNumber numberWithUnsignedChar:mSpinSpeedCurrentValue.Value()] : [NSNumber numberWithUnsignedChar:3U]; + [cluster writeAttributeSpinSpeedCurrentWithValue:spinSpeedCurrentArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1): Error: %@", err); + } else { + NSLog(@"Step 4: TH writes a supported SpinSpeedCurrent attribute that is a valid index into the list of spin speeds (0 to numSpinSpeeds-1): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait2Seconds_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 2000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheSpinSpeedCurrentAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpinSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute: Error: %@", err); + } else { + NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SpinSpeedCurrent attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SpinSpeedCurrent", actualValue)); + VerifyOrReturn(CheckValue("SpinSpeedCurrent", actualValue, mSpinSpeedCurrentValue.HasValue() ? mSpinSpeedCurrentValue.Value() : 3U)); + } + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("spinSpeedCurrent", "int8u", "int8u")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThWritesAnUnsupportedSpinSpeedCurrentAttributeThatIsOtherThan0ToDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id spinSpeedCurrentArgument; + spinSpeedCurrentArgument = mUnsupportedSpinSpeedCurrentValue.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedSpinSpeedCurrentValue.Value()] : [NSNumber numberWithUnsignedChar:17U]; + [cluster writeAttributeSpinSpeedCurrentWithValue:spinSpeedCurrentArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH writes an unsupported SpinSpeedCurrent attribute that is other than 0 to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WASHERCTRL_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WASHERCTRL_2_2() + : TestCommandBridge("Test_TC_WASHERCTRL_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("NumberOfRinsesValue", 0, UINT8_MAX, &mNumberOfRinsesValue); + AddArgument("unsupportedNumberOfRinsesValue", 0, UINT8_MAX, &mUnsupportedNumberOfRinsesValue); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WASHERCTRL_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WASHERCTRL_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WASHERCTRL_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the the NumberOfRinses attribute\n"); + if (ShouldSkip("WASHERCTRL.S.A0002")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheTheNumberOfRinsesAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the the SupportedRinses attribute\n"); + if (ShouldSkip("WASHERCTRL.S.A0003")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheTheSupportedRinsesAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list\n"); + if (ShouldSkip("WASHERCTRL.S.A0002")) { + NextTest(); + return; + } + err = TestStep4ThWritesASupportedNumberOfRinsesAttributeToDutWithinTheRangeOfTheSupportedRinsesList_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 2 seconds\n"); + err = TestWait2Seconds_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute\n"); + if (ShouldSkip("WASHERCTRL.S.A0002")) { + NextTest(); + return; + } + err = TestStep5AfterAFewSecondsThReadsFromTheDutTheNumberOfRinsesAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: Operate device to set the condition to read only\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && WASHERCTRL.S.M.ManuallyControlled")) { + NextTest(); + return; + } + err = TestStep6OperateDeviceToSetTheConditionToReadOnly_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.\n"); + if (ShouldSkip("WASHERCTRL.S.M.ManuallyControlled && WASHERCTRL.S.A0002")) { + NextTest(); + return; + } + err = TestStep7ThWritesAnUnsupportedNumberOfRinsesAttributeToDutWhileDutIsNotInAValidState_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mNumberOfRinsesValue; + chip::Optional mUnsupportedNumberOfRinsesValue; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheTheNumberOfRinsesAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfRinsesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the the NumberOfRinses attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the the NumberOfRinses attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("numberOfRinses", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("numberOfRinses", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfRinses", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheTheSupportedRinsesAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedRinsesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the the SupportedRinses attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the the SupportedRinses attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("supportedRinses", "list", "list")); + VerifyOrReturn(CheckConstraintMaxLength("supportedRinses", value, 4)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThWritesASupportedNumberOfRinsesAttributeToDutWithinTheRangeOfTheSupportedRinsesList_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id numberOfRinsesArgument; + numberOfRinsesArgument = mNumberOfRinsesValue.HasValue() ? [NSNumber numberWithUnsignedChar:mNumberOfRinsesValue.Value()] : [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeNumberOfRinsesWithValue:numberOfRinsesArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list: Error: %@", err); + } else { + NSLog(@"Step 4: TH writes a supported NumberOfRinses attribute to DUT within the range of the SupportedRinses list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait2Seconds_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 2000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheNumberOfRinsesAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfRinsesWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute: Error: %@", err); + } else { + NSLog(@"Step 5: after a few seconds, TH reads from the DUT the NumberOfRinses attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NumberOfRinses", actualValue, mNumberOfRinsesValue.HasValue() ? mNumberOfRinsesValue.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6OperateDeviceToSetTheConditionToReadOnly_6() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep7ThWritesAnUnsupportedNumberOfRinsesAttributeToDutWhileDutIsNotInAValidState_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryWasherControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id numberOfRinsesArgument; + numberOfRinsesArgument = mUnsupportedNumberOfRinsesValue.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedNumberOfRinsesValue.Value()] : [NSNumber numberWithUnsignedChar:5U]; + [cluster writeAttributeNumberOfRinsesWithValue:numberOfRinsesArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.: Error: %@", err); + } else { + NSLog(@"Step 7: TH writes an unsupported NumberOfRinses attribute to DUT while DUT is not in a valid state.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DRYERCTRL_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DRYERCTRL_1_1() + : TestCommandBridge("Test_TC_DRYERCTRL_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DRYERCTRL_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRYERCTRL_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRYERCTRL_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DRYERCTRL_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DRYERCTRL_2_1() + : TestCommandBridge("Test_TC_DRYERCTRL_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("unsupportedSelectedDrynessLevel", 0, UINT8_MAX, &mUnsupportedSelectedDrynessLevel); + AddArgument("SupportedDrynessLevel", 0, UINT8_MAX, &mSupportedDrynessLevel); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DRYERCTRL_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRYERCTRL_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRYERCTRL_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels\n"); + if (ShouldSkip("DRYERCTRL.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMandatoryAttributeSupportedDrynessLevels_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel\n"); + if (ShouldSkip("DRYERCTRL.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMandatoryAttributeSelectedDrynessLevel_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels\n"); + if (ShouldSkip("DRYERCTRL.S.A0001")) { + NextTest(); + return; + } + err = TestStep4thWritesASupportedSelectedDrynessLevelAttributeThatIsWithinTheListOfSupportedDrynessLevels_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait 2 seconds\n"); + err = TestWait2Seconds_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute\n"); + if (ShouldSkip("DRYERCTRL.S.A0001")) { + NextTest(); + return; + } + err = TestStep5AfterAFewSecondsThReadsFromTheDutTheSelectedDrynessLevelAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT\n"); + if (ShouldSkip("DRYERCTRL.S.A0001")) { + NextTest(); + return; + } + err = TestStep6ThWritesAnUnsupportedSelectedDrynessLevelAttributeThatIsNotInListOfSupportedDrynessLevelsToDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: Operate device to set the condition to read only\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DRYERCTRL.S.M.ManuallyControlled")) { + NextTest(); + return; + } + err = TestStep6OperateDeviceToSetTheConditionToReadOnly_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.\n"); + if (ShouldSkip("DRYERCTRL.S.M.ManuallyControlled && DRYERCTRL.S.A0001")) { + NextTest(); + return; + } + err = TestStep7ThWritesASupportedSelectedDrynessLevelAttributeToDutWhileDutIsNotInAValidState_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mUnsupportedSelectedDrynessLevel; + chip::Optional mSupportedDrynessLevel; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMandatoryAttributeSupportedDrynessLevels_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedDrynessLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the mandatory attribute: SupportedDrynessLevels: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("supportedDrynessLevels", "list", "list")); + VerifyOrReturn(CheckConstraintMaxLength("supportedDrynessLevels", value, 16)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMandatoryAttributeSelectedDrynessLevel_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSelectedDrynessLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the mandatory attribute: SelectedDrynessLevel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("selectedDrynessLevel", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("selectedDrynessLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("selectedDrynessLevel", [value unsignedCharValue], 15U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4thWritesASupportedSelectedDrynessLevelAttributeThatIsWithinTheListOfSupportedDrynessLevels_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id selectedDrynessLevelArgument; + selectedDrynessLevelArgument = mSupportedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mSupportedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels: Error: %@", err); + } else { + NSLog(@"Step 4:TH writes a supported SelectedDrynessLevel attribute that is within the list of SupportedDrynessLevels: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait2Seconds_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 2000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5AfterAFewSecondsThReadsFromTheDutTheSelectedDrynessLevelAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSelectedDrynessLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute: Error: %@", err); + } else { + NSLog(@"Step 5: after a few seconds, TH reads from the DUT the SelectedDrynessLevel attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SelectedDrynessLevel", actualValue)); + VerifyOrReturn(CheckValue("SelectedDrynessLevel", actualValue, mSupportedDrynessLevel.HasValue() ? mSupportedDrynessLevel.Value() : 1U)); + } + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("selectedDrynessLevel", "enum8", "enum8")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThWritesAnUnsupportedSelectedDrynessLevelAttributeThatIsNotInListOfSupportedDrynessLevelsToDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id selectedDrynessLevelArgument; + selectedDrynessLevelArgument = mUnsupportedSelectedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mUnsupportedSelectedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:4U]; + [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH writes an unsupported SelectedDrynessLevel attribute that is not in list of SupportedDrynessLevels to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6OperateDeviceToSetTheConditionToReadOnly_7() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep7ThWritesASupportedSelectedDrynessLevelAttributeToDutWhileDutIsNotInAValidState_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLaundryDryerControls alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id selectedDrynessLevelArgument; + selectedDrynessLevelArgument = mSupportedDrynessLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mSupportedDrynessLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeSelectedDrynessLevelWithValue:selectedDrynessLevelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.: Error: %@", err); + } else { + NSLog(@"Step 7: TH writes a supported SelectedDrynessLevel attribute to DUT while DUT is not in a valid state.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LOWPOWER_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LOWPOWER_1_1() + : TestCommandBridge("Test_TC_LOWPOWER_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LOWPOWER_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LOWPOWER_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LOWPOWER_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); + err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); + err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the EventList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(6))); + VerifyOrReturn(CheckValue("", actualValue[0], 65528UL)); + VerifyOrReturn(CheckValue("", actualValue[1], 65529UL)); + VerifyOrReturn(CheckValue("", actualValue[2], 65530UL)); + VerifyOrReturn(CheckValue("", actualValue[3], 65531UL)); + VerifyOrReturn(CheckValue("", actualValue[4], 65532UL)); + VerifyOrReturn(CheckValue("", actualValue[5], 65533UL)); + } + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AttributeList", [actualValue count], static_cast(5))); + VerifyOrReturn(CheckValue("", actualValue[0], 65528UL)); + VerifyOrReturn(CheckValue("", actualValue[1], 65529UL)); + VerifyOrReturn(CheckValue("", actualValue[2], 65531UL)); + VerifyOrReturn(CheckValue("", actualValue[3], 65532UL)); + VerifyOrReturn(CheckValue("", actualValue[4], 65533UL)); + } + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_KEYPADINPUT_1_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_KEYPADINPUT_1_2() + : TestCommandBridge("Test_TC_KEYPADINPUT_1_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_KEYPADINPUT_1_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_1_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_1_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); + if (ShouldSkip(" !KEYPADINPUT.S.F00 && KEYPADINPUT.S.F01 && !KEYPADINPUT.S.F02 ")) { + NextTest(); + return; + } + err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not\n"); + if (ShouldSkip("KEYPADINPUT.S.F00")) { + NextTest(); + return; + } + err = TestStep2bGivenKeypadinputsf00nvFeatureMapBitMaskIsSetOrNot_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not\n"); + if (ShouldSkip("KEYPADINPUT.S.F01")) { + NextTest(); + return; + } + err = TestStep2cGivenKeypadinputsf01lkFeatureMapBitMaskIsSetOrNot_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not\n"); + if (ShouldSkip("KEYPADINPUT.S.F02")) { + NextTest(); + return; + } + err = TestStep2dGivenKeypadinputsf02nkFeatureMapBitMaskIsSetOrNot_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); + err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 11; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bGivenKeypadinputsf00nvFeatureMapBitMaskIsSetOrNot_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not: Error: %@", err); + } else { + NSLog(@"Step 2b: Given (KEYPADINPUT.S.F00(NV)) FeatureMap bit mask is set or not: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cGivenKeypadinputsf01lkFeatureMapBitMaskIsSetOrNot_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not: Error: %@", err); + } else { + NSLog(@"Step 2c: Given (KEYPADINPUT.S.F01(LK)) FeatureMap bit mask is set or not: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dGivenKeypadinputsf02nkFeatureMapBitMaskIsSetOrNot_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not: Error: %@", err); + } else { + NSLog(@"Step 2d: Given (KEYPADINPUT.S.F02(NK)) FeatureMap bit mask is set or not: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_APPLAUNCHER_1_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_APPLAUNCHER_1_3() + : TestCommandBridge("Test_TC_APPLAUNCHER_1_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_APPLAUNCHER_1_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_1_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_1_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); + if (ShouldSkip("APPLAUNCHER.S.F00")) { + NextTest(); + return; + } + err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads the FeatureMap attribute from the DUT\n"); + if (ShouldSkip(" !APPLAUNCHER.S.F00 ")) { + NextTest(); + return; + } + err = TestStep2bThReadsTheFeatureMapAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3b: TH reads the optional attribute(CatalogList) in AttributeList\n"); + if (ShouldSkip("APPLAUNCHER.S.A0000")) { + NextTest(); + return; + } + err = TestStep3bThReadsTheOptionalAttributeCatalogListInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList\n"); + if (ShouldSkip("APPLAUNCHER.S.A0001")) { + NextTest(); + return; + } + err = TestStep3cThReadsTheOptionalAttributeCurrentAppInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); + err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 11; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThReadsTheFeatureMapAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsTheOptionalAttributeCatalogListInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads the optional attribute(CatalogList) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads the optional attribute(CatalogList) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsTheOptionalAttributeCurrentAppInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads the optional attribute(CurrentApp) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_MEDIAINPUT_1_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MEDIAINPUT_1_4() + : TestCommandBridge("Test_TC_MEDIAINPUT_1_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MEDIAINPUT_1_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_1_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_1_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); + if (ShouldSkip(" !MEDIAINPUT.S.F00 ")) { + NextTest(); + return; + } + err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("MEDIAINPUT.S.F00")) { + NextTest(); + return; + } + err = TestStep2GivenMediainputsf00nuEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3b: TH reads the optional attribute(InputList) in AttributeList\n"); + if (ShouldSkip("MEDIAINPUT.S.A0000")) { + NextTest(); + return; + } + err = TestStep3bThReadsTheOptionalAttributeInputListInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList\n"); + if (ShouldSkip("MEDIAINPUT.S.A0001")) { + NextTest(); + return; + } + err = TestStep3cThReadsTheOptionalAttributeCurrentInputInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); + err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 11; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2GivenMediainputsf00nuEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2: Given MEDIAINPUT.S.F00(NU) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsTheOptionalAttributeInputListInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads the optional attribute(InputList) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads the optional attribute(InputList) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsTheOptionalAttributeCurrentInputInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads the optional attribute(CurrentInput) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WAKEONLAN_1_5 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WAKEONLAN_1_5() + : TestCommandBridge("Test_TC_WAKEONLAN_1_5") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WAKEONLAN_1_5() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WAKEONLAN_1_5\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WAKEONLAN_1_5\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); + err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(MACAddress) in AttributeList\n"); + if (ShouldSkip("WAKEONLAN.S.A0000")) { + NextTest(); + return; + } + err = TestStep3bThReadsTheOptionalAttributeMACAddressInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the global attribute: AcceptedCommandList\n"); + err = TestStep4ThReadsTheGlobalAttributeAcceptedCommandList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the global attribute: GeneratedCommandList\n"); + err = TestStep5ThReadsTheGlobalAttributeGeneratedCommandList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsTheOptionalAttributeMACAddressInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads the optional attribute(MACAddress) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads the optional attribute(MACAddress) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheGlobalAttributeAcceptedCommandList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheGlobalAttributeGeneratedCommandList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CHANNEL_1_6 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CHANNEL_1_6() + : TestCommandBridge("Test_TC_CHANNEL_1_6") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CHANNEL_1_6() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_1_6\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_1_6\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: read the global attribute: ClusterRevision\n"); + err = TestStep1ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: Read the global attribute: FeatureMap\n"); + if (ShouldSkip("( !CHANNEL.S.F00 && !CHANNEL.S.F01 )")) { + NextTest(); + return; + } + err = TestStep2aReadTheGlobalAttributeFeatureMap_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CHANNEL.S.F00")) { + NextTest(); + return; + } + err = TestStep2bGivenCchannelsf00clEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CHANNEL.S.F01")) { + NextTest(); + return; + } + err = TestStep2cGivenChannelsf01liEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aReadTheGlobalAttributeAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aReadTheGlobalAttributeAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: Read the optional attribute(ChannelList): AttributeList\n"); + if (ShouldSkip("CHANNEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep3bReadTheOptionalAttributeChannelListAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: Reading optional attribute(Lineup) in AttributeList\n"); + if (ShouldSkip("CHANNEL.S.A0001")) { + NextTest(); + return; + } + err = TestStep3cReadingOptionalAttributeLineupInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: Read the optional attribute(CurrentChannel): AttributeList\n"); + if (ShouldSkip("CHANNEL.S.A0002")) { + NextTest(); + return; + } + err = TestStep3dReadTheOptionalAttributeCurrentChannelAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList\n"); + if (ShouldSkip("CHANNEL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep4aReadTheOptionalCommandChangeChannelInAcceptedCommandList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList\n"); + if (ShouldSkip("CHANNEL.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep4bReadTheOptionalCommandChangeChannelByNumberInAcceptedCommandList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList\n"); + if (ShouldSkip("CHANNEL.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep4cReadTheOptionalCommandSkipChannelInAcceptedCommandList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: Read the global attribute: GeneratedCommandList\n"); + if (ShouldSkip("( !CHANNEL.S.F00 && !CHANNEL.S.F01 )")) { + NextTest(); + return; + } + err = TestStep5aReadTheGlobalAttributeGeneratedCommandList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: Read the global attribute: GeneratedCommandList\n"); + if (ShouldSkip("CHANNEL.S.F00 || CHANNEL.S.F01")) { + NextTest(); + return; + } + err = TestStep5bReadTheGlobalAttributeGeneratedCommandList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 16; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 1: read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aReadTheGlobalAttributeFeatureMap_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: Read the global attribute: FeatureMap: Error: %@", err); + } else { + NSLog(@"Step 2a: Read the global attribute: FeatureMap: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bGivenCchannelsf00clEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2b: Given CCHANNEL.S.F00(CL) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cGivenChannelsf01liEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2c: Given CHANNEL.S.F01(LI) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bReadTheOptionalAttributeChannelListAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Read the optional attribute(ChannelList): AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3b: Read the optional attribute(ChannelList): AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cReadingOptionalAttributeLineupInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Reading optional attribute(Lineup) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3c: Reading optional attribute(Lineup) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dReadTheOptionalAttributeCurrentChannelAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Read the optional attribute(CurrentChannel): AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3d: Read the optional attribute(CurrentChannel): AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheOptionalCommandChangeChannelInAcceptedCommandList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the optional command(ChangeChannel) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheOptionalCommandChangeChannelByNumberInAcceptedCommandList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the optional command(ChangeChannelByNumber) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cReadTheOptionalCommandSkipChannelInAcceptedCommandList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4c: Read the optional command(SkipChannel) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aReadTheGlobalAttributeGeneratedCommandList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 5a: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bReadTheGlobalAttributeGeneratedCommandList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 5b: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_MEDIAPLAYBACK_1_7 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MEDIAPLAYBACK_1_7() + : TestCommandBridge("Test_TC_MEDIAPLAYBACK_1_7") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MEDIAPLAYBACK_1_7() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_1_7\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_1_7\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); + if (ShouldSkip(" !MEDIAPLAYBACK.S.F00 && !MEDIAPLAYBACK.S.F01 ")) { + NextTest(); + return; + } + err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.F00")) { + NextTest(); + return; + } + err = TestStep2bGivenMediaplaybacksf00asEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.F01")) { + NextTest(); + return; + } + err = TestStep2cGivenMediaplaybacksf01vsEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads the optional attribute(StartTime) in AttributeList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0001")) { + NextTest(); + return; + } + err = TestStep3bThReadsTheOptionalAttributeStartTimeInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: TH reads the optional attribute(Duration) in AttributeList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0002")) { + NextTest(); + return; + } + err = TestStep3cThReadsTheOptionalAttributeDurationInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0003")) { + NextTest(); + return; + } + err = TestStep3dThReadsTheOptionalAttributeSampledPositionInAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0004")) { + NextTest(); + return; + } + err = TestStep3eThReadsTheOptionalAttributePlaybackSpeedInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0005")) { + NextTest(); + return; + } + err = TestStep3fThReadsTheOptionalAttributeSeekRangeEndInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0006")) { + NextTest(); + return; + } + err = TestStep3gThReadsTheOptionalAttributeSeekRangeStartInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4a: TH reads the AcceptedCommandList attribute from the DUT\n"); + err = TestStep4aThReadsTheAcceptedCommandListAttributeFromTheDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalCommandStartOverInAcceptedCommandList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4c: TH reads the optional command(Previous) in AcceptedCommandList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheOptionalCommandPreviousInAcceptedCommandList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4d: TH reads the optional command(Next) in AcceptedCommandList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheOptionalCommandNextInAcceptedCommandList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep4eThReadsTheOptionalCommandRewindInAcceptedCommandList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4fThReadsTheOptionalCommandFastForwardInAcceptedCommandList_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep4gThReadsTheOptionalCommandSkipForwardInAcceptedCommandList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C09.Rsp")) { + NextTest(); + return; + } + err = TestStep4hThReadsTheOptionalCommandSkipBackwardInAcceptedCommandList_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4i: TH reads the optional command(Seek) in AcceptedCommandList\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { + NextTest(); + return; + } + err = TestStep4iThReadsTheOptionalCommandSeekInAcceptedCommandList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6: TH reads the EventList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 24; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bGivenMediaplaybacksf00asEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2b: Given MEDIAPLAYBACK.S.F00(AS) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cGivenMediaplaybacksf01vsEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2c: Given MEDIAPLAYBACK.S.F01(VS) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsTheOptionalAttributeStartTimeInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads the optional attribute(StartTime) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads the optional attribute(StartTime) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsTheOptionalAttributeDurationInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads the optional attribute(Duration) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads the optional attribute(Duration) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThReadsTheOptionalAttributeSampledPositionInAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads the optional attribute(SampledPosition) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eThReadsTheOptionalAttributePlaybackSpeedInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3e: TH reads the optional attribute(PlaybackSpeed) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fThReadsTheOptionalAttributeSeekRangeEndInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3f: TH reads the optional attribute(SeekRangeEnd) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gThReadsTheOptionalAttributeSeekRangeStartInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3g: TH reads the optional attribute(SeekRangeStart) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheAcceptedCommandListAttributeFromTheDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the AcceptedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalCommandStartOverInAcceptedCommandList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional command(StartOver) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheOptionalCommandPreviousInAcceptedCommandList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the optional command(Previous) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the optional command(Previous) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheOptionalCommandNextInAcceptedCommandList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the optional command(Next) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the optional command(Next) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsTheOptionalCommandRewindInAcceptedCommandList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads the optional command(Rewind) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsTheOptionalCommandFastForwardInAcceptedCommandList_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads the optional command(FastForward) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThReadsTheOptionalCommandSkipForwardInAcceptedCommandList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4g: TH reads the optional command(SkipForward) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsTheOptionalCommandSkipBackwardInAcceptedCommandList_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads the optional command(SkipBackward) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 9UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThReadsTheOptionalCommandSeekInAcceptedCommandList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads the optional command(Seek) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads the optional command(Seek) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_AUDIOOUTPUT_1_8 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_AUDIOOUTPUT_1_8() + : TestCommandBridge("Test_TC_AUDIOOUTPUT_1_8") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_AUDIOOUTPUT_1_8() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_1_8\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_1_8\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); + if (ShouldSkip("AUDIOOUTPUT.S.F00")) { + NextTest(); + return; + } + err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TTH reads the FeatureMap attribute from the DUT\n"); + if (ShouldSkip(" !AUDIOOUTPUT.S.F00 ")) { + NextTest(); + return; + } + err = TestStep2bTthReadsTheFeatureMapAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); + err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the EventList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bTthReadsTheFeatureMapAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TTH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TTH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TGTNAV_1_9 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TGTNAV_1_9() + : TestCommandBridge("Test_TC_TGTNAV_1_9") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TGTNAV_1_9() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TGTNAV_1_9\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TGTNAV_1_9\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); + err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList\n"); + if (ShouldSkip("TGTNAV.S.A0001")) { + NextTest(); + return; + } + err = TestStep3bThReadsTheOptionalAttributeCurrentTargetInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); + err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the EventList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsTheOptionalAttributeCurrentTargetInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads the optional attribute(CurrentTarget) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_APBSC_1_10 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_APBSC_1_10() + : TestCommandBridge("Test_TC_APBSC_1_10") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_APBSC_1_10() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_APBSC_1_10\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APBSC_1_10\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); + err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads the optional attribute(VendorName) in AttributeList\n"); + if (ShouldSkip("APBSC.S.A0000")) { + NextTest(); + return; + } + err = TestStep3bThReadsTheOptionalAttributeVendorNameInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3c: TH reads the optional attribute(VendorID) in AttributeList\n"); + if (ShouldSkip("APBSC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3cThReadsTheOptionalAttributeVendorIDInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3d: TH reads the optional attribute(ProductID) in AttributeList\n"); + if (ShouldSkip("APBSC.S.A0003")) { + NextTest(); + return; + } + err = TestStep3dThReadsTheOptionalAttributeProductIDInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); + err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads the EventList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 11; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsTheOptionalAttributeVendorNameInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads the optional attribute(VendorName) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads the optional attribute(VendorName) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsTheOptionalAttributeVendorIDInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads the optional attribute(VendorID) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads the optional attribute(VendorID) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThReadsTheOptionalAttributeProductIDInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads the optional attribute(ProductID) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads the optional attribute(ProductID) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CONTENTLAUNCHER_1_11 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CONTENTLAUNCHER_1_11() + : TestCommandBridge("Test_TC_CONTENTLAUNCHER_1_11") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CONTENTLAUNCHER_1_11() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_1_11\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_1_11\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads the FeatureMap attribute from the DUT\n"); + if (ShouldSkip("( !CONTENTLAUNCHER.S.F00 && !CONTENTLAUNCHER.S.F01 )")) { + NextTest(); + return; + } + err = TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.F00")) { + NextTest(); + return; + } + err = TestStep2bGivenContentlaunchersf00CsEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.F01")) { + NextTest(); + return; + } + err = TestStep2cGivenContentlaunchersf01upEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.A0000")) { + NextTest(); + return; + } + err = TestStep3bThReadsTheOptionalAttributeAcceptHeaderAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.A0001")) { + NextTest(); + return; + } + err = TestStep3cThReadsTheOptionalAttributeSupportedStreamingProtocolsAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute\n"); + if (ShouldSkip("CONTENTLAUNCHER.C.C00.Tx")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheOptionalCommandLaunchContentInAcceptedCommandListAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute\n"); + if (ShouldSkip("CONTENTLAUNCHER.C.C01.Tx")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalCommandLaunchURLInAcceptedCommandListAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads the EventList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 13; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bGivenContentlaunchersf00CsEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2b: Given CONTENTLAUNCHER.S.F00 (CS) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cGivenContentlaunchersf01upEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2c: Given CONTENTLAUNCHER.S.F01(UP) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsTheOptionalAttributeAcceptHeaderAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads the optional attribute(AcceptHeader): AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsTheOptionalAttributeSupportedStreamingProtocolsAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads the optional attribute(SupportedStreamingProtocols): AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheOptionalCommandLaunchContentInAcceptedCommandListAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the optional command(LaunchContent) in AcceptedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalCommandLaunchURLInAcceptedCommandListAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional command(LaunchURL) in AcceptedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ALOGIN_1_12 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ALOGIN_1_12() + : TestCommandBridge("Test_TC_ALOGIN_1_12") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ALOGIN_1_12() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ALOGIN_1_12\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ALOGIN_1_12\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the FeatureMap attribute from the DUT\n"); + err = TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheAttributeListAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads the AcceptedCommandList attribute from the DUT\n"); + err = TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the GeneratedCommandList attribute from the DUT\n"); + err = TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the EventList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheAttributeListAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheAcceptedCommandListAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the AcceptedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheGeneratedCommandListAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the GeneratedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_LOWPOWER_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_LOWPOWER_2_1() + : TestCommandBridge("Test_TC_LOWPOWER_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_LOWPOWER_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_LOWPOWER_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_LOWPOWER_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends Sleep command to DUT\n"); + if (ShouldSkip("LOWPOWER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep1ThSendsSleepCommandToDut_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThSendsSleepCommandToDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster sleepWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH sends Sleep command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH sends Sleep command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_KEYPADINPUT_3_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_KEYPADINPUT_3_2() + : TestCommandBridge("Test_TC_KEYPADINPUT_3_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_KEYPADINPUT_3_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_3_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_3_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends CEC Settings Keys(0x0A) to DUT\n"); + if (ShouldSkip("KEYPADINPUT.S.F01 && KEYPADINPUT.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep1ThSendsCecSettingsKeys0x0AToDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends CEC Home Keys(0x09) to DUT\n"); + if (ShouldSkip("KEYPADINPUT.S.F01 && KEYPADINPUT.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsCecHomeKeys0x09ToDut_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThSendsCecSettingsKeys0x0AToDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:10U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH sends CEC Settings Keys(0x0A) to DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH sends CEC Settings Keys(0x0A) to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsCecHomeKeys0x09ToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:9U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends CEC Home Keys(0x09) to DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends CEC Home Keys(0x09) to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_KEYPADINPUT_3_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_KEYPADINPUT_3_3() + : TestCommandBridge("Test_TC_KEYPADINPUT_3_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_KEYPADINPUT_3_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_KEYPADINPUT_3_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_KEYPADINPUT_3_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends Numbers1\n"); + if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { + NextTest(); + return; + } + err = TestStep1aThSendsNumbers1_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH sends Numbers2\n"); + if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { + NextTest(); + return; + } + err = TestStep1bThSendsNumbers2_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH sends Numbers3\n"); + if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { + NextTest(); + return; + } + err = TestStep1cThSendsNumbers3_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH sends Numbers4\n"); + if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { + NextTest(); + return; + } + err = TestStep1dThSendsNumbers4_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH sends Numbers5\n"); + if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { + NextTest(); + return; + } + err = TestStep1eThSendsNumbers5_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH sends Numbers6\n"); + if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { + NextTest(); + return; + } + err = TestStep1fThSendsNumbers6_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1g: TH sends Numbers7\n"); + if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { + NextTest(); + return; + } + err = TestStep1gThSendsNumbers7_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1h: TH sends Numbers8\n"); + if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { + NextTest(); + return; + } + err = TestStep1hThSendsNumbers8_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 1i: TH sends Numbers9\n"); + if (ShouldSkip("KEYPADINPUT.S.C00.Rsp && KEYPADINPUT.S.F02")) { + NextTest(); + return; + } + err = TestStep1iThSendsNumbers9_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThSendsNumbers1_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:33U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH sends Numbers1: Error: %@", err); + } else { + NSLog(@"Step 1a: TH sends Numbers1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThSendsNumbers2_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:34U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH sends Numbers2: Error: %@", err); + } else { + NSLog(@"Step 1b: TH sends Numbers2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1cThSendsNumbers3_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:35U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: TH sends Numbers3: Error: %@", err); + } else { + NSLog(@"Step 1c: TH sends Numbers3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1dThSendsNumbers4_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:36U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1d: TH sends Numbers4: Error: %@", err); + } else { + NSLog(@"Step 1d: TH sends Numbers4: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1eThSendsNumbers5_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:37U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1e: TH sends Numbers5: Error: %@", err); + } else { + NSLog(@"Step 1e: TH sends Numbers5: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1fThSendsNumbers6_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:38U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1f: TH sends Numbers6: Error: %@", err); + } else { + NSLog(@"Step 1f: TH sends Numbers6: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1gThSendsNumbers7_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:39U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1g: TH sends Numbers7: Error: %@", err); + } else { + NSLog(@"Step 1g: TH sends Numbers7: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1hThSendsNumbers8_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:40U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1h: TH sends Numbers8: Error: %@", err); + } else { + NSLog(@"Step 1h: TH sends Numbers8: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1iThSendsNumbers9_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:41U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1i: TH sends Numbers9: Error: %@", err); + } else { + NSLog(@"Step 1i: TH sends Numbers9: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_APPLAUNCHER_3_5 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_APPLAUNCHER_3_5() + : TestCommandBridge("Test_TC_APPLAUNCHER_3_5") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_APPLAUNCHER_3_5() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_3_5\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_3_5\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog\n"); + if (ShouldSkip("APPLAUNCHER.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsCatalogListAttributeFromTheDutForTheListOfSupportedApplicationCatalogsAndWhereEachEntryInTheListIsACsaIssuedVendorIdOfTypeUnsigned16BitIntegerRangingBetween065536ForTheCatalog_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsCatalogListAttributeFromTheDutForTheListOfSupportedApplicationCatalogsAndWhereEachEntryInTheListIsACsaIssuedVendorIdOfTypeUnsigned16BitIntegerRangingBetween065536ForTheCatalog_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCatalogListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads CatalogList attribute from the DUT for the list of supported application catalogs and where each entry in the list is a CSA-issued Vendor Id of type unsigned 16 bit integer ranging between 0-65536 for the catalog: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_APPLAUNCHER_3_6 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_APPLAUNCHER_3_6() + : TestCommandBridge("Test_TC_APPLAUNCHER_3_6") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_APPLAUNCHER_3_6() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_APPLAUNCHER_3_6\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APPLAUNCHER_3_6\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application\n"); + if (ShouldSkip("APPLAUNCHER.S.A0001")) { + NextTest(); + return; + } + err = TestStep1ThReadsCurrentAppAttributeFromTheDutAndVerifyTheInFocusApplicationAttributesWhichShouldIncludeTheDisplayApplicationIDtypeuint16CatalogVendorIDtypestringOrNullIfThereIsNoCurrentInFocusApplication_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsCurrentAppAttributeFromTheDutAndVerifyTheInFocusApplicationAttributesWhichShouldIncludeTheDisplayApplicationIDtypeuint16CatalogVendorIDtypestringOrNullIfThereIsNoCurrentInFocusApplication_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentAppWithCompletion:^(MTRApplicationLauncherClusterApplicationEPStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads CurrentApp attribute from the DUT and Verify the in-focus application attributes, which should include the display Application ID(type:uint16) Catalog Vendor ID(type:string) or Null if there is no current in-focus application: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_MEDIAINPUT_3_10 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MEDIAINPUT_3_10() + : TestCommandBridge("Test_TC_MEDIAINPUT_3_10") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MEDIAINPUT_3_10() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_10\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_10\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); + if (ShouldSkip("MEDIAINPUT.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_MEDIAINPUT_3_11 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MEDIAINPUT_3_11() + : TestCommandBridge("Test_TC_MEDIAINPUT_3_11") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("Index", 0, UINT8_MAX, &mIndex); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MEDIAINPUT_3_11() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_11\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_11\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); + if (ShouldSkip("MEDIAINPUT.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.\n"); + if (ShouldSkip("MEDIAINPUT.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsSelectInputCommandToDutToSelectAnInputByPassingTheIndexOfThePreferredInput_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.\n"); + if (ShouldSkip("MEDIAINPUT.S.A0001 && MEDIAINPUT.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThReadsCurrentInputAttributeFromTheDutToShowTheCurrentInputSelected_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mIndex; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsSelectInputCommandToDutToSelectAnInputByPassingTheIndexOfThePreferredInput_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaInputClusterSelectInputParams alloc] init]; + params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; + [cluster selectInputWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends SelectInput command to DUT to select an input by passing the index of the preferred input.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsCurrentInputAttributeFromTheDutToShowTheCurrentInputSelected_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentInputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads _CurrentInput attribute from the DUT to show the current input selected.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentInput", actualValue, mIndex.HasValue() ? mIndex.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_MEDIAINPUT_3_12 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MEDIAINPUT_3_12() + : TestCommandBridge("Test_TC_MEDIAINPUT_3_12") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MEDIAINPUT_3_12() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_12\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_12\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String)\n"); + if (ShouldSkip("MEDIAINPUT.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list\n"); + if (ShouldSkip("MEDIAINPUT.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsShowInputStatusCommandToDutToShowActiveStatusOfTheInputList_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list\n"); + if (ShouldSkip("MEDIAINPUT.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThSendsHideInputStatusCommandToDutToHideActiveStatusOfTheInputList_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyListOfAvailableInputsSupportedByTheDeviceIsProvidedWhereEachEntryInTheListContainsAnIndextypeuint8InputTypeInputTypeEnumsNameTypeStringsAndDescriptionTypeString_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available and Verify list of available inputs supported by the device is provided, where each entry in the list contains an index(type:uint 8), InputType (InputType Enums), Name (type: Strings), and Description(Type:String): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsShowInputStatusCommandToDutToShowActiveStatusOfTheInputList_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster showInputStatusWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends ShowInputStatus command to DUT to show active status of the input list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThSendsHideInputStatusCommandToDutToHideActiveStatusOfTheInputList_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster hideInputStatusWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list: Error: %@", err); + } else { + NSLog(@"Step 3: TH sends HideInputStatus command to DUT to hide active status of the input list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_MEDIAINPUT_3_13 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MEDIAINPUT_3_13() + : TestCommandBridge("Test_TC_MEDIAINPUT_3_13") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("Index", 0, UINT8_MAX, &mIndex); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MEDIAINPUT_3_13() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAINPUT_3_13\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAINPUT_3_13\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available\n"); + if (ShouldSkip("MEDIAINPUT.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1\n"); + if (ShouldSkip("MEDIAINPUT.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsARenameInputCommandToDutToRenameAnInputFromTheListReturnedInStep1_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the InputList attribute from the DUT to show list of Inputs available\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAINPUT.S.A0000 && MEDIAINPUT.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mIndex; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the InputList attribute from the DUT to show list of Inputs available: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("inputList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsARenameInputCommandToDutToRenameAnInputFromTheListReturnedInStep1_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaInputClusterRenameInputParams alloc] init]; + params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; + params.name = @"A1"; + [cluster renameInputWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends a RenameInput command to DUT to rename an input from the list returned in step 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheInputListAttributeFromTheDutToShowListOfInputsAvailable_3() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } +}; + +class Test_TC_CHANNEL_5_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CHANNEL_5_1() + : TestCommandBridge("Test_TC_CHANNEL_5_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CHANNEL_5_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional)\n"); + if (ShouldSkip("CHANNEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheChannelListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsAListOfTheKnownTvChannelsEachListElementShouldConsistOfTheFollowingMajorNumberUnsigned16BitIntegerMandatoryMinorNumberUnsigned16BitIntegerMandatoryNameStringOptionalCallSignStringOptionalAffiliateCallSignStringOptional_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheChannelListAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsAListOfTheKnownTvChannelsEachListElementShouldConsistOfTheFollowingMajorNumberUnsigned16BitIntegerMandatoryMinorNumberUnsigned16BitIntegerMandatoryNameStringOptionalCallSignStringOptionalAffiliateCallSignStringOptional_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional): Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT to show list of Inputs available and Verify that the response contains a list of the known TV channels. Each list element should consist of the following,Major number (unsigned 16-bit integer, mandatory),Minor number (unsigned 16-bit integer, mandatory),Name (String, optional),Call sign (String, optional),Affiliate call sign (String, optional): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CHANNEL_5_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CHANNEL_5_2() + : TestCommandBridge("Test_TC_CHANNEL_5_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("majornumber", 0, UINT16_MAX, &mMajornumber); + AddArgument("minornumber", 0, UINT16_MAX, &mMinornumber); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CHANNEL_5_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the ChannelList attribute from the DUT\n"); + if (ShouldSkip("CHANNEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheChannelListAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1\n"); + if (ShouldSkip("CHANNEL.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsAChangeChannelByNumberCommandToTheDutWithChannelInformationMajorAndMinorNumbersFromTheListInStep1_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: Verify that the channel has changed on the device\n"); + if (ShouldSkip("PICS_USER_PROMPT && CHANNEL.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep2aVerifyThatTheChannelHasChangedOnTheDevice_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads the CurrentChannel attribute from the DUT\n"); + if (ShouldSkip("CHANNEL.S.A0002 && CHANNEL.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_4(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mMajornumber; + chip::Optional mMinornumber; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheChannelListAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the ChannelList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("channelList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsAChangeChannelByNumberCommandToTheDutWithChannelInformationMajorAndMinorNumbersFromTheListInStep1_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = mMajornumber.HasValue() ? [NSNumber numberWithUnsignedShort:mMajornumber.Value()] : [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = mMinornumber.HasValue() ? [NSNumber numberWithUnsignedShort:mMinornumber.Value()] : [NSNumber numberWithUnsignedShort:1U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends a ChangeChannelByNumber command to the DUT with channel information (major and minor numbers) from the list in step 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aVerifyThatTheChannelHasChangedOnTheDevice_3() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if channel has changed on the devicegarbage: not in length on purpose", 53); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber.HasValue() ? mMajornumber.Value() : 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber.HasValue() ? mMinornumber.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CHANNEL_5_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CHANNEL_5_3() + : TestCommandBridge("Test_TC_CHANNEL_5_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("majornumber", 0, UINT16_MAX, &mMajornumber); + AddArgument("minornumber", 0, UINT16_MAX, &mMinornumber); + AddArgument("majornumber2", 0, UINT16_MAX, &mMajornumber2); + AddArgument("minornumber2", 0, UINT16_MAX, &mMinornumber2); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CHANNEL_5_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CHANNEL_5_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CHANNEL_5_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object\n"); + if (ShouldSkip("CHANNEL.S.A0001")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheLineupAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsALineupInfoObject_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the ChannelList attribute from the DUT\n"); + if (ShouldSkip("CHANNEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsTheChannelListAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the CurrentChannel attribute from the DUT\n"); + if (ShouldSkip("CHANNEL.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends a SkipChannel command to the DUT with a value of 1\n"); + if (ShouldSkip("CHANNEL.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThSendsASkipChannelCommandToTheDutWithAValueOf1_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: Verify that the channel has changed on the device\n"); + if (ShouldSkip("PICS_USER_PROMPT && CHANNEL.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep4aVerifyThatTheChannelHasChangedOnTheDevice_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the CurrentChannel attribute from the DUT\n"); + if (ShouldSkip("CHANNEL.S.A0002 && CHANNEL.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThReadsTheCurrentChannelAttributeFromTheDut_6(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 7; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mMajornumber; + chip::Optional mMinornumber; + chip::Optional mMajornumber2; + chip::Optional mMinornumber2; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheLineupAttributeFromTheDutToShowListOfInputsAvailableAndVerifyThatTheResponseContainsALineupInfoObject_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLineupWithCompletion:^(MTRChannelClusterLineupInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the Lineup attribute from the DUT to show list of Inputs available and Verify that the response contains a lineup info object: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsTheChannelListAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ChannelList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ChannelList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("channelList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheCurrentChannelAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the CurrentChannel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber.HasValue() ? mMajornumber.Value() : 6U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber.HasValue() ? mMinornumber.Value() : 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThSendsASkipChannelCommandToTheDutWithAValueOf1_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:1]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends a SkipChannel command to the DUT with a value of 1: Error: %@", err); + } else { + NSLog(@"Step 4: TH sends a SkipChannel command to the DUT with a value of 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aVerifyThatTheChannelHasChangedOnTheDevice_5() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if channel has changed on the devicegarbage: not in length on purpose", 53); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep5ThReadsTheCurrentChannelAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the CurrentChannel attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the CurrentChannel attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, mMajornumber2.HasValue() ? mMajornumber2.Value() : 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, mMinornumber2.HasValue() ? mMinornumber2.Value() : 1U)); + } + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentChannel", "ChannelInfoStruct", "ChannelInfoStruct")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_MEDIAPLAYBACK_6_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MEDIAPLAYBACK_6_1() + : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MEDIAPLAYBACK_6_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Play command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsAPlayCommandToTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that the media state is playing\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaStateIsPlaying_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the CurrentState attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH sends a Pause command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThSendsAPauseCommandToTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that the media is paused\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaIsPaused_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads the CurrentState attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp && MEDIAPLAYBACK.S.A0000")) { + NextTest(); + return; + } + err = TestStep5ThReadsTheCurrentStateAttributeFromTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH sends a Stop command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep6ThSendsAStopCommandToTheDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Verify that the media is stoped\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaIsStoped_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads the CurrentState attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep7ThReadsTheCurrentStateAttributeFromTheDut_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster pauseWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); + } else { + NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsAPlayCommandToTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster playWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends a Play command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends a Play command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_4() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThSendsAPauseCommandToTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster pauseWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends a Pause command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH sends a Pause command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaIsPaused_7() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media state is pausedgarbage: not in length on purpose", 41); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep5ThReadsTheCurrentStateAttributeFromTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the CurrentState attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the CurrentState attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThSendsAStopCommandToTheDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster stopWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH sends a Stop command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH sends a Stop command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaIsStoped_10() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media state is stopedgarbage: not in length on purpose", 41); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep7ThReadsTheCurrentStateAttributeFromTheDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads the CurrentState attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads the CurrentState attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentState", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_MEDIAPLAYBACK_6_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MEDIAPLAYBACK_6_2() + : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MEDIAPLAYBACK_6_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Play command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsAPlayCommandToTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that the media state is playing\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaStateIsPlaying_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the CurrentState attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH sends a StartOver command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThSendsAStartOverCommandToTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that the media is started over\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaIsStartedOver_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH sends a Next command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThSendsANextCommandToTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Verify that the next media item in the queue has been loaded\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheNextMediaItemInTheQueueHasBeenLoaded_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH sends a Previous command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep6ThSendsAPreviousCommandToTheDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Verify that the previous media item in the queue has been loaded\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatThePreviousMediaItemInTheQueueHasBeenLoaded_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep7ThSendsASkipForwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Verify that the media has skipped forward 10 seconds\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaHasSkippedForward10Seconds_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 8: TH reads the SampledPosition attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep8ThReadsTheSampledPositionAttributeFromTheDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C09.Rsp")) { + NextTest(); + return; + } + err = TestStep9ThSendsASkipBackwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Verify that the media has skipped backward 10 seconds\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C09.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaHasSkippedBackward10Seconds_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 10: TH reads the SampledPosition attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C09.Rsp")) { + NextTest(); + return; + } + err = TestStep10ThReadsTheSampledPositionAttributeFromTheDut_17(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 18; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster pauseWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); + } else { + NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsAPlayCommandToTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster playWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends a Play command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends a Play command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_4() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3ThReadsTheCurrentStateAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the CurrentState attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThSendsAStartOverCommandToTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster startOverWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends a StartOver command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH sends a StartOver command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaIsStartedOver_7() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media is started overgarbage: not in length on purpose", 41); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep5ThSendsANextCommandToTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster nextWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH sends a Next command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH sends a Next command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheNextMediaItemInTheQueueHasBeenLoaded_9() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media item in the queue has been loadedgarbage: not in length on purpose", 59); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep6ThSendsAPreviousCommandToTheDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster previousWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH sends a Previous command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH sends a Previous command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatThePreviousMediaItemInTheQueueHasBeenLoaded_11() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if previous media item in the queue has been loadedgarbage: not in length on purpose", 68); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep7ThSendsASkipForwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterSkipForwardParams alloc] init]; + params.deltaPositionMilliseconds = + [NSNumber numberWithUnsignedLongLong:10000ULL]; + [cluster skipForwardWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000: Error: %@", err); + } else { + NSLog(@"Step 7: TH sends a SkipForward command to the DUT with a DeltaPositionMilliseconds value of 10000: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaHasSkippedForward10Seconds_13() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media has skipped forward 10 secondsgarbage: not in length on purpose", 56); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep8ThReadsTheSampledPositionAttributeFromTheDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads the SampledPosition attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads the SampledPosition attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); + VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); + VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 10000ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThSendsASkipBackwardCommandToTheDutWithADeltaPositionMillisecondsValueOf10000_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterSkipBackwardParams alloc] init]; + params.deltaPositionMilliseconds = + [NSNumber numberWithUnsignedLongLong:10000ULL]; + [cluster skipBackwardWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000: Error: %@", err); + } else { + NSLog(@"Step 9: TH sends a SkipBackward command to the DUT with a DeltaPositionMilliseconds value of 10000: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaHasSkippedBackward10Seconds_16() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media has skipped backward 10 secondsgarbage: not in length on purpose", 57); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep10ThReadsTheSampledPositionAttributeFromTheDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads the SampledPosition attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads the SampledPosition attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); + VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); + VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_MEDIAPLAYBACK_6_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MEDIAPLAYBACK_6_3() + : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("SeekPosition", 0, UINT64_MAX, &mSeekPosition); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MEDIAPLAYBACK_6_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends a Seek command to the DUT with a Position value of 10000\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { + NextTest(); + return; + } + err = TestStep1ThSendsASeekCommandToTheDutWithAPositionValueOf10000_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the media has moved to 10 seconds from the starting point\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C0b.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaHasMovedTo10SecondsFromTheStartingPoint_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads the SampledPosition attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0003 && MEDIAPLAYBACK.S.C0b.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThReadsTheSampledPositionAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH reads the StartTime attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheStartTimeAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the SeekRangeEnd attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0005")) { + NextTest(); + return; + } + err = TestStep4ThReadsTheSeekRangeEndAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the SeekRangeStart attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0006")) { + NextTest(); + return; + } + err = TestStep5ThReadsTheSeekRangeStartAttributeFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH reads the Duration attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0002")) { + NextTest(); + return; + } + err = TestStep6ThReadsTheDurationAttributeFromTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media)\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C0b.Rsp")) { + NextTest(); + return; + } + err = TestStep7ThSendsASeekCommandToTheDutWithAPositionValueBeyondTheFurthestValidPositionExBeyondTheDurationOfTheMedia_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : verify that the media has not moved.\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C0b.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaHasNotMoved_10(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 11; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mSeekPosition; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster pauseWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); + } else { + NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1ThSendsASeekCommandToTheDutWithAPositionValueOf10000_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; + params.position = + [NSNumber numberWithUnsignedLongLong:10000ULL]; + [cluster seekWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH sends a Seek command to the DUT with a Position value of 10000: Error: %@", err); + } else { + NSLog(@"Step 1: TH sends a Seek command to the DUT with a Position value of 10000: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaHasMovedTo10SecondsFromTheStartingPoint_3() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media has moved to 10 seconds from the starting pointgarbage: not in length on purpose", 73); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheSampledPositionAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the SampledPosition attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the SampledPosition attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); + VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); + VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 10000ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheStartTimeAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the StartTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the StartTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("startTime", "epoch_us", "epoch_us")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheSeekRangeEndAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSeekRangeEndWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the SeekRangeEnd attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the SeekRangeEnd attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("seekRangeEnd", "int64u", "int64u")); + VerifyOrReturn(CheckConstraintMinValue("seekRangeEnd", [value unsignedLongLongValue], 0ULL)); + VerifyOrReturn(CheckConstraintMaxValue("seekRangeEnd", [value unsignedLongLongValue], 18446744073709551615ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheSeekRangeStartAttributeFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSeekRangeStartWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the SeekRangeStart attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the SeekRangeStart attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("seekRangeStart", "int64u", "int64u")); + VerifyOrReturn(CheckConstraintMinValue("seekRangeStart", [value unsignedLongLongValue], 0ULL)); + VerifyOrReturn(CheckConstraintMaxValue("seekRangeStart", [value unsignedLongLongValue], 18446744073709551615ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsTheDurationAttributeFromTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDurationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads the Duration attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads the Duration attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("duration", "int64u", "int64u")); + VerifyOrReturn(CheckConstraintMinValue("duration", [value unsignedLongLongValue], 0ULL)); + VerifyOrReturn(CheckConstraintMaxValue("duration", [value unsignedLongLongValue], 18446744073709551615ULL)); + } + VerifyOrReturn(CheckConstraintNotValue("duration", value, 0ULL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThSendsASeekCommandToTheDutWithAPositionValueBeyondTheFurthestValidPositionExBeyondTheDurationOfTheMedia_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; + params.position = mSeekPosition.HasValue() ? [NSNumber numberWithUnsignedLongLong:mSeekPosition.Value()] : [NSNumber numberWithUnsignedLongLong:100000000ULL]; + [cluster seekWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media): Error: %@", err); + } else { + NSLog(@"Step 7: TH sends a Seek command to the DUT with a Position value beyond the furthest valid position (ex: beyond the duration of the media): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 5U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaHasNotMoved_10() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media has not movedgarbage: not in length on purpose", 39); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } +}; + +class Test_TC_MEDIAPLAYBACK_6_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MEDIAPLAYBACK_6_4() + : TestCommandBridge("Test_TC_MEDIAPLAYBACK_6_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MEDIAPLAYBACK_6_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MEDIAPLAYBACK_6_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MEDIAPLAYBACK_6_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Media content in a paused state at the beginning of the content\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH reads the CurrentState attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH reads the PlaybackSpeed attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThReadsThePlaybackSpeedAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH sends a FastForward command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThSendsAFastForwardCommandToTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : verify that the media state is playing\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaStateIsPlaying_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads the CurrentState attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThReadsTheCurrentStateAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH reads the PlaybackSpeed attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThReadsThePlaybackSpeedAttributeFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH sends a FastForward command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep6ThSendsAFastForwardCommandToTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : verify that the media play speed has increased.\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaPlaySpeedHasIncreased_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads the PlaybackSpeed attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep7ThReadsThePlaybackSpeedAttributeFromTheDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 8: TH sends a Rewind command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep8ThSendsARewindCommandToTheDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : verify that the media play has reversed direction.\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaPlayHasReversedDirection_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 9: TH reads the CurrentState attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0000 && MEDIAPLAYBACK.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep9ThReadsTheCurrentStateAttributeFromTheDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 10: TH reads the PlaybackSpeed attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep10ThReadsThePlaybackSpeedAttributeFromTheDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 11: TH sends a Rewind command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep11ThSendsARewindCommandToTheDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : verify that the media play speed has increased in the reverse direction.\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaPlaySpeedHasIncreasedInTheReverseDirection_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 12: TH reads the PlaybackSpeed attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep12ThReadsThePlaybackSpeedAttributeFromTheDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 13: TH sends a Play command to the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep13ThSendsAPlayCommandToTheDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : verify that the media is has resumed playing forward at the default speed.\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatTheMediaIsHasResumedPlayingForwardAtTheDefaultSpeed_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 14: TH reads the PlaybackSpeed attribute from the DUT\n"); + if (ShouldSkip("MEDIAPLAYBACK.S.A0004 && MEDIAPLAYBACK.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep14ThReadsThePlaybackSpeedAttributeFromTheDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 15: STH sends consecutive FastForward commands up to the manufacturer defined max speed\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C07.Rsp")) { + NextTest(); + return; + } + err = TestStep15SthSendsConsecutiveFastForwardCommandsUpToTheManufacturerDefinedMaxSpeed_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 16: TH sends consecutive Rewind commands up to the manufacturer defined max speed\n"); + if (ShouldSkip("PICS_USER_PROMPT && MEDIAPLAYBACK.S.C06.Rsp")) { + NextTest(); + return; + } + err = TestStep16ThSendsConsecutiveRewindCommandsUpToTheManufacturerDefinedMaxSpeed_22(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 23; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionMediaContentInAPausedStateAtTheBeginningOfTheContent_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster pauseWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Error: %@", err); + } else { + NSLog(@"Precondition: Media content in a paused state at the beginning of the content: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1ThReadsTheCurrentStateAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the CurrentState attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentState", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsThePlaybackSpeedAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the PlaybackSpeed attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 0.0f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThSendsAFastForwardCommandToTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; + [cluster fastForwardWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH sends a FastForward command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH sends a FastForward command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaStateIsPlaying_5() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media state is playinggarbage: not in length on purpose", 42); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep4ThReadsTheCurrentStateAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the CurrentState attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the CurrentState attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsThePlaybackSpeedAttributeFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the PlaybackSpeed attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 1.0f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThSendsAFastForwardCommandToTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; + [cluster fastForwardWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH sends a FastForward command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH sends a FastForward command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaPlaySpeedHasIncreased_9() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media play speed has increased.garbage: not in length on purpose", 51); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep7ThReadsThePlaybackSpeedAttributeFromTheDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads the PlaybackSpeed attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 2.0f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThSendsARewindCommandToTheDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; + [cluster rewindWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH sends a Rewind command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 8: TH sends a Rewind command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaPlayHasReversedDirection_12() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media play has reversed directiongarbage: not in length on purpose", 53); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep9ThReadsTheCurrentStateAttributeFromTheDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads the CurrentState attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads the CurrentState attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsThePlaybackSpeedAttributeFromTheDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads the PlaybackSpeed attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, -1.0f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThSendsARewindCommandToTheDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; + [cluster rewindWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH sends a Rewind command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 11: TH sends a Rewind command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaPlaySpeedHasIncreasedInTheReverseDirection_16() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media play speed has increased in the reverse directiongarbage: not in length on purpose", 75); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep12ThReadsThePlaybackSpeedAttributeFromTheDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads the PlaybackSpeed attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, -2.0f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13ThSendsAPlayCommandToTheDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster playWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH sends a Play command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 13: TH sends a Play command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheMediaIsHasResumedPlayingForwardAtTheDefaultSpeed_19() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if media is has resumed playing forward at the default speedgarbage: not in length on purpose", 77); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep14ThReadsThePlaybackSpeedAttributeFromTheDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14: TH reads the PlaybackSpeed attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 14: TH reads the PlaybackSpeed attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 1.0f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep15SthSendsConsecutiveFastForwardCommandsUpToTheManufacturerDefinedMaxSpeed_21() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep16ThSendsConsecutiveRewindCommandsUpToTheManufacturerDefinedMaxSpeed_22() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } +}; + +class Test_TC_AUDIOOUTPUT_7_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_AUDIOOUTPUT_7_1() + : TestCommandBridge("Test_TC_AUDIOOUTPUT_7_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("Index", 0, UINT8_MAX, &mIndex); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_AUDIOOUTPUT_7_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_7_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_7_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the OutputList attribute\n"); + if (ShouldSkip("AUDIOOUTPUT.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheOutputListAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1\n"); + if (ShouldSkip("AUDIOOUTPUT.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsASelectAudioOutputCommandToTheDutWithAnIndexFromTheListInStep1_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the CurrentOutput attribute from the DUT\n"); + if (ShouldSkip("AUDIOOUTPUT.S.A0001 && AUDIOOUTPUT.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheCurrentOutputAttributeFromTheDut_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mIndex; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheOutputListAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the OutputList attribute: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the OutputList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("outputList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsASelectAudioOutputCommandToTheDutWithAnIndexFromTheListInStep1_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAudioOutputClusterSelectOutputParams alloc] init]; + params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; + [cluster selectOutputWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends a SelectAudioOutput command to the DUT with an index from the list in step 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheCurrentOutputAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentOutputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the CurrentOutput attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the CurrentOutput attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentOutput", actualValue, mIndex.HasValue() ? mIndex.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_AUDIOOUTPUT_7_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_AUDIOOUTPUT_7_2() + : TestCommandBridge("Test_TC_AUDIOOUTPUT_7_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("Index", 0, UINT8_MAX, &mIndex); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_AUDIOOUTPUT_7_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_AUDIOOUTPUT_7_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_AUDIOOUTPUT_7_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the OutputList attribute from the DUT\n"); + if (ShouldSkip("AUDIOOUTPUT.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheOutputListAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest'\n"); + if (ShouldSkip("AUDIOOUTPUT.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsARenameOutputCommandToTheDutWithAnIndexFromTheListInStep1AndTheNameCertTest_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the OutputList attribute from the DUT. Verify that the output at the index provided in step 2 has the name CertTest\n"); + if (ShouldSkip("PICS_USER_PROMPT && AUDIOOUTPUT.S.A0001 && AUDIOOUTPUT.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheOutputListAttributeFromTheDutVerifyThatTheOutputAtTheIndexProvidedInStep2HasTheNameCertTest_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mIndex; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSArray * _Nonnull audioOutputListValues; + + CHIP_ERROR TestStep1ThReadsTheOutputListAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the OutputList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the OutputList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("outputList", "list", "list")); + { + audioOutputListValues = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsARenameOutputCommandToTheDutWithAnIndexFromTheListInStep1AndTheNameCertTest_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAudioOutputClusterRenameOutputParams alloc] init]; + params.index = mIndex.HasValue() ? [NSNumber numberWithUnsignedChar:mIndex.Value()] : [NSNumber numberWithUnsignedChar:1U]; + params.name = @"CertTest"; + [cluster renameOutputWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest': Error: %@", err); + } else { + NSLog(@"Step 2: TH sends a RenameOutput command to the DUT with an index from the list in step 1 and the name 'CertTest': Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheOutputListAttributeFromTheDutVerifyThatTheOutputAtTheIndexProvidedInStep2HasTheNameCertTest_3() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } +}; + +class Test_TC_TGTNAV_8_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TGTNAV_8_1() + : TestCommandBridge("Test_TC_TGTNAV_8_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("targetvalue", 0, UINT8_MAX, &mTargetvalue); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TGTNAV_8_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TGTNAV_8_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TGTNAV_8_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads the CurrentTarget attribute\n"); + if (ShouldSkip("TGTNAV.S.A0001")) { + NextTest(); + return; + } + err = TestStep1aThReadsTheCurrentTargetAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads the TargetList attribute\n"); + if (ShouldSkip("TGTNAV.S.A0000")) { + NextTest(); + return; + } + err = TestStep1bThReadsTheTargetListAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH Sends a NavigateTarget command\n"); + if (ShouldSkip("TGTNAV.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsANavigateTargetCommand_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH reads the CurrentTarget attribute\n"); + if (ShouldSkip("TGTNAV.S.A0001 && TGTNAV.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThReadsTheCurrentTargetAttribute_4(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTargetvalue; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThReadsTheCurrentTargetAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH reads the CurrentTarget attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH reads the CurrentTarget attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentTarget", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentTarget", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentTarget", [value unsignedCharValue], 255U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSArray * _Nonnull TargetListValues; + + CHIP_ERROR TestStep1bThReadsTheTargetListAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH reads the TargetList attribute: Error: %@", err); + } else { + NSLog(@"Step 1b: TH reads the TargetList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("targetList", "list", "list")); + { + TargetListValues = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsANavigateTargetCommand_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTargetNavigatorClusterNavigateTargetParams alloc] init]; + params.target = mTargetvalue.HasValue() ? [NSNumber numberWithUnsignedChar:mTargetvalue.Value()] : [NSNumber numberWithUnsignedChar:1U]; + [cluster navigateTargetWithParams:params completion: + ^(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH Sends a NavigateTarget command: Error: %@", err); + } else { + NSLog(@"Step 2a: TH Sends a NavigateTarget command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThReadsTheCurrentTargetAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads the CurrentTarget attribute: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads the CurrentTarget attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentTarget", actualValue, mTargetvalue.HasValue() ? mTargetvalue.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_APBSC_9_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_APBSC_9_1() + : TestCommandBridge("Test_TC_APBSC_9_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_APBSC_9_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_APBSC_9_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_APBSC_9_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the VendorName attribute from the DUT\n"); + if (ShouldSkip("APBSC.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheVendorNameAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the VendorID attribute from the DUT\n"); + if (ShouldSkip("APBSC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsTheVendorIDAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads the ApplicationName attribute from the DUT\n"); + if (ShouldSkip("APBSC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheApplicationNameAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads the ProductID attribute from the DUT\n"); + if (ShouldSkip("APBSC.S.A0003")) { + NextTest(); + return; + } + err = TestStep4ThReadsTheProductIDAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads the Application attribute from the DUT\n"); + if (ShouldSkip("APBSC.S.A0004")) { + NextTest(); + return; + } + err = TestStep5ThReadsTheApplicationAttributeFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads the Status attribute from the DUT\n"); + if (ShouldSkip("APBSC.S.A0005")) { + NextTest(); + return; + } + err = TestStep6ThReadsTheStatusAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads the ApplicationVersion attribute from the DUT\n"); + if (ShouldSkip("APBSC.S.A0006")) { + NextTest(); + return; + } + err = TestStep7ThReadsTheApplicationVersionAttributeFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH reads the AllowedVendorList attribute from the DUT\n"); + if (ShouldSkip("APBSC.S.A0007")) { + NextTest(); + return; + } + err = TestStep8ThReadsTheAllowedVendorListAttributeFromTheDut_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheVendorNameAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the VendorName attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the VendorName attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("vendorName", "char_string", "char_string")); + VerifyOrReturn(CheckConstraintMaxLength("vendorName", value, 32)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsTheVendorIDAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the VendorID attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the VendorID attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("vendorID", "vendor_id", "vendor_id")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheApplicationNameAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeApplicationNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the ApplicationName attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the ApplicationName attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("applicationName", "long_char_string", "long_char_string")); + VerifyOrReturn(CheckConstraintMaxLength("applicationName", value, 256)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheProductIDAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeProductIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the ProductID attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the ProductID attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("productID", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("productID", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("productID", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheApplicationAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeApplicationWithCompletion:^(MTRApplicationBasicClusterApplicationStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the Application attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the Application attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("application", "ApplicationStruct", "ApplicationStruct")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsTheStatusAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads the Status attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads the Status attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("status", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("status", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsTheApplicationVersionAttributeFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeApplicationVersionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads the ApplicationVersion attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads the ApplicationVersion attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("applicationVersion", "char_string", "char_string")); + VerifyOrReturn(CheckConstraintMaxLength("applicationVersion", value, 32)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsTheAllowedVendorListAttributeFromTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAllowedVendorListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads the AllowedVendorList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads the AllowedVendorList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("allowedVendorList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CONTENTLAUNCHER_10_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CONTENTLAUNCHER_10_1() + : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CONTENTLAUNCHER_10_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the AcceptHeader attribute from the DUT\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheAcceptHeaderAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsTheSupportedStreamingProtocolsAttributeFromTheDut_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheAcceptHeaderAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptHeaderWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the AcceptHeader attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the AcceptHeader attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptHeader", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsTheSupportedStreamingProtocolsAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedStreamingProtocolsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the SupportedStreamingProtocols attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("supportedStreamingProtocols", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WAKEONLAN_4_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WAKEONLAN_4_1() + : TestCommandBridge("Test_TC_WAKEONLAN_4_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WAKEONLAN_4_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WAKEONLAN_4_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WAKEONLAN_4_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads the MACAddress attribute from the DUT\n"); + if (ShouldSkip("WAKEONLAN.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsTheMACAddressAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends a Sleep command to DUT\n"); + if (ShouldSkip("LOWPOWER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsASleepCommandToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends a Wake-On LAN magic packet containing the MAC address from step 1\n"); + if (ShouldSkip("PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep3ThSendsAWakeOnLanMagicPacketContainingTheMacAddressFromStep1_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsTheMACAddressAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMACAddressWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads the MACAddress attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads the MACAddress attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinLength("MACAddress", value, 12)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsASleepCommandToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster sleepWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends a Sleep command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends a Sleep command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThSendsAWakeOnLanMagicPacketContainingTheMacAddressFromStep1_3() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } +}; + +class Test_TC_ALOGIN_12_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ALOGIN_12_1() + : TestCommandBridge("Test_TC_ALOGIN_12_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("TempAccountIdentifier", &mTempAccountIdentifier); + AddArgument("catalogVendorId", 0, UINT16_MAX, &mCatalogVendorId); + AddArgument("applicationId", &mApplicationId); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ALOGIN_12_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ALOGIN_12_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ALOGIN_12_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Launch an app with the provided a application ID\n"); + if (ShouldSkip("APPLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestLaunchAnAppWithTheProvidedAApplicationId_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.\n"); + if (ShouldSkip("ALOGIN.S.C00.Rsp && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep1ThSendsAGetSetupPINCommandToTheDutWithTestValuesProvidedByTheProductMaker_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a Login command to the DUT with test values provided by the product maker.\n"); + if (ShouldSkip("ALOGIN.S.C02.Rsp && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep2ThSendsALoginCommandToTheDutWithTestValuesProvidedByTheProductMaker_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.\n"); + if (ShouldSkip("ALOGIN.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep3ThSendsALogoutCommandToTheDutWithTestValuesProvidedByTheProductMaker_4(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTempAccountIdentifier; + chip::Optional mCatalogVendorId; + chip::Optional mApplicationId; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestLaunchAnAppWithTheProvidedAApplicationId_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRApplicationLauncherClusterLaunchAppParams alloc] init]; + params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; + ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = mCatalogVendorId.HasValue() ? [NSNumber numberWithUnsignedShort:mCatalogVendorId.Value()] : [NSNumber numberWithUnsignedShort:123U]; + ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = mApplicationId.HasValue() ? [[NSString alloc] initWithBytes:mApplicationId.Value().data() length:mApplicationId.Value().size() encoding:NSUTF8StringEncoding] : @"exampleid"; + + params.data = + [[NSData alloc] initWithBytes:"Hello World" length:11]; + [cluster launchAppWithParams:params completion: + ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Launch an app with the provided a application ID: Error: %@", err); + } else { + NSLog(@"Launch an app with the provided a application ID: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSString * _Nonnull setupPIN; + + CHIP_ERROR TestStep1ThSendsAGetSetupPINCommandToTheDutWithTestValuesProvidedByTheProductMaker_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAccountLoginClusterGetSetupPINParams alloc] init]; + params.tempAccountIdentifier = mTempAccountIdentifier.HasValue() ? [[NSString alloc] initWithBytes:mTempAccountIdentifier.Value().data() length:mTempAccountIdentifier.Value().size() encoding:NSUTF8StringEncoding] : @"1111"; + [cluster getSetupPINWithParams:params completion: + ^(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.: Error: %@", err); + } else { + NSLog(@"Step 1: TH sends a GetSetupPIN command to the DUT with test values provided by the product maker.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinLength("setupPIN", values.setupPIN, 8)); + { + setupPIN = values.setupPIN; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsALoginCommandToTheDutWithTestValuesProvidedByTheProductMaker_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAccountLoginClusterLoginParams alloc] init]; + params.tempAccountIdentifier = mTempAccountIdentifier.HasValue() ? [[NSString alloc] initWithBytes:mTempAccountIdentifier.Value().data() length:mTempAccountIdentifier.Value().size() encoding:NSUTF8StringEncoding] : @"1111"; + params.setupPIN = + [setupPIN copy]; + params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; + [cluster loginWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends a Login command to the DUT with test values provided by the product maker.: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends a Login command to the DUT with test values provided by the product maker.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThSendsALogoutCommandToTheDutWithTestValuesProvidedByTheProductMaker_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAccountLoginClusterLogoutParams alloc] init]; + params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; + [cluster logoutWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.: Error: %@", err); + } else { + NSLog(@"Step 3: TH sends a Logout command to the DUT with test values provided by the product maker.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CONTENTLAUNCHER_10_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CONTENTLAUNCHER_10_3() + : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("data", &mData); + AddArgument("SearchValue", &mSearchValue); + AddArgument("ExternalIdName", &mExternalIdName); + AddArgument("ExternalIdValue", &mExternalIdValue); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CONTENTLAUNCHER_10_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep1ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToFalse_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT present via its user interface a list of matches based on the provided search criteria.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutPresentViaItsUserInterfaceAListOfMatchesBasedOnTheProvidedSearchCriteria_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToTrue_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT should also begin playing content that best matched the given search criteria\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldAlsoBeginPlayingContentThatBestMatchedTheGivenSearchCriteria_4(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mData; + chip::Optional mSearchValue; + chip::Optional mExternalIdName; + chip::Optional mExternalIdValue; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToFalse_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mSearchValue.HasValue() ? [[NSString alloc] initWithBytes:mSearchValue.Value().data() length:mSearchValue.Value().size() encoding:NSUTF8StringEncoding] : @"exampleValue"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; + ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = mExternalIdName.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdName.Value().data() length:mExternalIdName.Value().size() encoding:NSUTF8StringEncoding] : @"name"; + ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = mExternalIdValue.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdValue.Value().data() length:mExternalIdValue.Value().size() encoding:NSUTF8StringEncoding] : @"value"; + + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; + } + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:false]; + params.data = mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + params.useCurrentContext = + [NSNumber numberWithBool:false]; + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false: Error: %@", err); + } else { + NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to false: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutPresentViaItsUserInterfaceAListOfMatchesBasedOnTheProvidedSearchCriteria_2() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT present via its user interface a list of matches based on the provided search criteria.garbage: not in length on purpose", 111); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2ThSendsALaunchContentCommandToTheDutWithASearchParameterAndStringAndAutoPlayFlagSetToTrue_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mSearchValue.HasValue() ? [[NSString alloc] initWithBytes:mSearchValue.Value().data() length:mSearchValue.Value().size() encoding:NSUTF8StringEncoding] : @"exampleValue"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; + ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = mExternalIdName.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdName.Value().data() length:mExternalIdName.Value().size() encoding:NSUTF8StringEncoding] : @"name"; + ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = mExternalIdValue.HasValue() ? [[NSString alloc] initWithBytes:mExternalIdValue.Value().data() length:mExternalIdValue.Value().size() encoding:NSUTF8StringEncoding] : @"value"; + + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; + } + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.data = mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + params.useCurrentContext = + [NSNumber numberWithBool:false]; + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with a search parameter and string, and AutoPlay flag set to true: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, mData.HasValue() ? [[NSString alloc] initWithBytes:mData.Value().data() length:mData.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldAlsoBeginPlayingContentThatBestMatchedTheGivenSearchCriteria_4() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT begin playing content that best matched the given search criteriagarbage: not in length on purpose", 89); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } +}; + +class Test_TC_CONTENTLAUNCHER_10_5 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CONTENTLAUNCHER_10_5() + : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_5") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("GoodURL", &mGoodURL); + AddArgument("BadURL", &mBadURL); + AddArgument("UnauthorizedURL", &mUnauthorizedURL); + AddArgument("DisplayContent", &mDisplayContent); + AddArgument("providerNameString", &mProviderNameString); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CONTENTLAUNCHER_10_5() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_5\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_5\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlString_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT launched the content at the given URL\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrl_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndADisplayString_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT launched the content at the given URL with the given display string in the application-specific description area\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithTheGivenDisplayStringInTheApplicationSpecificDescriptionArea_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndABrandInformationObject_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Verify that DUT launched the content at the given URL with the player interface updated as per the provided branding information\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithThePlayerInterfaceUpdatedAsPerTheProvidedBrandingInformation_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThSendsALaunchURLCommandToTheDutWithAKnownUnreachableContentUrlString_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThSendsALaunchURLCommandToTheDutWithAKnownUnAuthorizedContentUrlString_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mGoodURL; + chip::Optional mBadURL; + chip::Optional mUnauthorizedURL; + chip::Optional mDisplayContent; + chip::Optional mProviderNameString; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlString_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; + params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; + params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; + ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; + + [cluster launchURLWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string: Error: %@", err); + } else { + NSLog(@"Step 1: TH sends a LaunchURL command to the DUT with a known good content URL string: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrl_2() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URLgarbage: not in length on purpose", 61); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndADisplayString_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; + params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; + params.displayString = mDisplayContent.HasValue() ? [[NSString alloc] initWithBytes:mDisplayContent.Value().data() length:mDisplayContent.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData"; + params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; + ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; + + [cluster launchURLWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends a LaunchURL command to the DUT with a known good content URL string and a display string: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, mDisplayContent.HasValue() ? [[NSString alloc] initWithBytes:mDisplayContent.Value().data() length:mDisplayContent.Value().size() encoding:NSUTF8StringEncoding] : @"exampleData")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithTheGivenDisplayStringInTheApplicationSpecificDescriptionArea_4() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URL with the given display string in the application-specific description areagarbage: not in length on purpose", 136); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3ThSendsALaunchURLCommandToTheDutWithAKnownGoodContentUrlStringAndABrandInformationObject_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; + params.contentURL = mGoodURL.HasValue() ? [[NSString alloc] initWithBytes:mGoodURL.Value().data() length:mGoodURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/"; + params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; + ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; + + [cluster launchURLWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.: Error: %@", err); + } else { + NSLog(@"Step 3: TH sends a LaunchURL command to the DUT with a known good content URL string and a brand information object.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutLaunchedTheContentAtTheGivenUrlWithThePlayerInterfaceUpdatedAsPerTheProvidedBrandingInformation_6() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT launched the content at the given URL with the player interface updated as per the provided branding informationgarbage: not in length on purpose", 136); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep4ThSendsALaunchURLCommandToTheDutWithAKnownUnreachableContentUrlString_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; + params.contentURL = mBadURL.HasValue() ? [[NSString alloc] initWithBytes:mBadURL.Value().data() length:mBadURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://badurl"; + params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; + ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; + + [cluster launchURLWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.: Error: %@", err); + } else { + NSLog(@"Step 4: TH sends a LaunchURL command to the DUT with a known unreachable content URL string.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThSendsALaunchURLCommandToTheDutWithAKnownUnAuthorizedContentUrlString_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; + params.contentURL = mUnauthorizedURL.HasValue() ? [[NSString alloc] initWithBytes:mUnauthorizedURL.Value().data() length:mUnauthorizedURL.Value().size() encoding:NSUTF8StringEncoding] : @"https://csa-iot.org/badauth"; + params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; + ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = mProviderNameString.HasValue() ? [[NSString alloc] initWithBytes:mProviderNameString.Value().data() length:mProviderNameString.Value().size() encoding:NSUTF8StringEncoding] : @"exampleName"; + + [cluster launchURLWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.: Error: %@", err); + } else { + NSLog(@"Step 5: TH sends a LaunchURL command to the DUT with a known un-authorized content URL string.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_CONTENTLAUNCHER_10_7 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_CONTENTLAUNCHER_10_7() + : TestCommandBridge("Test_TC_CONTENTLAUNCHER_10_7") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("PopularityName", &mPopularityName); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_CONTENTLAUNCHER_10_7() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_CONTENTLAUNCHER_10_7\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_CONTENTLAUNCHER_10_7\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep1ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsActorAndValueAsAnActorsNameForExampleGabySHoffman_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsChannelAndValueAsChannelNameNameForExamplePbs_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsCharacterAndValueAsCharactersNameforExampleSnowWhite_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsDirectorAndValueAsDirectorsNameForExampleSpikeLee_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsEventAndValueAsAnEventsNameForExampleFootballGames_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsFranchiseAndValueAsFranchisesNameforExampleStarWars_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep7ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsGenreAndValueAsGenresNameForExampleHorror_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep8ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsLeagueAndValueAsLeaguesNameForExampleNcaa_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep9ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsPopularityAndValueAsPopularitysName_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep10ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsProviderAndValueAsProvidersNameForExampleNetflix_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep11ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportAndValueAsSportsNameForExampleFootball_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep12ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportsTeamAndValueAsSportTeamsNameForExampleArsenel_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries\n"); + if (ShouldSkip("CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep13ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsTypeAndValueAsTypesNameForExampleTVSeries_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Verify that DUT should play or display the search result.\n"); + if (ShouldSkip("PICS_USER_PROMPT && CONTENTLAUNCHER.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_26(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 27; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mPopularityName; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsActorAndValueAsAnActorsNameForExampleGabySHoffman_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Gaby sHoffman"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman: Error: %@", err); + } else { + NSLog(@"Step 1: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Actor and Value as An Actor’s name, for example, Gaby sHoffman: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_2() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsChannelAndValueAsChannelNameNameForExamplePbs_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"PBS"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Channel and Value as Channel Name name, for example, PBS: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_4() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsCharacterAndValueAsCharactersNameforExampleSnowWhite_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Snow White"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:false]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White: Error: %@", err); + } else { + NSLog(@"Step 3: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Character and Value as Character’s name,for example,Snow White: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_6() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep4ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsDirectorAndValueAsDirectorsNameForExampleSpikeLee_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Spike Lee"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee: Error: %@", err); + } else { + NSLog(@"Step 4: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Director and Value as Director’s name, for example, Spike Lee: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_8() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep5ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsEventAndValueAsAnEventsNameForExampleFootballGames_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:4U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Football games"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games: Error: %@", err); + } else { + NSLog(@"Step 5: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Event and Value as An Event’s name , for example Football games: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_10() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep6ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsFranchiseAndValueAsFranchisesNameforExampleStarWars_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Star Wars"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars: Error: %@", err); + } else { + NSLog(@"Step 6: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Franchise and Value as Franchise’s name,for example Star Wars: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_12() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep7ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsGenreAndValueAsGenresNameForExampleHorror_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:6U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Horror"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror: Error: %@", err); + } else { + NSLog(@"Step 7: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Genre and Value as Genre’s name, for example Horror: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_14() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep8ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsLeagueAndValueAsLeaguesNameForExampleNcaa_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:7U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"NCAA"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA: Error: %@", err); + } else { + NSLog(@"Step 8: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As League and Value as League’s name, for example NCAA: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_16() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep9ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsPopularityAndValueAsPopularitysName_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:8U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = mPopularityName.HasValue() ? [[NSString alloc] initWithBytes:mPopularityName.Value().data() length:mPopularityName.Value().size() encoding:NSUTF8StringEncoding] : @"popular content"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name: Error: %@", err); + } else { + NSLog(@"Step 9: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Popularity and Value as Popularity’s name: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_18() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep10ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsProviderAndValueAsProvidersNameForExampleNetflix_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:9U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Netflix"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix: Error: %@", err); + } else { + NSLog(@"Step 10: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Provider and Value as Provider’s name, for example Netflix: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_20() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep11ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportAndValueAsSportsNameForExampleFootball_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:10U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"football"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football: Error: %@", err); + } else { + NSLog(@"Step 11: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Sport and Value as Sport’s name, for example, football: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_22() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep12ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsSportsTeamAndValueAsSportTeamsNameForExampleArsenel_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:11U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"Arsenel"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel: Error: %@", err); + } else { + NSLog(@"Step 12: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As SportsTeam and Value as SportTeam’s name , for example Arsenel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_24() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep13ThSendsALaunchContentCommandToTheDutWithSearchParameterConsistingOfTypeAsTypeAndValueAsTypesNameForExampleTVSeries_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:12U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"TVSeries"; + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries: Error: %@", err); + } else { + NSLog(@"Step 13: TH sends a LaunchContent command to the DUT with search parameter consisting of Type As Type and Value as Type’s name, for example TVSeries: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatDutShouldPlayOrDisplayTheSearchResult_26() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' if DUT play or display the search result.garbage: not in length on purpose", 58); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } +}; + +class Test_TC_MOD_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_MOD_1_1() + : TestCommandBridge("Test_TC_MOD_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_MOD_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_MOD_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_MOD_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip("MOD.S.F00")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip(" !MOD.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT\n"); + if (ShouldSkip("MOD.S.A0004")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT\n"); + if (ShouldSkip("MOD.S.F00 && MOD.S.A0005")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheFeatureDependentAttributeOnModeInAttributeListFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 11; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheFeatureDependentAttributeOnModeInAttributeListFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the Feature dependent attribute(OnMode) in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class OTA_SuccessfulTransfer : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + OTA_SuccessfulTransfer() + : TestCommandBridge("OTA_SuccessfulTransfer") + , mTestIndex(0) + { + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("requestorNodeId", 0, UINT64_MAX, &mRequestorNodeId); + AddArgument("providerNodeId", 0, UINT64_MAX, &mProviderNodeId); + AddArgument("providerPayload", &mProviderPayload); + AddArgument("providerDiscriminator", 0, UINT16_MAX, &mProviderDiscriminator); + AddArgument("providerPort", 0, UINT16_MAX, &mProviderPort); + AddArgument("providerKvs", &mProviderKvs); + AddArgument("otaImageFilePath", &mOtaImageFilePath); + AddArgument("rawImageFilePath", &mRawImageFilePath); + AddArgument("rawImageContent", &mRawImageContent); + AddArgument("downloadImageFilePath", &mDownloadImageFilePath); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~OTA_SuccessfulTransfer() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: OTA_SuccessfulTransfer\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: OTA_SuccessfulTransfer\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Create OTA image\n"); + err = TestCreateOtaImage_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Start the provider with an image\n"); + err = TestStartTheProviderWithAnImage_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Commission the provider from alpha\n"); + err = TestCommissionTheProviderFromAlpha_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Wait for the commissioned provider to be retrieved for alpha\n"); + err = TestWaitForTheCommissionedProviderToBeRetrievedForAlpha_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Install ACL for QueryImage\n"); + err = TestInstallAclForQueryImage_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Stop the requestor\n"); + err = TestStopTheRequestor_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Start the requestor with an OTA download path\n"); + err = TestStartTheRequestorWithAnOtaDownloadPath_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Wait for the commissioned requestor to be retrieved for alpha\n"); + err = TestWaitForTheCommissionedRequestorToBeRetrievedForAlpha_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Send an announce OTA provider command to the requestor\n"); + err = TestSendAnAnnounceOtaProviderCommandToTheRequestor_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Wait for transfer complete message\n"); + err = TestWaitForTransferCompleteMessage_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Compare original file to downloaded file\n"); + err = TestCompareOriginalFileToDownloadedFile_10(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 11; + + chip::Optional mEndpoint; + chip::Optional mRequestorNodeId; + chip::Optional mProviderNodeId; + chip::Optional mProviderPayload; + chip::Optional mProviderDiscriminator; + chip::Optional mProviderPort; + chip::Optional mProviderKvs; + chip::Optional mOtaImageFilePath; + chip::Optional mRawImageFilePath; + chip::Optional mRawImageContent; + chip::Optional mDownloadImageFilePath; + chip::Optional mTimeout; + + CHIP_ERROR TestCreateOtaImage_0() + { + + chip::app::Clusters::SystemCommands::Commands::CreateOtaImage::Type value; + value.otaImageFilePath = mOtaImageFilePath.HasValue() ? mOtaImageFilePath.Value() : chip::Span("/tmp/otaImage", 13); + value.rawImageFilePath = mRawImageFilePath.HasValue() ? mRawImageFilePath.Value() : chip::Span("/tmp/rawImage", 13); + value.rawImageContent = mRawImageContent.HasValue() ? mRawImageContent.Value() : chip::Span("Have a hootenanny!", 18); + return CreateOtaImage("alpha", value); + } + + CHIP_ERROR TestStartTheProviderWithAnImage_1() + { + + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + value.registerKey.Emplace(); + value.registerKey.Value() = chip::Span("chip-ota-provider-appgarbage: not in length on purpose", 21); + value.discriminator.Emplace(); + value.discriminator.Value() = mProviderDiscriminator.HasValue() ? mProviderDiscriminator.Value() : 50U; + value.port.Emplace(); + value.port.Value() = mProviderPort.HasValue() ? mProviderPort.Value() : 5560U; + value.kvs.Emplace(); + value.kvs.Value() = mProviderKvs.HasValue() ? mProviderKvs.Value() : chip::Span("/tmp/chip_kvs_provider", 22); + value.filepath.Emplace(); + value.filepath.Value() = mOtaImageFilePath.HasValue() ? mOtaImageFilePath.Value() : chip::Span("/tmp/otaImage", 13); + return Start("alpha", value); + } + + CHIP_ERROR TestCommissionTheProviderFromAlpha_2() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mProviderNodeId.HasValue() ? mProviderNodeId.Value() : 12648430ULL; + value.payload = mProviderPayload.HasValue() ? mProviderPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); + return PairWithCode("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedProviderToBeRetrievedForAlpha_3() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mProviderNodeId.HasValue() ? mProviderNodeId.Value() : 12648430ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestInstallAclForQueryImage_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:112233ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = + [NSNumber numberWithUnsignedInt:41UL]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Install ACL for QueryImage: Error: %@", err); + } else { + NSLog(@"Install ACL for QueryImage: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStopTheRequestor_5() + { + + chip::app::Clusters::SystemCommands::Commands::Stop::Type value; + return Stop("alpha", value); + } + + CHIP_ERROR TestStartTheRequestorWithAnOtaDownloadPath_6() + { + + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + value.otaDownloadPath.Emplace(); + value.otaDownloadPath.Value() = mDownloadImageFilePath.HasValue() ? mDownloadImageFilePath.Value() : chip::Span("/tmp/downloadedImage", 20); + return Start("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedRequestorToBeRetrievedForAlpha_7() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mRequestorNodeId.HasValue() ? mRequestorNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestSendAnAnnounceOtaProviderCommandToTheRequestor_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOTASoftwareUpdateRequestor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROTASoftwareUpdateRequestorClusterAnnounceOTAProviderParams alloc] init]; + params.providerNodeID = mProviderNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mProviderNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:12648430ULL]; + params.vendorID = + [NSNumber numberWithUnsignedShort:0U]; + params.announcementReason = + [NSNumber numberWithUnsignedChar:0U]; + params.endpoint = mEndpoint.HasValue() ? [NSNumber numberWithUnsignedShort:mEndpoint.Value()] : [NSNumber numberWithUnsignedShort:0U]; + [cluster announceOTAProviderWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send an announce OTA provider command to the requestor: Error: %@", err); + } else { + NSLog(@"Send an announce OTA provider command to the requestor: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForTransferCompleteMessage_9() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMessage::Type value; + value.registerKey.Emplace(); + value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); + value.message = chip::Span("OTA image downloadedgarbage: not in length on purpose", 20); + return WaitForMessage("alpha", value); + } + + CHIP_ERROR TestCompareOriginalFileToDownloadedFile_10() + { + + chip::app::Clusters::SystemCommands::Commands::CompareFiles::Type value; + value.file1 = mRawImageFilePath.HasValue() ? mRawImageFilePath.Value() : chip::Span("/tmp/rawImage", 13); + value.file2 = mDownloadImageFilePath.HasValue() ? mDownloadImageFilePath.Value() : chip::Span("/tmp/downloadedImage", 20); + return CompareFiles("alpha", value); + } +}; + +class Test_TC_OCC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OCC_1_1() + : TestCommandBridge("Test_TC_OCC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OCC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); + err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); + err = TestStep3ThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList\n"); + if (ShouldSkip("OCC.S.A0010")) { + NextTest(); + return; + } + err = TestStep4bThReadsOptionalAttributePIROccupiedToUnoccupiedDelayInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList\n"); + if (ShouldSkip("OCC.S.A0011")) { + NextTest(); + return; + } + err = TestStep4cThReadsOptionalAttributePIRUnoccupiedToOccupiedDelayInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList\n"); + if (ShouldSkip("OCC.S.A0012")) { + NextTest(); + return; + } + err = TestStep4dThReadsOptionalAttributePIRUnoccupiedToOccupiedThresholdInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList\n"); + if (ShouldSkip("OCC.S.A0020")) { + NextTest(); + return; + } + err = TestStep4eThReadsOptionalAttributeUltrasonicOccupiedToUnoccupiedDelayInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList\n"); + if (ShouldSkip("OCC.S.A0021")) { + NextTest(); + return; + } + err = TestStep4fThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedDelayInAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList\n"); + if (ShouldSkip("OCC.S.A0022")) { + NextTest(); + return; + } + err = TestStep4gThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedThresholdInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList\n"); + if (ShouldSkip("OCC.S.A0030")) { + NextTest(); + return; + } + err = TestStep4hThReadsOptionalAttributePhysicalContactOccupiedToUnoccupiedDelayInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList\n"); + if (ShouldSkip("OCC.S.A0031")) { + NextTest(); + return; + } + err = TestStep4iThReadsTheOptionalAttributePhysicalContactUnoccupiedToOccupiedDelayInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList\n"); + if (ShouldSkip("OCC.S.A0032")) { + NextTest(); + return; + } + err = TestStep4jThReadsOptionalAttributePhysicalContactUnoccupiedToOccupiedThresholdInAttributeList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute\n"); + err = TestStep6ThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); + err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_16(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 17; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsOptionalAttributePIROccupiedToUnoccupiedDelayInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads optional attribute(PIROccupiedToUnoccupiedDelay) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsOptionalAttributePIRUnoccupiedToOccupiedDelayInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads optional attribute(PIRUnoccupiedToOccupiedDelay) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsOptionalAttributePIRUnoccupiedToOccupiedThresholdInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads optional attribute(PIRUnoccupiedToOccupiedThreshold) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsOptionalAttributeUltrasonicOccupiedToUnoccupiedDelayInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads optional attribute(UltrasonicOccupiedToUnoccupiedDelay) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedDelayInAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedDelay) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThReadsOptionalAttributeUltrasonicUnoccupiedToOccupiedThresholdInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4g: TH reads optional attribute(UltrasonicUnoccupiedToOccupiedThreshold) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsOptionalAttributePhysicalContactOccupiedToUnoccupiedDelayInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads optional attribute(PhysicalContactOccupiedToUnoccupiedDelay) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThReadsTheOptionalAttributePhysicalContactUnoccupiedToOccupiedDelayInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads the optional attribute(PhysicalContactUnoccupiedToOccupiedDelay) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsOptionalAttributePhysicalContactUnoccupiedToOccupiedThresholdInAttributeList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads optional attribute(PhysicalContactUnoccupiedToOccupiedThreshold) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OCC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OCC_2_1() + : TestCommandBridge("Test_TC_OCC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OCC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0x0000) Occupancy attribute\n"); + if (ShouldSkip("OCC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutThe0x0000OccupancyAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute\n"); + if (ShouldSkip("OCC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutThe0x0001OccupancySensorTypeAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute\n"); + if (ShouldSkip("OCC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4thReadsFromTheDutThe0x0002OccupancySensorTypeBitmapAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor\n"); + if (ShouldSkip("OCC.S.A0010")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutThe0x0010PIROccupiedToUnoccupiedDelayOptionalAttributeIfPirSensor_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor\n"); + if (ShouldSkip("OCC.S.A0011")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutThe0x0011PIRUnoccupiedToOccupiedDelayOptionalAttributeIfPirSensor_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor\n"); + if (ShouldSkip("OCC.S.A0012")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutThe0x0012PIRUnoccupiedToOccupiedThresholdOptionalAttributeIfPirSensor_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor\n"); + if (ShouldSkip("OCC.S.A0020")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutThe0x0020UltrasonicOccupiedToUnoccupiedDelayOptionalAttributeIfUltrasonicSensor_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor\n"); + if (ShouldSkip("OCC.S.A0021")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutThe0x0021UltrasonicUnoccupiedToOccupiedDelayOptionalAttributeIfUltrasonicSensor_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor\n"); + if (ShouldSkip("OCC.S.A0022")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutThe0x0022UltrasonicUnoccupiedToOccupiedThresholdOptionalAttributeIfUltrasonicSensor_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor\n"); + if (ShouldSkip("OCC.S.A0030")) { + NextTest(); + return; + } + err = TestStep11thReadsFromTheDutThe0x0030PhysicalContactOccupiedToUnoccupiedDelayOptionalAttributeIfPhysicalContactSensor_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor\n"); + if (ShouldSkip("OCC.S.A0031")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutThe0x0031PhysicalContactUnoccupiedToOccupiedDelayOptionalAttributeIfPhysicalContactSensor_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor\n"); + if (ShouldSkip("OCC.S.A0032")) { + NextTest(); + return; + } + err = TestStep13ThReadsFromTheDutThe0x0032PhysicalContactUnoccupiedToOccupiedThresholdOptionalAttributeIfPhysicalContactSensor_12(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 13; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutThe0x0000OccupancyAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOccupancyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the (0x0000) Occupancy attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the (0x0000) Occupancy attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("occupancy", "bitmap8", "bitmap8")); + VerifyOrReturn(CheckConstraintMinValue("occupancy", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("occupancy", [value unsignedCharValue], 1U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutThe0x0001OccupancySensorTypeAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOccupancySensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the (0x0001) OccupancySensorType attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("occupancySensorType", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("occupancySensorType", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("occupancySensorType", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4thReadsFromTheDutThe0x0002OccupancySensorTypeBitmapAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOccupancySensorTypeBitmapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute: Error: %@", err); + } else { + NSLog(@"Step 4:TH reads from the DUT the (0x0002) OccupancySensorTypeBitmap attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("occupancySensorTypeBitmap", "bitmap8", "bitmap8")); + VerifyOrReturn(CheckConstraintMinValue("occupancySensorTypeBitmap", [value unsignedCharValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("occupancySensorTypeBitmap", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutThe0x0010PIROccupiedToUnoccupiedDelayOptionalAttributeIfPirSensor_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePIROccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the (0x0010) PIROccupiedToUnoccupiedDelay optional attribute, if PIR sensor: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("PIROccupiedToUnoccupiedDelay", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("PIROccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PIROccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutThe0x0011PIRUnoccupiedToOccupiedDelayOptionalAttributeIfPirSensor_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePIRUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the (0x0011) PIRUnoccupiedToOccupiedDelay optional attribute, if PIR sensor: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("PIRUnoccupiedToOccupiedDelay", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("PIRUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("PIRUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutThe0x0012PIRUnoccupiedToOccupiedThresholdOptionalAttributeIfPirSensor_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePIRUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the (0x0012) PIRUnoccupiedToOccupiedThreshold optional attribute, if PIR sensor: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("PIRUnoccupiedToOccupiedThreshold", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("PIRUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("PIRUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutThe0x0020UltrasonicOccupiedToUnoccupiedDelayOptionalAttributeIfUltrasonicSensor_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUltrasonicOccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the (0x0020) UltrasonicOccupiedToUnoccupiedDelay optional attribute, if ultrasonic sensor: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("ultrasonicOccupiedToUnoccupiedDelay", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("ultrasonicOccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("ultrasonicOccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutThe0x0021UltrasonicUnoccupiedToOccupiedDelayOptionalAttributeIfUltrasonicSensor_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUltrasonicUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the (0x0021) UltrasonicUnoccupiedToOccupiedDelay optional attribute, if ultrasonic sensor: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("ultrasonicUnoccupiedToOccupiedDelay", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("ultrasonicUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("ultrasonicUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutThe0x0022UltrasonicUnoccupiedToOccupiedThresholdOptionalAttributeIfUltrasonicSensor_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUltrasonicUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the (0x0022) UltrasonicUnoccupiedToOccupiedThreshold optional attribute, if ultrasonic sensor: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("ultrasonicUnoccupiedToOccupiedThreshold", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("ultrasonicUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("ultrasonicUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11thReadsFromTheDutThe0x0030PhysicalContactOccupiedToUnoccupiedDelayOptionalAttributeIfPhysicalContactSensor_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePhysicalContactOccupiedToUnoccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor: Error: %@", err); + } else { + NSLog(@"Step 11:TH reads from the DUT the (0x0030) PhysicalContactOccupiedToUnoccupiedDelay optional attribute, if Physical Contact sensor: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("physicalContactOccupiedToUnoccupiedDelay", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("physicalContactOccupiedToUnoccupiedDelay", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("physicalContactOccupiedToUnoccupiedDelay", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutThe0x0031PhysicalContactUnoccupiedToOccupiedDelayOptionalAttributeIfPhysicalContactSensor_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePhysicalContactUnoccupiedToOccupiedDelayWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the (0x0031) PhysicalContactUnoccupiedToOccupiedDelay optional attribute, if Physical Contact sensor: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("physicalContactUnoccupiedToOccupiedDelay", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("physicalContactUnoccupiedToOccupiedDelay", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("physicalContactUnoccupiedToOccupiedDelay", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13ThReadsFromTheDutThe0x0032PhysicalContactUnoccupiedToOccupiedThresholdOptionalAttributeIfPhysicalContactSensor_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePhysicalContactUnoccupiedToOccupiedThresholdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor: Error: %@", err); + } else { + NSLog(@"Step 13: TH reads from the DUT the (0x0032) PhysicalContactUnoccupiedToOccupiedThreshold optional attribute, if Physical Contact sensor: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("physicalContactUnoccupiedToOccupiedThreshold", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("physicalContactUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("physicalContactUnoccupiedToOccupiedThreshold", [value unsignedCharValue], 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OCC_2_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OCC_2_3() + : TestCommandBridge("Test_TC_OCC_2_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OCC_2_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OCC_2_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OCC_2_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads OccupancySensorType attribute from DUT\n"); + if (ShouldSkip("OCC.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsOccupancySensorTypeAttributeFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT\n"); + if (ShouldSkip("OCC.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsOccupancySensorTypeBitmapAttributeFromDut_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsOccupancySensorTypeAttributeFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOccupancySensorTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads OccupancySensorType attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads OccupancySensorType attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("occupancySensorType", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("occupancySensorType", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("occupancySensorType", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsOccupancySensorTypeBitmapAttributeFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOccupancySensing alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOccupancySensorTypeBitmapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads OccupancySensorTypeBitmap attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("occupancySensorTypeBitmap", "bitmap8", "bitmap8")); + VerifyOrReturn(CheckConstraintMinValue("occupancySensorTypeBitmap", [value unsignedCharValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("occupancySensorTypeBitmap", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OO_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OO_1_1() + : TestCommandBridge("Test_TC_OO_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OO_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip("( !OO.S.F00 && !OO.S.F01 )")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("OO.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenOosf00ltEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("OO.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenOosf01dfEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList\n"); + if (ShouldSkip("OO.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheFeatureDependentOOSF00AttributeInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList\n"); + if (ShouldSkip("OO.S.F00")) { + NextTest(); + return; + } + err = TestStep6bThReadsTheFeatureDependentOOSF00CommandsInAcceptedCommandList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("clusterRevision", [value unsignedShortValue], 5U)); + VerifyOrReturn(CheckConstraintMaxValue("clusterRevision", [value unsignedShortValue], 6U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenOosf00ltEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given OO.S.F00(LT) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenOosf01dfEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given OO.S.F01(DF) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheFeatureDependentOOSF00AttributeInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the feature dependent(OO.S.F00) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16384UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16385UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16386UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16387UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsTheFeatureDependentOOSF00CommandsInAcceptedCommandList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads the feature dependent(OO.S.F00) commands in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 65UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 66UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OO_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OO_2_1() + : TestCommandBridge("Test_TC_OO_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OO_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the OnOff attribute from the DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsTheOnOffAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the GlobalSceneControl attribute from the DUT\n"); + if (ShouldSkip("OO.S.A4000")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheGlobalSceneControlAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the OnTime attribute from the DUT\n"); + if (ShouldSkip("OO.S.A4001")) { + NextTest(); + return; + } + err = TestStep4ThReadsTheOnTimeAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the OffWaitTime attribute from the DUT\n"); + if (ShouldSkip("OO.S.A4002")) { + NextTest(); + return; + } + err = TestStep5ThReadsTheOffWaitTimeAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads the StartUpOnOff attribute from the DUT\n"); + if (ShouldSkip("OO.S.A4003")) { + NextTest(); + return; + } + err = TestStep6ThReadsTheStartUpOnOffAttributeFromTheDut_5(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 6; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheOnOffAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the OnOff attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the OnOff attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("onOff", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheGlobalSceneControlAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGlobalSceneControlWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the GlobalSceneControl attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the GlobalSceneControl attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("globalSceneControl", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheOnTimeAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the OnTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the OnTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("onTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("onTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("onTime", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheOffWaitTimeAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOffWaitTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the OffWaitTime attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the OffWaitTime attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("offWaitTime", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("offWaitTime", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("offWaitTime", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsTheStartUpOnOffAttributeFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartUpOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads the StartUpOnOff attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads the StartUpOnOff attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("startUpOnOff", "enum8", "enum8")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OO_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OO_2_2() + : TestCommandBridge("Test_TC_OO_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OO_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH sends Off command to DUT\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsOffCommandToDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: after a few seconds, TH reads OnOff attribute from DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep2bAfterAFewSecondsThReadsOnOffAttributeFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsOnCommandToDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: after a few seconds, TH reads OnOff attribute from DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep3bAfterAFewSecondsThReadsOnOffAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3c: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep3cThSendsOnCommandToDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: after a few seconds, TH reads OnOff attribute from DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep3dAfterAFewSecondsThReadsOnOffAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH sends Off command to DUT\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsOffCommandToDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: after a few seconds, TH reads OnOff attribute from DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep4bAfterAFewSecondsThReadsOnOffAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH sends Off command to DUT\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep4cThSendsOffCommandToDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: after a few seconds, TH reads OnOff attribute from DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep4dAfterAFewSecondsThReadsOnOffAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5c: TH sends Toggle command to DUT\n"); + if (ShouldSkip("OO.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep5cThSendsToggleCommandToDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait 1000ms\n"); + err = TestWait1000ms_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5d: after a few seconds, TH reads OnOff attribute from DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep5dAfterAFewSecondsThReadsOnOffAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : TH sends Toggle command to DUT\n"); + if (ShouldSkip("OO.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestThSendsToggleCommandToDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 1000ms\n"); + err = TestWait1000ms_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Check on/off attribute value is false after toggle command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterToggleCommand_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6a: Operate on device to set OnOff attribute manually to on\n"); + if (ShouldSkip("PICS_USER_PROMPT && OO.M.ManuallyControlled && OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep6aOperateOnDeviceToSetOnOffAttributeManuallyToOn_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6b: after a few seconds, TH reads OnOff attribute from DUT\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && OO.S.A0000 && OO.M.ManuallyControlled")) { + NextTest(); + return; + } + err = TestStep6bAfterAFewSecondsThReadsOnOffAttributeFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6c: Operate on device to set OnOff attribute manually to off\n"); + if (ShouldSkip("PICS_USER_PROMPT && OO.M.ManuallyControlled && OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep6cOperateOnDeviceToSetOnOffAttributeManuallyToOff_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 6d: after a few seconds, TH reads OnOff attribute from DUT\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && OO.S.A0000 && OO.M.ManuallyControlled")) { + NextTest(); + return; + } + err = TestStep6dAfterAFewSecondsThReadsOnOffAttributeFromDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Reset Off Command\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestResetOffCommand_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Check on/off attribute value is false after off command\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 23; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2aThSendsOffCommandToDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends Off command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends Off command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bAfterAFewSecondsThReadsOnOffAttributeFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: after a few seconds, TH reads OnOff attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsOnCommandToDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bAfterAFewSecondsThReadsOnOffAttributeFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: after a few seconds, TH reads OnOff attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThSendsOnCommandToDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dAfterAFewSecondsThReadsOnOffAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: after a few seconds, TH reads OnOff attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsOffCommandToDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends Off command to DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends Off command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bAfterAFewSecondsThReadsOnOffAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: after a few seconds, TH reads OnOff attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThSendsOffCommandToDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH sends Off command to DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH sends Off command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dAfterAFewSecondsThReadsOnOffAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4d: after a few seconds, TH reads OnOff attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5cThSendsToggleCommandToDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster toggleWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5c: TH sends Toggle command to DUT: Error: %@", err); + } else { + NSLog(@"Step 5c: TH sends Toggle command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait1000ms_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5dAfterAFewSecondsThReadsOnOffAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5d: after a few seconds, TH reads OnOff attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestThSendsToggleCommandToDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster toggleWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH sends Toggle command to DUT: Error: %@", err); + } else { + NSLog(@"TH sends Toggle command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait1000ms_15() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterToggleCommand_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after toggle command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after toggle command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aOperateOnDeviceToSetOnOffAttributeManuallyToOn_17() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep6bAfterAFewSecondsThReadsOnOffAttributeFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6b: after a few seconds, TH reads OnOff attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cOperateOnDeviceToSetOnOffAttributeManuallyToOff_19() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep6dAfterAFewSecondsThReadsOnOffAttributeFromDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: after a few seconds, TH reads OnOff attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 6d: after a few seconds, TH reads OnOff attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestResetOffCommand_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Reset Off Command: Error: %@", err); + } else { + NSLog(@"Reset Off Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OO_2_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OO_2_4() + : TestCommandBridge("Test_TC_OO_2_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OO_2_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OO_2_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OO_2_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH sends On command to DUT\n"); + if (ShouldSkip("OO.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsOnCommandToDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT\n"); + if (ShouldSkip("OO.S.A4003")) { + NextTest(); + return; + } + err = TestStep3aThWritesAValueOf0ToStartUpOnOffAttributeOfDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Reboot target device\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep3bRebootTargetDevice_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Reboot target device(DUT)\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep3cRebootTargetDeviceDUT_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: TH reads the OnOff attribute from the DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep3dThReadsTheOnOffAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT\n"); + if (ShouldSkip("OO.S.A4003")) { + NextTest(); + return; + } + err = TestStep4aThWritesAValueOf1ToStartUpOnOffAttributeOfDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: Reboot target device\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep4bRebootTargetDevice_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: Reboot target device(DUT)\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep4cRebootTargetDeviceDUT_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: TH reads the OnOff attribute from the DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheOnOffAttributeFromTheDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT\n"); + if (ShouldSkip("OO.S.A4003")) { + NextTest(); + return; + } + err = TestStep5aThWritesAValueOf2ToStartUpOnOffAttributeOfDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5b: Reboot target device\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep5bRebootTargetDevice_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5c: Reboot target device(DUT)\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep5cRebootTargetDeviceDUT_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5d: TH reads the OnOff attribute from the DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep5dThReadsTheOnOffAttributeFromTheDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5e: Reboot target device\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep5eRebootTargetDevice_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5f: Reboot target device(DUT)\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep5fRebootTargetDeviceDUT_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5g: TH reads the OnOff attribute from the DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep5gThReadsTheOnOffAttributeFromTheDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 6a: TH writes NULL to StartUpOnOff attribute of DUT\n"); + if (ShouldSkip("OO.S.A4003")) { + NextTest(); + return; + } + err = TestStep6aThWritesNullToStartUpOnOffAttributeOfDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 6b: Reboot target device\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep6bRebootTargetDevice_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6c: Reboot target device(DUT)\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep6cRebootTargetDeviceDUT_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 6d: TH reads the OnOff attribute from the DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep6dThReadsTheOnOffAttributeFromTheDut_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 6e: TH sends Off command to DUT\n"); + if (ShouldSkip("OO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6eThSendsOffCommandToDut_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 6f: TH reads the OnOff attribute from the DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep6fThReadsTheOnOffAttributeFromTheDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6g: Reboot target device\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep6gRebootTargetDevice_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 6h: Reboot target device(DUT)\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep6hRebootTargetDeviceDUT_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 6i: TH reads the OnOff attribute from the DUT\n"); + if (ShouldSkip("OO.S.A0000")) { + NextTest(); + return; + } + err = TestStep6iThReadsTheOnOffAttributeFromTheDut_31(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 32; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThSendsOnCommandToDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends On command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends On command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThWritesAValueOf0ToStartUpOnOffAttributeOfDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id startUpOnOffArgument; + startUpOnOffArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH writes a value of 0 to StartUpOnOff attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bRebootTargetDevice_3() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestStep3cRebootTargetDeviceDUT_4() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep3dThReadsTheOnOffAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads the OnOff attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads the OnOff attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThWritesAValueOf1ToStartUpOnOffAttributeOfDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id startUpOnOffArgument; + startUpOnOffArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH writes a value of 1 to StartUpOnOff attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bRebootTargetDevice_8() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestStep4cRebootTargetDeviceDUT_9() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_10() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep4dThReadsTheOnOffAttributeFromTheDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the OnOff attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the OnOff attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThWritesAValueOf2ToStartUpOnOffAttributeOfDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id startUpOnOffArgument; + startUpOnOffArgument = + [NSNumber numberWithUnsignedChar:2U]; + [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 5a: TH writes a value of 2 to StartUpOnOff attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bRebootTargetDevice_13() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestStep5cRebootTargetDeviceDUT_14() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_15() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep5dThReadsTheOnOffAttributeFromTheDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5d: TH reads the OnOff attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5d: TH reads the OnOff attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5eRebootTargetDevice_17() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestStep5fRebootTargetDeviceDUT_18() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_19() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep5gThReadsTheOnOffAttributeFromTheDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5g: TH reads the OnOff attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5g: TH reads the OnOff attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThWritesNullToStartUpOnOffAttributeOfDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id startUpOnOffArgument; + startUpOnOffArgument = nil; + [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH writes NULL to StartUpOnOff attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 6a: TH writes NULL to StartUpOnOff attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bRebootTargetDevice_22() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestStep6cRebootTargetDeviceDUT_23() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_24() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep6dThReadsTheOnOffAttributeFromTheDut_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: TH reads the OnOff attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6d: TH reads the OnOff attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6eThSendsOffCommandToDut_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6e: TH sends Off command to DUT: Error: %@", err); + } else { + NSLog(@"Step 6e: TH sends Off command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6fThReadsTheOnOffAttributeFromTheDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6f: TH reads the OnOff attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6f: TH reads the OnOff attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6gRebootTargetDevice_28() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestStep6hRebootTargetDeviceDUT_29() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_30() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep6iThReadsTheOnOffAttributeFromTheDut_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6i: TH reads the OnOff attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6i: TH reads the OnOff attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OPSTATE_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OPSTATE_1_1() + : TestCommandBridge("Test_TC_OPSTATE_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OPSTATE_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OPSTATE_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OPSTATE_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT\n"); + if (ShouldSkip("OPSTATE.S.A0002")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5a: TH reads from the DUT the EventList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5b: TH reads from the DUT the optional event(OperationCompletion) in EventList.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && OPSTATE.S.E01")) { + NextTest(); + return; + } + NextTest(); + return; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: TH reads the optional command(Start) in AcceptedCommandList\n"); + if (ShouldSkip("OPSTATE.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep6aThReadsTheOptionalCommandStartInAcceptedCommandList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6b: TH reads the optional command(Stop) in AcceptedCommandList\n"); + if (ShouldSkip("OPSTATE.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6c: TH reads the optional command(Pause) in AcceptedCommandList\n"); + if (ShouldSkip("OPSTATE.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6cThReadsTheOptionalCommandPauseInAcceptedCommandList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6d: TH reads the optional command(Resume) in AcceptedCommandList\n"); + if (ShouldSkip("OPSTATE.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH reads from the DUT the AcceptedCommandList attribute\n"); + if (ShouldSkip("!OPSTATE.S.C00.Rsp && !OPSTATE.S.C01.Rsp && !OPSTATE.S.C02.Rsp && !OPSTATE.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheAcceptedCommandListAttribute_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); + if (ShouldSkip("(OPSTATE.S.C00.Rsp || OPSTATE.S.C01.Rsp || OPSTATE.S.C02.Rsp || OPSTATE.S.C03.Rsp)")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 14; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsTheOptionalCommandStartInAcceptedCommandList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads the optional command(Start) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads the optional command(Start) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cThReadsTheOptionalCommandPauseInAcceptedCommandList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: TH reads the optional command(Pause) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6c: TH reads the optional command(Pause) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheAcceptedCommandListAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the AcceptedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PS_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PS_1_1() + : TestCommandBridge("Test_TC_PS_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PS_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PS_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PS_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap\n"); + if (ShouldSkip(" !PS.S.F00 && !PS.S.F01 && !PS.S.F02 && !PS.S.F03 ")) { + NextTest(); + return; + } + err = TestStep3aReadTheGlobalAttributeFeatureMap_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PS.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenPssf00wiredEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PS.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenPssf01batEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PS.S.F02")) { + NextTest(); + return; + } + err = TestStep3cGivenPssf02rechgEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PS.S.F03")) { + NextTest(); + return; + } + err = TestStep3dGivenPssf03replcEnsureFeaturemapHasTheCorrectBitSet_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ReadTheGlobalAttributeAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ReadTheGlobalAttributeAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: Read the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList\n"); + if (ShouldSkip("PS.S.F00")) { + NextTest(); + return; + } + err = TestStep4aReadTheFeatureDependentPSSF00WiredAttributeInAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: Read the Feature dependent(PS.S.F01-BAT) attribute in AttributeList\n"); + if (ShouldSkip("PS.S.F01")) { + NextTest(); + return; + } + err = TestStep4bReadTheFeatureDependentPSSF01BatAttributeInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: Read the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList\n"); + if (ShouldSkip("PS.S.F02")) { + NextTest(); + return; + } + err = TestStep4cReadTheFeatureDependentPSSF02RechgAttributeInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: Read the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList\n"); + if (ShouldSkip("PS.S.F03")) { + NextTest(); + return; + } + err = TestStep4dReadTheFeatureDependentPSSF03ReplcAttributeInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5: Read the global attribute: AcceptedCommandList\n"); + err = TestStep5ReadTheGlobalAttributeAcceptedCommandList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6: Read the global attribute: GeneratedCommandList\n"); + err = TestStep6ReadTheGlobalAttributeGeneratedCommandList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7a: Read the global attribute: EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !PS.S.E00 && !PS.S.E01 && !PS.S.E02 ")) { + NextTest(); + return; + } + NextTest(); + return; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7b: Read PS.S.E00(WiredFaultChange) event in EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E00")) { + NextTest(); + return; + } + NextTest(); + return; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 7c: Read PS.S.E01(BatFaultChange) event in EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E01")) { + NextTest(); + return; + } + NextTest(); + return; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 7d: Read PS.S.E02(BatChargeFaultChange) event in EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PS.S.E02")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 19; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMap_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: FeatureMap: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: FeatureMap: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenPssf00wiredEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given PS.S.F00(WIRED) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenPssf01batEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given PS.S.F01(BAT) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenPssf02rechgEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given PS.S.F02(RECHG) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenPssf03replcEnsureFeaturemapHasTheCorrectBitSet_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given PS.S.F03(REPLC) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ReadTheGlobalAttributeAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheFeatureDependentPSSF00WiredAttributeInAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the Feature dependent(PS.S.F00-WIRED) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheFeatureDependentPSSF01BatAttributeInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the Feature dependent(PS.S.F01-BAT) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the Feature dependent(PS.S.F01-BAT) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cReadTheFeatureDependentPSSF02RechgAttributeInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Read the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: Read the Feature dependent(PS.S.F02-RECHG) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dReadTheFeatureDependentPSSF03ReplcAttributeInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: Read the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: Read the Feature dependent(PS.S.F03-REPLC) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ReadTheGlobalAttributeAcceptedCommandList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 5: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ReadTheGlobalAttributeGeneratedCommandList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PS_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PS_2_1() + : TestCommandBridge("Test_TC_PS_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PS_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PS_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PS_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Test Harness Client reads Status from server DUT\n"); + if (ShouldSkip("PS.S.A0000")) { + NextTest(); + return; + } + err = TestStep2TestHarnessClientReadsStatusFromServerDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Test Harness Client reads Order from server DUT\n"); + if (ShouldSkip("PS.S.A0001")) { + NextTest(); + return; + } + err = TestStep3TestHarnessClientReadsOrderFromServerDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: Test Harness Client reads Order from server DUT\n"); + if (ShouldSkip("PS.S.A0002")) { + NextTest(); + return; + } + err = TestStep4TestHarnessClientReadsOrderFromServerDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT\n"); + if (ShouldSkip("PS.S.A0003")) { + NextTest(); + return; + } + err = TestStep5TestHarnessClientReadsWiredAssessedInputVoltageFromServerDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT\n"); + if (ShouldSkip("PS.S.A0004")) { + NextTest(); + return; + } + err = TestStep6TestHarnessClientReadsWiredAssessedInputFrequencyfromServerDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: Test Harness Client reads WiredCurrentType from server DUT\n"); + if (ShouldSkip("PS.S.A0005")) { + NextTest(); + return; + } + err = TestStep7TestHarnessClientReadsWiredCurrentTypeFromServerDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT\n"); + if (ShouldSkip("PS.S.A0006")) { + NextTest(); + return; + } + err = TestStep8TestHarnessClientReadsWiredAssessedCurrentFromServerDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: Test Harness Client reads WiredNominalVoltage from server DUT\n"); + if (ShouldSkip("PS.S.A0007")) { + NextTest(); + return; + } + err = TestStep9TestHarnessClientReadsWiredNominalVoltageFromServerDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT\n"); + if (ShouldSkip("PS.S.A0008")) { + NextTest(); + return; + } + err = TestStep10TestHarnessClientReadsWiredMaximumCurrentFromServerDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: Test Harness Client reads WiredPresent from Server DUT\n"); + if (ShouldSkip("PS.S.A0009")) { + NextTest(); + return; + } + err = TestStep11TestHarnessClientReadsWiredPresentFromServerDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT\n"); + if (ShouldSkip("PS.S.A000a")) { + NextTest(); + return; + } + err = TestStep12TestHarnessClientReadsActiveWiredFaultsFromServerDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: Test Harness Client reads BatVoltage from Server DUT\n"); + if (ShouldSkip("PS.S.A000b")) { + NextTest(); + return; + } + err = TestStep13TestHarnessClientReadsBatVoltageFromServerDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: Test Harness Client reads BatPercentRemaining from Server DUT\n"); + if (ShouldSkip("PS.S.A000c")) { + NextTest(); + return; + } + err = TestStep14TestHarnessClientReadsBatPercentRemainingFromServerDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: Test Harness Client reads BatTimeRemaining from Server DUT\n"); + if (ShouldSkip("PS.S.A000d")) { + NextTest(); + return; + } + err = TestStep15TestHarnessClientReadsBatTimeRemainingFromServerDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: Test Harness Client reads BatChargeLevel from Server DUT\n"); + if (ShouldSkip("PS.S.A000e")) { + NextTest(); + return; + } + err = TestStep16TestHarnessClientReadsBatChargeLevelFromServerDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT\n"); + if (ShouldSkip("PS.S.A000f")) { + NextTest(); + return; + } + err = TestStep17TestHarnessClientReadsBatReplacementNeededFromServerDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: Test Harness Client reads BatReplaceability from Server DUT\n"); + if (ShouldSkip("PS.S.A0010")) { + NextTest(); + return; + } + err = TestStep18TestHarnessClientReadsBatReplaceabilityFromServerDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: Test Harness Client reads BatPresent from Server DUT\n"); + if (ShouldSkip("PS.S.A0011")) { + NextTest(); + return; + } + err = TestStep19TestHarnessClientReadsBatPresentFromServerDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: Test Harness Client readsActiveBatFaults from Server DUT\n"); + if (ShouldSkip("PS.S.A0012")) { + NextTest(); + return; + } + err = TestStep20TestHarnessClientReadsActiveBatFaultsFromServerDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 21: Test Harness Client reads BatReplacementDescription from Server DUT\n"); + if (ShouldSkip("PS.S.A0013")) { + NextTest(); + return; + } + err = TestStep21TestHarnessClientReadsBatReplacementDescriptionFromServerDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 22: Test Harness Client reads BatCommonDesignation from Server DUT\n"); + if (ShouldSkip("PS.S.A0014")) { + NextTest(); + return; + } + err = TestStep22TestHarnessClientReadsBatCommonDesignationFromServerDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 23: Test Harness Client reads BatANSIDesignation from Server DUT\n"); + if (ShouldSkip("PS.S.A0015")) { + NextTest(); + return; + } + err = TestStep23TestHarnessClientReadsBatANSIDesignationFromServerDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 24: Test Harness Client reads BatIECDesignation from Server DUT\n"); + if (ShouldSkip("PS.S.A0016")) { + NextTest(); + return; + } + err = TestStep24TestHarnessClientReadsBatIECDesignationFromServerDut_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT\n"); + if (ShouldSkip("PS.S.A0017")) { + NextTest(); + return; + } + err = TestStep25TestHarnessClientReadsBatApprovedChemistryFromServerDut_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 26: Test Harness Client reads BatCapacity from Server DUT\n"); + if (ShouldSkip("PS.S.A0018")) { + NextTest(); + return; + } + err = TestStep26TestHarnessClientReadsBatCapacityFromServerDut_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 27: Test Harness Client reads BatQuantity from Server DUT\n"); + if (ShouldSkip("PS.S.A0019")) { + NextTest(); + return; + } + err = TestStep27TestHarnessClientReadsBatQuantityFromServerDut_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 28: Test Harness Client reads BatChargeState from Server DUT\n"); + if (ShouldSkip("PS.S.A001a")) { + NextTest(); + return; + } + err = TestStep28TestHarnessClientReadsBatChargeStateFromServerDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT\n"); + if (ShouldSkip("PS.S.A001b")) { + NextTest(); + return; + } + err = TestStep29TestHarnessClientReadsBatTimeToFullChargeFromServerDut_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT\n"); + if (ShouldSkip("PS.S.A001c")) { + NextTest(); + return; + } + err = TestStep30TestHarnessClientReadsBatFunctionalWhileChargingFromServerDut_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Step 31: Test Harness Client reads BatChargingCurrent from Server DUT\n"); + if (ShouldSkip("PS.S.A001d")) { + NextTest(); + return; + } + err = TestStep31TestHarnessClientReadsBatChargingCurrentFromServerDut_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT\n"); + if (ShouldSkip("PS.S.A001e")) { + NextTest(); + return; + } + err = TestStep32TestHarnessClientReadsActiveBatChargeFaultsFromServerDut_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Step 33: Test Harness Client reads EndpointList from Server DUT\n"); + if (ShouldSkip("PS.S.A001f")) { + NextTest(); + return; + } + err = TestStep33TestHarnessClientReadsEndpointListFromServerDut_32(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 33; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2TestHarnessClientReadsStatusFromServerDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Test Harness Client reads Status from server DUT: Error: %@", err); + } else { + NSLog(@"Step 2: Test Harness Client reads Status from server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("status", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("status", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("status", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3TestHarnessClientReadsOrderFromServerDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOrderWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: Test Harness Client reads Order from server DUT: Error: %@", err); + } else { + NSLog(@"Step 3: Test Harness Client reads Order from server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("order", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("order", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("order", [value unsignedCharValue], 255U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4TestHarnessClientReadsOrderFromServerDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: Test Harness Client reads Order from server DUT: Error: %@", err); + } else { + NSLog(@"Step 4: Test Harness Client reads Order from server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("description", "char_string", "char_string")); + VerifyOrReturn(CheckConstraintMaxLength("description", value, 60)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5TestHarnessClientReadsWiredAssessedInputVoltageFromServerDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWiredAssessedInputVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT: Error: %@", err); + } else { + NSLog(@"Step 5: Test Harness Client reads WiredAssessedInputVoltage from server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("wiredAssessedInputVoltage", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("wiredAssessedInputVoltage", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedInputVoltage", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6TestHarnessClientReadsWiredAssessedInputFrequencyfromServerDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWiredAssessedInputFrequencyWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT: Error: %@", err); + } else { + NSLog(@"Step 6: Test Harness Client reads WiredAssessedInputFrequencyfrom server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("wiredAssessedInputFrequency", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("wiredAssessedInputFrequency", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedInputFrequency", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7TestHarnessClientReadsWiredCurrentTypeFromServerDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWiredCurrentTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Test Harness Client reads WiredCurrentType from server DUT: Error: %@", err); + } else { + NSLog(@"Step 7: Test Harness Client reads WiredCurrentType from server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("wiredCurrentType", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("wiredCurrentType", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("wiredCurrentType", [value unsignedCharValue], 1U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8TestHarnessClientReadsWiredAssessedCurrentFromServerDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWiredAssessedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT: Error: %@", err); + } else { + NSLog(@"Step 8: Test Harness Client reads WiredAssessedCurrent from server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("wiredAssessedCurrent", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("wiredAssessedCurrent", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("wiredAssessedCurrent", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9TestHarnessClientReadsWiredNominalVoltageFromServerDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWiredNominalVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: Test Harness Client reads WiredNominalVoltage from server DUT: Error: %@", err); + } else { + NSLog(@"Step 9: Test Harness Client reads WiredNominalVoltage from server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("wiredNominalVoltage", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("wiredNominalVoltage", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("wiredNominalVoltage", [value unsignedIntValue], 4294967295UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10TestHarnessClientReadsWiredMaximumCurrentFromServerDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWiredMaximumCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 10: Test Harness Client reads WiredMaximumCurrent from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("wiredMaximumCurrent", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("wiredMaximumCurrent", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("wiredMaximumCurrent", [value unsignedIntValue], 4294967295UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11TestHarnessClientReadsWiredPresentFromServerDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWiredPresentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: Test Harness Client reads WiredPresent from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 11: Test Harness Client reads WiredPresent from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("wiredPresent", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12TestHarnessClientReadsActiveWiredFaultsFromServerDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeActiveWiredFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 12: Test Harness Client reads ActiveWiredFaults from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("activeWiredFaults", "list", "list")); + VerifyOrReturn(CheckConstraintMaxLength("activeWiredFaults", value, 8)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13TestHarnessClientReadsBatVoltageFromServerDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatVoltageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: Test Harness Client reads BatVoltage from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 13: Test Harness Client reads BatVoltage from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("batVoltage", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("batVoltage", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("batVoltage", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep14TestHarnessClientReadsBatPercentRemainingFromServerDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatPercentRemainingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14: Test Harness Client reads BatPercentRemaining from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 14: Test Harness Client reads BatPercentRemaining from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("batPercentRemaining", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("batPercentRemaining", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("batPercentRemaining", [value unsignedCharValue], 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep15TestHarnessClientReadsBatTimeRemainingFromServerDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatTimeRemainingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 15: Test Harness Client reads BatTimeRemaining from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 15: Test Harness Client reads BatTimeRemaining from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("batTimeRemaining", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("batTimeRemaining", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("batTimeRemaining", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16TestHarnessClientReadsBatChargeLevelFromServerDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatChargeLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16: Test Harness Client reads BatChargeLevel from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 16: Test Harness Client reads BatChargeLevel from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batChargeLevel", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("batChargeLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("batChargeLevel", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep17TestHarnessClientReadsBatReplacementNeededFromServerDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatReplacementNeededWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 17: Test Harness Client reads BatReplacementNeeded from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batReplacementNeeded", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep18TestHarnessClientReadsBatReplaceabilityFromServerDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatReplaceabilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 18: Test Harness Client reads BatReplaceability from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 18: Test Harness Client reads BatReplaceability from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batReplaceability", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("batReplaceability", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("batReplaceability", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep19TestHarnessClientReadsBatPresentFromServerDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatPresentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 19: Test Harness Client reads BatPresent from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 19: Test Harness Client reads BatPresent from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batPresent", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep20TestHarnessClientReadsActiveBatFaultsFromServerDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeActiveBatFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 20: Test Harness Client readsActiveBatFaults from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 20: Test Harness Client readsActiveBatFaults from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("activeBatFaults", "list", "list")); + VerifyOrReturn(CheckConstraintMaxLength("activeBatFaults", value, 8)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep21TestHarnessClientReadsBatReplacementDescriptionFromServerDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatReplacementDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 21: Test Harness Client reads BatReplacementDescription from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 21: Test Harness Client reads BatReplacementDescription from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batReplacementDescription", "char_string", "char_string")); + VerifyOrReturn(CheckConstraintMaxLength("batReplacementDescription", value, 60)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep22TestHarnessClientReadsBatCommonDesignationFromServerDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatCommonDesignationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 22: Test Harness Client reads BatCommonDesignation from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 22: Test Harness Client reads BatCommonDesignation from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batCommonDesignation", "enum16", "enum16")); + VerifyOrReturn(CheckConstraintMinValue("batCommonDesignation", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("batCommonDesignation", [value unsignedShortValue], 80U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep23TestHarnessClientReadsBatANSIDesignationFromServerDut_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatANSIDesignationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 23: Test Harness Client reads BatANSIDesignation from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 23: Test Harness Client reads BatANSIDesignation from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batANSIDesignation", "char_string", "char_string")); + VerifyOrReturn(CheckConstraintMaxLength("batANSIDesignation", value, 20)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep24TestHarnessClientReadsBatIECDesignationFromServerDut_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatIECDesignationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 24: Test Harness Client reads BatIECDesignation from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 24: Test Harness Client reads BatIECDesignation from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batIECDesignation", "char_string", "char_string")); + VerifyOrReturn(CheckConstraintMaxLength("batIECDesignation", value, 20)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep25TestHarnessClientReadsBatApprovedChemistryFromServerDut_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatApprovedChemistryWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 25: Test Harness Client reads BatApprovedChemistry from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batApprovedChemistry", "enum16", "enum16")); + VerifyOrReturn(CheckConstraintMinValue("batApprovedChemistry", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("batApprovedChemistry", [value unsignedShortValue], 32U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep26TestHarnessClientReadsBatCapacityFromServerDut_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatCapacityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 26: Test Harness Client reads BatCapacity from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 26: Test Harness Client reads BatCapacity from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batCapacity", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("batCapacity", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("batCapacity", [value unsignedIntValue], 4294967295UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep27TestHarnessClientReadsBatQuantityFromServerDut_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatQuantityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 27: Test Harness Client reads BatQuantity from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 27: Test Harness Client reads BatQuantity from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batQuantity", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("batQuantity", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("batQuantity", [value unsignedCharValue], 255U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep28TestHarnessClientReadsBatChargeStateFromServerDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatChargeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 28: Test Harness Client reads BatChargeState from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 28: Test Harness Client reads BatChargeState from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batChargeState", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("batChargeState", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("batChargeState", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep29TestHarnessClientReadsBatTimeToFullChargeFromServerDut_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatTimeToFullChargeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 29: Test Harness Client reads BatTimeToFullCharge from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("batTimeToFullCharge", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("batTimeToFullCharge", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("batTimeToFullCharge", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep30TestHarnessClientReadsBatFunctionalWhileChargingFromServerDut_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatFunctionalWhileChargingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 30: Test Harness Client reads BatFunctionalWhileCharging from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batFunctionalWhileCharging", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep31TestHarnessClientReadsBatChargingCurrentFromServerDut_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatChargingCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 31: Test Harness Client reads BatChargingCurrent from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 31: Test Harness Client reads BatChargingCurrent from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("batChargingCurrent", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("batChargingCurrent", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("batChargingCurrent", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep32TestHarnessClientReadsActiveBatChargeFaultsFromServerDut_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeActiveBatChargeFaultsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 32: Test Harness Client reads ActiveBatChargeFaults from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("activeBatChargeFaults", "list", "list")); + VerifyOrReturn(CheckConstraintMaxLength("activeBatChargeFaults", value, 16)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep33TestHarnessClientReadsEndpointListFromServerDut_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPowerSource alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEndpointListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 33: Test Harness Client reads EndpointList from Server DUT: Error: %@", err); + } else { + NSLog(@"Step 33: Test Harness Client reads EndpointList from Server DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("endpointList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PRS_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PRS_1_1() + : TestCommandBridge("Test_TC_PRS_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PRS_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip(" !PRS.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PRS.S.F00")) { + NextTest(); + return; + } + err = TestStep3GivenPrssf00extEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList\n"); + if (ShouldSkip("PRS.S.A0010")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeScaledValueInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList\n"); + if (ShouldSkip("PRS.S.A0011")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheOptionalAttributeMinScaledValueInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList\n"); + if (ShouldSkip("PRS.S.A0012")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheOptionalAttributeMaxScaledValueInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4e: TH reads the optional attribute(Scale) in AttributeList\n"); + if (ShouldSkip("PRS.S.A0014")) { + NextTest(); + return; + } + err = TestStep4eThReadsTheOptionalAttributeScaleInAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4f: TH reads the optional attribute(Tolerance) in AttributeList\n"); + if (ShouldSkip("PRS.S.A0003")) { + NextTest(); + return; + } + err = TestStep4fThReadsTheOptionalAttributeToleranceInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList\n"); + if (ShouldSkip("PRS.S.A0013")) { + NextTest(); + return; + } + err = TestStep4gThReadsTheOptionalAttributeScaledToleranceInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_14(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 15; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3GivenPrssf00extEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3: Given PRS.S.F00(EXT) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeScaledValueInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute(ScaledValue) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheOptionalAttributeMinScaledValueInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the optional attribute(MinScaledValue) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheOptionalAttributeMaxScaledValueInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the optional attribute(MaxScaledValue) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsTheOptionalAttributeScaleInAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads the optional attribute(Scale) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads the optional attribute(Scale) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsTheOptionalAttributeToleranceInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads the optional attribute(Tolerance) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThReadsTheOptionalAttributeScaledToleranceInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4g: TH reads the optional attribute(ScaledTolerance) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PRS_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PRS_2_1() + : TestCommandBridge("Test_TC_PRS_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PRS_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinMeasuredValue attribute.\n"); + if (ShouldSkip("PRS.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxMeasuredValue attribute.\n"); + if (ShouldSkip("PRS.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MeasuredValue attribute.\n"); + if (ShouldSkip("PRS.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the Tolerance attribute.\n"); + if (ShouldSkip("PRS.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutTheToleranceAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the MinScaledValue attribute.\n"); + if (ShouldSkip("PRS.S.A0011")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheMinScaledValueAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the MaxScaledValue attribute.\n"); + if (ShouldSkip("PRS.S.A0012")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheMaxScaledValueAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the ScaledValue attribute.\n"); + if (ShouldSkip("PRS.S.A0010")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheScaledValueAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the ScaledTolerance attribute.\n"); + if (ShouldSkip("PRS.S.A0013")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheScaledToleranceAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the Scale attribute.\n"); + if (ShouldSkip("PRS.S.A0014")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheScaleAttribute_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable MinMeasuredValueValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value shortValue], -32767)); + VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value shortValue], 32766)); + } + { + MinMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxMeasuredValueValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxMeasuredValueAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxMeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value shortValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value shortValue], 32767)); + } + { + MaxMeasuredValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMeasuredValueAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MeasuredValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value shortValue], MinMeasuredValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value shortValue], MaxMeasuredValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheToleranceAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the Tolerance attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the Tolerance attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MinScaledValueValue; + + CHIP_ERROR TestStep6ThReadsFromTheDutTheMinScaledValueAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the MinScaledValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the MinScaledValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minScaledValue", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("minScaledValue", [value shortValue], -32767)); + VerifyOrReturn(CheckConstraintMaxValue("minScaledValue", [value shortValue], 32766)); + } + { + MinScaledValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable MaxScaledValueValue; + + CHIP_ERROR TestStep7ThReadsFromTheDutTheMaxScaledValueAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the MaxScaledValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the MaxScaledValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxScaledValue", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("maxScaledValue", [value shortValue], MinScaledValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("maxScaledValue", [value shortValue], 32767)); + } + { + MaxScaledValueValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheScaledValueAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeScaledValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the ScaledValue attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the ScaledValue attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("scaledValue", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("scaledValue", [value shortValue], MinScaledValueValue)); + VerifyOrReturn(CheckConstraintMaxValue("scaledValue", [value shortValue], MaxScaledValueValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheScaledToleranceAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeScaledToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the ScaledTolerance attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the ScaledTolerance attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("scaledTolerance", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("scaledTolerance", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("scaledTolerance", [value unsignedShortValue], 2048U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheScaleAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeScaleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the Scale attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the Scale attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("scale", "int8s", "int8s")); + VerifyOrReturn(CheckConstraintMinValue("scale", [value charValue], -127)); + VerifyOrReturn(CheckConstraintMaxValue("scale", [value charValue], 127)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PRS_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PRS_2_2() + : TestCommandBridge("Test_TC_PRS_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PRS_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PRS_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PRS_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MeasuredValue attribute\n"); + if (ShouldSkip("PRS.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMeasuredValueAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: Operate on device to change the pressure significantly\n"); + if (ShouldSkip("PICS_USER_PROMPT && PRS.M.PressureChange")) { + NextTest(); + return; + } + err = TestStep3OperateOnDeviceToChangeThePressureSignificantly_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Wait 2s\n"); + err = TestWait2s_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute\n"); + if (ShouldSkip("PRS.S.A0000 && PRS.M.PressureChange")) { + NextTest(); + return; + } + err = TestStep4AfterAFewSecondsThReadsFromTheDutTheMeasuredValueAttribute_4(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable ValueBeforeChange; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMeasuredValueAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MeasuredValue attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MeasuredValue attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ValueBeforeChange = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3OperateOnDeviceToChangeThePressureSignificantly_2() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestWait2s_3() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 2000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4AfterAFewSecondsThReadsFromTheDutTheMeasuredValueAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPressureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute: Error: %@", err); + } else { + NSLog(@"Step 4: After a few seconds, TH reads from the DUT the MeasuredValue attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("measuredValue", value, ValueBeforeChange)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PCC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PCC_1_1() + : TestCommandBridge("Test_TC_PCC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PCC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap attribute from the DUT\n"); + if (ShouldSkip(" !PCC.S.F00 && !PCC.S.F01 && !PCC.S.F02 && !PCC.S.F03 && !PCC.S.F04 && !PCC.S.F05 && !PCC.S.F06 ")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PCC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenPccsf00prsconstEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PCC.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenPccsf01prscompEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PCC.S.F02")) { + NextTest(); + return; + } + err = TestStep3dGivenPccsf02flwEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PCC.S.F03")) { + NextTest(); + return; + } + err = TestStep3eGivenPccsf03spdEnsureFeaturemapHasTheCorrectBitSet_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PCC.S.F04")) { + NextTest(); + return; + } + err = TestStep3fGivenPccsf04tempEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PCC.S.F05")) { + NextTest(); + return; + } + err = TestStep3gGivenPccsf05autoEnsureFeaturemapHasTheCorrectBitSet_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("PCC.S.F06")) { + NextTest(); + return; + } + err = TestStep3hGivenPccsf06localEnsureFeaturemapHasTheCorrectBitSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0003")) { + NextTest(); + return; + } + err = TestStep4bThReadsOptionalAttributeMinConstPressureAttributeInAttributeListFromTheDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0004")) { + NextTest(); + return; + } + err = TestStep4cThReadsOptionalAttributeMaxConstPressureAttributeInAttributeListFromTheDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0005")) { + NextTest(); + return; + } + err = TestStep4dThReadsOptionalAttributeMinCompPressureAttributeInAttributeListFromTheDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0006")) { + NextTest(); + return; + } + err = TestStep4eThReadsOptionalAttributeMaxCompPressureAttributeInAttributeListFromTheDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0007")) { + NextTest(); + return; + } + err = TestStep4fThReadsOptionalAttributeMinConstSpeedAttributeInAttributeListFromTheDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0008")) { + NextTest(); + return; + } + err = TestStep4gThReadsOptionalAttributeMaxConstSpeedAttributeInAttributeListFromTheDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0009")) { + NextTest(); + return; + } + err = TestStep4hThReadsOptionalAttributeMinConstFlowAttributeInAttributeListFromTheDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A000a")) { + NextTest(); + return; + } + err = TestStep4iThReadsOptionalAttributeMaxConstFlowAttributeInAttributeListFromTheDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A000b")) { + NextTest(); + return; + } + err = TestStep4jThReadsOptionalAttributeMinConstTempAttributeInAttributeListFromTheDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A000c")) { + NextTest(); + return; + } + err = TestStep4kThReadsOptionalAttributeMaxConstTempAttributeInAttributeListFromTheDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0010")) { + NextTest(); + return; + } + err = TestStep4lThReadsOptionalAttributePumpStatusAttributeInAttributeListFromTheDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0014")) { + NextTest(); + return; + } + err = TestStep4mThReadsOptionalAttributeSpeedAttributeInAttributeListFromTheDut_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0015")) { + NextTest(); + return; + } + err = TestStep4nThReadsOptionalAttributeLifetimeRunningHoursAttributeInAttributeListFromTheDut_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0016")) { + NextTest(); + return; + } + err = TestStep4oThReadsOptionalAttributePowerAttributeInAttributeListFromTheDut_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0017")) { + NextTest(); + return; + } + err = TestStep4pThReadsOptionalAttributeLifetimeEnergyConsumedAttributeInAttributeListFromTheDut_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT\n"); + if (ShouldSkip("PCC.S.A0021")) { + NextTest(); + return; + } + err = TestStep4qThReadsOptionalAttributeControlModeAttributeInAttributeListFromTheDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5a: TH reads EventList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !PCC.S.E00 && !PCC.S.E01 && !PCC.S.E02 && !PCC.S.E03 && !PCC.S.E04 && !PCC.S.E05 && !PCC.S.E06 && !PCC.S.E07 && !PCC.S.E08 && !PCC.S.E09 && !PCC.S.E0a && !PCC.S.E0b && !PCC.S.E0c && !PCC.S.E0d && !PCC.S.E0e && !PCC.S.E0f && !PCC.S.E10 ")) { + NextTest(); + return; + } + NextTest(); + return; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 5b: TH reads from the DUT the EventList optional (SupplyVoltageLow)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E00")) { + NextTest(); + return; + } + NextTest(); + return; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Step 5c: TH reads from the DUT the EventList optional (SupplyVoltageHigh)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E01")) { + NextTest(); + return; + } + NextTest(); + return; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 5d: TH reads from the DUT the EventList optional (PowerMissingPhase)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E02")) { + NextTest(); + return; + } + NextTest(); + return; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Step 5e: TH reads from the DUT the EventList optional (SystemPressureLow)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E03")) { + NextTest(); + return; + } + NextTest(); + return; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Step 5f: TH reads from the DUT the EventList optional (SystemPressureHigh)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E04")) { + NextTest(); + return; + } + NextTest(); + return; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Step 5g: TH reads from the DUT the EventList optional (DryRunning)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E05")) { + NextTest(); + return; + } + NextTest(); + return; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Step 5h: TH reads from the DUT the EventList optional (MotorTemperatureHigh)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E06")) { + NextTest(); + return; + } + NextTest(); + return; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Step 5i: TH reads from the DUT the EventList optional (PumpMotorFatalFailure)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E07")) { + NextTest(); + return; + } + NextTest(); + return; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5j: TH reads from the DUT the EventList optional (ElectronicTemperatureHigh)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E08")) { + NextTest(); + return; + } + NextTest(); + return; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Step 5k: TH reads from the DUT the EventList optional (PumpBlocked)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E09")) { + NextTest(); + return; + } + NextTest(); + return; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Step 5l: TH reads from the DUT the EventList optional (SensorFailure)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0a")) { + NextTest(); + return; + } + NextTest(); + return; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Step 5m: TH reads from the DUT the EventList optional (ElectronicNonFatalFailure)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0b")) { + NextTest(); + return; + } + NextTest(); + return; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Step 5n: TH reads from the DUT the EventList optional (ElectronicFatalFailure)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0c")) { + NextTest(); + return; + } + NextTest(); + return; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Step 5o: TH reads from the DUT the EventList optional (GeneralFault)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0d")) { + NextTest(); + return; + } + NextTest(); + return; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Step 5p: TH reads from the DUT the EventList optional (Leakage)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0e")) { + NextTest(); + return; + } + NextTest(); + return; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Step 5q: TH reads from the DUT the EventList optional (AirDetection)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E0f")) { + NextTest(); + return; + } + NextTest(); + return; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Step 5r: TH reads from the DUT the EventList optional (TurbineOperation)attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && PCC.S.E10")) { + NextTest(); + return; + } + NextTest(); + return; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_47(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 48; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenPccsf00prsconstEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given PCC.S.F00(PRSCONST) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenPccsf01prscompEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given PCC.S.F01(PRSCOMP) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenPccsf02flwEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given PCC.S.F02(FLW) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenPccsf03spdEnsureFeaturemapHasTheCorrectBitSet_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3e: Given PCC.S.F03(SPD) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenPccsf04tempEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given PCC.S.F04(TEMP) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenPccsf05autoEnsureFeaturemapHasTheCorrectBitSet_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3g: Given PCC.S.F05(AUTO) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenPccsf06localEnsureFeaturemapHasTheCorrectBitSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given PCC.S.F06(LOCAL) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsOptionalAttributeMinConstPressureAttributeInAttributeListFromTheDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads optional attribute(MinConstPressure) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsOptionalAttributeMaxConstPressureAttributeInAttributeListFromTheDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4c TH reads optional attribute(MaxConstPressure) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsOptionalAttributeMinCompPressureAttributeInAttributeListFromTheDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads optional attribute(MinCompPressure) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsOptionalAttributeMaxCompPressureAttributeInAttributeListFromTheDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads optional attribute(MaxCompPressure) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsOptionalAttributeMinConstSpeedAttributeInAttributeListFromTheDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads optional attribute(MinConstSpeed) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThReadsOptionalAttributeMaxConstSpeedAttributeInAttributeListFromTheDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4g: TH reads optional attribute(MaxConstSpeed) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsOptionalAttributeMinConstFlowAttributeInAttributeListFromTheDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads optional attribute(MinConstFlow) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThReadsOptionalAttributeMaxConstFlowAttributeInAttributeListFromTheDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads optional attribute(MaxConstFlow) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsOptionalAttributeMinConstTempAttributeInAttributeListFromTheDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads optional attribute(MinConstTemp) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kThReadsOptionalAttributeMaxConstTempAttributeInAttributeListFromTheDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4k: TH reads optional attribute(MaxConstTemp) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4lThReadsOptionalAttributePumpStatusAttributeInAttributeListFromTheDut_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4l: TH reads optional attribute(PumpStatus) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4mThReadsOptionalAttributeSpeedAttributeInAttributeListFromTheDut_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4m: TH reads optional attribute(Speed) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4nThReadsOptionalAttributeLifetimeRunningHoursAttributeInAttributeListFromTheDut_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4n: TH reads optional attribute(LifetimeRunningHours) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4oThReadsOptionalAttributePowerAttributeInAttributeListFromTheDut_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4o: TH reads optional attribute(Power) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4pThReadsOptionalAttributeLifetimeEnergyConsumedAttributeInAttributeListFromTheDut_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4p: TH reads optional attribute(LifetimeEnergyConsumed) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4qThReadsOptionalAttributeControlModeAttributeInAttributeListFromTheDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4q: TH reads optional attribute(ControlMode) attribute in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PCC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PCC_2_1() + : TestCommandBridge("Test_TC_PCC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PCC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MaxPressure attribute.\n"); + if (ShouldSkip("PCC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMaxPressureAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxSpeed attribute.\n"); + if (ShouldSkip("PCC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxSpeedAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MaxFlow attribute.\n"); + if (ShouldSkip("PCC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMaxFlowAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the MinConstPressure attribute.\n"); + if (ShouldSkip("PCC.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutTheMinConstPressureAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the MaxConstPressure attribute.\n"); + if (ShouldSkip("PCC.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheMaxConstPressureAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the MinCompPressure attribute.\n"); + if (ShouldSkip("PCC.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheMinCompPressureAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the MaxCompPressure attribute.\n"); + if (ShouldSkip("PCC.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheMaxCompPressureAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the MinConstSpeed attribute.\n"); + if (ShouldSkip("PCC.S.A0007")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheMinConstSpeedAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the MaxConstSpeed attribute.\n"); + if (ShouldSkip("PCC.S.A0008")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheMaxConstSpeedAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the MinConstFlow attribute.\n"); + if (ShouldSkip("PCC.S.A0009")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheMinConstFlowAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the MaxConstFlow attribute.\n"); + if (ShouldSkip("PCC.S.A000a")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheMaxConstFlowAttribute_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the MinConstTemp attribute.\n"); + if (ShouldSkip("PCC.S.A000b")) { + NextTest(); + return; + } + err = TestStep13ThReadsFromTheDutTheMinConstTempAttribute_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the MaxConstTemp attribute.\n"); + if (ShouldSkip("PCC.S.A000c")) { + NextTest(); + return; + } + err = TestStep14ThReadsFromTheDutTheMaxConstTempAttribute_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 15: TH reads from the DUT the PumpStatus attribute.\n"); + if (ShouldSkip("PCC.S.A0010")) { + NextTest(); + return; + } + err = TestStep15ThReadsFromTheDutThePumpStatusAttribute_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 16: TH reads from the DUT the EffectiveOperationMode attribute.\n"); + if (ShouldSkip("PCC.S.A0011")) { + NextTest(); + return; + } + err = TestStep16ThReadsFromTheDutTheEffectiveOperationModeAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 17: TH reads from the DUT the EffectiveControlMode attribute.\n"); + if (ShouldSkip("PCC.S.A0012")) { + NextTest(); + return; + } + err = TestStep17ThReadsFromTheDutTheEffectiveControlModeAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 18: TH reads from the DUT the Capacity attribute.\n"); + if (ShouldSkip("PCC.S.A0013")) { + NextTest(); + return; + } + err = TestStep18ThReadsFromTheDutTheCapacityAttribute_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 19: TH reads from the DUT the Speed attribute.\n"); + if (ShouldSkip("PCC.S.A0014")) { + NextTest(); + return; + } + err = TestStep19ThReadsFromTheDutTheSpeedAttribute_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 20: TH reads from the DUT the LifetimeRunningHours attribute.\n"); + if (ShouldSkip("PCC.S.A0015")) { + NextTest(); + return; + } + err = TestStep20ThReadsFromTheDutTheLifetimeRunningHoursAttribute_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 21: TH reads from the DUT the Power attribute.\n"); + if (ShouldSkip("PCC.S.A0016")) { + NextTest(); + return; + } + err = TestStep21ThReadsFromTheDutThePowerAttribute_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); + if (ShouldSkip("PCC.S.A0017")) { + NextTest(); + return; + } + err = TestStep22ThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 23: TH reads from the DUT the OperationMode attribute.\n"); + if (ShouldSkip("PCC.S.A0020")) { + NextTest(); + return; + } + err = TestStep23ThReadsFromTheDutTheOperationModeAttribute_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 24: TH reads from the DUT the ControlMode attribute.\n"); + if (ShouldSkip("PCC.S.A0021")) { + NextTest(); + return; + } + err = TestStep24ThReadsFromTheDutTheControlModeAttribute_23(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 24; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMaxPressureAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MaxPressure attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MaxPressure attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxPressure", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("maxPressure", [value shortValue], -32768)); + VerifyOrReturn(CheckConstraintMaxValue("maxPressure", [value shortValue], 32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxSpeedAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxSpeed attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxSpeed attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxSpeed", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("maxSpeed", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("maxSpeed", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMaxFlowAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MaxFlow attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MaxFlow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxFlow", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("maxFlow", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("maxFlow", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheMinConstPressureAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinConstPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the MinConstPressure attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the MinConstPressure attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minConstPressure", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("minConstPressure", [value shortValue], -32768)); + VerifyOrReturn(CheckConstraintMaxValue("minConstPressure", [value shortValue], 32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheMaxConstPressureAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxConstPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the MaxConstPressure attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the MaxConstPressure attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxConstPressure", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("maxConstPressure", [value shortValue], -32768)); + VerifyOrReturn(CheckConstraintMaxValue("maxConstPressure", [value shortValue], 32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheMinCompPressureAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinCompPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the MinCompPressure attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the MinCompPressure attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minCompPressure", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("minCompPressure", [value shortValue], -32768)); + VerifyOrReturn(CheckConstraintMaxValue("minCompPressure", [value shortValue], 32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheMaxCompPressureAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxCompPressureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the MaxCompPressure attribute.: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the MaxCompPressure attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxCompPressure", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("maxCompPressure", [value shortValue], -32768)); + VerifyOrReturn(CheckConstraintMaxValue("maxCompPressure", [value shortValue], 32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheMinConstSpeedAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinConstSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the MinConstSpeed attribute.: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the MinConstSpeed attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minConstSpeed", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("minConstSpeed", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("minConstSpeed", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheMaxConstSpeedAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxConstSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the MaxConstSpeed attribute.: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the MaxConstSpeed attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxConstSpeed", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("maxConstSpeed", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("maxConstSpeed", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheMinConstFlowAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinConstFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the MinConstFlow attribute.: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the MinConstFlow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minConstFlow", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("minConstFlow", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("minConstFlow", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheMaxConstFlowAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxConstFlowWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the MaxConstFlow attribute.: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the MaxConstFlow attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxConstFlow", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("maxConstFlow", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("maxConstFlow", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13ThReadsFromTheDutTheMinConstTempAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinConstTempWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH reads from the DUT the MinConstTemp attribute.: Error: %@", err); + } else { + NSLog(@"Step 13: TH reads from the DUT the MinConstTemp attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minConstTemp", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("minConstTemp", [value shortValue], -32768)); + VerifyOrReturn(CheckConstraintMaxValue("minConstTemp", [value shortValue], 32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep14ThReadsFromTheDutTheMaxConstTempAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxConstTempWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14: TH reads from the DUT the MaxConstTemp attribute.: Error: %@", err); + } else { + NSLog(@"Step 14: TH reads from the DUT the MaxConstTemp attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxConstTemp", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("maxConstTemp", [value shortValue], -32768)); + VerifyOrReturn(CheckConstraintMaxValue("maxConstTemp", [value shortValue], 32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep15ThReadsFromTheDutThePumpStatusAttribute_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePumpStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 15: TH reads from the DUT the PumpStatus attribute.: Error: %@", err); + } else { + NSLog(@"Step 15: TH reads from the DUT the PumpStatus attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("pumpStatus", "bitmap16", "bitmap16")); + VerifyOrReturn(CheckConstraintMinValue("pumpStatus", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("pumpStatus", [value unsignedShortValue], 8U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16ThReadsFromTheDutTheEffectiveOperationModeAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 16: TH reads from the DUT the EffectiveOperationMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 16: TH reads from the DUT the EffectiveOperationMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("effectiveOperationMode", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("effectiveOperationMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("effectiveOperationMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep17ThReadsFromTheDutTheEffectiveControlModeAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 17: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 17: TH reads from the DUT the EffectiveControlMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("effectiveControlMode", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("effectiveControlMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("effectiveControlMode", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep18ThReadsFromTheDutTheCapacityAttribute_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCapacityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 18: TH reads from the DUT the Capacity attribute.: Error: %@", err); + } else { + NSLog(@"Step 18: TH reads from the DUT the Capacity attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("capacity", "int16s", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("capacity", [value shortValue], -32768)); + VerifyOrReturn(CheckConstraintMaxValue("capacity", [value shortValue], 32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep19ThReadsFromTheDutTheSpeedAttribute_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 19: TH reads from the DUT the Speed attribute.: Error: %@", err); + } else { + NSLog(@"Step 19: TH reads from the DUT the Speed attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("speed", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("speed", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("speed", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep20ThReadsFromTheDutTheLifetimeRunningHoursAttribute_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 20: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); + } else { + NSLog(@"Step 20: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("lifetimeRunningHours", "int24u", "int24u")); + VerifyOrReturn(CheckConstraintMinValue("lifetimeRunningHours", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("lifetimeRunningHours", [value unsignedIntValue], 16777215UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep21ThReadsFromTheDutThePowerAttribute_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePowerWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 21: TH reads from the DUT the Power attribute.: Error: %@", err); + } else { + NSLog(@"Step 21: TH reads from the DUT the Power attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("power", "int24u", "int24u")); + VerifyOrReturn(CheckConstraintMinValue("power", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("power", [value unsignedIntValue], 16777215UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep22ThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); + } else { + NSLog(@"Step 22: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("lifetimeEnergyConsumed", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("lifetimeEnergyConsumed", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("lifetimeEnergyConsumed", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep23ThReadsFromTheDutTheOperationModeAttribute_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 23: TH reads from the DUT the OperationMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 23: TH reads from the DUT the OperationMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("operationMode", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("operationMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("operationMode", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep24ThReadsFromTheDutTheControlModeAttribute_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 24: TH reads from the DUT the ControlMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 24: TH reads from the DUT the ControlMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("controlMode", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("controlMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("controlMode", [value unsignedCharValue], 7U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PCC_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PCC_2_2() + : TestCommandBridge("Test_TC_PCC_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PCC_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT\n"); + if (ShouldSkip("PCC.S.A0020")) { + NextTest(); + return; + } + err = TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the EffectiveOperationMode attribute\n"); + if (ShouldSkip("PCC.S.A0011")) { + NextTest(); + return; + } + err = TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT\n"); + if (ShouldSkip("PCC.S.F03 && PCC.S.A0020")) { + NextTest(); + return; + } + err = TestStep3aThWrite1MinimumToTheOperationModeAttributeToDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the EffectiveOperationMode attribute\n"); + if (ShouldSkip("PCC.S.F03 && PCC.S.A0011")) { + NextTest(); + return; + } + err = TestStep3bThReadsFromTheDutTheEffectiveOperationModeAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.\n"); + if (ShouldSkip("PCC.S.F03 && PCC.S.A0020")) { + NextTest(); + return; + } + err = TestStep4aThWrite2MaximumToTheOperationModeAttributeToDutOneAtATime_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the EffectiveOperationMode attribute\n"); + if (ShouldSkip("PCC.S.F03 && PCC.S.A0011")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheEffectiveOperationModeAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT\n"); + if (ShouldSkip("PCC.S.F06 && PCC.S.A0020")) { + NextTest(); + return; + } + err = TestStep5aThWrite3LocalToTheOperationModeAttributeToDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the EffectiveOperationMode attribute\n"); + if (ShouldSkip("PCC.S.F06 && PCC.S.A0011")) { + NextTest(); + return; + } + err = TestStep5bThReadsFromTheDutTheEffectiveOperationModeAttribute_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id operationModeArgument; + operationModeArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThWrite1MinimumToTheOperationModeAttributeToDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id operationModeArgument; + operationModeArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH write 1 (Minimum) to the OperationMode attribute to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsFromTheDutTheEffectiveOperationModeAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThWrite2MaximumToTheOperationModeAttributeToDutOneAtATime_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id operationModeArgument; + operationModeArgument = + [NSNumber numberWithUnsignedChar:2U]; + [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH write 2 (Maximum) to the OperationMode attribute to DUT one at a time.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheEffectiveOperationModeAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThWrite3LocalToTheOperationModeAttributeToDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id operationModeArgument; + operationModeArgument = + [NSNumber numberWithUnsignedChar:3U]; + [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT: Error: %@", err); + } else { + NSLog(@"Step 5a: TH write 3 (Local) to the OperationMode attribute to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bThReadsFromTheDutTheEffectiveOperationModeAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); + } else { + NSLog(@"Step 5b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PCC_2_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PCC_2_3() + : TestCommandBridge("Test_TC_PCC_2_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PCC_2_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.\n"); + if (ShouldSkip("PCC.S.A0020")) { + NextTest(); + return; + } + err = TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the EffectiveOperationMode attribute\n"); + if (ShouldSkip("PCC.S.A0011")) { + NextTest(); + return; + } + err = TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.\n"); + if (ShouldSkip("PCC.S.F03 && PCC.S.A0021")) { + NextTest(); + return; + } + err = TestStep3aThWrite0ConstantSpeedToTheControlModeAttributeToDutOneAtATime_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the EffectiveControlMode attribute.\n"); + if (ShouldSkip("PCC.S.F03 && PCC.S.A0012")) { + NextTest(); + return; + } + err = TestStep3bThReadsFromTheDutTheEffectiveControlModeAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.\n"); + if (ShouldSkip("PCC.S.F00 && PCC.S.A0021")) { + NextTest(); + return; + } + err = TestStep4aThWrite1ConstantPressureToTheControlModeAttributeToDutOneAtATime_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the EffectiveControlMode attribute.\n"); + if (ShouldSkip("PCC.S.F00 && PCC.S.A0012")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheEffectiveControlModeAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.\n"); + if (ShouldSkip("PCC.S.F01 && PCC.S.A0021")) { + NextTest(); + return; + } + err = TestStep5aThWrite2ProportionalPressureToTheControlModeAttributeToDutOneAtATime_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the EffectiveControlMode attribute.\n"); + if (ShouldSkip("PCC.S.F01 && PCC.S.A0012")) { + NextTest(); + return; + } + err = TestStep5bThReadsFromTheDutTheEffectiveControlModeAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.\n"); + if (ShouldSkip("PCC.S.F02 && PCC.S.A0021")) { + NextTest(); + return; + } + err = TestStep6aThWrite3ConstantFlowToTheControlModeAttributeToDutOneAtATime_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.\n"); + if (ShouldSkip("PCC.S.F02 && PCC.S.A0012")) { + NextTest(); + return; + } + err = TestStep6bThReadsFromTheDutTheEffectiveControlModeAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.\n"); + if (ShouldSkip("PCC.S.F04 && PCC.S.A0021")) { + NextTest(); + return; + } + err = TestStep7aThWrite5ConstantTemperatureToTheControlModeAttributeToDutOneAtATime_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b: TH reads from the DUT the EffectiveControlMode attribute.\n"); + if (ShouldSkip("PCC.S.F04 && PCC.S.A0012")) { + NextTest(); + return; + } + err = TestStep7bThReadsFromTheDutTheEffectiveControlModeAttribute_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.\n"); + if (ShouldSkip("PCC.S.F05 && PCC.S.A0021")) { + NextTest(); + return; + } + err = TestStep8aThWrite7AutomaticToTheControlModeAttributeToDutOneAtATime_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 8b: TH reads from the DUT the EffectiveControlMode attribute.\n"); + if (ShouldSkip("PCC.S.F05 && PCC.S.A0012")) { + NextTest(); + return; + } + err = TestStep8bThReadsFromTheDutTheEffectiveControlModeAttribute_14(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 15; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2aThWrite0NormalToTheOperationModeAttributeToDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id operationModeArgument; + operationModeArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeOperationModeWithValue:operationModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.: Error: %@", err); + } else { + NSLog(@"Step 2a: TH write 0 (Normal) to the OperationMode attribute to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThReadsFromTheDutTheEffectiveOperationModeAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveOperationModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads from the DUT the EffectiveOperationMode attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EffectiveOperationMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThWrite0ConstantSpeedToTheControlModeAttributeToDutOneAtATime_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id controlModeArgument; + controlModeArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.: Error: %@", err); + } else { + NSLog(@"Step 3a: TH write 0 (ConstantSpeed) to the ControlMode attribute to DUT one at a time.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsFromTheDutTheEffectiveControlModeAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThWrite1ConstantPressureToTheControlModeAttributeToDutOneAtATime_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id controlModeArgument; + controlModeArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH write 1 (ConstantPressure) to the ControlMode attribute to DUT one at a time.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheEffectiveControlModeAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThWrite2ProportionalPressureToTheControlModeAttributeToDutOneAtATime_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id controlModeArgument; + controlModeArgument = + [NSNumber numberWithUnsignedChar:2U]; + [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.: Error: %@", err); + } else { + NSLog(@"Step 5a: TH write 2 (ProportionalPressure) to the ControlMode attribute to DUT one at a time.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bThReadsFromTheDutTheEffectiveControlModeAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 5b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThWrite3ConstantFlowToTheControlModeAttributeToDutOneAtATime_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id controlModeArgument; + controlModeArgument = + [NSNumber numberWithUnsignedChar:3U]; + [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.: Error: %@", err); + } else { + NSLog(@"Step 6a: TH write 3 (ConstantFlow) to the ControlMode attribute to DUT one at a time.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsFromTheDutTheEffectiveControlModeAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads from the DUT the _EffectiveControlMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7aThWrite5ConstantTemperatureToTheControlModeAttributeToDutOneAtATime_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id controlModeArgument; + controlModeArgument = + [NSNumber numberWithUnsignedChar:5U]; + [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.: Error: %@", err); + } else { + NSLog(@"Step 7a: TH write 5 (ConstantTemperature) to the ControlMode attribute to DUT one at a time.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7bThReadsFromTheDutTheEffectiveControlModeAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 7b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 5U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8aThWrite7AutomaticToTheControlModeAttributeToDutOneAtATime_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id controlModeArgument; + controlModeArgument = + [NSNumber numberWithUnsignedChar:7U]; + [cluster writeAttributeControlModeWithValue:controlModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.: Error: %@", err); + } else { + NSLog(@"Step 8a: TH write 7 (Automatic) to the ControlMode attribute to DUT one at a time.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8bThReadsFromTheDutTheEffectiveControlModeAttribute_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEffectiveControlModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8b: TH reads from the DUT the EffectiveControlMode attribute.: Error: %@", err); + } else { + NSLog(@"Step 8b: TH reads from the DUT the EffectiveControlMode attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("EffectiveControlMode", actualValue, 7U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_PCC_2_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_PCC_2_4() + : TestCommandBridge("Test_TC_PCC_2_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_PCC_2_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_PCC_2_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_PCC_2_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT\n"); + if (ShouldSkip("PCC.S.A0015")) { + NextTest(); + return; + } + err = TestStep2aThWrite1ToTheLifetimeRunningHoursAttributeToDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); + if (ShouldSkip("PCC.S.A0015")) { + NextTest(); + return; + } + err = TestStep2bThReadsFromTheDutTheLifetimeRunningHoursAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.\n"); + if (ShouldSkip("PCC.S.A0015")) { + NextTest(); + return; + } + err = TestStep3aThWrite2ToTheLifetimeRunningHoursAttributeOfDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); + if (ShouldSkip("PCC.S.A0015")) { + NextTest(); + return; + } + err = TestStep3bThReadsFromTheDutTheLifetimeRunningHoursAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT\n"); + if (ShouldSkip("PCC.S.A0015")) { + NextTest(); + return; + } + err = TestStep4aThWrite3ToTheLifetimeRunningHoursAttributeToDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.\n"); + if (ShouldSkip("PCC.S.A0015")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheLifetimeRunningHoursAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.\n"); + if (ShouldSkip("PCC.S.A0017")) { + NextTest(); + return; + } + err = TestStep5aThWrite1ToTheLifetimeEnergyConsumedAttributeOfDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); + if (ShouldSkip("PCC.S.A0017")) { + NextTest(); + return; + } + err = TestStep5bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.\n"); + if (ShouldSkip("PCC.S.A0017")) { + NextTest(); + return; + } + err = TestStep6aThWrite2ToTheLifetimeEnergyConsumedAttributeOfDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); + if (ShouldSkip("PCC.S.A0017")) { + NextTest(); + return; + } + err = TestStep6bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.\n"); + if (ShouldSkip("PCC.S.A0017")) { + NextTest(); + return; + } + err = TestStep7aThWrite3ToTheLifetimeEnergyConsumedAttributeOfDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.\n"); + if (ShouldSkip("PCC.S.A0017")) { + NextTest(); + return; + } + err = TestStep7bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_12(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 13; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2aThWrite1ToTheLifetimeRunningHoursAttributeToDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id lifetimeRunningHoursArgument; + lifetimeRunningHoursArgument = + [NSNumber numberWithUnsignedInt:1UL]; + [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH Write 1 to the LifetimeRunningHours attribute to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThReadsFromTheDutTheLifetimeRunningHoursAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); + VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 1UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThWrite2ToTheLifetimeRunningHoursAttributeOfDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id lifetimeRunningHoursArgument; + lifetimeRunningHoursArgument = + [NSNumber numberWithUnsignedInt:2UL]; + [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.: Error: %@", err); + } else { + NSLog(@"Step 3a: TH write 2 to the LifetimeRunningHours attribute of DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsFromTheDutTheLifetimeRunningHoursAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); + VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 2UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThWrite3ToTheLifetimeRunningHoursAttributeToDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id lifetimeRunningHoursArgument; + lifetimeRunningHoursArgument = + [NSNumber numberWithUnsignedInt:3UL]; + [cluster writeAttributeLifetimeRunningHoursWithValue:lifetimeRunningHoursArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH Write 3 to the LifetimeRunningHours attribute to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheLifetimeRunningHoursAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLifetimeRunningHoursWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the LifetimeRunningHours attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("LifetimeRunningHours", actualValue)); + VerifyOrReturn(CheckValue("LifetimeRunningHours", actualValue, 3UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThWrite1ToTheLifetimeEnergyConsumedAttributeOfDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id lifetimeEnergyConsumedArgument; + lifetimeEnergyConsumedArgument = + [NSNumber numberWithUnsignedInt:1UL]; + [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); + } else { + NSLog(@"Step 5a: TH write 1 to the LifetimeEnergyConsumed attribute of DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); + } else { + NSLog(@"Step 5b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); + VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 1UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThWrite2ToTheLifetimeEnergyConsumedAttributeOfDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id lifetimeEnergyConsumedArgument; + lifetimeEnergyConsumedArgument = + [NSNumber numberWithUnsignedInt:2UL]; + [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); + } else { + NSLog(@"Step 6a: TH write 2 to the LifetimeEnergyConsumed attribute of DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); + VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 2UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7aThWrite3ToTheLifetimeEnergyConsumedAttributeOfDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id lifetimeEnergyConsumedArgument; + lifetimeEnergyConsumedArgument = + [NSNumber numberWithUnsignedInt:3UL]; + [cluster writeAttributeLifetimeEnergyConsumedWithValue:lifetimeEnergyConsumedArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.: Error: %@", err); + } else { + NSLog(@"Step 7a: TH write 3 to the LifetimeEnergyConsumed attribute of DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7bThReadsFromTheDutTheLifetimeEnergyConsumedAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterPumpConfigurationAndControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLifetimeEnergyConsumedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Error: %@", err); + } else { + NSLog(@"Step 7b: TH reads from the DUT the LifetimeEnergyConsumed attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("LifetimeEnergyConsumed", actualValue)); + VerifyOrReturn(CheckValue("LifetimeEnergyConsumed", actualValue, 3UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_REFALM_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_REFALM_1_1() + : TestCommandBridge("Test_TC_REFALM_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_REFALM_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_REFALM_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_REFALM_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_REFALM_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_REFALM_2_1() + : TestCommandBridge("Test_TC_REFALM_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_REFALM_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_REFALM_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_REFALM_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Ensure that the door alarm is not locally suppressed and the door is closed\n"); + if (ShouldSkip("PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep2EnsureThatTheDoorAlarmIsNotLocallySuppressedAndTheDoorIsClosed_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3:TH reads from the DUT the Mask attribute\n"); + if (ShouldSkip("REFALM.S.A0000")) { + NextTest(); + return; + } + err = TestStep3thReadsFromTheDutTheMaskAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4:TH reads from the DUT the State attribute\n"); + if (ShouldSkip("REFALM.S.A0002")) { + NextTest(); + return; + } + err = TestStep4thReadsFromTheDutTheStateAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5:TH reads from the DUT the Supportedask attribute\n"); + if (ShouldSkip("REFALM.S.A0003")) { + NextTest(); + return; + } + err = TestStep5thReadsFromTheDutTheSupportedaskAttribute_4(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2EnsureThatTheDoorAlarmIsNotLocallySuppressedAndTheDoorIsClosed_1() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3thReadsFromTheDutTheMaskAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3:TH reads from the DUT the Mask attribute: Error: %@", err); + } else { + NSLog(@"Step 3:TH reads from the DUT the Mask attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("mask", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4thReadsFromTheDutTheStateAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4:TH reads from the DUT the State attribute: Error: %@", err); + } else { + NSLog(@"Step 4:TH reads from the DUT the State attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("state", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5thReadsFromTheDutTheSupportedaskAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5:TH reads from the DUT the Supportedask attribute: Error: %@", err); + } else { + NSLog(@"Step 5:TH reads from the DUT the Supportedask attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("supported", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_RH_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_RH_1_1() + : TestCommandBridge("Test_TC_RH_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_RH_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_RH_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RH_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT.\n"); + err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap attribute from the DUT.\n"); + err = TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the AttributeList attribute from the DUT.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); + if (ShouldSkip("RH.S.A0003")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads the AcceptedCommandList attribute from the DUT.\n"); + err = TestStep5ThReadsTheAcceptedCommandListAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads the GeneratedCommandList attribute from the DUT.\n"); + err = TestStep6ThReadsTheGeneratedCommandListAttributeFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads the EventList attribute from the DUT.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheAcceptedCommandListAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the AcceptedCommandList attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the AcceptedCommandList attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsTheGeneratedCommandListAttributeFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRelativeHumidityMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads the GeneratedCommandList attribute from the DUT.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads the GeneratedCommandList attribute from the DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_RVCCLEANM_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_RVCCLEANM_1_1() + : TestCommandBridge("Test_TC_RVCCLEANM_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_RVCCLEANM_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCCLEANM_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCCLEANM_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip(" !RVCCLEANM.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: Given RVCCLEANM.S.F00(DEPONOFF) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("RVCCLEANM.S.F00")) { + NextTest(); + return; + } + err = TestStep3GivenRvccleanmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT\n"); + if (ShouldSkip("RVCCLEANM.S.A0002")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT\n"); + if (ShouldSkip("RVCCLEANM.S.F00")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT\n"); + if (ShouldSkip(" !RVCCLEANM.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode)\n"); + if (ShouldSkip("RVCCLEANM.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse)\n"); + if (ShouldSkip("RVCCLEANM.S.C01.Tx")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3GivenRvccleanmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: Given RVCCLEANM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3: Given RVCCLEANM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheFeatureDependentRVCCLEANMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the Feature dependent(RVCCLEANM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCCleanMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_RVCRUNM_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_RVCRUNM_1_1() + : TestCommandBridge("Test_TC_RVCRUNM_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_RVCRUNM_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCRUNM_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCRUNM_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip(" !RVCRUNM.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given RVCRUNM.S.F00(DEPONOFF) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("RVCRUNM.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenRvcrunmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT\n"); + if (ShouldSkip("RVCRUNM.S.A0002")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT\n"); + if (ShouldSkip("RVCRUNM.S.F00")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT\n"); + if (ShouldSkip(" !RVCRUNM.S.F00 ")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode)\n"); + if (ShouldSkip("RVCRUNM.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse)\n"); + if (ShouldSkip("RVCRUNM.S.C01.Tx")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_11(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 12; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenRvcrunmsf00deponoffEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given RVCRUNM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given RVCRUNM.S.F00(DEPONOFF) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeStartUpModeInAttributeListFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute(StartUpMode) in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsInAttributeListFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheFeatureDependentRVCRUNMSF00DeponoffAndOptionalAttributeOnModeIsNotInAttributeListFromTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the Feature dependent(RVCRUNM.S.F00 - DEPONOFF) and optional attribute(OnMode) is not in AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttributeCheckIfItContainsId0x0ChangeToMode_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute. Check if it contains id 0x0 (ChangeToMode): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttributeCheckIfItContainsId0x1ChangeToModeResponse_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCRunMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute. Check if it contains id 0x1 (ChangeToModeResponse): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 1UL)); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_RVCOPSTATE_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_RVCOPSTATE_1_1() + : TestCommandBridge("Test_TC_RVCOPSTATE_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_RVCOPSTATE_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_RVCOPSTATE_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_RVCOPSTATE_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT\n"); + if (ShouldSkip("RVCOPSTATE.S.A0002")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5a: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5b: TH reads from the DUT the optional event(OperationCompletion) in EventList.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && RVCOPSTATE.S.E01")) { + NextTest(); + return; + } + NextTest(); + return; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: TH reads the optional command(Pause) in AcceptedCommandList\n"); + if (ShouldSkip("RVCOPSTATE.S.C00.Rsp || RVCOPSTATE.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep6aThReadsTheOptionalCommandPauseInAcceptedCommandList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6b: TH reads the optional command(Stop) in AcceptedCommandList\n"); + if (ShouldSkip("RVCOPSTATE.S.C01.Rsp || RVCOPSTATE.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6c: TH reads the optional command(Start) in AcceptedCommandList\n"); + if (ShouldSkip("RVCOPSTATE.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep6cThReadsTheOptionalCommandStartInAcceptedCommandList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6d: TH reads the optional command(Resume) in AcceptedCommandList\n"); + if (ShouldSkip("RVCOPSTATE.S.C03.Rsp || RVCOPSTATE.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); + if (ShouldSkip(" !RVCOPSTATE.S.C00.Rsp && !RVCOPSTATE.S.C01.Rsp && !RVCOPSTATE.S.C02.Rsp && !RVCOPSTATE.S.C03.Rsp ")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); + if (ShouldSkip(" RVCOPSTATE.S.C00.Rsp || RVCOPSTATE.S.C01.Rsp || RVCOPSTATE.S.C02.Rsp || RVCOPSTATE.S.C03.Rsp ")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 14; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsTheOptionalCommandPauseInAcceptedCommandList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads the optional command(Pause) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads the optional command(Pause) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsTheOptionalCommandStopInAcceptedCommandList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads the optional command(Stop) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cThReadsTheOptionalCommandStartInAcceptedCommandList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: TH reads the optional command(Start) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6c: TH reads the optional command(Start) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6dThReadsTheOptionalCommandResumeInAcceptedCommandList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6d: TH reads the optional command(Resume) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_SMOKECO_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_SMOKECO_1_1() + : TestCommandBridge("Test_TC_SMOKECO_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_SMOKECO_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_SMOKECO_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SMOKECO_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute\n"); + if (ShouldSkip("!SMOKECO.S.F00 && !SMOKECO.S.F01")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm)\n"); + if (ShouldSkip("SMOKECO.S.F00 && !SMOKECO.S.F01")) { + NextTest(); + return; + } + err = TestStep3bThReadsFromTheDutTheFeatureMapAttributeSmokeAlarm_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm)\n"); + if (ShouldSkip("SMOKECO.S.F01 && !SMOKECO.S.F00")) { + NextTest(); + return; + } + err = TestStep3cThReadsFromTheDutTheFeatureMapAttributeCOAlarm_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm)\n"); + if (ShouldSkip("SMOKECO.S.F00 && SMOKECO.S.F01")) { + NextTest(); + return; + } + err = TestStep3dThReadsFromTheDutTheFeatureMapAttributeSmokeAlarmCoAlarm_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute\n"); + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState)\n"); + if (ShouldSkip("SMOKECO.S.A0001 && SMOKECO.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheAttributeListAttributeSmokeState_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads from the DUT the AttributeList attribute(COState)\n"); + if (ShouldSkip("SMOKECO.S.A0002 && SMOKECO.S.F01")) { + NextTest(); + return; + } + err = TestStep4cThReadsFromTheDutTheAttributeListAttributeCOState_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted)\n"); + if (ShouldSkip("SMOKECO.S.A0004")) { + NextTest(); + return; + } + err = TestStep4dThReadsFromTheDutTheAttributeListAttributeDeviceMuted_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm)\n"); + if (ShouldSkip("SMOKECO.S.A0008")) { + NextTest(); + return; + } + err = TestStep4eThReadsFromTheDutTheAttributeListAttributeInterconnectSmokeAlarm_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm)\n"); + if (ShouldSkip("SMOKECO.S.A0009")) { + NextTest(); + return; + } + err = TestStep4fThReadsFromTheDutTheAttributeListAttributeInterconnectCOAlarm_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState)\n"); + if (ShouldSkip("SMOKECO.S.A000a")) { + NextTest(); + return; + } + err = TestStep4gThReadsFromTheDutTheAttributeListAttributeContaminationState_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel)\n"); + if (ShouldSkip("SMOKECO.S.A000b")) { + NextTest(); + return; + } + err = TestStep4hThReadsFromTheDutTheAttributeListAttributeSmokeSensitivityLevel_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate)\n"); + if (ShouldSkip("SMOKECO.S.A000c")) { + NextTest(); + return; + } + err = TestStep4iThReadsFromTheDutTheAttributeListAttributeExpiryDate_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads from the DUT the EventList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads from the DUT the EventList attribute(SmokeAlarm)\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E00")) { + NextTest(); + return; + } + NextTest(); + return; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5c: TH reads from the DUT the EventList attribute(COAlarm)\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E01")) { + NextTest(); + return; + } + NextTest(); + return; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 5d: TH reads from the DUT the EventList attribute(AlarmMuted)\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E06")) { + NextTest(); + return; + } + NextTest(); + return; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 5e: TH reads from the DUT the EventList attribute(MuteEnded)\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E07")) { + NextTest(); + return; + } + NextTest(); + return; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5f: TH reads from the DUT the EventList attribute(InterconnectSmokeAlarm)\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E08")) { + NextTest(); + return; + } + NextTest(); + return; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5g: TH reads from the DUT the EventList attribute(InterconnectCOAlarm)\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SMOKECO.S.E09")) { + NextTest(); + return; + } + NextTest(); + return; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute\n"); + if (ShouldSkip("!SMOKECO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 6b: TH reads from the DUT the AcceptedCommandList attribute\n"); + if (ShouldSkip("SMOKECO.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6bThReadsFromTheDutTheAcceptedCommandListAttribute_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 7: TH reads from the DUT the GeneratedCommandList attribute\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_24(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 25; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsFromTheDutTheFeatureMapAttributeSmokeAlarm_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm): Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute(Smoke Alarm): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 1UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsFromTheDutTheFeatureMapAttributeCOAlarm_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm): Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute(CO Alarm): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 2UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThReadsFromTheDutTheFeatureMapAttributeSmokeAlarmCoAlarm_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm): Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute(Smoke Alarm & CO Alarm): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 3UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttributeSmokeState_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState): Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute(SmokeState): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttributeCOState_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute(COState): Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute(COState): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsFromTheDutTheAttributeListAttributeDeviceMuted_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted): Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute(DeviceMuted): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsFromTheDutTheAttributeListAttributeInterconnectSmokeAlarm_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm): Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads from the DUT the AttributeList attribute(InterconnectSmokeAlarm): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsFromTheDutTheAttributeListAttributeInterconnectCOAlarm_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm): Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads from the DUT the AttributeList attribute(InterconnectCOAlarm): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThReadsFromTheDutTheAttributeListAttributeContaminationState_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState): Error: %@", err); + } else { + NSLog(@"Step 4g: TH reads from the DUT the AttributeList attribute(ContaminationState): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsFromTheDutTheAttributeListAttributeSmokeSensitivityLevel_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel): Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads from the DUT the AttributeList attribute(SmokeSensitivityLevel): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThReadsFromTheDutTheAttributeListAttributeExpiryDate_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate): Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads from the DUT the AttributeList attribute(ExpiryDate): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsFromTheDutTheAcceptedCommandListAttribute_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads from the DUT the AcceptedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_SMOKECO_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_SMOKECO_2_1() + : TestCommandBridge("Test_TC_SMOKECO_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_SMOKECO_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_SMOKECO_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SMOKECO_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ExpressedState attribute\n"); + if (ShouldSkip("SMOKECO.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheExpressedStateAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SmokeState attribute\n"); + if (ShouldSkip("SMOKECO.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheSmokeStateAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the COState attribute\n"); + if (ShouldSkip("SMOKECO.S.A0002")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheCOStateAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the BatteryAlert attribute\n"); + if (ShouldSkip("SMOKECO.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutTheBatteryAlertAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the DeviceMuted attribute\n"); + if (ShouldSkip("SMOKECO.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheDeviceMutedAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the TestInProgress attribute\n"); + if (ShouldSkip("SMOKECO.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheTestInProgressAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the HardwareFaultAlert attribute\n"); + if (ShouldSkip("SMOKECO.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheHardwareFaultAlertAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the EndOfServiceAlert attribute\n"); + if (ShouldSkip("SMOKECO.S.A0007")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheEndOfServiceAlertAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute\n"); + if (ShouldSkip("SMOKECO.S.A0008")) { + NextTest(); + return; + } + err = TestStep10ThReadsFromTheDutTheInterconnectSmokeAlarmAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads from the DUT the InterconnectCOAlarm attribute\n"); + if (ShouldSkip("SMOKECO.S.A0009")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheInterconnectCOAlarmAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads from the DUT the ContaminationState attribute\n"); + if (ShouldSkip("SMOKECO.S.A000a")) { + NextTest(); + return; + } + err = TestStep12ThReadsFromTheDutTheContaminationStateAttribute_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute\n"); + if (ShouldSkip("SMOKECO.S.A000b")) { + NextTest(); + return; + } + err = TestStep13ThReadsFromTheDutTheSmokeSensitivityLevelAttribute_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads from the DUT the ExpiryDate attribute\n"); + if (ShouldSkip("SMOKECO.S.A000c")) { + NextTest(); + return; + } + err = TestStep14ThReadsFromTheDutTheExpiryDateAttribute_13(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 14; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheExpressedStateAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeExpressedStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ExpressedState attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ExpressedState attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("expressedState", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("expressedState", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("expressedState", [value unsignedCharValue], 8U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheSmokeStateAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSmokeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the SmokeState attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the SmokeState attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("smokeState", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("smokeState", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("smokeState", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheCOStateAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCOStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the COState attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the COState attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("COState", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("COState", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("COState", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheBatteryAlertAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBatteryAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the BatteryAlert attribute: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the BatteryAlert attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("batteryAlert", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("batteryAlert", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("batteryAlert", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheDeviceMutedAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDeviceMutedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the DeviceMuted attribute: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the DeviceMuted attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("deviceMuted", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("deviceMuted", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("deviceMuted", [value unsignedCharValue], 1U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheTestInProgressAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTestInProgressWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the TestInProgress attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the TestInProgress attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("testInProgress", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheHardwareFaultAlertAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeHardwareFaultAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the HardwareFaultAlert attribute: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the HardwareFaultAlert attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("hardwareFaultAlert", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheEndOfServiceAlertAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEndOfServiceAlertWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the EndOfServiceAlert attribute: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the EndOfServiceAlert attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("endOfServiceAlert", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("endOfServiceAlert", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("endOfServiceAlert", [value unsignedCharValue], 1U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsFromTheDutTheInterconnectSmokeAlarmAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInterconnectSmokeAlarmWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads from the DUT the InterconnectSmokeAlarm attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("interconnectSmokeAlarm", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("interconnectSmokeAlarm", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("interconnectSmokeAlarm", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheInterconnectCOAlarmAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInterconnectCOAlarmWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the InterconnectCOAlarm attribute: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the InterconnectCOAlarm attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("interconnectCOAlarm", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("interconnectCOAlarm", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("interconnectCOAlarm", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsFromTheDutTheContaminationStateAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeContaminationStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads from the DUT the ContaminationState attribute: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads from the DUT the ContaminationState attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("contaminationState", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("contaminationState", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("contaminationState", [value unsignedCharValue], 3U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13ThReadsFromTheDutTheSmokeSensitivityLevelAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSmokeSensitivityLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute: Error: %@", err); + } else { + NSLog(@"Step 13: TH reads from the DUT the SmokeSensitivityLevel attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("smokeSensitivityLevel", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("smokeSensitivityLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("smokeSensitivityLevel", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep14ThReadsFromTheDutTheExpiryDateAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSmokeCOAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeExpiryDateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14: TH reads from the DUT the ExpiryDate attribute: Error: %@", err); + } else { + NSLog(@"Step 14: TH reads from the DUT the ExpiryDate attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("expiryDate", "epoch_s", "epoch_s")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_SWTCH_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_SWTCH_1_1() + : TestCommandBridge("Test_TC_SWTCH_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_SWTCH_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_SWTCH_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_SWTCH_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 3: Read the global attribute: ClusterRevision\n"); + err = TestStep3ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: Read FeatureMap attribute and Check values of flags in this FeatureMap\n"); + if (ShouldSkip("!SWTCH.S.F00 && !SWTCH.S.F01 && !SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04")) { + NextTest(); + return; + } + err = TestStep2aReadFeatureMapAttributeAndCheckValuesOfFlagsInThisFeatureMap_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("SWTCH.S.F00")) { + NextTest(); + return; + } + err = TestStep2bGivenSwtchsf00lsEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("SWTCH.S.F01")) { + NextTest(); + return; + } + err = TestStep2cGivenSwtchsf01msEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("SWTCH.S.F02")) { + NextTest(); + return; + } + err = TestStep2dGivenSwtchsf02msrEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("SWTCH.S.F03")) { + NextTest(); + return; + } + err = TestStep2eGivenSwtchsf03mslEnsureFeaturemapHasTheCorrectBitSet_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("SWTCH.S.F04")) { + NextTest(); + return; + } + err = TestStep2fGivenSwtchsf04msmEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("SWTCH.S.F04")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !SWTCH.S.F04")) { + NextTest(); + return; + } + err = TestStep4bReadTheGlobalAttributeAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED && !SWTCH.S.F04")) { + NextTest(); + return; + } + err = TestStep4bReadTheGlobalAttributeAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5a: Read the global attribute: EventList \n"); + if (ShouldSkip("!SWTCH.S.F00 && !SWTCH.S.F01 && !SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04 ")) { + NextTest(); + return; + } + NextTest(); + return; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5b: Read EventList if SWTCH.S.F00(LS)\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SWTCH.S.F00")) { + NextTest(); + return; + } + NextTest(); + return; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5c: Read EventList if SWTCH.S.F01(MS) & !SWTCH.S.F02(MSR)\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && !SWTCH.S.F02")) { + NextTest(); + return; + } + NextTest(); + return; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5d: Read EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & !SWTCH.S.F03(MSL) & !SWTCH.S.F04(MSM)\n"); + if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && !SWTCH.S.F03 && !SWTCH.S.F04 ")) { + NextTest(); + return; + } + NextTest(); + return; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5e: Read EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & SWTCH.S.F03(MSL) & !SWTCH.S.F04(MSM)\n"); + if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && SWTCH.S.F03 && !SWTCH.S.F04 ")) { + NextTest(); + return; + } + NextTest(); + return; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5f: Read EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & !SWTCH.S.F03(MSL) & SWTCH.S.F04(MSM) \n"); + if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && !SWTCH.S.F03 && SWTCH.S.F04 ")) { + NextTest(); + return; + } + NextTest(); + return; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5g: Read EventList if SWTCH.S.F01(MS) & SWTCH.S.F02(MSR) & SWTCH.S.F03(MSL) & SWTCH.S.F04(MSM) \n"); + if (ShouldSkip(" PICS_EVENT_LIST_ENABLED && SWTCH.S.F01 && SWTCH.S.F02 && SWTCH.S.F03 && SWTCH.S.F04 ")) { + NextTest(); + return; + } + NextTest(); + return; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: Read the global attribute: AcceptedCommandList\n"); + err = TestStep6ReadTheGlobalAttributeAcceptedCommandList_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 7: Read the global attribute: GeneratedCommandList\n"); + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_19(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 20; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep3ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 3: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aReadFeatureMapAttributeAndCheckValuesOfFlagsInThisFeatureMap_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: Read FeatureMap attribute and Check values of flags in this FeatureMap: Error: %@", err); + } else { + NSLog(@"Step 2a: Read FeatureMap attribute and Check values of flags in this FeatureMap: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bGivenSwtchsf00lsEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2b: Given SWTCH.S.F00(LS) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cGivenSwtchsf01msEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2c: Given SWTCH.S.F01(MS) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dGivenSwtchsf02msrEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2d: Given SWTCH.S.F02(MSR) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2eGivenSwtchsf03mslEnsureFeaturemapHasTheCorrectBitSet_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2e: Given SWTCH.S.F03(MSL) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2fGivenSwtchsf04msmEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 2f: Given SWTCH.S.F04(MSM) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheGlobalAttributeAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheGlobalAttributeAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ReadTheGlobalAttributeAcceptedCommandList_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: Read the global attribute: AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSwitch alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TCCM_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TCCM_1_1() + : TestCommandBridge("Test_TC_TCCM_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TCCM_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCCM_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCCM_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip("!TCCM.S.F00")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF)\n"); + if (ShouldSkip("TCCM.S.F00")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTccmsf00deponoff_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode)\n"); + if (ShouldSkip("TCCM.S.A0002")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0002ShallBeIncludedIfAndOnlyIfTCCMSA0002StartUpMode_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF)\n"); + if (ShouldSkip("TCCM.S.F00")) { + NextTest(); + return; + } + err = TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTccmsf00deponoff_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 11; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTccmsf00deponoff_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF): Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute, bit 0: SHALL be 1 if and only if TCCM.S.F00(DEPONOFF): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x0002ShallBeIncludedIfAndOnlyIfTCCMSA0002StartUpMode_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode): Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0002: SHALL be included if and only if TCCM.S.A0002(StartUpMode): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTccmsf00deponoff_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF): Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003 SHALL be included if and only if TCCM.S.F00(DEPONOFF): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRefrigeratorAndTemperatureControlledCabinetMode alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TCTL_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TCTL_1_1() + : TestCommandBridge("Test_TC_TCTL_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TCTL_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute\n"); + if (ShouldSkip("!TCTL.S.F00 && !TCTL.S.F01 && !TCTL.S.F02")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL)\n"); + if (ShouldSkip("TCTL.S.F00 && !TCTL.S.F01")) { + NextTest(); + return; + } + err = TestStep3bThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTctlsf00tntctlsf01tl_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN)\n"); + if (ShouldSkip("TCTL.S.F01 && !TCTL.S.F00")) { + NextTest(); + return; + } + err = TestStep3cThReadsFromTheDutTheFeatureMapAttributeBit1ShallBe1IfAndOnlyIfTctlsf01tltctlsf00tn_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN)\n"); + if (ShouldSkip("TCTL.S.F02 && TCTL.S.F00")) { + NextTest(); + return; + } + err = TestStep3dThReadsFromTheDutTheFeatureMapAttributeBit2ShallBe1IfAndOnlyIfTctlsf02aStepTctlsf00tn_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN)\n"); + if (ShouldSkip("TCTL.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheAttributeListAttribute0x00000x00010x0002ShallBeIncludedIfAndOnlyIfTctlsf00tn_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP)\n"); + if (ShouldSkip("TCTL.S.F02")) { + NextTest(); + return; + } + err = TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTctlsf02aStep_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL)\n"); + if (ShouldSkip("TCTL.S.F01")) { + NextTest(); + return; + } + err = TestStep4dThReadsFromTheDutTheAttributeListAttribute0x00040x0005ShallBeIncludedIfAndOnlyIfTctlsf01tl_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 14; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsFromTheDutTheFeatureMapAttributeBit0ShallBe1IfAndOnlyIfTctlsf00tntctlsf01tl_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL): Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads from the DUT the FeatureMap attribute. bit 0: SHALL be 1 if and only if TCTL.S.F00(TN) & !TCTL.S.F01(TL): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsFromTheDutTheFeatureMapAttributeBit1ShallBe1IfAndOnlyIfTctlsf01tltctlsf00tn_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN): Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads from the DUT the FeatureMap attribute. bit 1: SHALL be 1 if and only if TCTL.S.F01(TL) & !TCTL.S.F00(TN): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThReadsFromTheDutTheFeatureMapAttributeBit2ShallBe1IfAndOnlyIfTctlsf02aStepTctlsf00tn_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN): Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads from the DUT the FeatureMap attribute. bit 2: SHALL be 1 if and only if TCTL.S.F02(A_STEP) & TCTL.S.F00(TN): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute0x00000x00010x0002ShallBeIncludedIfAndOnlyIfTctlsf00tn_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN): Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute. 0x0000, 0x0001, 0x0002: SHALL be included if and only if TCTL.S.F00(TN): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsFromTheDutTheAttributeListAttribute0x0003ShallBeIncludedIfAndOnlyIfTctlsf02aStep_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP): Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads from the DUT the AttributeList attribute. 0x0003: SHALL be included if and only if TCTL.S.F02(A_STEP): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsFromTheDutTheAttributeListAttribute0x00040x0005ShallBeIncludedIfAndOnlyIfTctlsf01tl_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL): Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads from the DUT the AttributeList attribute. 0x0004 & 0x0005: SHALL be included if and only if TCTL.S.F01(TL): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TCTL_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TCTL_2_2() + : TestCommandBridge("Test_TC_TCTL_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TCTL_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the MinTemperature attribute\n"); + if (ShouldSkip("TCTL.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheMinTemperatureAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MaxTemperature attribute\n"); + if (ShouldSkip("TCTL.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMaxTemperatureAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the TemperatureSetpoint attribute\n"); + if (ShouldSkip("TCTL.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheTemperatureSetpointAttribute_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull MinTemperatureValue; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheMinTemperatureAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the MinTemperature attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the MinTemperature attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("minTemperature", "temperature", "temperature")); + { + MinTemperatureValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull MaxTemperatureValue; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMaxTemperatureAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MaxTemperature attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MaxTemperature attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("maxTemperature", "temperature", "temperature")); + VerifyOrReturn(CheckConstraintMinValue("maxTemperature", [value shortValue], MinTemperatureValue)); + { + MaxTemperatureValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull temperatureValue; + + CHIP_ERROR TestStep4ThReadsFromTheDutTheTemperatureSetpointAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the TemperatureSetpoint attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("temperatureSetpoint", [value shortValue], MinTemperatureValue)); + VerifyOrReturn(CheckConstraintMaxValue("temperatureSetpoint", [value shortValue], MaxTemperatureValue)); + { + temperatureValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TCTL_2_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TCTL_2_3() + : TestCommandBridge("Test_TC_TCTL_2_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TCTL_2_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_2_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_2_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); + if (ShouldSkip("TCTL.S.A0004")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute\n"); + if (ShouldSkip("TCTL.S.A0005")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Verify that the DUT response contains a list of strings with each string length not exceeding 16 characters.\n"); + if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.A0005")) { + NextTest(); + return; + } + err = TestVerifyThatTheDutResponseContainsAListOfStringsWithEachStringLengthNotExceeding16Characters_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("selectedTemperatureLevel", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("selectedTemperatureLevel", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("selectedTemperatureLevel", [value unsignedCharValue], 31U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("supportedTemperatureLevels", "list", "list")); + VerifyOrReturn(CheckConstraintMaxLength("supportedTemperatureLevels", value, 32)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatTheDutResponseContainsAListOfStringsWithEachStringLengthNotExceeding16Characters_3() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } +}; + +class Test_TC_TCTL_3_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TCTL_3_2() + : TestCommandBridge("Test_TC_TCTL_3_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("Step_5_setTemp", INT16_MIN, INT16_MAX, &mStep5SetTemp); + AddArgument("InvalidTemp", INT16_MIN, INT16_MAX, &mInvalidTemp); + AddArgument("Step_10_setTemp", INT16_MIN, INT16_MAX, &mStep10SetTemp); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TCTL_3_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_3_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_3_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Operate device such that a temperature number can be accepted\n"); + if (ShouldSkip("PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep2OperateDeviceSuchThatATemperatureNumberCanBeAccepted_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the MinTemperature attribute\n"); + if (ShouldSkip("TCTL.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheMinTemperatureAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the MaxTemperature attribute\n"); + if (ShouldSkip("TCTL.S.A0002")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheMaxTemperatureAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp\n"); + if (ShouldSkip("TCTL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for 5s\n"); + err = TestWaitFor5s_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the TemperatureSetpoint attribute\n"); + if (ShouldSkip("TCTL.S.A0000")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheTemperatureSetpointAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends command SetTemperatureCommand with an invalid value\n"); + if (ShouldSkip("TCTL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait for 5s\n"); + err = TestWaitFor5s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH reads from the DUT the TemperatureSetpoint attribute\n"); + if (ShouldSkip("TCTL.S.A0000")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheTemperatureSetpointAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 9: Operate device such that a temperature number cannot be accepted\n"); + if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { + NextTest(); + return; + } + err = TestStep9OperateDeviceSuchThatATemperatureNumberCannotBeAccepted_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp\n"); + if (ShouldSkip("TCTL.S.C00.Rsp && PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { + NextTest(); + return; + } + err = TestStep10ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for 5s\n"); + err = TestWaitFor5s_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 11: TH reads from the DUT the TemperatureSetpoint attribute\n"); + if (ShouldSkip("TCTL.S.A0000 && TCTL.S.M.SupportsInvalidInMode")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheTemperatureSetpointAttribute_13(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_IN_STATE)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 14; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mStep5SetTemp; + chip::Optional mInvalidTemp; + chip::Optional mStep10SetTemp; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2OperateDeviceSuchThatATemperatureNumberCanBeAccepted_1() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + NSNumber * _Nonnull minTemp; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheMinTemperatureAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the MinTemperature attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the MinTemperature attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("minTemperature", "temperature", "temperature")); + { + minTemp = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull maxTemp; + + CHIP_ERROR TestStep4ThReadsFromTheDutTheMaxTemperatureAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxTemperatureWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the MaxTemperature attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the MaxTemperature attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("maxTemperature", "temperature", "temperature")); + { + maxTemp = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; + params.targetTemperature = mStep5SetTemp.HasValue() ? [NSNumber numberWithShort:mStep5SetTemp.Value()] : [NSNumber numberWithShort:5]; + [cluster setTemperatureWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Error: %@", err); + } else { + NSLog(@"Step 5: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheTemperatureSetpointAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the TemperatureSetpoint attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; + params.targetTemperature = mInvalidTemp.HasValue() ? [NSNumber numberWithShort:mInvalidTemp.Value()] : [NSNumber numberWithShort:100]; + [cluster setTemperatureWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Error: %@", err); + } else { + NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheTemperatureSetpointAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the TemperatureSetpoint attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9OperateDeviceSuchThatATemperatureNumberCannotBeAccepted_10() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep10ThSendsCommandSetTemperatureCommandWithATemperatureNumberBetweenMinTempAndMaxTempInclusiveSavedAsSetTemp_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; + params.targetTemperature = mStep10SetTemp.HasValue() ? [NSNumber numberWithShort:mStep10SetTemp.Value()] : [NSNumber numberWithShort:50]; + [cluster setTemperatureWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Error: %@", err); + } else { + NSLog(@"Step 10: TH sends command SetTemperatureCommand with a temperature number between minTemp and maxTemp inclusive, saved as setTemp: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_IN_STATE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheTemperatureSetpointAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureSetpointWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the TemperatureSetpoint attribute: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the TemperatureSetpoint attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TemperatureSetpoint", actualValue, mStep5SetTemp.HasValue() ? mStep5SetTemp.Value() : 5)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TCTL_3_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TCTL_3_3() + : TestCommandBridge("Test_TC_TCTL_3_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("Step_4_setLevel", 0, UINT8_MAX, &mStep4SetLevel); + AddArgument("Step_7_setLevel", 0, UINT8_MAX, &mStep7SetLevel); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TCTL_3_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TCTL_3_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TCTL_3_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Operate device such that a temperature level can be accepted\n"); + if (ShouldSkip("PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep2OperateDeviceSuchThatATemperatureLevelCanBeAccepted_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute\n"); + if (ShouldSkip("TCTL.S.A0005")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel\n"); + if (ShouldSkip("TCTL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThSendsCommandSetTemperatureCommandWithAValueFromSupportedLevelsSavedAsSetLevel_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Wait for 5s\n"); + if (ShouldSkip("TCTL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestWaitFor5s_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); + if (ShouldSkip("TCTL.S.A0004 && TCTL.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6:Operate device such that a temperature level cannot be accepted\n"); + if (ShouldSkip("PICS_USER_PROMPT && TCTL.S.M.SupportsInvalidInMode")) { + NextTest(); + return; + } + err = TestStep6OperateDeviceSuchThatATemperatureLevelCannotBeAccepted_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH sends command SetTemperatureCommand with an invalid value\n"); + if (ShouldSkip("TCTL.S.C00.Rsp && TCTL.S.M.SupportsInvalidInMode")) { + NextTest(); + return; + } + err = TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait for 5s\n"); + if (ShouldSkip("TCTL.S.C00.Rsp && TCTL.S.M.SupportsInvalidInMode")) { + NextTest(); + return; + } + err = TestWaitFor5s_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute\n"); + if (ShouldSkip("TCTL.S.A0004 && TCTL.S.M.SupportsInvalidInMode")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mStep4SetLevel; + chip::Optional mStep7SetLevel; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2OperateDeviceSuchThatATemperatureLevelCanBeAccepted_1() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + NSArray * _Nonnull supportedLevels; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheSupportedTemperatureLevelsAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the SupportedTemperatureLevels attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("supportedTemperatureLevels", "list", "list")); + { + supportedLevels = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThSendsCommandSetTemperatureCommandWithAValueFromSupportedLevelsSavedAsSetLevel_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; + params.targetTemperatureLevel = mStep4SetLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mStep4SetLevel.Value()] : [NSNumber numberWithUnsignedChar:1U]; + [cluster setTemperatureWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel: Error: %@", err); + } else { + NSLog(@"Step 4: TH sends command SetTemperatureCommand with a value from supportedLevels saved as setLevel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, mStep4SetLevel.HasValue() ? mStep4SetLevel.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6OperateDeviceSuchThatATemperatureLevelCannotBeAccepted_6() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' after successgarbage: not in length on purpose", 30); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep7ThSendsCommandSetTemperatureCommandWithAnInvalidValue_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; + params.targetTemperatureLevel = mStep7SetLevel.HasValue() ? [NSNumber numberWithUnsignedChar:mStep7SetLevel.Value()] : [NSNumber numberWithUnsignedChar:3U]; + [cluster setTemperatureWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Error: %@", err); + } else { + NSLog(@"Step 7: TH sends command SetTemperatureCommand with an invalid value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitFor5s_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheSelectedTemperatureLevelAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the SelectedTemperatureLevel attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, mStep4SetLevel.HasValue() ? mStep4SetLevel.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TMP_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TMP_1_1() + : TestCommandBridge("Test_TC_TMP_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TMP_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TMP_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TMP_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads ClusterRevision attribute from the DUT\n"); + err = TestStep2ThReadsClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads FeatureMap attribute from the DUT\n"); + err = TestStep3ThReadsFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheGlobalAttributeAttributeList_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheGlobalAttributeAttributeList_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads the optional attribute(Tolerance) in AttributeList\n"); + if (ShouldSkip("TMP.S.A0003")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads AcceptedCommandList attribute from the DUT\n"); + err = TestStep5ThReadsAcceptedCommandListAttributeFromTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads GeneratedCommandList attribute from the DUT\n"); + err = TestStep6ThReadsGeneratedCommandListAttributeFromTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads EventList attribute from the DUT.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheGlobalAttributeAttributeList_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheGlobalAttributeAttributeList_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheOptionalAttributeToleranceInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the optional attribute(Tolerance) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsAcceptedCommandListAttributeFromTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads AcceptedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads AcceptedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsGeneratedCommandListAttributeFromTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads GeneratedCommandList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads GeneratedCommandList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TMP_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TMP_2_1() + : TestCommandBridge("Test_TC_TMP_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TMP_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TMP_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TMP_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the MinMeasuredValue attribute from the DUT\n"); + if (ShouldSkip("TMP.S.A0001")) { + NextTest(); + return; + } + err = TestStep2ThReadsTheMinMeasuredValueAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the MaxMeasuredValue attribute from the DUT\n"); + if (ShouldSkip("TMP.S.A0002")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheMaxMeasuredValueAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the MeasuredValue attribute from the DUT\n"); + if (ShouldSkip("TMP.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsTheMeasuredValueAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads the Tolerance attribute from the DUT\n"); + if (ShouldSkip("TMP.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsTheToleranceAttributeFromTheDut_4(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable CurrentMinMeasured; + + CHIP_ERROR TestStep2ThReadsTheMinMeasuredValueAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the MinMeasuredValue attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the MinMeasuredValue attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("minMeasuredValue", "temperature", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("minMeasuredValue", [value shortValue], -27315)); + VerifyOrReturn(CheckConstraintMaxValue("minMeasuredValue", [value shortValue], 32766)); + } + { + CurrentMinMeasured = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable CurrentMaxMeasured; + + CHIP_ERROR TestStep3ThReadsTheMaxMeasuredValueAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the MaxMeasuredValue attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the MaxMeasuredValue attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("maxMeasuredValue", "temperature", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("maxMeasuredValue", [value shortValue], CurrentMinMeasured)); + VerifyOrReturn(CheckConstraintMaxValue("maxMeasuredValue", [value shortValue], 32767)); + } + { + CurrentMaxMeasured = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheMeasuredValueAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMeasuredValueWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the MeasuredValue attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the MeasuredValue attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("measuredValue", "temperature", "int16s")); + VerifyOrReturn(CheckConstraintMinValue("measuredValue", [value shortValue], CurrentMinMeasured)); + VerifyOrReturn(CheckConstraintMaxValue("measuredValue", [value shortValue], CurrentMaxMeasured)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsTheToleranceAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureMeasurement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeToleranceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads the Tolerance attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("tolerance", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("tolerance", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("tolerance", [value unsignedShortValue], 2048U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TSTAT_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TSTAT_1_1() + : TestCommandBridge("Test_TC_TSTAT_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TSTAT_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSTAT_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSTAT_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Read the global attribute: ClusterRevision\n"); + err = TestStep2ReadTheGlobalAttributeClusterRevision_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: Read the global attribute: FeatureMap\n"); + if (ShouldSkip("!TSTAT.S.F00 && !TSTAT.S.F01 && !TSTAT.S.F02 && !TSTAT.S.F03 && !TSTAT.S.F04 && !TSTAT.S.F05")) { + NextTest(); + return; + } + err = TestStep3aReadTheGlobalAttributeFeatureMap_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TSTAT.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenTstatsf00heatEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TSTAT.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenTstatsf01coolEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TSTAT.S.F02")) { + NextTest(); + return; + } + err = TestStep3dGivenTstatsf02occEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TSTAT.S.F03")) { + NextTest(); + return; + } + err = TestStep3eGivenTstatsf03schEnsureFeaturemapHasTheCorrectBitSet_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TSTAT.S.F04")) { + NextTest(); + return; + } + err = TestStep3fGivenTstatsf04sbEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TSTAT.S.F05")) { + NextTest(); + return; + } + err = TestStep3gGivenTstatsf05autoEnsureFeaturemapHasTheCorrectBitSet_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TSTAT.S.F06")) { + NextTest(); + return; + } + err = TestStep3hGivenTstatsf06ltneEnsureFeaturemapHasTheCorrectBitSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: Read the global attribute: AttributeList\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aReadTheGlobalAttributeAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: Read the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F00")) { + NextTest(); + return; + } + err = TestStep4bReadTheFeatureDependentTSTATSF00HEATAttributeInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: Read the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F01")) { + NextTest(); + return; + } + err = TestStep4cReadTheFeatureDependentTSTATSF01COOLAttributeInAttributeList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4d: Read the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F02")) { + NextTest(); + return; + } + err = TestStep4dReadTheFeatureDependentTSTATSF02OCCAttributeInAttributeList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4e: Read the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.F02")) { + NextTest(); + return; + } + err = TestStep4eReadTheFeatureDependentTSTATSF00HEATTstatsf02occAttributeInAttributeList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4f: Read the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.F02")) { + NextTest(); + return; + } + err = TestStep4fReadTheFeatureDependentTSTATSF01COOLTstatsf02occAttributeInAttributeList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4g: Read the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F05")) { + NextTest(); + return; + } + err = TestStep4gReadTheFeatureDependentTSTATSF05AUTOAttributeInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4h: Read the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F03")) { + NextTest(); + return; + } + err = TestStep4hReadTheFeatureDependentTSTATSF03SCHAttributeInAttributeList_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4i: Read the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F04")) { + NextTest(); + return; + } + err = TestStep4iReadTheFeatureDependentTSTATSF04SBAttributeInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4j: Read the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F04 && TSTAT.S.F02")) { + NextTest(); + return; + } + err = TestStep4jReadTheFeatureDependentTSTATSF04SBTstatsf02occAttributeInAttributeList_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4k: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0001")) { + NextTest(); + return; + } + err = TestStep4kReadTheOptionalAttributeInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4l: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0009")) { + NextTest(); + return; + } + err = TestStep4lReadTheOptionalAttributeInAttributeList_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4m: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0010")) { + NextTest(); + return; + } + err = TestStep4mReadTheOptionalAttributeInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4n: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A001a")) { + NextTest(); + return; + } + err = TestStep4nReadTheOptionalAttributeInAttributeList_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4o: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A001d")) { + NextTest(); + return; + } + err = TestStep4oReadTheOptionalAttributeInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4p: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0023")) { + NextTest(); + return; + } + err = TestStep4pReadTheOptionalAttributeInAttributeList_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4q: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0024")) { + NextTest(); + return; + } + err = TestStep4qReadTheOptionalAttributeInAttributeList_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4r: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0025")) { + NextTest(); + return; + } + err = TestStep4rReadTheOptionalAttributeInAttributeList_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4s: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0029")) { + NextTest(); + return; + } + err = TestStep4sReadTheOptionalAttributeInAttributeList_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4t: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0030")) { + NextTest(); + return; + } + err = TestStep4tReadTheOptionalAttributeInAttributeList_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4u: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0031")) { + NextTest(); + return; + } + err = TestStep4uReadTheOptionalAttributeInAttributeList_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4x: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0032")) { + NextTest(); + return; + } + err = TestStep4xReadTheOptionalAttributeInAttributeList_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Step 5y: Read the optional attribute: AttributeList\n"); + if (ShouldSkip("TSTAT.S.A003a")) { + NextTest(); + return; + } + err = TestStep5yReadTheOptionalAttributeAttributeList_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4z: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0040")) { + NextTest(); + return; + } + err = TestStep4zReadTheOptionalAttributeInAttributeList_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4A: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0041")) { + NextTest(); + return; + } + err = TestStep4aReadTheOptionalAttributeInAttributeList_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4B: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0042")) { + NextTest(); + return; + } + err = TestStep4bReadTheOptionalAttributeInAttributeList_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Step 4C: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0043")) { + NextTest(); + return; + } + err = TestStep4cReadTheOptionalAttributeInAttributeList_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Step 5D: Read the optional attribute: AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0044")) { + NextTest(); + return; + } + err = TestStep5dReadTheOptionalAttributeAttributeList_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Step 4E: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0045")) { + NextTest(); + return; + } + err = TestStep4eReadTheOptionalAttributeInAttributeList_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Step 4F: Read the optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0046")) { + NextTest(); + return; + } + err = TestStep4fReadTheOptionalAttributeInAttributeList_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Step 5G: Read the optional attribute: AttributeList\n"); + if (ShouldSkip("TSTAT.S.A0047")) { + NextTest(); + return; + } + err = TestStep5gReadTheOptionalAttributeAttributeList_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Step 4H: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0003")) { + NextTest(); + return; + } + err = TestStep4hReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Step 4I: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0004")) { + NextTest(); + return; + } + err = TestStep4iReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Step 4J: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0008")) { + NextTest(); + return; + } + err = TestStep4jReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Step 4K: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0015")) { + NextTest(); + return; + } + err = TestStep4kReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Step 4L: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F00 && TSTAT.S.A0016")) { + NextTest(); + return; + } + err = TestStep4lReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Step 4M: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0005")) { + NextTest(); + return; + } + err = TestStep4mReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Step 4N: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0007")) { + NextTest(); + return; + } + err = TestStep4nReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_48(); + break; + case 49: + ChipLogProgress(chipTool, " ***** Test Step 49 : Step 4O: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0007")) { + NextTest(); + return; + } + err = TestStep4oReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_49(); + break; + case 50: + ChipLogProgress(chipTool, " ***** Test Step 50 : Step 4P: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0017")) { + NextTest(); + return; + } + err = TestStep4pReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_50(); + break; + case 51: + ChipLogProgress(chipTool, " ***** Test Step 51 : Step 4Q: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F01 && TSTAT.S.A0018")) { + NextTest(); + return; + } + err = TestStep4qReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_51(); + break; + case 52: + ChipLogProgress(chipTool, " ***** Test Step 52 : Step 4R: Read the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList\n"); + if (ShouldSkip("TSTAT.S.F05 && TSTAT.S.A001e")) { + NextTest(); + return; + } + err = TestStep4rReadTheFeatureDependentTSTATSF05AUTOOptionalAttributeInAttributeList_52(); + break; + case 53: + ChipLogProgress(chipTool, " ***** Test Step 53 : Step 5a: Read the mandatory commands in AcceptedCommandList\n"); + err = TestStep5aReadTheMandatoryCommandsInAcceptedCommandList_53(); + break; + case 54: + ChipLogProgress(chipTool, " ***** Test Step 54 : Step 5b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList\n"); + if (ShouldSkip("TSTAT.S.F03")) { + NextTest(); + return; + } + err = TestStep5bReadFeatureDependentTSTATSF03SCHCommandsInAcceptedCommandList_54(); + break; + case 55: + ChipLogProgress(chipTool, " ***** Test Step 55 : Step 5c: Read the optional (GetRelayStatusLog) command in AcceptedCommandList\n"); + if (ShouldSkip("TSTAT.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep5cReadTheOptionalGetRelayStatusLogCommandInAcceptedCommandList_55(); + break; + case 56: + ChipLogProgress(chipTool, " ***** Test Step 56 : Step 6a: Read the global attribute: GeneratedCommandList\n"); + if (ShouldSkip(" !TSTAT.S.C04.Rsp && !TSTAT.S.C02.Rsp ")) { + NextTest(); + return; + } + err = TestStep6aReadTheGlobalAttributeGeneratedCommandList_56(); + break; + case 57: + ChipLogProgress(chipTool, " ***** Test Step 57 : Step 6b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList\n"); + if (ShouldSkip("TSTAT.S.F03")) { + NextTest(); + return; + } + err = TestStep6bReadFeatureDependentTSTATSF03SCHCommandsInGeneratedCommandList_57(); + break; + case 58: + ChipLogProgress(chipTool, " ***** Test Step 58 : Step 6c: Read optional command (GetRelayStatusLogResponse) in GeneratedCommandList\n"); + if (ShouldSkip("TSTAT.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep6cReadOptionalCommandGetRelayStatusLogResponseInGeneratedCommandList_58(); + break; + case 59: + ChipLogProgress(chipTool, " ***** Test Step 59 : Step 7: Read EventList attribute from the DUT.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 49: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 50: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 51: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 52: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 53: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 54: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 55: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 56: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 57: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 58: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 59: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 60; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ReadTheGlobalAttributeClusterRevision_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Error: %@", err); + } else { + NSLog(@"Step 2: Read the global attribute: ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 6U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aReadTheGlobalAttributeFeatureMap_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: Read the global attribute: FeatureMap: Error: %@", err); + } else { + NSLog(@"Step 3a: Read the global attribute: FeatureMap: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenTstatsf00heatEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given TSTAT.S.F00(HEAT ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenTstatsf01coolEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given TSTAT.S.F01(COOL) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenTstatsf02occEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given TSTAT.S.F02(OCC) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenTstatsf03schEnsureFeaturemapHasTheCorrectBitSet_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3e: Given TSTAT.S.F03(SCH) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenTstatsf04sbEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given TSTAT.S.F04(SB) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenTstatsf05autoEnsureFeaturemapHasTheCorrectBitSet_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3g: Given TSTAT.S.F05(AUTO) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenTstatsf06ltneEnsureFeaturemapHasTheCorrectBitSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given TSTAT.S.F06(LTNE) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheGlobalAttributeAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4a: Read the global attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheFeatureDependentTSTATSF00HEATAttributeInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: Read the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: Read the Feature dependent(TSTAT.S.F00(HEAT)) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cReadTheFeatureDependentTSTATSF01COOLAttributeInAttributeList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Read the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: Read the Feature dependent(TSTAT.S.F01(COOL)) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dReadTheFeatureDependentTSTATSF02OCCAttributeInAttributeList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: Read the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: Read the Feature dependent(TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eReadTheFeatureDependentTSTATSF00HEATTstatsf02occAttributeInAttributeList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Read the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: Read the Feature dependent(TSTAT.S.F00(HEAT) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fReadTheFeatureDependentTSTATSF01COOLTstatsf02occAttributeInAttributeList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: Read the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: Read the Feature dependent(TSTAT.S.F01(COOL) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gReadTheFeatureDependentTSTATSF05AUTOAttributeInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Read the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4g: Read the Feature dependent(TSTAT.S.F05(AUTO)) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hReadTheFeatureDependentTSTATSF03SCHAttributeInAttributeList_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: Read the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: Read the Feature dependent(TSTAT.S.F03(SCH)) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iReadTheFeatureDependentTSTATSF04SBAttributeInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: Read the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4i: Read the Feature dependent(TSTAT.S.F04(SB)) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 53UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jReadTheFeatureDependentTSTATSF04SBTstatsf02occAttributeInAttributeList_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: Read the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: Read the Feature dependent(TSTAT.S.F04(SB) & TSTAT.S.F02(OCC)) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 57UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kReadTheOptionalAttributeInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4k: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4lReadTheOptionalAttributeInAttributeList_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4l: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4l: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4mReadTheOptionalAttributeInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4m: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4m: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4nReadTheOptionalAttributeInAttributeList_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4n: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4n: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4oReadTheOptionalAttributeInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4o: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4o: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 29UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4pReadTheOptionalAttributeInAttributeList_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4p: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4p: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4qReadTheOptionalAttributeInAttributeList_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4q: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4q: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4rReadTheOptionalAttributeInAttributeList_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4r: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4r: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4sReadTheOptionalAttributeInAttributeList_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4s: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4s: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4tReadTheOptionalAttributeInAttributeList_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4t: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4t: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4uReadTheOptionalAttributeInAttributeList_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4u: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4u: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4xReadTheOptionalAttributeInAttributeList_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4x: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4x: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5yReadTheOptionalAttributeAttributeList_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5y: Read the optional attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 5y: Read the optional attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4zReadTheOptionalAttributeInAttributeList_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4z: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4z: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 64UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aReadTheOptionalAttributeInAttributeList_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4A: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4A: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bReadTheOptionalAttributeInAttributeList_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4B: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4B: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 66UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cReadTheOptionalAttributeInAttributeList_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4C: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4C: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 67UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5dReadTheOptionalAttributeAttributeList_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5D: Read the optional attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 5D: Read the optional attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 68UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eReadTheOptionalAttributeInAttributeList_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4E: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4E: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 69UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fReadTheOptionalAttributeInAttributeList_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4F: Read the optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4F: Read the optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 70UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5gReadTheOptionalAttributeAttributeList_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5G: Read the optional attribute: AttributeList: Error: %@", err); + } else { + NSLog(@"Step 5G: Read the optional attribute: AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 71UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4H: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4H: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4I: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4I: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4J: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4J: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4K: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4K: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4lReadTheFeatureDependentTSTATSF00HEATOptionalAttributeInAttributeList_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4L: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4L: Read the Feature dependent(TSTAT.S.F00(HEAT)) optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4mReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4M: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4M: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4nReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4N: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4N: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4oReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_49() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4O: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4O: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4pReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_50() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4P: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4P: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4qReadTheFeatureDependentTSTATSF01COOLOptionalAttributeInAttributeList_51() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4Q: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4Q: Read the Feature dependent(TSTAT.S.F01(COOL)) optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4rReadTheFeatureDependentTSTATSF05AUTOOptionalAttributeInAttributeList_52() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4R: Read the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4R: Read the Feature dependent(TSTAT.S.F05(AUTO)) optional attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 30UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aReadTheMandatoryCommandsInAcceptedCommandList_53() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: Read the mandatory commands in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 5a: Read the mandatory commands in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bReadFeatureDependentTSTATSF03SCHCommandsInAcceptedCommandList_54() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 5b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5cReadTheOptionalGetRelayStatusLogCommandInAcceptedCommandList_55() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5c: Read the optional (GetRelayStatusLog) command in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 5c: Read the optional (GetRelayStatusLog) command in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aReadTheGlobalAttributeGeneratedCommandList_56() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6a: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bReadFeatureDependentTSTATSF03SCHCommandsInGeneratedCommandList_57() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6b: Read Feature dependent(TSTAT.S.F03(SCH)) commands in GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cReadOptionalCommandGetRelayStatusLogResponseInGeneratedCommandList_58() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostat alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: Read optional command (GetRelayStatusLogResponse) in GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6c: Read optional command (GetRelayStatusLogResponse) in GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TSUIC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TSUIC_1_1() + : TestCommandBridge("Test_TC_TSUIC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TSUIC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList\n"); + if (ShouldSkip("TSUIC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4bThReadsOptionalAttributeScheduleProgrammingVisibilityInAttributeList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsOptionalAttributeScheduleProgrammingVisibilityInAttributeList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads optional attribute(ScheduleProgrammingVisibility) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheAcceptedCommandListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheGeneratedCommandListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TSUIC_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TSUIC_2_1() + : TestCommandBridge("Test_TC_TSUIC_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TSUIC_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the TemperatureDisplayMode attribute from the DUT\n"); + if (ShouldSkip("TSUIC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsTheTemperatureDisplayModeAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the KeypadLockout attribute from the DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsTheKeypadLockoutAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT\n"); + if (ShouldSkip("TSUIC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4ThReadsTheScheduleProgrammingVisibilityAttributeFromTheDut_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheTemperatureDisplayModeAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the TemperatureDisplayMode attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the TemperatureDisplayMode attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("temperatureDisplayMode", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("temperatureDisplayMode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("temperatureDisplayMode", [value unsignedCharValue], 1U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheKeypadLockoutAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the KeypadLockout attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the KeypadLockout attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("keypadLockout", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("keypadLockout", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("keypadLockout", [value unsignedCharValue], 5U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsTheScheduleProgrammingVisibilityAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads the ScheduleProgrammingVisibility attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("scheduleProgrammingVisibility", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("scheduleProgrammingVisibility", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("scheduleProgrammingVisibility", [value unsignedCharValue], 1U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TSUIC_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TSUIC_2_2() + : TestCommandBridge("Test_TC_TSUIC_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TSUIC_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TSUIC_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TSUIC_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2aThWritesAValueOf0ToTemperatureDisplayModeAttributeOfDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Verify device temperature displayed in °C\n"); + if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0000")) { + NextTest(); + return; + } + err = TestVerifyDeviceTemperatureDisplayedInc_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads the TemperatureDisplayMode attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2bThReadsTheTemperatureDisplayModeAttributeOfDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2cThWritesAValueOf1ToTemperatureDisplayModeAttributeOfDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Verify device temperature displayed in °F\n"); + if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0000")) { + NextTest(); + return; + } + err = TestVerifyDeviceTemperatureDisplayedInf_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2d: TH reads the TemperatureDisplayMode attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2dThReadsTheTemperatureDisplayModeAttributeOfDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2eThWritesAValueOfGreaterThan1ToTemperatureDisplayModeAttributeOfDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2f: TH reads the TemperatureDisplayMode attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0000")) { + NextTest(); + return; + } + err = TestStep2fThReadsTheTemperatureDisplayModeAttributeOfDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3aThWritesAValueOf0ToKeypadLockoutAttributeOfDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Verify all device functionality available to the user\n"); + if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestVerifyAllDeviceFunctionalityAvailableToTheUser_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH reads the KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3bThReadsTheKeypadLockoutAttributeOfDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3cThWritesAValueOf1ToKeypadLockoutAttributeOfDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Verify device operates at Level 1 reduced functionality\n"); + if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestVerifyDeviceOperatesAtLevel1ReducedFunctionality_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: TH reads the KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3dThReadsTheKeypadLockoutAttributeOfDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3eThWritesAValueOf2ToKeypadLockoutAttributeOfDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Verify device operates at Level 2 reduced functionality\n"); + if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestVerifyDeviceOperatesAtLevel2ReducedFunctionality_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3f: TH reads the KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3fThReadsTheKeypadLockoutAttributeOfDut_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3gThWritesAValueOf3ToKeypadLockoutAttributeOfDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Verify device operates at Level 3 reduced functionality\n"); + if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestVerifyDeviceOperatesAtLevel3ReducedFunctionality_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3h: TH reads the KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3hThReadsTheKeypadLockoutAttributeOfDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3iThWritesAValueOf4ToKeypadLockoutAttributeOfDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Verify device operates at Level 4 reduced functionality\n"); + if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestVerifyDeviceOperatesAtLevel4ReducedFunctionality_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3j: TH reads the KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3jThReadsTheKeypadLockoutAttributeOfDut_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3kThWritesAValueOf5ToKeypadLockoutAttributeOfDut_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Verify device operates at least functionality level\n"); + if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestVerifyDeviceOperatesAtLeastFunctionalityLevel_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 3l: TH reads the KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3lThReadsTheKeypadLockoutAttributeOfDut_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3mWritesAValueOfGreaterThan5ToKeypadLockoutAttributeOfDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 3n: TH reads the KeypadLockout attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0001")) { + NextTest(); + return; + } + err = TestStep3nThReadsTheKeypadLockoutAttributeOfDut_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4aThWritesAValueOf0ToScheduleProgrammingVisibilityAttributeOfDut_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Verify local schedule programming functionality is enabled at the thermostat\n"); + if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0002")) { + NextTest(); + return; + } + err = TestVerifyLocalScheduleProgrammingFunctionalityIsEnabledAtTheThermostat_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheScheduleProgrammingVisibilityAttributeOfDut_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4cThWritesAValueOf1ToScheduleProgrammingVisibilityAttributeOfDut_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Verify local schedule programming functionality is disabled at the thermostat\n"); + if (ShouldSkip("PICS_USER_PROMPT && TSUIC.S.A0002")) { + NextTest(); + return; + } + err = TestVerifyLocalScheduleProgrammingFunctionalityIsDisabledAtTheThermostat_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheScheduleProgrammingVisibilityAttributeOfDut_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4eThWritesAValueOfGreaterThan1ToScheduleProgrammingVisibilityAttributeOfDut_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT\n"); + if (ShouldSkip("TSUIC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4fThReadsTheScheduleProgrammingVisibilityAttributeOfDut_36(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 37; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2aThWritesAValueOf0ToTemperatureDisplayModeAttributeOfDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id temperatureDisplayModeArgument; + temperatureDisplayModeArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH writes a value of 0 to TemperatureDisplayMode attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyDeviceTemperatureDisplayedInc_2() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2bThReadsTheTemperatureDisplayModeAttributeOfDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads the TemperatureDisplayMode attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cThWritesAValueOf1ToTemperatureDisplayModeAttributeOfDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id temperatureDisplayModeArgument; + temperatureDisplayModeArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH writes a value of 1 to TemperatureDisplayMode attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyDeviceTemperatureDisplayedInf_5() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep2dThReadsTheTemperatureDisplayModeAttributeOfDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads the TemperatureDisplayMode attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2eThWritesAValueOfGreaterThan1ToTemperatureDisplayModeAttributeOfDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id temperatureDisplayModeArgument; + temperatureDisplayModeArgument = + [NSNumber numberWithUnsignedChar:2U]; + [cluster writeAttributeTemperatureDisplayModeWithValue:temperatureDisplayModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 2e: TH writes a value of greater than 1 to TemperatureDisplayMode attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2fThReadsTheTemperatureDisplayModeAttributeOfDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTemperatureDisplayModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH reads the TemperatureDisplayMode attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 2f: TH reads the TemperatureDisplayMode attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TemperatureDisplayMode", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThWritesAValueOf0ToKeypadLockoutAttributeOfDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id keypadLockoutArgument; + keypadLockoutArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH writes a value of 0 to KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyAllDeviceFunctionalityAvailableToTheUser_10() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3bThReadsTheKeypadLockoutAttributeOfDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads the KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads the KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThWritesAValueOf1ToKeypadLockoutAttributeOfDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id keypadLockoutArgument; + keypadLockoutArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH writes a value of 1 to KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyDeviceOperatesAtLevel1ReducedFunctionality_13() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3dThReadsTheKeypadLockoutAttributeOfDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads the KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads the KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eThWritesAValueOf2ToKeypadLockoutAttributeOfDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id keypadLockoutArgument; + keypadLockoutArgument = + [NSNumber numberWithUnsignedChar:2U]; + [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3e: TH writes a value of 2 to KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyDeviceOperatesAtLevel2ReducedFunctionality_16() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3fThReadsTheKeypadLockoutAttributeOfDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: TH reads the KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3f: TH reads the KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gThWritesAValueOf3ToKeypadLockoutAttributeOfDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id keypadLockoutArgument; + keypadLockoutArgument = + [NSNumber numberWithUnsignedChar:3U]; + [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3g: TH writes a value of 3 to KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyDeviceOperatesAtLevel3ReducedFunctionality_19() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3hThReadsTheKeypadLockoutAttributeOfDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: TH reads the KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3h: TH reads the KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iThWritesAValueOf4ToKeypadLockoutAttributeOfDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id keypadLockoutArgument; + keypadLockoutArgument = + [NSNumber numberWithUnsignedChar:4U]; + [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3i: TH writes a value of 4 to KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyDeviceOperatesAtLevel4ReducedFunctionality_22() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3jThReadsTheKeypadLockoutAttributeOfDut_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: TH reads the KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3j: TH reads the KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kThWritesAValueOf5ToKeypadLockoutAttributeOfDut_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id keypadLockoutArgument; + keypadLockoutArgument = + [NSNumber numberWithUnsignedChar:5U]; + [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3k: TH writes a value of 5 to KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyDeviceOperatesAtLeastFunctionalityLevel_25() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3lThReadsTheKeypadLockoutAttributeOfDut_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: TH reads the KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3l: TH reads the KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 5U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3mWritesAValueOfGreaterThan5ToKeypadLockoutAttributeOfDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id keypadLockoutArgument; + keypadLockoutArgument = + [NSNumber numberWithUnsignedChar:6U]; + [cluster writeAttributeKeypadLockoutWithValue:keypadLockoutArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3m: Writes a value of greater than 5 to KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3nThReadsTheKeypadLockoutAttributeOfDut_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeKeypadLockoutWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3n: TH reads the KeypadLockout attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 3n: TH reads the KeypadLockout attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("KeypadLockout", actualValue, 5U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThWritesAValueOf0ToScheduleProgrammingVisibilityAttributeOfDut_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id scheduleProgrammingVisibilityArgument; + scheduleProgrammingVisibilityArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH writes a value of 0 to ScheduleProgrammingVisibility attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyLocalScheduleProgrammingFunctionalityIsEnabledAtTheThermostat_30() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep4bThReadsTheScheduleProgrammingVisibilityAttributeOfDut_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThWritesAValueOf1ToScheduleProgrammingVisibilityAttributeOfDut_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id scheduleProgrammingVisibilityArgument; + scheduleProgrammingVisibilityArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH writes a value of 1 to ScheduleProgrammingVisibility attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyLocalScheduleProgrammingFunctionalityIsDisabledAtTheThermostat_33() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep4dThReadsTheScheduleProgrammingVisibilityAttributeOfDut_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThWritesAValueOfGreaterThan1ToScheduleProgrammingVisibilityAttributeOfDut_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id scheduleProgrammingVisibilityArgument; + scheduleProgrammingVisibilityArgument = + [NSNumber numberWithUnsignedChar:2U]; + [cluster writeAttributeScheduleProgrammingVisibilityWithValue:scheduleProgrammingVisibilityArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 4e: TH writes a value of greater than 1 to ScheduleProgrammingVisibility attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsTheScheduleProgrammingVisibilityAttributeOfDut_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThermostatUserInterfaceConfiguration alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeScheduleProgrammingVisibilityWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads the ScheduleProgrammingVisibility attribute of DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ScheduleProgrammingVisibility", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DGTHREAD_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DGTHREAD_1_1() + : TestCommandBridge("Test_TC_DGTHREAD_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DGTHREAD_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGTHREAD_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGTHREAD_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); + err = TestStep2ThReadsTheClusterRevisionFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); + if (ShouldSkip(" !DGTHREAD.S.F00 && !DGTHREAD.S.F01 && !DGTHREAD.S.F02 && !DGTHREAD.S.F03 ")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheFeatureMapFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DGTHREAD.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenDgthreadsf00pktcntEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DGTHREAD.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenDgthreadsf01errcntEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DGTHREAD.S.F02")) { + NextTest(); + return; + } + err = TestStep3dGivenDgthreadsf02mlecntEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DGTHREAD.S.F03")) { + NextTest(); + return; + } + err = TestStep3eGivenDgthreadsf03maccntEnsureFeaturemapHasTheCorrectBitSet_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads mandatory attributes in AttributeList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads mandatory attributes in AttributeList from DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList\n"); + if (ShouldSkip("DGTHREAD.S.A0006 && DGTHREAD.S.F01")) { + NextTest(); + return; + } + err = TestStep4bThReadsFeatureDependentAttributeDGTHREADSF01ERRCNTInAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList\n"); + if (ShouldSkip("DGTHREAD.S.F02")) { + NextTest(); + return; + } + err = TestStep4cThReadsFeatureDependentAttributeDgthreadsf02mlecntInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList\n"); + if (ShouldSkip("DGTHREAD.S.F03")) { + NextTest(); + return; + } + err = TestStep4dThReadsFeatureDependentAttributeDgthreadsf03maccntInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList\n"); + if (ShouldSkip("DGTHREAD.S.A0038")) { + NextTest(); + return; + } + err = TestStep4eThReadsTheOptionalAttributeActiveTimestampInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList\n"); + if (ShouldSkip("DGTHREAD.S.A0039")) { + NextTest(); + return; + } + err = TestStep4fThReadsTheOptionalAttributePendingTimestampInAttributeList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4g: TH reads the optional attribute (Delay) in AttributeList\n"); + if (ShouldSkip("DGTHREAD.S.A003a")) { + NextTest(); + return; + } + err = TestStep4gThReadsTheOptionalAttributeDelayInAttributeList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5a: TH reads EventList from DUT\n"); + if (ShouldSkip(" !DGTHREAD.S.E00 && !DGTHREAD.S.E01 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5b: TH reads DGTHREAD.S.E00(ConnectionStatus) event in EventList\n"); + if (ShouldSkip("DGTHREAD.S.E00 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5c: TH reads DGTHREAD.S.E01(NetworkFaultChange) event in EventList\n"); + if (ShouldSkip("DGTHREAD.S.E01 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6: TH reads AcceptedCommandList from DUT\n"); + if (ShouldSkip(" !DGTHREAD.S.F01 ")) { + NextTest(); + return; + } + err = TestStep6ThReadsAcceptedCommandListFromDut_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6: TH reads AcceptedCommandList from DUT\n"); + if (ShouldSkip("DGTHREAD.S.F01")) { + NextTest(); + return; + } + err = TestStep6ThReadsAcceptedCommandListFromDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7: TH reads GeneratedCommandList from DUT\n"); + err = TestStep7ThReadsGeneratedCommandListFromDut_20(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 21; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenDgthreadsf00pktcntEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given DGTHREAD.S.F00(PKTCNT) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenDgthreadsf01errcntEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given DGTHREAD.S.F01(ERRCNT) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenDgthreadsf02mlecntEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given DGTHREAD.S.F02(MLECNT) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenDgthreadsf03maccntEnsureFeaturemapHasTheCorrectBitSet_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3e: Given DGTHREAD.S.F03(MACCNT) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 61UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 62UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsMandatoryAttributesInAttributeListFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads mandatory attributes in AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 59UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 60UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 61UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 62UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFeatureDependentAttributeDGTHREADSF01ERRCNTInAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads Feature dependent attribute(DGTHREAD.S.F01(ERRCNT)) in attributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsFeatureDependentAttributeDgthreadsf02mlecntInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads Feature dependent attribute (DGTHREAD.S.F02(MLECNT)) in attributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsFeatureDependentAttributeDgthreadsf03maccntInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads Feature dependent attribute (DGTHREAD.S.F03(MACCNT)) in attributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 29UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 30UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 31UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 32UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 39UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 43UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 44UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 45UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 46UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 47UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 50UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 52UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 53UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 54UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 55UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsTheOptionalAttributeActiveTimestampInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads the optional attribute (ActiveTimestamp) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 56UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsTheOptionalAttributePendingTimestampInAttributeList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads the optional attribute (PendingTimestamp) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 57UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThReadsTheOptionalAttributeDelayInAttributeList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH reads the optional attribute (Delay) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4g: TH reads the optional attribute (Delay) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 58UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterThreadNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TIMESYNC_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TIMESYNC_1_1() + : TestCommandBridge("Test_TC_TIMESYNC_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TIMESYNC_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TIMESYNC_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TIMESYNC_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip("TIMESYNC.S.F00")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear\n"); + if (ShouldSkip("!TIMESYNC.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGiventimesyncsf00tzEnsureFeaturemapHasTheCorrectBitClear_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TIMESYNC.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenTimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear\n"); + if (ShouldSkip("!TIMESYNC.S.F01")) { + NextTest(); + return; + } + err = TestStep3dGiventimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitClear_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TIMESYNC.S.F02")) { + NextTest(); + return; + } + err = TestStep3eGivenTimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitSet_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear\n"); + if (ShouldSkip("!TIMESYNC.S.F02")) { + NextTest(); + return; + } + err = TestStep3fGiventimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitClear_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("TIMESYNC.S.F03")) { + NextTest(); + return; + } + err = TestStep3gGivenTimesyncsf03tscEnsureFeaturemapHasTheCorrectBitSet_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear\n"); + if (ShouldSkip("!TIMESYNC.S.F03")) { + NextTest(); + return; + } + err = TestStep3hGiventimesyncsf03tscEnsureFeaturemapHasTheCorrectBitClear_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheAttributeListAttribute_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: Check for optional attribute TimeSource in AttributeList\n"); + if (ShouldSkip("TIMESYNC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4cCheckForOptionalAttributeTimeSourceInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4d: Check for optional attribute TimeSource not in AttributeList\n"); + if (ShouldSkip("!TIMESYNC.S.A0002")) { + NextTest(); + return; + } + err = TestStep4dCheckForOptionalAttributeTimeSourceNotInAttributeList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4e: Check for TZ feature-based attributes in AttributeList\n"); + if (ShouldSkip("TIMESYNC.S.F00")) { + NextTest(); + return; + } + err = TestStep4eCheckForTzFeatureBasedAttributesInAttributeList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4f: Check for TZ feature-based attributes not in AttributeList\n"); + if (ShouldSkip("!TIMESYNC.S.F00")) { + NextTest(); + return; + } + err = TestStep4fCheckForTzFeatureBasedAttributesNotInAttributeList_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4g: Check for NTPC feature-based attributes in AttributeList\n"); + if (ShouldSkip("TIMESYNC.S.F01")) { + NextTest(); + return; + } + err = TestStep4gCheckForNtpcFeatureBasedAttributesInAttributeList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4h: Check for NTPC feature-based attributes not in AttributeList\n"); + if (ShouldSkip("!TIMESYNC.S.F01")) { + NextTest(); + return; + } + err = TestStep4hCheckForNtpcFeatureBasedAttributesNotInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4i: Check for NTPS feature-based attributes in AttributeList\n"); + if (ShouldSkip("TIMESYNC.S.F02")) { + NextTest(); + return; + } + err = TestStep4iCheckForNtpsFeatureBasedAttributesInAttributeList_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4j: Check for NTPS feature-based attributes not in AttributeList\n"); + if (ShouldSkip("!TIMESYNC.S.F02")) { + NextTest(); + return; + } + err = TestStep4jCheckForNtpsFeatureBasedAttributesNotInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4k: Check for TSC feature-based attributes in AttributeList\n"); + if (ShouldSkip("TIMESYNC.S.F03")) { + NextTest(); + return; + } + err = TestStep4kCheckForTscFeatureBasedAttributesInAttributeList_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4l: Check for TSC feature-based attributes not in AttributeList\n"); + if (ShouldSkip("!TIMESYNC.S.F03")) { + NextTest(); + return; + } + err = TestStep4lCheckForTscFeatureBasedAttributesNotInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5a: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 5b: Check for TZ feature-based events in EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && TIMESYNC.S.F00")) { + NextTest(); + return; + } + NextTest(); + return; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 5c: Check for TZ feature-based events not in EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !TIMESYNC.S.F00")) { + NextTest(); + return; + } + NextTest(); + return; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 5d: Check for TSC feature-based events in EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && TIMESYNC.S.F03")) { + NextTest(); + return; + } + NextTest(); + return; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5e: Check for TSC feature-based events not in EventList\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && !TIMESYNC.S.F03")) { + NextTest(); + return; + } + NextTest(); + return; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 6b: Check for TZ feature-based commands in AcceptedCommandList\n"); + if (ShouldSkip("TIMESYNC.S.F00")) { + NextTest(); + return; + } + err = TestStep6bCheckForTzFeatureBasedCommandsInAcceptedCommandList_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 6c: Check for TZ feature-based commands in not AcceptedCommandList\n"); + if (ShouldSkip("!TIMESYNC.S.F00")) { + NextTest(); + return; + } + err = TestStep6cCheckForTzFeatureBasedCommandsInNotAcceptedCommandList_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Step 6d: Check for NTPC feature-based commands in AcceptedCommandList\n"); + if (ShouldSkip("TIMESYNC.S.F01")) { + NextTest(); + return; + } + err = TestStep6dCheckForNtpcFeatureBasedCommandsInAcceptedCommandList_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList\n"); + if (ShouldSkip("!TIMESYNC.S.F01")) { + NextTest(); + return; + } + err = TestStep6eCheckForNtpcFeatureBasedCommandsInNotAcceptedCommandList_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Step 6f: Check for TSC feature-based commands in AcceptedCommandList\n"); + if (ShouldSkip("TIMESYNC.S.F03")) { + NextTest(); + return; + } + err = TestStep6fCheckForTscFeatureBasedCommandsInAcceptedCommandList_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Step 6g: Check for TSC feature-based commands in not AcceptedCommandList\n"); + if (ShouldSkip("!TIMESYNC.S.F03")) { + NextTest(); + return; + } + err = TestStep6gCheckForTscFeatureBasedCommandsInNotAcceptedCommandList_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Step 7a: TH reads from the DUT the GeneratedCommandList attribute\n"); + if (ShouldSkip("TIMESYNC.S.F00")) { + NextTest(); + return; + } + err = TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Step 7b: Check for TZ feature-based commands in not GeneratedCommandList\n"); + if (ShouldSkip("!TIMESYNC.S.F00")) { + NextTest(); + return; + } + err = TestStep7bCheckForTzFeatureBasedCommandsInNotGeneratedCommandList_35(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 36; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGiventimesyncsf00tzEnsureFeaturemapHasTheCorrectBitClear_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3b: Given !TIMESYNC.S.F00(TZ) ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenTimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGiventimesyncsf01ntpcEnsureFeaturemapHasTheCorrectBitClear_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3d: Given !TIMESYNC.S.F01(NTPC) ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenTimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitSet_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3e: Given TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGiventimesyncsf02ntpsEnsureFeaturemapHasTheCorrectBitClear_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3f: Given !TIMESYNC.S.F02(NTPS) ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenTimesyncsf03tscEnsureFeaturemapHasTheCorrectBitSet_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3g: Given TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGiventimesyncsf03tscEnsureFeaturemapHasTheCorrectBitClear_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear: Error: %@", err); + } else { + NSLog(@"Step 3h: Given !TIMESYNC.S.F03(TSC) ensure featuremap has the correct bit clear: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheAttributeListAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cCheckForOptionalAttributeTimeSourceInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: Check for optional attribute TimeSource in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: Check for optional attribute TimeSource in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dCheckForOptionalAttributeTimeSourceNotInAttributeList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: Check for optional attribute TimeSource not in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: Check for optional attribute TimeSource not in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eCheckForTzFeatureBasedAttributesInAttributeList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: Check for TZ feature-based attributes in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: Check for TZ feature-based attributes in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fCheckForTzFeatureBasedAttributesNotInAttributeList_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: Check for TZ feature-based attributes not in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: Check for TZ feature-based attributes not in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 6UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 8UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 10UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 11UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gCheckForNtpcFeatureBasedAttributesInAttributeList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: Check for NTPC feature-based attributes in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4g: Check for NTPC feature-based attributes in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hCheckForNtpcFeatureBasedAttributesNotInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: Check for NTPC feature-based attributes not in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: Check for NTPC feature-based attributes not in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 12UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iCheckForNtpsFeatureBasedAttributesInAttributeList_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: Check for NTPS feature-based attributes in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4i: Check for NTPS feature-based attributes in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jCheckForNtpsFeatureBasedAttributesNotInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: Check for NTPS feature-based attributes not in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: Check for NTPS feature-based attributes not in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 9UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kCheckForTscFeatureBasedAttributesInAttributeList_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: Check for TSC feature-based attributes in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4k: Check for TSC feature-based attributes in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4lCheckForTscFeatureBasedAttributesNotInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4l: Check for TSC feature-based attributes not in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4l: Check for TSC feature-based attributes not in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintExcludes("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bCheckForTzFeatureBasedCommandsInAcceptedCommandList_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: Check for TZ feature-based commands in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6b: Check for TZ feature-based commands in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cCheckForTzFeatureBasedCommandsInNotAcceptedCommandList_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: Check for TZ feature-based commands in not AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6c: Check for TZ feature-based commands in not AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6dCheckForNtpcFeatureBasedCommandsInAcceptedCommandList_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: Check for NTPC feature-based commands in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6d: Check for NTPC feature-based commands in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6eCheckForNtpcFeatureBasedCommandsInNotAcceptedCommandList_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6e: Check for NTPC feature-based commands in not AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6fCheckForTscFeatureBasedCommandsInAcceptedCommandList_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6f: Check for TSC feature-based commands in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6f: Check for TSC feature-based commands in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6gCheckForTscFeatureBasedCommandsInNotAcceptedCommandList_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6g: Check for TSC feature-based commands in not AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6g: Check for TSC feature-based commands in not AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintExcludes("acceptedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7bCheckForTzFeatureBasedCommandsInNotGeneratedCommandList_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7b: Check for TZ feature-based commands in not GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7b: Check for TZ feature-based commands in not GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintExcludes("generatedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_TIMESYNC_2_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_TIMESYNC_2_3() + : TestCommandBridge("Test_TC_TIMESYNC_2_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_TIMESYNC_2_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_TIMESYNC_2_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_TIMESYNC_2_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read commissioner nodeID and saves as th_node_id\n"); + err = TestReadCommissionerNodeIDAndSavesAsThNodeId_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0\n"); + err = TestStep1ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceFieldsSetAsFollowsNodeIDThNodeIdEndpoint0_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx\n"); + err = TestStep2ThReadsFromTheDutTheCurrentFabricIndexAttributeFromTheNodeOperationalCredentialsClusterAndSavesAsThFabricIdx_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3: TH reads from the DUT the TrustedTimeSource attribute.\n"); + err = TestStep3ThReadsFromTheDutTheTrustedTimeSourceAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.\n"); + err = TestStep4ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceSetToNull_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the TrustedTimeSource attribute.\n"); + err = TestStep5ThReadsFromTheDutTheTrustedTimeSourceAttribute_6(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 7; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull th_node_id; + + CHIP_ERROR TestReadCommissionerNodeIDAndSavesAsThNodeId_1() + { + + chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; + return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { + { + th_node_id = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; + } + NextTest(); + }); + } + + CHIP_ERROR TestStep1ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceFieldsSetAsFollowsNodeIDThNodeIdEndpoint0_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetTrustedTimeSourceParams alloc] init]; + params.trustedTimeSource = [[MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct alloc] init]; + ((MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct *) params.trustedTimeSource).nodeID = + [th_node_id copy]; + ((MTRTimeSynchronizationClusterFabricScopedTrustedTimeSourceStruct *) params.trustedTimeSource).endpoint = + [NSNumber numberWithUnsignedShort:0U]; + + [cluster setTrustedTimeSourceWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0: Error: %@", err); + } else { + NSLog(@"Step 1: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource fields set as follows: NodeID: th_node_id, Endpoint: 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull th_fabric_idx; + + CHIP_ERROR TestStep2ThReadsFromTheDutTheCurrentFabricIndexAttributeFromTheNodeOperationalCredentialsClusterAndSavesAsThFabricIdx_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the CurrentFabricIndex attribute from the Node Operational Credentials Cluster and saves as th_fabric_idx: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + th_fabric_idx = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheTrustedTimeSourceAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTrustedTimeSourceWithCompletion:^(MTRTimeSynchronizationClusterTrustedTimeSourceStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the TrustedTimeSource attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the TrustedTimeSource attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("TrustedTimeSource", actualValue)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).fabricIndex, th_fabric_idx)); + VerifyOrReturn(CheckValue("NodeID", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).nodeID, th_node_id)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRTimeSynchronizationClusterTrustedTimeSourceStruct *) actualValue).endpoint, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThSendsTheSetTrustedTimeSourceCommandToTheDutWithTheTrustedTimeSourceSetToNull_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetTrustedTimeSourceParams alloc] init]; + params.trustedTimeSource = nil; + [cluster setTrustedTimeSourceWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.: Error: %@", err); + } else { + NSLog(@"Step 4: TH sends the SetTrustedTimeSource command to the DUT with the TrustedTimeSource set to null.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheTrustedTimeSourceAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTrustedTimeSourceWithCompletion:^(MTRTimeSynchronizationClusterTrustedTimeSourceStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the TrustedTimeSource attribute.: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the TrustedTimeSource attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("TrustedTimeSource", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ULABEL_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ULABEL_1_1() + : TestCommandBridge("Test_TC_ULABEL_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ULABEL_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the FeatureMap attribute.\n"); + err = TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ULABEL_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ULABEL_2_1() + : TestCommandBridge("Test_TC_ULABEL_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ULABEL_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads LabelList from the DUT\n"); + if (ShouldSkip("ULABEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThReadsLabelListFromTheDut_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsLabelListFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads LabelList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads LabelList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("labelList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ULABEL_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ULABEL_2_2() + : TestCommandBridge("Test_TC_ULABEL_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ULABEL_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom'\n"); + if (ShouldSkip("ULABEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThWritesLabelListAttributeOnTheDutWithFollowingEntryroomNamemasterBedroom1orientationeastfloor2roomTypebedroom_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads LabelList attribute of the DUT\n"); + if (ShouldSkip("ULABEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsLabelListAttributeOfTheDut_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThWritesLabelListAttributeOnTheDutWithFollowingEntryroomNamemasterBedroom1orientationeastfloor2roomTypebedroom_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id labelListArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"roomName"; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"master bedroom 1"; + + temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"Orientation"; + ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"east"; + + temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; + ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"2"; + + temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"roomType"; + ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"bedroom"; + + labelListArgument = temp_0; + } + [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom': Error: %@", err); + } else { + NSLog(@"Step 1: TH writes LabelList attribute on the DUT with following entry: 'roomName':'master bedroom 1','orientation':'east', 'floor':'2', 'roomType':'bedroom': Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsLabelListAttributeOfTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"roomName")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"master bedroom 1")); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"Orientation")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"east")); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"2")); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"roomType")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"bedroom")); + } + + VerifyOrReturn(CheckConstraintType("labelList", "list", "list")); + VerifyOrReturn(CheckConstraintMinLength("labelList", value, 4)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ULABEL_2_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ULABEL_2_3() + : TestCommandBridge("Test_TC_ULABEL_2_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ULABEL_2_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong'\n"); + if (ShouldSkip("ULABEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThWritesLabelListAttributeOfTheDutBySettingroom17BytesIsTooLong_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar'\n"); + if (ShouldSkip("ULABEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThWritesLabelListAttributeOfTheDutBySetting17BytesIsTooLongfoobar_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThWritesLabelListAttributeOfTheDutBySettingroom17BytesIsTooLong_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id labelListArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"17_bytesIsTooLongforuserlabelnotexpected"; + + labelListArgument = temp_0; + } + [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong': Error: %@", err); + } else { + NSLog(@"Step 1: TH writes LabelList attribute of the DUT by setting 'room':'17_bytesIsTooLong': Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThWritesLabelListAttributeOfTheDutBySetting17BytesIsTooLongfoobar_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id labelListArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"17_bytesIsTooLongforuserlabelnotexpected"; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"foobar"; + + labelListArgument = temp_0; + } + [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar': Error: %@", err); + } else { + NSLog(@"Step 2: TH writes LabelList attribute of the DUT by setting '17_bytesIsTooLong':'foobar': Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ULABEL_2_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ULABEL_2_4() + : TestCommandBridge("Test_TC_ULABEL_2_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ULABEL_2_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ULABEL_2_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ULABEL_2_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' \n"); + if (ShouldSkip("ULABEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep1ThWritesLabelListAttributeOfTheDutWithEntryAsFollowingroombedroom1orientationeast_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH reads LabelList attribute of the DUT\n"); + if (ShouldSkip("ULABEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsLabelListAttributeOfTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list\n"); + if (ShouldSkip("ULABEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep3ThWritesLabelListAttributeOfTheDutWithAnEntryAsEmptyValuesInTheList_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads LabelList attribute of the DUT\n"); + if (ShouldSkip("ULABEL.S.A0000")) { + NextTest(); + return; + } + err = TestStep4ThReadsLabelListAttributeOfTheDut_4(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThWritesLabelListAttributeOfTheDutWithEntryAsFollowingroombedroom1orientationeast_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id labelListArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 1"; + + temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"Orientation"; + ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"east"; + + labelListArgument = temp_0; + } + [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' : Error: %@", err); + } else { + NSLog(@"Step 1: TH writes LabelList attribute of the DUT with entry as following: 'room':'bedroom 1','orientation':'east' : Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThReadsLabelListAttributeOfTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads LabelList attribute of the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 1")); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"Orientation")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"east")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThWritesLabelListAttributeOfTheDutWithAnEntryAsEmptyValuesInTheList_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id labelListArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @""; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @""; + + labelListArgument = temp_0; + } + [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list: Error: %@", err); + } else { + NSLog(@"Step 3: TH writes LabelList attribute of the DUT with an entry as empty values in the list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsLabelListAttributeOfTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads LabelList attribute of the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads LabelList attribute of the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DGWIFI_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DGWIFI_1_1() + : TestCommandBridge("Test_TC_DGWIFI_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DGWIFI_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); + err = TestStep2ThReadsTheClusterRevisionFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); + if (ShouldSkip("( !DGWIFI.S.F00 && !DGWIFI.S.F01 )")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheFeatureMapFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DGWIFI.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenDGWIFISF00PacketCountsEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DGWIFI.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenDGWIFISF01ErrorCountsEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT\n"); + if (ShouldSkip("DGWIFI.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsFeatureDependentDGWIFISF00AttributesInAttributeListFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT\n"); + if (ShouldSkip("DGWIFI.S.F01")) { + NextTest(); + return; + } + err = TestStep4cThReadsFeatureDependentDGWIFISF01AttributesInAttributeListFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT\n"); + if (ShouldSkip("DGWIFI.S.A000b")) { + NextTest(); + return; + } + err = TestStep4dThReadsOptionalAttributeCurrentMaxRateInAttributeListFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH reads EventList from DUT\n"); + if (ShouldSkip(" !DGWIFI.S.E00 && !DGWIFI.S.E01 && !DGWIFI.S.E02 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5b: TH reads optional attribute (Disconnection) in EventList from DUT\n"); + if (ShouldSkip("DGWIFI.S.E00 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5c: TH reads optional attribute (AssociationFailure) in EventList from DUT\n"); + if (ShouldSkip("DGWIFI.S.E01 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5d: TH reads optional attribute (ConnectionStatus) in EventList from DUT\n"); + if (ShouldSkip("DGWIFI.S.E02 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6a: TH reads AcceptedCommandList from DUT\n"); + if (ShouldSkip(" !DGWIFI.S.F01 ")) { + NextTest(); + return; + } + err = TestStep6aThReadsAcceptedCommandListFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT\n"); + if (ShouldSkip("DGWIFI.S.F01")) { + NextTest(); + return; + } + err = TestStep6bThReadsFeatureDependentDGWIFISF01CommandInAcceptedCommandListFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 7: TH reads GeneratedCommandList from DUT\n"); + err = TestStep7ThReadsGeneratedCommandListFromDut_16(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 17; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenDGWIFISF00PacketCountsEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given DGWIFI.S.F00(PacketCounts) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenDGWIFISF01ErrorCountsEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given DGWIFI.S.F01(ErrorCounts) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFeatureDependentDGWIFISF00AttributesInAttributeListFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads Feature dependent(DGWIFI.S.F00) attributes in attributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 8UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 9UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsFeatureDependentDGWIFISF01AttributesInAttributeListFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads Feature dependent(DGWIFI.S.F01) attributes in attributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsOptionalAttributeCurrentMaxRateInAttributeListFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads optional attribute (CurrentMaxRate) in AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsAcceptedCommandListFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsFeatureDependentDGWIFISF01CommandInAcceptedCommandListFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads Feature dependent(DGWIFI.S.F01) command in AcceptedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DGWIFI_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DGWIFI_2_1() + : TestCommandBridge("Test_TC_DGWIFI_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DGWIFI_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads BSSID attribute from DUT\n"); + if (ShouldSkip("DGWIFI.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsBssidAttributeFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads SecurityType attribute constraints\n"); + if (ShouldSkip("DGWIFI.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsSecurityTypeAttributeConstraints_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads WiFiVersion attribute constraints\n"); + if (ShouldSkip("DGWIFI.S.A0002")) { + NextTest(); + return; + } + err = TestStep4ThReadsWiFiVersionAttributeConstraints_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads ChannelNumber attribute constraints\n"); + if (ShouldSkip("DGWIFI.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsChannelNumberAttributeConstraints_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads RSSI attribute constraints\n"); + if (ShouldSkip("DGWIFI.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsRssiAttributeConstraints_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads BeaconLostCount attribute constraints\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsBeaconLostCountAttributeConstraints_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads BeaconRxCount attribute constraints\n"); + if (ShouldSkip("DGWIFI.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsBeaconRxCountAttributeConstraints_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads PacketMulticastRxCount attribute constraints\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0007")) { + NextTest(); + return; + } + err = TestStep9ThReadsPacketMulticastRxCountAttributeConstraints_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 10: TH reads PacketMulticastTxCount attribute constraints\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0008")) { + NextTest(); + return; + } + err = TestStep10ThReadsPacketMulticastTxCountAttributeConstraints_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 11: TH reads PacketUnicastRxCount attribute constraints\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A0009")) { + NextTest(); + return; + } + err = TestStep11ThReadsPacketUnicastRxCountAttributeConstraints_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 12: TH reads PacketUnicastTxCount attribute constraints\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000a")) { + NextTest(); + return; + } + err = TestStep12ThReadsPacketUnicastTxCountAttributeConstraints_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 13: TH reads CurrentMaxRate attribute constraints\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000b")) { + NextTest(); + return; + } + err = TestStep13ThReadsCurrentMaxRateAttributeConstraints_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 14: TH reads OverrunCount attribute constraints\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.A000c")) { + NextTest(); + return; + } + err = TestStep14ThReadsOverrunCountAttributeConstraints_13(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 14; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsBssidAttributeFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBSSIDWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads BSSID attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads BSSID attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("bssid", "octet_string", "octet_string")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsSecurityTypeAttributeConstraints_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSecurityTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads SecurityType attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads SecurityType attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("securityType", "enum8", "enum8")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsWiFiVersionAttributeConstraints_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWiFiVersionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads WiFiVersion attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads WiFiVersion attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("wiFiVersion", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("wiFiVersion", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("wiFiVersion", [value unsignedCharValue], 6U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsChannelNumberAttributeConstraints_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeChannelNumberWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads ChannelNumber attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads ChannelNumber attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("channelNumber", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("channelNumber", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("channelNumber", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsRssiAttributeConstraints_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRSSIWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads RSSI attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads RSSI attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("rssi", "int8s", "int8s")); + VerifyOrReturn(CheckConstraintMinValue("rssi", [value charValue], -120)); + VerifyOrReturn(CheckConstraintMaxValue("rssi", [value charValue], 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsBeaconLostCountAttributeConstraints_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBeaconLostCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads BeaconLostCount attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads BeaconLostCount attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("beaconLostCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("beaconLostCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("beaconLostCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsBeaconRxCountAttributeConstraints_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBeaconRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads BeaconRxCount attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads BeaconRxCount attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("beaconRxCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("beaconRxCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("beaconRxCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsPacketMulticastRxCountAttributeConstraints_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketMulticastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads PacketMulticastRxCount attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads PacketMulticastRxCount attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("packetMulticastRxCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("packetMulticastRxCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("packetMulticastRxCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThReadsPacketMulticastTxCountAttributeConstraints_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketMulticastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH reads PacketMulticastTxCount attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 10: TH reads PacketMulticastTxCount attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("packetMulticastTxCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("packetMulticastTxCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("packetMulticastTxCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsPacketUnicastRxCountAttributeConstraints_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketUnicastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads PacketUnicastRxCount attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads PacketUnicastRxCount attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("packetUnicastRxCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("packetUnicastRxCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("packetUnicastRxCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThReadsPacketUnicastTxCountAttributeConstraints_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketUnicastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH reads PacketUnicastTxCount attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 12: TH reads PacketUnicastTxCount attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("packetUnicastTxCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("packetUnicastTxCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("packetUnicastTxCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13ThReadsCurrentMaxRateAttributeConstraints_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentMaxRateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH reads CurrentMaxRate attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 13: TH reads CurrentMaxRate attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentMaxRate", "int64u", "int64u")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep14ThReadsOverrunCountAttributeConstraints_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOverrunCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14: TH reads OverrunCount attribute constraints: Error: %@", err); + } else { + NSLog(@"Step 14: TH reads OverrunCount attribute constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("overrunCount", "int64u", "int64u")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DGWIFI_2_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DGWIFI_2_3() + : TestCommandBridge("Test_TC_DGWIFI_2_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DGWIFI_2_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGWIFI_2_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGWIFI_2_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: TWait for the commissioned device to be retrieved\n"); + err = TestStep1TWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH sends ResetCounts command to DUT\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsResetCountsCommandToDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2a: TH reads BeaconLostCount attribute from DUT\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0005")) { + NextTest(); + return; + } + err = TestStep2aThReadsBeaconLostCountAttributeFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH reads BeaconRxCount attribute from DUT\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0006")) { + NextTest(); + return; + } + err = TestStep2bThReadsBeaconRxCountAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2c: TH reads PacketMulticastRxCount attribute from DUT\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0007")) { + NextTest(); + return; + } + err = TestStep2cThReadsPacketMulticastRxCountAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2d: TH reads PacketMulticastTxCount attribute from DUT\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0008")) { + NextTest(); + return; + } + err = TestStep2dThReadsPacketMulticastTxCountAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2e: TH reads PacketUnicastRxCount attribute from DUT\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A0009")) { + NextTest(); + return; + } + err = TestStep2eThReadsPacketUnicastRxCountAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2f: TH reads PacketUnicastTxCount attribute from DUT\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && DGWIFI.S.C00.Rsp && DGWIFI.S.A000a")) { + NextTest(); + return; + } + err = TestStep2fThReadsPacketUnicastTxCountAttributeFromDut_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1TWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThSendsResetCountsCommandToDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster resetCountsWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends ResetCounts command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends ResetCounts command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThReadsBeaconLostCountAttributeFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBeaconLostCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH reads BeaconLostCount attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH reads BeaconLostCount attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("beaconLostCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("beaconLostCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("beaconLostCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThReadsBeaconRxCountAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBeaconRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads BeaconRxCount attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads BeaconRxCount attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("beaconRxCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("beaconRxCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("beaconRxCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cThReadsPacketMulticastRxCountAttributeFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketMulticastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads PacketMulticastRxCount attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads PacketMulticastRxCount attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("packetMulticastRxCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("packetMulticastRxCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("packetMulticastRxCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dThReadsPacketMulticastTxCountAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketMulticastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads PacketMulticastTxCount attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads PacketMulticastTxCount attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("packetMulticastTxCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("packetMulticastTxCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("packetMulticastTxCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2eThReadsPacketUnicastRxCountAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketUnicastRxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH reads PacketUnicastRxCount attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2e: TH reads PacketUnicastRxCount attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("packetUnicastRxCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("packetUnicastRxCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("packetUnicastRxCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2fThReadsPacketUnicastTxCountAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWiFiNetworkDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePacketUnicastTxCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH reads PacketUnicastTxCount attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2f: TH reads PacketUnicastTxCount attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("packetUnicastTxCount", "int32u", "int32u")); + VerifyOrReturn(CheckConstraintMinValue("packetUnicastTxCount", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("packetUnicastTxCount", [value unsignedIntValue], 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_1_1() + : TestCommandBridge("Test_TC_WNCV_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute\n"); + err = TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute\n"); + if (ShouldSkip("!WNCV.S.F00 && !WNCV.S.F01 && !WNCV.S.F02 && !WNCV.S.F03 && !WNCV.S.F04 ")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("WNCV.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenWncvsf00lfEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("WNCV.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenWncvsf01tlEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("WNCV.S.F02")) { + NextTest(); + return; + } + err = TestStep3dGivenWncvsf02paLfEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("WNCV.S.F03")) { + NextTest(); + return; + } + err = TestStep3eGivenWncvsf03absEnsureFeaturemapHasTheCorrectBitSet_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("WNCV.S.F04")) { + NextTest(); + return; + } + err = TestStep3fGivenWncvsf04paTlEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList\n"); + if (ShouldSkip("WNCV.S.A001a")) { + NextTest(); + return; + } + err = TestStep4bThReadsOptionalAttributeSafetyStatusInAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.F03")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheFeatureDependentWNCVSF00Wncvsf02Wncvsf03AttributeInAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheFeatureDependentWNCVSF00Wncvsf02AttributeInAttributeList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.F03")) { + NextTest(); + return; + } + err = TestStep4eThReadsTheFeatureDependentWNCVSF01Wncvsf04Wncvsf03AttributeInAttributeList_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04")) { + NextTest(); + return; + } + err = TestStep4fThReadsTheFeatureDependentWNCVSF01Wncvsf04AttributeInAttributeList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5: TH reads from the DUT the (0xFFFA) EventList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute\n"); + err = TestStep6aThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02")) { + NextTest(); + return; + } + err = TestStep6bThReadsFeatureDependentWNCVSF00Wncvsf02CommandInAcceptedCommandList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F03")) { + NextTest(); + return; + } + err = TestStep6cThReadsFeatureDependentWNCVSF01Wncvsf03CommandInAcceptedCommandList_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04")) { + NextTest(); + return; + } + err = TestStep6dThReadsFeatureDependentWNCVSF01Wncvsf04CommandInAcceptedCommandList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute\n"); + err = TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_20(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 21; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutThe0xFFFDClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the (0xFFFD) ClusterRevision attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("clusterRevision", [value unsignedShortValue], 5U)); + VerifyOrReturn(CheckConstraintMaxValue("clusterRevision", [value unsignedShortValue], 200U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutThe0xFFFCFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the (0xFFFC) FeatureMap attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenWncvsf00lfEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given WNCV.S.F00(LF) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenWncvsf01tlEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given WNCV.S.F01(TL) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenWncvsf02paLfEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given WNCV.S.F02(PA_LF) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenWncvsf03absEnsureFeaturemapHasTheCorrectBitSet_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3e: Given WNCV.S.F03(ABS) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenWncvsf04paTlEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given WNCV.S.F04(PA_TL) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutThe0xFFFBAttributeListAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the (0xFFFB) AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 10UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 13UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsOptionalAttributeSafetyStatusInAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads optional attribute(SafetyStatus) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheFeatureDependentWNCVSF00Wncvsf02Wncvsf03AttributeInAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 & WNCV.S.F03) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 16UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheFeatureDependentWNCVSF00Wncvsf02AttributeInAttributeList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the Feature dependent(WNCV.S.F00 & WNCV.S.F02 ) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 11UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 14UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsTheFeatureDependentWNCVSF01Wncvsf04Wncvsf03AttributeInAttributeList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 & WNCV.S.F03) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsTheFeatureDependentWNCVSF01Wncvsf04AttributeInAttributeList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads the Feature dependent(WNCV.S.F01 & WNCV.S.F04 ) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 12UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 15UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsFromTheDutThe0xFFF9AcceptedCommandListAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads from the DUT the (0xFFF9) AcceptedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsFeatureDependentWNCVSF00Wncvsf02CommandInAcceptedCommandList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads Feature dependent(WNCV.S.F00 & WNCV.S.F02) command in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cThReadsFeatureDependentWNCVSF01Wncvsf03CommandInAcceptedCommandList_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6c: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F03) command in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6dThReadsFeatureDependentWNCVSF01Wncvsf04CommandInAcceptedCommandList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6d: TH reads Feature dependent(WNCV.S.F01 & WNCV.S.F04) command in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 8UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutThe0xFFF8GeneratedCommandListAttribute_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the (0xFFF8) GeneratedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_2_1() + : TestCommandBridge("Test_TC_WNCV_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads from the DUT the ( 0) Type attribute\n"); + if (ShouldSkip("WNCV.S.A0000")) { + NextTest(); + return; + } + err = TestStep1aThReadsFromTheDutThe0TypeAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute\n"); + if (ShouldSkip("WNCV.S.A0007")) { + NextTest(); + return; + } + err = TestStep1bThReadsFromTheDutThe7ConfigStatusAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep1cThReadsFromTheDutThe10OperationalStatusAttributeOperationalStatus_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads from the DUT the (13) EndProductType attribute\n"); + if (ShouldSkip("WNCV.S.A000d")) { + NextTest(); + return; + } + err = TestStep1dThReadsFromTheDutThe13EndProductTypeAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads from the DUT the (23) Mode attribute\n"); + if (ShouldSkip("WNCV.S.A0017")) { + NextTest(); + return; + } + err = TestStep1eThReadsFromTheDutThe23ModeAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH writes to (23) Mode attribute the value 0\n"); + if (ShouldSkip("WNCV.S.A0017")) { + NextTest(); + return; + } + err = TestStep1fThWritesTo23ModeAttributeTheValue0_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute\n"); + if (ShouldSkip("WNCV.S.A000b")) { + NextTest(); + return; + } + err = TestStep2aThReadsFromTheDutThe11TargetPositionLiftPercent100thsAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute\n"); + if (ShouldSkip("WNCV.S.A000c")) { + NextTest(); + return; + } + err = TestStep2bThReadsFromTheDutThe12TargetPositionTiltPercent100thsAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute\n"); + if (ShouldSkip("WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep2cThReadsFromTheDutThe14CurrentPositionLiftPercent100thsAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute\n"); + if (ShouldSkip("WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep2dThReadsFromTheDutThe15CurrentPositionTiltPercent100thsAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute\n"); + if (ShouldSkip("WNCV.S.A0010")) { + NextTest(); + return; + } + err = TestStep2eThReadsFromTheDutThe16InstalledOpenLimitLiftAttribute_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute\n"); + if (ShouldSkip("WNCV.S.A0011")) { + NextTest(); + return; + } + err = TestStep2fThReadsFromTheDutThe17InstalledClosedLimitLiftAttribute_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute\n"); + if (ShouldSkip("WNCV.S.A0012")) { + NextTest(); + return; + } + err = TestStep2gThReadsFromTheDutThe18InstalledOpenLimitTiltAttribute_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute\n"); + if (ShouldSkip("WNCV.S.A0013")) { + NextTest(); + return; + } + err = TestStep2hThReadsFromTheDutThe19InstalledClosedLimitTiltAttribute_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a: TH reads from the DUT the (26) SafetyStatus attribute\n"); + if (ShouldSkip("WNCV.S.A001a")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutThe26SafetyStatusAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute\n"); + if (ShouldSkip("WNCV.S.A0001")) { + NextTest(); + return; + } + err = TestStep3bThReadsFromTheDutThe1PhysicalClosedLimitLiftAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute\n"); + if (ShouldSkip("WNCV.S.A0002")) { + NextTest(); + return; + } + err = TestStep3cThReadsFromTheDutThe2PhysicalClosedLimitTiltAttribute_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute\n"); + if (ShouldSkip("WNCV.S.A0003 && !WNCV.S.A0010 && !WNCV.S.A0011")) { + NextTest(); + return; + } + err = TestStep3dThReadsFromTheDutThe3CurrentPositionLiftAttribute_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3d: TH reads the RO optional attribute default: CurrentPositionLift\n"); + if (ShouldSkip("WNCV.S.A0003 && WNCV.S.A0010 && WNCV.S.A0011")) { + NextTest(); + return; + } + err = TestStep3dThReadsTheRoOptionalAttributeDefaultCurrentPositionLift_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute\n"); + if (ShouldSkip("WNCV.S.A0004 && !WNCV.S.A0012 && !WNCV.S.A0013")) { + NextTest(); + return; + } + err = TestStep3eThReadsFromTheDutThe4CurrentPositionTiltAttribute_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt\n"); + if (ShouldSkip("WNCV.S.A0004 && WNCV.S.A0012 && WNCV.S.A0013")) { + NextTest(); + return; + } + err = TestStep3eThReadsTheRoOptionalAttributeDefaultCurrentPositionTilt_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute\n"); + if (ShouldSkip("WNCV.S.A0005")) { + NextTest(); + return; + } + err = TestStep3fThReadsFromTheDutThe5NumberOfActuationsLiftAttribute_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute\n"); + if (ShouldSkip("WNCV.S.A0006")) { + NextTest(); + return; + } + err = TestStep3gThReadsFromTheDutThe6NumberOfActuationsTiltAttribute_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute\n"); + if (ShouldSkip("WNCV.S.A0008")) { + NextTest(); + return; + } + err = TestStep3hThReadsFromTheDutThe8CurrentPositionLiftPercentageAttribute_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute\n"); + if (ShouldSkip("WNCV.S.A0009")) { + NextTest(); + return; + } + err = TestStep3iThReadsFromTheDutThe9CurrentPositionTiltPercentageAttribute_25(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 26; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThReadsFromTheDutThe0TypeAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH reads from the DUT the ( 0) Type attribute: Error: %@", err); + } else { + NSLog(@"Step 1a: TH reads from the DUT the ( 0) Type attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("type", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("type", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("type", [value unsignedCharValue], 9U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThReadsFromTheDutThe7ConfigStatusAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute: Error: %@", err); + } else { + NSLog(@"Step 1b: TH reads from the DUT the ( 7) ConfigStatus attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); + VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1cThReadsFromTheDutThe10OperationalStatusAttributeOperationalStatus_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus: Error: %@", err); + } else { + NSLog(@"Step 1c: TH reads from the DUT the (10) OperationalStatus attribute: OperationalStatus: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); + VerifyOrReturn(CheckConstraintMinValue("operationalStatus", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("operationalStatus", [value unsignedCharValue], 127U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1dThReadsFromTheDutThe13EndProductTypeAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEndProductTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1d: TH reads from the DUT the (13) EndProductType attribute: Error: %@", err); + } else { + NSLog(@"Step 1d: TH reads from the DUT the (13) EndProductType attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("endProductType", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("endProductType", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("endProductType", [value unsignedCharValue], 23U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1eThReadsFromTheDutThe23ModeAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1e: TH reads from the DUT the (23) Mode attribute: Error: %@", err); + } else { + NSLog(@"Step 1e: TH reads from the DUT the (23) Mode attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("mode", "bitmap8", "bitmap8")); + VerifyOrReturn(CheckConstraintMinValue("mode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("mode", [value unsignedCharValue], 15U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1fThWritesTo23ModeAttributeTheValue0_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id modeArgument; + modeArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1f: TH writes to (23) Mode attribute the value 0: Error: %@", err); + } else { + NSLog(@"Step 1f: TH writes to (23) Mode attribute the value 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThReadsFromTheDutThe11TargetPositionLiftPercent100thsAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute: Error: %@", err); + } else { + NSLog(@"Step 2a: TH reads from the DUT the (11) TargetPositionLiftPercent100ths attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThReadsFromTheDutThe12TargetPositionTiltPercent100thsAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads from the DUT the (12) TargetPositionTiltPercent100ths attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cThReadsFromTheDutThe14CurrentPositionLiftPercent100thsAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads from the DUT the (14) CurrentPositionLiftPercent100ths attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dThReadsFromTheDutThe15CurrentPositionTiltPercent100thsAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute: Error: %@", err); + } else { + NSLog(@"Step 2d: TH reads from the DUT the (15) CurrentPositionTiltPercent100ths attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull InstalledOpenLimitLiftValue; + + CHIP_ERROR TestStep2eThReadsFromTheDutThe16InstalledOpenLimitLiftAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInstalledOpenLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute: Error: %@", err); + } else { + NSLog(@"Step 2e: TH reads from the DUT the (16) InstalledOpenLimitLift attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("installedOpenLimitLift", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("installedOpenLimitLift", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("installedOpenLimitLift", [value unsignedShortValue], 65535U)); + { + InstalledOpenLimitLiftValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull InstalledClosedLimitLiftValue; + + CHIP_ERROR TestStep2fThReadsFromTheDutThe17InstalledClosedLimitLiftAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInstalledClosedLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute: Error: %@", err); + } else { + NSLog(@"Step 2f: TH reads from the DUT the (17) InstalledClosedLimitLift attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("installedClosedLimitLift", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("installedClosedLimitLift", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("installedClosedLimitLift", [value unsignedShortValue], 65535U)); + { + InstalledClosedLimitLiftValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull InstalledOpenLimitTiltValue; + + CHIP_ERROR TestStep2gThReadsFromTheDutThe18InstalledOpenLimitTiltAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInstalledOpenLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute: Error: %@", err); + } else { + NSLog(@"Step 2g: TH reads from the DUT the (18) InstalledOpenLimitTilt attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("installedOpenLimitTilt", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("installedOpenLimitTilt", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("installedOpenLimitTilt", [value unsignedShortValue], 65535U)); + { + InstalledOpenLimitTiltValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull InstalledClosedLimitTiltValue; + + CHIP_ERROR TestStep2hThReadsFromTheDutThe19InstalledClosedLimitTiltAttribute_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInstalledClosedLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute: Error: %@", err); + } else { + NSLog(@"Step 2h: TH reads from the DUT the (19) InstalledClosedLimitTilt attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("installedClosedLimitTilt", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("installedClosedLimitTilt", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("installedClosedLimitTilt", [value unsignedShortValue], 65535U)); + { + InstalledClosedLimitTiltValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutThe26SafetyStatusAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSafetyStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the (26) SafetyStatus attribute: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the (26) SafetyStatus attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("safetyStatus", "bitmap16", "bitmap16")); + VerifyOrReturn(CheckConstraintMinValue("safetyStatus", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("safetyStatus", [value unsignedShortValue], 2047U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsFromTheDutThe1PhysicalClosedLimitLiftAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePhysicalClosedLimitLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads from the DUT the ( 1) PhysicalClosedLimitLift attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("physicalClosedLimitLift", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("physicalClosedLimitLift", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("physicalClosedLimitLift", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsFromTheDutThe2PhysicalClosedLimitTiltAttribute_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePhysicalClosedLimitTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads from the DUT the ( 2) PhysicalClosedLimitTilt attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("physicalClosedLimitTilt", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("physicalClosedLimitTilt", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("physicalClosedLimitTilt", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThReadsFromTheDutThe3CurrentPositionLiftAttribute_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads from the DUT the ( 3) CurrentPositionLift attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLift", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLift", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLift", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThReadsTheRoOptionalAttributeDefaultCurrentPositionLift_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads the RO optional attribute default: CurrentPositionLift: Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads the RO optional attribute default: CurrentPositionLift: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLift", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLift", [value unsignedShortValue], InstalledOpenLimitLiftValue)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLift", [value unsignedShortValue], InstalledClosedLimitLiftValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eThReadsFromTheDutThe4CurrentPositionTiltAttribute_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute: Error: %@", err); + } else { + NSLog(@"Step 3e: TH reads from the DUT the ( 4) CurrentPositionTilt attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTilt", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTilt", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTilt", [value unsignedShortValue], 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eThReadsTheRoOptionalAttributeDefaultCurrentPositionTilt_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt: Error: %@", err); + } else { + NSLog(@"Step 3e: TH reads the RO optional attribute default: CurrentPositionTilt: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTilt", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTilt", [value unsignedShortValue], InstalledOpenLimitTiltValue)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTilt", [value unsignedShortValue], InstalledClosedLimitTiltValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fThReadsFromTheDutThe5NumberOfActuationsLiftAttribute_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfActuationsLiftWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute: Error: %@", err); + } else { + NSLog(@"Step 3f: TH reads from the DUT the ( 5) NumberOfActuationsLift attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("numberOfActuationsLift", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("numberOfActuationsLift", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfActuationsLift", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gThReadsFromTheDutThe6NumberOfActuationsTiltAttribute_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfActuationsTiltWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute: Error: %@", err); + } else { + NSLog(@"Step 3g: TH reads from the DUT the ( 6) NumberOfActuationsTilt attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("numberOfActuationsTilt", "int16u", "int16u")); + VerifyOrReturn(CheckConstraintMinValue("numberOfActuationsTilt", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfActuationsTilt", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hThReadsFromTheDutThe8CurrentPositionLiftPercentageAttribute_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute: Error: %@", err); + } else { + NSLog(@"Step 3h: TH reads from the DUT the ( 8) CurrentPositionLiftPercentage attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iThReadsFromTheDutThe9CurrentPositionTiltPercentageAttribute_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute: Error: %@", err); + } else { + NSLog(@"Step 3i: TH reads from the DUT the ( 9) CurrentPositionTiltPercentage attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_2_2() + : TestCommandBridge("Test_TC_WNCV_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b\n"); + if (ShouldSkip("WNCV.S.A0007 && WNCV.S.F00 && WNCV.S.F02")) { + NextTest(); + return; + } + err = TestStep1aThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b\n"); + if (ShouldSkip("WNCV.S.A0007 && !WNCV.S.F00 && !WNCV.S.F02")) { + NextTest(); + return; + } + err = TestStep1bThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,\n"); + if (ShouldSkip("WNCV.S.A0007 && WNCV.S.F01 && WNCV.S.F04")) { + NextTest(); + return; + } + err = TestStep1cThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,\n"); + if (ShouldSkip("WNCV.S.A0007 && !WNCV.S.F01 && !WNCV.S.F04")) { + NextTest(); + return; + } + err = TestStep1dThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational)\n"); + if (ShouldSkip("WNCV.S.A0007")) { + NextTest(); + return; + } + err = TestStep1eThReadsConfigStatusAttributeFromDutValueOfBit0MustBe1bOperational_5(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 6; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Error: %@", err); + } else { + NSLog(@"Step 1a: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThReadsConfigStatusAttributeFromDutIfWncvsf00lfWncvsf02paLfValueOfBit3MustBe1bElse0b_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Error: %@", err); + } else { + NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F00(LF) & WNCV.S.F02(PA_LF)) value of bit 3 must be 1b else 0b: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1cThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Error: %@", err); + } else { + NSLog(@"Step 1c: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1dThReadsConfigStatusAttributeFromDutIfWncvsf01tlWncvsf04paTlValueOfBit4MustBe1bElse0b_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Error: %@", err); + } else { + NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT, if (WNCV.S.F01(TL) & WNCV.S.F04(PA_TL)) value of bit 4 must be 1b else 0b,: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1eThReadsConfigStatusAttributeFromDutValueOfBit0MustBe1bOperational_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational): Error: %@", err); + } else { + NSLog(@"Step 1e: TH reads ConfigStatus attribute from DUT, value of bit 0 must be 1b (operational): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("configStatus", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_2_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_2_3() + : TestCommandBridge("Test_TC_WNCV_2_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_2_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step Wait for the commissioned device to be retrieved\n"); + err = TestStepWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH set the Mode Attribute bit0 of the DUT\n"); + if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0017")) { + NextTest(); + return; + } + err = TestStep1aThSetTheModeAttributeBit0OfTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH reads ConfigStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0007")) { + NextTest(); + return; + } + err = TestStep1bThReadsConfigStatusAttributeFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH clear the Mode Attribute bit0 of the DUT\n"); + if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0017")) { + NextTest(); + return; + } + err = TestStep1cThClearTheModeAttributeBit0OfTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH reads ConfigStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.M.Reversal && WNCV.S.A0007")) { + NextTest(); + return; + } + err = TestStep1dThReadsConfigStatusAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2a: TH set the Mode Attribute bit1 of the DUT\n"); + if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { + NextTest(); + return; + } + err = TestStep2aThSetTheModeAttributeBit1OfTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2b: TH reads ConfigStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0007")) { + NextTest(); + return; + } + err = TestStep2bThReadsConfigStatusAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT\n"); + if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2cIfConfigStatusBit00ThSendDownOrCloseCommandToTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2d: TH clear the Mode Attribute bit1 of the DUT\n"); + if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { + NextTest(); + return; + } + err = TestStep2dThClearTheModeAttributeBit1OfTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2e: TH reads ConfigStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0007")) { + NextTest(); + return; + } + err = TestStep2eThReadsConfigStatusAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2f: TH reads the Mode Attribute from the DUT\n"); + if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.A0017")) { + NextTest(); + return; + } + err = TestStep2fThReadsTheModeAttributeFromTheDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2g: TH send DownOrClose command to the DUT\n"); + if (ShouldSkip("WNCV.S.M.Calibration && WNCV.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2gThSendDownOrCloseCommandToTheDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a: TH set the Mode Attribute bit2 of the DUT\n"); + if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0017")) { + NextTest(); + return; + } + err = TestStep3aThSetTheModeAttributeBit2OfTheDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3b: TH send DownOrClose command to the DUT\n"); + if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep3bThSendDownOrCloseCommandToTheDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3c: TH reads ConfigStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0007")) { + NextTest(); + return; + } + err = TestStep3cThReadsConfigStatusAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3d: TH clear the Mode Attribute bit2 of the DUT\n"); + if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0017")) { + NextTest(); + return; + } + err = TestStep3dThClearTheModeAttributeBit2OfTheDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3e: TH send DownOrClose command to the DUT\n"); + if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep3eThSendDownOrCloseCommandToTheDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3f: TH reads ConfigStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.M.Maintenance && WNCV.S.A0007")) { + NextTest(); + return; + } + err = TestStep3fThReadsConfigStatusAttributeFromDut_17(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_BUSY)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 18; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStepWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThSetTheModeAttributeBit0OfTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id modeArgument; + modeArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH set the Mode Attribute bit0 of the DUT: Error: %@", err); + } else { + NSLog(@"Step 1a: TH set the Mode Attribute bit0 of the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThReadsConfigStatusAttributeFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH reads ConfigStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 4U)); + VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1cThClearTheModeAttributeBit0OfTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id modeArgument; + modeArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: TH clear the Mode Attribute bit0 of the DUT: Error: %@", err); + } else { + NSLog(@"Step 1c: TH clear the Mode Attribute bit0 of the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1dThReadsConfigStatusAttributeFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1d: TH reads ConfigStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSetTheModeAttributeBit1OfTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id modeArgument; + modeArgument = + [NSNumber numberWithUnsignedChar:2U]; + [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH set the Mode Attribute bit1 of the DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH set the Mode Attribute bit1 of the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull configStatusValA; + + CHIP_ERROR TestStep2bThReadsConfigStatusAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH reads ConfigStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH reads ConfigStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); + { + configStatusValA = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cIfConfigStatusBit00ThSendDownOrCloseCommandToTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster downOrCloseWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: If (ConfigStatus bit0 == 0) TH send DownOrClose command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dThClearTheModeAttributeBit1OfTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id modeArgument; + modeArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: TH clear the Mode Attribute bit1 of the DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: TH clear the Mode Attribute bit1 of the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2eThReadsConfigStatusAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH reads ConfigStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2e: TH reads ConfigStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2fThReadsTheModeAttributeFromTheDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2f: TH reads the Mode Attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2f: TH reads the Mode Attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("mode", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("mode", [value unsignedCharValue], 127U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2gThSendDownOrCloseCommandToTheDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster downOrCloseWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2g: TH send DownOrClose command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 2g: TH send DownOrClose command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSetTheModeAttributeBit2OfTheDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id modeArgument; + modeArgument = + [NSNumber numberWithUnsignedChar:4U]; + [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH set the Mode Attribute bit2 of the DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH set the Mode Attribute bit2 of the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThSendDownOrCloseCommandToTheDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster downOrCloseWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH send DownOrClose command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH send DownOrClose command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_BUSY)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull configStatusValB; + + CHIP_ERROR TestStep3cThReadsConfigStatusAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads ConfigStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads ConfigStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); + { + configStatusValB = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThClearTheModeAttributeBit2OfTheDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id modeArgument; + modeArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeModeWithValue:modeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH clear the Mode Attribute bit2 of the DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: TH clear the Mode Attribute bit2 of the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eThSendDownOrCloseCommandToTheDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster downOrCloseWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: TH send DownOrClose command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 3e: TH send DownOrClose command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fThReadsConfigStatusAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConfigStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: TH reads ConfigStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3f: TH reads ConfigStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("configStatus", [value unsignedCharValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("configStatus", [value unsignedCharValue], 127U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_2_5 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_2_5() + : TestCommandBridge("Test_TC_WNCV_2_5") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_2_5() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_2_5\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_2_5\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads EndProductType attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000d")) { + NextTest(); + return; + } + err = TestStep1ThReadsEndProductTypeAttributeFromDut_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1ThReadsEndProductTypeAttributeFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEndProductTypeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads EndProductType attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads EndProductType attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("endProductType", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("endProductType", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("endProductType", [value unsignedCharValue], 23U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_3_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_3_1() + : TestCommandBridge("Test_TC_WNCV_3_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("Step1bWaitTime", 0, UINT16_MAX, &mStep1bWaitTime); + AddArgument("Step2bWaitTime", 0, UINT16_MAX, &mStep2bWaitTime); + AddArgument("Step2eWaitTime", 0, UINT16_MAX, &mStep2eWaitTime); + AddArgument("Step4bWaitTime", 0, UINT16_MAX, &mStep4bWaitTime); + AddArgument("Step5aWaitTime", 0, UINT16_MAX, &mStep5aWaitTime); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_3_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); + if (ShouldSkip("WNCV.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH Waits for 5 - 15 seconds movement(s) on the device\n"); + err = TestStep1bThWaitsFor515SecondsMovementsOnTheDevice_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { + NextTest(); + return; + } + err = TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { + NextTest(); + return; + } + err = TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH sends UpOrOpen command to DUT\n"); + if (ShouldSkip("WNCV.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsUpOrOpenCommandToDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH waits for 100-1000 ms\n"); + err = TestStep2bThWaitsFor1001000Ms_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { + NextTest(); + return; + } + err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { + NextTest(); + return; + } + err = TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH waits for 1-5 seconds movement(s) on the DUT\n"); + err = TestStep2eThWaitsFor15SecondsMovementsOnTheDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a1: TH reads OperationalStatus attribute's bit 0..1\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep3a1ThReadsOperationalStatusAttributesBit01_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep3a2WriteAttributeBitmap8WithOperationalStatusValueToDoTheBitsChecksInUpcomingOperationalStatusReadSteps_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF))\n"); + if (ShouldSkip("WNCV.S.A000a && WNCV.S.F00")) { + NextTest(); + return; + } + err = TestStep3a3ThChecksOperationalStatusValueBit23Wncvsf00lf_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a4: TH check OperationalStatus value bit 2..3 (WNCV.S.F00(LF))\n"); + if (ShouldSkip("WNCV.S.A000a && !WNCV.S.F00")) { + NextTest(); + return; + } + err = TestStep3a4ThCheckOperationalStatusValueBit23Wncvsf00lf_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL))\n"); + if (ShouldSkip("WNCV.S.A000a && WNCV.S.F01")) { + NextTest(); + return; + } + err = TestStep3a5ThChecksOperationalStatusValueBit45Wncvsf01tl_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a6: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL))\n"); + if (ShouldSkip("WNCV.S.A000a && !WNCV.S.F01")) { + NextTest(); + return; + } + err = TestStep3a6ThChecksOperationalStatusValueBit45Wncvsf01tl_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3a7: DUT updates its attributes\n"); + err = TestStep3a7DutUpdatesItsAttributes_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { + NextTest(); + return; + } + err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { + NextTest(); + return; + } + err = TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4a: TH sends a StopMotion command to DUT\n"); + if (ShouldSkip("WNCV.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsAStopMotionCommandToDut_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); + err = TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4c: TH reads OperationalStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep4cThReadsOperationalStatusAttributeFromDut_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5a: TH waits for 100-1000 ms\n"); + err = TestStep5aThWaitsFor1001000Ms_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { + NextTest(); + return; + } + err = TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { + NextTest(); + return; + } + err = TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_28(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 29; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mStep1bWaitTime; + chip::Optional mStep2bWaitTime; + chip::Optional mStep2eWaitTime; + chip::Optional mStep4bWaitTime; + chip::Optional mStep5aWaitTime; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster downOrCloseWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); + } else { + NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDevice_2() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mStep1bWaitTime.HasValue() ? mStep1bWaitTime.Value() : 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsUpOrOpenCommandToDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster upOrOpenWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThWaitsFor1001000Ms_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mStep2bWaitTime.HasValue() ? mStep2bWaitTime.Value() : 500UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2eThWaitsFor15SecondsMovementsOnTheDut_11() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mStep2eWaitTime.HasValue() ? mStep2eWaitTime.Value() : 1000UL; + return WaitForMs("alpha", value); + } + NSNumber * _Nonnull OperationalStatusValue; + + CHIP_ERROR TestStep3a1ThReadsOperationalStatusAttributesBit01_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a1: TH reads OperationalStatus attribute's bit 0..1: Error: %@", err); + } else { + NSLog(@"Step 3a1: TH reads OperationalStatus attribute's bit 0..1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); + { + OperationalStatusValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a2WriteAttributeBitmap8WithOperationalStatusValueToDoTheBitsChecksInUpcomingOperationalStatusReadSteps_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap8Argument; + bitmap8Argument = + [OperationalStatusValue copy]; + [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.: Error: %@", err); + } else { + NSLog(@"Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a3ThChecksOperationalStatusValueBit23Wncvsf00lf_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Error: %@", err); + } else { + NSLog(@"Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); + } + + VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a4ThCheckOperationalStatusValueBit23Wncvsf00lf_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a4: TH check OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Error: %@", err); + } else { + NSLog(@"Step 3a4: TH check OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); + } + + VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a5ThChecksOperationalStatusValueBit45Wncvsf01tl_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Error: %@", err); + } else { + NSLog(@"Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); + } + + VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a6ThChecksOperationalStatusValueBit45Wncvsf01tl_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a6: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Error: %@", err); + } else { + NSLog(@"Step 3a6: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); + } + + VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a7DutUpdatesItsAttributes_18() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 3000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 99U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 99U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsAStopMotionCommandToDut_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster stopMotionWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_24() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mStep4bWaitTime.HasValue() ? mStep4bWaitTime.Value() : 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4cThReadsOperationalStatusAttributeFromDut_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThWaitsFor1001000Ms_26() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mStep5aWaitTime.HasValue() ? mStep5aWaitTime.Value() : 500UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_3_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_3_2() + : TestCommandBridge("Test_TC_WNCV_3_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("Step1bWaitTime", 0, UINT16_MAX, &mStep1bWaitTime); + AddArgument("Step2bWaitTime", 0, UINT16_MAX, &mStep2bWaitTime); + AddArgument("Step2eWaitTime", 0, UINT16_MAX, &mStep2eWaitTime); + AddArgument("Step4bWaitTime", 0, UINT16_MAX, &mStep4bWaitTime); + AddArgument("Step5aWaitTime", 0, UINT16_MAX, &mStep5aWaitTime); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_3_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction\n"); + if (ShouldSkip("WNCV.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep1aThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH Waits for 10 seconds movement(s) on the device\n"); + err = TestStep1bThWaitsFor10SecondsMovementsOnTheDevice_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { + NextTest(); + return; + } + err = TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { + NextTest(); + return; + } + err = TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2a: TH sends DownOrClose command to DUT\n"); + if (ShouldSkip("WNCV.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsDownOrCloseCommandToDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2b: TH waits for 100-1000 ms\n"); + err = TestStep2bThWaitsFor1001000Ms_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { + NextTest(); + return; + } + err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { + NextTest(); + return; + } + err = TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2e: TH leave the device moving for 2 seconds\n"); + err = TestStep2eThLeaveTheDeviceMovingFor2Seconds_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3a1: TH reads OperationalStatus attribute's bit 0..1\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep3a1ThReadsOperationalStatusAttributesBit01_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep3a2WriteAttributeBitmap8WithOperationalStatusValueToDoTheBitsChecksInUpcomingOperationalStatusReadSteps_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF))\n"); + if (ShouldSkip("WNCV.S.A000a && WNCV.S.F00")) { + NextTest(); + return; + } + err = TestStep3a3ThChecksOperationalStatusValueBit23Wncvsf00lf_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3a4: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF))\n"); + if (ShouldSkip("WNCV.S.A000a && !WNCV.S.F00")) { + NextTest(); + return; + } + err = TestStep3a4ThChecksOperationalStatusValueBit23Wncvsf00lf_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL))\n"); + if (ShouldSkip("WNCV.S.A000a && WNCV.S.F01")) { + NextTest(); + return; + } + err = TestStep3a5ThChecksOperationalStatusValueBit45Wncvsf01tl_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 3a6: TH chesks OperationalStatus value bit 4..5 (WNCV.S.F01(TL))\n"); + if (ShouldSkip("WNCV.S.A000a && !WNCV.S.F01")) { + NextTest(); + return; + } + err = TestStep3a6ThChesksOperationalStatusValueBit45Wncvsf01tl_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 3a7: DUT updates its attributes\n"); + err = TestStep3a7DutUpdatesItsAttributes_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { + NextTest(); + return; + } + err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { + NextTest(); + return; + } + err = TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4a: TH sends a StopMotion command to DUT\n"); + if (ShouldSkip("WNCV.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsAStopMotionCommandToDut_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); + err = TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4c: TH reads OperationalStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep4cThReadsOperationalStatusAttributeFromDut_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 5a: TH waits for 100-1000 ms\n"); + err = TestStep5aThWaitsFor1001000Ms_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { + NextTest(); + return; + } + err = TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { + NextTest(); + return; + } + err = TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_28(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 29; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mStep1bWaitTime; + chip::Optional mStep2bWaitTime; + chip::Optional mStep2eWaitTime; + chip::Optional mStep4bWaitTime; + chip::Optional mStep5aWaitTime; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster upOrOpenWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Error: %@", err); + } else { + NSLog(@"Step 1a: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThWaitsFor10SecondsMovementsOnTheDevice_2() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mStep1bWaitTime.HasValue() ? mStep1bWaitTime.Value() : 10000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 9999U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 99U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1eIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1e: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 9999U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1fIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1f: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 99U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsDownOrCloseCommandToDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster downOrCloseWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThWaitsFor1001000Ms_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mStep2bWaitTime.HasValue() ? mStep2bWaitTime.Value() : 500UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2d: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2eThLeaveTheDeviceMovingFor2Seconds_11() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mStep2eWaitTime.HasValue() ? mStep2eWaitTime.Value() : 1000UL; + return WaitForMs("alpha", value); + } + NSNumber * _Nonnull OperationalStatusValue; + + CHIP_ERROR TestStep3a1ThReadsOperationalStatusAttributesBit01_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a1: TH reads OperationalStatus attribute's bit 0..1: Error: %@", err); + } else { + NSLog(@"Step 3a1: TH reads OperationalStatus attribute's bit 0..1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); + { + OperationalStatusValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a2WriteAttributeBitmap8WithOperationalStatusValueToDoTheBitsChecksInUpcomingOperationalStatusReadSteps_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap8Argument; + bitmap8Argument = + [OperationalStatusValue copy]; + [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.: Error: %@", err); + } else { + NSLog(@"Step 3a2: Write attribute BITMAP8 with OperationalStatusValue to do the bits checks in upcoming OperationalStatus read steps.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a3ThChecksOperationalStatusValueBit23Wncvsf00lf_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Error: %@", err); + } else { + NSLog(@"Step 3a3: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); + } + + VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a4ThChecksOperationalStatusValueBit23Wncvsf00lf_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a4: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Error: %@", err); + } else { + NSLog(@"Step 3a4: TH checks OperationalStatus value bit 2..3 (WNCV.S.F00(LF)): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); + } + + VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a5ThChecksOperationalStatusValueBit45Wncvsf01tl_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Error: %@", err); + } else { + NSLog(@"Step 3a5: TH checks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); + } + + VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a6ThChesksOperationalStatusValueBit45Wncvsf01tl_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a6: TH chesks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Error: %@", err); + } else { + NSLog(@"Step 3a6: TH chesks OperationalStatus value bit 4..5 (WNCV.S.F01(TL)): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, OperationalStatusValue)); + } + + VerifyOrReturn(CheckConstraintType("bitmap8", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3a7DutUpdatesItsAttributes_18() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 3000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionLiftPercentage", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eIfPaLfThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3e: If (PA & LF) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("currentPositionTiltPercentage", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsAStopMotionCommandToDut_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster stopMotionWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends a StopMotion command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThWaitsFor15SecondsEndOfMotionsOnTheDut_24() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mStep4bWaitTime.HasValue() ? mStep4bWaitTime.Value() : 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4cThReadsOperationalStatusAttributeFromDut_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads OperationalStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThWaitsFor1001000Ms_26() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mStep5aWaitTime.HasValue() ? mStep5aWaitTime.Value() : 500UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5bIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("targetPositionLiftPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("targetPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("targetPositionTiltPercent100ths", "percent100ths", "percent100ths")); + VerifyOrReturn(CheckConstraintMinValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 1U)); + VerifyOrReturn(CheckConstraintMaxValue("targetPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_3_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_3_3() + : TestCommandBridge("Test_TC_WNCV_3_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_3_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); + if (ShouldSkip("WNCV.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 6-8 seconds movement(s) on the DUT\n"); + err = TestStep1bThWaitsFor68SecondsMovementsOnTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction\n"); + if (ShouldSkip("WNCV.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1d: TH waits for 1-5 seconds revert motion(s) on the DUT\n"); + err = TestStep1dThWaitsFor15SecondsRevertMotionsOnTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1e: TH reads OperationalStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep1eThReadsOperationalStatusAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1f: TH waits for 2 seconds\n"); + err = TestStep1fThWaitsFor2Seconds_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute\n"); + err = TestReportStep2SubscribeToDutReportsOnOperationalStatusAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2: Subscribe to DUT reports on OperationalStatus attribute\n"); + err = TestStep2SubscribeToDutReportsOnOperationalStatusAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH sends a StopMotion command to DUT\n"); + if (ShouldSkip("WNCV.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsAStopMotionCommandToDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH waits for 1-5 seconds end of motion(s) on the DUT\n"); + err = TestStep2bThWaitsFor15SecondsEndOfMotionsOnTheDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2c: TH reads OperationalStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep2cThReadsOperationalStatusAttributeFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 2d: TH waits for 100ms - 3s attributes update on the device\n"); + err = TestStep2dThWaitsFor100ms3sAttributesUpdateOnTheDevice_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 2e: TH reads OperationalStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep2eThReadsOperationalStatusAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000c && WNCV.S.A000f && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_17(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 18; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster downOrCloseWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); + } else { + NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThWaitsFor68SecondsMovementsOnTheDut_2() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 6000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep1cThSendsUpOrOpenCommandToPrepositionTheDutInTheOppositeDirection_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster upOrOpenWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Error: %@", err); + } else { + NSLog(@"Step 1c: TH sends UpOrOpen command to preposition the DUT in the opposite direction: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1dThWaitsFor15SecondsRevertMotionsOnTheDut_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 2000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep1eThReadsOperationalStatusAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1e: TH reads OperationalStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1e: TH reads OperationalStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("operationalStatus", value, 0U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1fThWaitsFor2Seconds_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 2000UL; + return WaitForMs("alpha", value); + } + bool testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled = false; + ResponseHandler _Nullable test_Test_TC_WNCV_3_3_OperationalStatus_Reported + = nil; + + CHIP_ERROR TestReportStep2SubscribeToDutReportsOnOperationalStatusAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_Test_TC_WNCV_3_3_OperationalStatus_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute: Error: %@", err); + } else { + NSLog(@"Report: Step 2: Subscribe to DUT reports on OperationalStatus attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("operationalStatus", "bitmap8", "bitmap8")); + testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled = true; + }; + + NextTest(); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2SubscribeToDutReportsOnOperationalStatusAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + uint16_t minIntervalArgument = 4U; + uint16_t maxIntervalArgument = 5U; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; + params.filterByFabric = true; + params.replaceExistingSubscriptions = true; + [cluster subscribeAttributeOperationalStatusWithParams:params + subscriptionEstablished:^{ + VerifyOrReturn(testSendClusterTest_TC_WNCV_3_3_7_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); + NextTest(); + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: Subscribe to DUT reports on OperationalStatus attribute: Error: %@", err); + } else { + NSLog(@"Step 2: Subscribe to DUT reports on OperationalStatus attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + if (test_Test_TC_WNCV_3_3_OperationalStatus_Reported + != nil) { + ResponseHandler callback = test_Test_TC_WNCV_3_3_OperationalStatus_Reported; + test_Test_TC_WNCV_3_3_OperationalStatus_Reported + = nil; + callback(value, err); + } + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsAStopMotionCommandToDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster stopMotionWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends a StopMotion command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends a StopMotion command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThWaitsFor15SecondsEndOfMotionsOnTheDut_10() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 3000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThReadsOperationalStatusAttributeFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads OperationalStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads OperationalStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dThWaitsFor100ms3sAttributesUpdateOnTheDevice_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 2000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2eThReadsOperationalStatusAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2e: TH reads OperationalStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2e: TH reads OperationalStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable attrCurrentPositionLift; + + CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); + } + { + attrCurrentPositionLift = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bIfPaLfThReadsTargetPositionLiftPercent100thsAttribute3cItMustBeEqualWithCurrentPositionLiftPercent100thsFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute 3c: it Must be equal with CurrentPositionLiftPercent100ths from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (attrCurrentPositionLift == nil) { + VerifyOrReturn(CheckValueNull("TargetPositionLiftPercent100ths", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, attrCurrentPositionLift)); + } + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable attrCurrentPositionTilt; + + CHIP_ERROR TestStep4aIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); + } + { + attrCurrentPositionTilt = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bIfPaTlThReadsTargetPositionTiltPercent100thsAttribute4cItMustBeEqualWithCurrentPositionTiltPercent100thsFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute 4c: it Must be equal with CurrentPositionTiltPercent100ths from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (attrCurrentPositionTilt == nil) { + VerifyOrReturn(CheckValueNull("TargetPositionTiltPercent100ths", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, attrCurrentPositionTilt)); + } + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_3_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_3_4() + : TestCommandBridge("Test_TC_WNCV_3_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("fastMotionDuration", 0, UINT16_MAX, &mFastMotionDuration); + AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_3_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); + if (ShouldSkip("WNCV.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 5-15 seconds movement(s) on the DUT\n"); + err = TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends UpOrOpen command to DUT\n"); + if (ShouldSkip("WNCV.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsUpOrOpenCommandToDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); + err = TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH checks OperationalStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep2cThChecksOperationalStatusAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { + NextTest(); + return; + } + err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { + NextTest(); + return; + } + err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mFastMotionDuration; + chip::Optional mFullMotionDuration; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster downOrCloseWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); + } else { + NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mFastMotionDuration.HasValue() ? mFastMotionDuration.Value() : 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2aThSendsUpOrOpenCommandToDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster upOrOpenWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends UpOrOpen command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThChecksOperationalStatusAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_3_5 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_3_5() + : TestCommandBridge("Test_TC_WNCV_3_5") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("fastMotionDuration", 0, UINT16_MAX, &mFastMotionDuration); + AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_3_5() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_3_5\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_3_5\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends UpOrOpen command to DUT\n"); + if (ShouldSkip("WNCV.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep1aThSendsUpOrOpenCommandToDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for 5-15 seconds movement(s) on the DUT\n"); + err = TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2a: TH sends DownOrClose command to DUT\n"); + if (ShouldSkip("WNCV.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsDownOrCloseCommandToDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2b: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); + err = TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2c: TH checks OperationalStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep2cThChecksOperationalStatusAttributeFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { + NextTest(); + return; + } + err = TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { + NextTest(); + return; + } + err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mFastMotionDuration; + chip::Optional mFullMotionDuration; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThSendsUpOrOpenCommandToDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster upOrOpenWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH sends UpOrOpen command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1a: TH sends UpOrOpen command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThWaitsFor515SecondsMovementsOnTheDut_2() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mFastMotionDuration.HasValue() ? mFastMotionDuration.Value() : 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2aThSendsDownOrCloseCommandToDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster downOrCloseWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends DownOrClose command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThWaitsForPixitwncvfullmotionOnTheDut_4() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThChecksOperationalStatusAttributeFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH checks OperationalStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 10000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_4_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_4_1() + : TestCommandBridge("Test_TC_WNCV_4_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_4_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); + if (ShouldSkip("WNCV.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for x seconds movement(s) on the DUT\n"); + err = TestStep1bThWaitsForXSecondsMovementsOnTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsGoToLiftPercentageCommandWith25PercentToDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH waits for 100-1000 ms\n"); + err = TestStep2bThWaitsFor1001000Ms_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { + NextTest(); + return; + } + err = TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); + err = TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH checks OperationalStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep3bThChecksOperationalStatusAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep3cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { + NextTest(); + return; + } + err = TestStep3dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsGoToLiftPercentageCommandWith7520PercentToDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH waits for 100-1000 ms\n"); + err = TestStep4bThWaitsFor1001000Ms_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000b")) { + NextTest(); + return; + } + err = TestStep4cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); + err = TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5b: TH checks OperationalStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep5bThChecksOperationalStatusAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep5cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008")) { + NextTest(); + return; + } + err = TestStep5dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_17(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 18; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mFullMotionDuration; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster downOrCloseWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); + } else { + NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThWaitsForXSecondsMovementsOnTheDut_2() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep1cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("currentPositionLiftPercent100ths", value, 0U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsGoToLiftPercentageCommandWith25PercentToDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; + params.liftPercent100thsValue = + [NSNumber numberWithUnsignedShort:2500U]; + [cluster goToLiftPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends GoToLiftPercentage command with 25 percent to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThWaitsFor1001000Ms_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 2500U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThChecksOperationalStatusAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 2500U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 25U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsGoToLiftPercentageCommandWith7520PercentToDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; + params.liftPercent100thsValue = + [NSNumber numberWithUnsignedShort:7520U]; + [cluster goToLiftPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 75.20 percent to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThWaitsFor1001000Ms_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4cIfPaLfThReadsTargetPositionLiftPercent100thsAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: If (PA & LF) TH reads TargetPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("TargetPositionLiftPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("TargetPositionLiftPercent100ths", actualValue, 7520U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5bThChecksOperationalStatusAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH checks OperationalStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5b: TH checks OperationalStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5cIfPaLfThReadsCurrentPositionLiftPercent100thsAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5c: If (PA & LF) TH reads CurrentPositionLiftPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, 7520U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5dIfPaLfThReadsCurrentPositionLiftPercentageOptionalAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5d: If (PA & LF) TH reads CurrentPositionLiftPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, 75U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_4_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_4_2() + : TestCommandBridge("Test_TC_WNCV_4_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("fullMotionDuration", 0, UINT16_MAX, &mFullMotionDuration); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_4_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction\n"); + if (ShouldSkip("WNCV.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b: TH waits for x seconds movement(s) on the DUT\n"); + err = TestStep1bThWaitsForXSecondsMovementsOnTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep1cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsGoToTiltPercentageCommandWith30PercentToDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH waits for 100-1000 ms\n"); + err = TestStep2bThWaitsFor1001000Ms_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { + NextTest(); + return; + } + err = TestStep2cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); + err = TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3b: TH checks OperationalStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep3bThChecksOperationalStatusAttributeFromDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { + NextTest(); + return; + } + err = TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsGoToTiltPercentageCommandWith6005PercentToDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4b: TH waits for 100-1000 ms\n"); + err = TestStep4bThWaitsFor1001000Ms_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000c")) { + NextTest(); + return; + } + err = TestStep4cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5a: TH waits for PIXIT.WNCV.FULLMOTION on the DUT\n"); + err = TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5b: TH reads OperationalStatus attribute from DUT\n"); + if (ShouldSkip("WNCV.S.A000a")) { + NextTest(); + return; + } + err = TestStep5bThReadsOperationalStatusAttributeFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep5cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A0009")) { + NextTest(); + return; + } + err = TestStep5dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 18; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mFullMotionDuration; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep1aThSendsDownOrCloseCommandToPrepositionTheDutInTheOppositeDirection_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster downOrCloseWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Error: %@", err); + } else { + NSLog(@"Step 1a: TH sends DownOrClose command to preposition the DUT in the opposite direction: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThWaitsForXSecondsMovementsOnTheDut_2() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep1cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 1c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("currentPositionTiltPercent100ths", value, 0U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsGoToTiltPercentageCommandWith30PercentToDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; + params.tiltPercent100thsValue = + [NSNumber numberWithUnsignedShort:3000U]; + [cluster goToTiltPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends GoToTiltPercentage command with 30 percent to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThWaitsFor1001000Ms_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 3000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThWaitsForPixitwncvfullmotionOnTheDut_7() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep3bThChecksOperationalStatusAttributeFromDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH checks OperationalStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 3000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 3d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 30U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsGoToTiltPercentageCommandWith6005PercentToDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; + params.tiltPercent100thsValue = + [NSNumber numberWithUnsignedShort:6005U]; + [cluster goToTiltPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 60.05 percent to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThWaitsFor1001000Ms_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep4cIfPaTlThReadsTargetPositionTiltPercent100thsAttributeFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 4c: If (PA & TL) TH reads TargetPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("TargetPositionTiltPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("TargetPositionTiltPercent100ths", actualValue, 6005U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThWaitsForPixitwncvfullmotionOnTheDut_14() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mFullMotionDuration.HasValue() ? mFullMotionDuration.Value() : 6000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep5bThReadsOperationalStatusAttributeFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH reads OperationalStatus attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5b: TH reads OperationalStatus attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5cIfPaTlThReadsCurrentPositionTiltPercent100thsAttributeFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5c: If (PA & TL) TH reads CurrentPositionTiltPercent100ths attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, 6005U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5dIfPaTlThReadsCurrentPositionTiltPercentageOptionalAttributeFromDut_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Error: %@", err); + } else { + NSLog(@"Step 5d: If (PA & TL) TH reads CurrentPositionTiltPercentage optional attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, 60U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_4_3 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_4_3() + : TestCommandBridge("Test_TC_WNCV_4_3") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_4_3() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_3\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_3\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep1aIfPaLfLfThReadsCurrentPositionLiftPercent100thsFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A0008 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep1b1cIfPaLfLfThReadsCurrentPositionLiftPercentageFromDutAssertCurrentPositionLiftPercent100ths100EqualsCurrentPositionLiftPercentage_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsGoToLiftPercentageCommandWithBadParamToDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsGoToLiftPercentageCommandWith10001ToDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 || WNCV.S.F00 && WNCV.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_5(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 6; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable attrCurrentPositionLiftPercent100ths; + + CHIP_ERROR TestStep1aIfPaLfLfThReadsCurrentPositionLiftPercent100thsFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); + } else { + NSLog(@"Step 1a: If (PA_LF & LF) TH reads CurrentPositionLiftPercent100ths from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercent100ths", [value unsignedShortValue], 10000U)); + } + { + attrCurrentPositionLiftPercent100ths = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1b1cIfPaLfLfThReadsCurrentPositionLiftPercentageFromDutAssertCurrentPositionLiftPercent100ths100EqualsCurrentPositionLiftPercentage_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage: Error: %@", err); + } else { + NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionLiftPercentage from DUT + assert CurrentPositionLiftPercent100ths/100 equals CurrentPositionLiftPercentage: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercentage", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionLiftPercentage", actualValue, [attrCurrentPositionLiftPercent100ths unsignedShortValue] / 100U)); + } + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentPositionLiftPercentage", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionLiftPercentage", [value unsignedCharValue], 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThSendsGoToLiftPercentageCommandWithBadParamToDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; + params.liftPercent100thsValue = + [NSNumber numberWithUnsignedShort:12288U]; + [cluster goToLiftPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends GoToLiftPercentage command with BadParam to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsGoToLiftPercentageCommandWith10001ToDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; + params.liftPercent100thsValue = + [NSNumber numberWithUnsignedShort:10001U]; + [cluster goToLiftPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends GoToLiftPercentage command with 10001 to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsGoToLiftPercentageCommandWith0xFFFFToDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; + params.liftPercent100thsValue = + [NSNumber numberWithUnsignedShort:65535U]; + [cluster goToLiftPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends GoToLiftPercentage command with 0xFFFF to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_4_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_4_4() + : TestCommandBridge("Test_TC_WNCV_4_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_4_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0: Wait for the commissioned device to be retrieved\n"); + err = TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep1aIfPaTlTlThReadsCurrentPositionTiltPercent100thsFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f && WNCV.S.A0009")) { + NextTest(); + return; + } + err = TestStep1b1cIfPaLfLfThReadsCurrentPositionTiltPercentageFromDutAssertCurrentPositionTiltPercent100ths100EqualsCurrentPositionTiltPercentage_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsGoToTiltPercentageCommandWithBadParamToDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep3aThSendsGoToTiltPercentageCommandWith10001ToDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 || WNCV.S.F01 && WNCV.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsGoToTiltPercentageCommandWith0xFFFFToDut_5(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 6; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nullable attrCurrentPositionTiltPercent100ths; + + CHIP_ERROR TestStep1aIfPaTlTlThReadsCurrentPositionTiltPercent100thsFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); + } else { + NSLog(@"Step 1a: If (PA_TL & TL) TH reads CurrentPositionTiltPercent100ths from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercent100ths", [value unsignedShortValue], 10000U)); + } + { + attrCurrentPositionTiltPercent100ths = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1b1cIfPaLfLfThReadsCurrentPositionTiltPercentageFromDutAssertCurrentPositionTiltPercent100ths100EqualsCurrentPositionTiltPercentage_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercentageWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage: Error: %@", err); + } else { + NSLog(@"Step 1b 1c: If (PA_LF & LF) TH reads CurrentPositionTiltPercentage from DUT + assert CurrentPositionTiltPercent100ths/100 equals CurrentPositionTiltPercentage: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercentage", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionTiltPercentage", actualValue, [attrCurrentPositionTiltPercent100ths unsignedShortValue] / 100U)); + } + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("currentPositionTiltPercentage", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("currentPositionTiltPercentage", [value unsignedCharValue], 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThSendsGoToTiltPercentageCommandWithBadParamToDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; + params.tiltPercent100thsValue = + [NSNumber numberWithUnsignedShort:12288U]; + [cluster goToTiltPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT: Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends GoToTiltPercentage command with BadParam to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsGoToTiltPercentageCommandWith10001ToDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; + params.tiltPercent100thsValue = + [NSNumber numberWithUnsignedShort:10001U]; + [cluster goToTiltPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends GoToTiltPercentage command with 10001 to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsGoToTiltPercentageCommandWith0xFFFFToDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; + params.tiltPercent100thsValue = + [NSNumber numberWithUnsignedShort:65535U]; + [cluster goToTiltPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends GoToTiltPercentage command with 0xFFFF to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_WNCV_4_5 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_WNCV_4_5() + : TestCommandBridge("Test_TC_WNCV_4_5") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_WNCV_4_5() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_WNCV_4_5\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_WNCV_4_5\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 0a: Wait for the commissioned device to be retrieved\n"); + err = TestStep0aWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0b: TH sends UpOrOpen command to preposition the DUT\n"); + err = TestStep0bThSendsUpOrOpenCommandToPrepositionTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep1aIfPaLfLfThSendsGoToLiftPercentageCommandWith90ToDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1b: TH Waits for 100ms-1s\n"); + err = TestStep1bThWaitsFor100ms1s_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1c: TH sends StopMotion command to DUT\n"); + if (ShouldSkip("WNCV.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep1cThSendsStopMotionCommandToDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1d: TH Waits for 100ms-1s\n"); + err = TestStep1dThWaitsFor100ms1s_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.C08.Rsp")) { + NextTest(); + return; + } + err = TestStep2aIfPaTlTlThSendsGoToTiltPercentageCommandWith90ToDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 2b: TH Waits for 100ms-1s\n"); + err = TestStep2bThWaitsFor100ms1s_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2c: TH sends StopMotion command to DUT\n"); + if (ShouldSkip("WNCV.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep2cThSendsStopMotionCommandToDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2d: TH Waits for 100ms-1s\n"); + err = TestStep2dThWaitsFor100ms1s_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep3aThReadsCurrentPositionLiftPercent100thsFromDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep3bThReadsCurrentPositionTiltPercent100thsFromDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3c: reboot/restart the DUT\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep3cRebootRestartTheDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step Reboot target device(DUT)\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStepRebootTargetDeviceDUT_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 3d: Wait for the commissioned device to be retrieved\n"); + err = TestStep3dWaitForTheCommissionedDeviceToBeRetrieved_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT\n"); + if (ShouldSkip("WNCV.S.F00 && WNCV.S.F02 && WNCV.S.A000e")) { + NextTest(); + return; + } + err = TestStep3eThReadsCurrentPositionLiftPercent100thsFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT\n"); + if (ShouldSkip("WNCV.S.F01 && WNCV.S.F04 && WNCV.S.A000f")) { + NextTest(); + return; + } + err = TestStep3fThReadsCurrentPositionTiltPercent100thsFromDut_16(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 17; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep0aWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep0bThSendsUpOrOpenCommandToPrepositionTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster upOrOpenWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0b: TH sends UpOrOpen command to preposition the DUT: Error: %@", err); + } else { + NSLog(@"Step 0b: TH sends UpOrOpen command to preposition the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1aIfPaLfLfThSendsGoToLiftPercentageCommandWith90ToDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToLiftPercentageParams alloc] init]; + params.liftPercent100thsValue = + [NSNumber numberWithUnsignedShort:9000U]; + [cluster goToLiftPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT: Error: %@", err); + } else { + NSLog(@"Step 1a: If (PA_LF & LF) TH sends GoToLiftPercentage command with 90%% to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThWaitsFor100ms1s_3() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep1cThSendsStopMotionCommandToDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster stopMotionWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: TH sends StopMotion command to DUT: Error: %@", err); + } else { + NSLog(@"Step 1c: TH sends StopMotion command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1dThWaitsFor100ms1s_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 500UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2aIfPaTlTlThSendsGoToTiltPercentageCommandWith90ToDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRWindowCoveringClusterGoToTiltPercentageParams alloc] init]; + params.tiltPercent100thsValue = + [NSNumber numberWithUnsignedShort:9000U]; + [cluster goToTiltPercentageWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT: Error: %@", err); + } else { + NSLog(@"Step 2a: If (PA_TL & TL) TH sends GoToTiltPercentage command with 90%% to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThWaitsFor100ms1s_7() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThSendsStopMotionCommandToDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster stopMotionWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH sends StopMotion command to DUT: Error: %@", err); + } else { + NSLog(@"Step 2c: TH sends StopMotion command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2dThWaitsFor100ms1s_9() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 500UL; + return WaitForMs("alpha", value); + } + NSNumber * _Nullable attrCurrentPositionLiftPercent100ths; + + CHIP_ERROR TestStep3aThReadsCurrentPositionLiftPercent100thsFromDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads CurrentPositionLiftPercent100ths from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("currentPositionLiftPercent100ths", value, 0U)); + { + attrCurrentPositionLiftPercent100ths = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable attrCurrentPositionTiltPercent100ths; + + CHIP_ERROR TestStep3bThReadsCurrentPositionTiltPercent100thsFromDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads CurrentPositionTiltPercent100ths from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("currentPositionTiltPercent100ths", value, 0U)); + { + attrCurrentPositionTiltPercent100ths = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cRebootRestartTheDut_12() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestStepRebootTargetDeviceDUT_13() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please reboot the DUT and enter 'y' after DUT startsgarbage: not in length on purpose", 52); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3dWaitForTheCommissionedDeviceToBeRetrieved_14() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep3eThReadsCurrentPositionLiftPercent100thsFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionLiftPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT: Error: %@", err); + } else { + NSLog(@"Step 3e: TH reads CurrentPositionLiftPercent100ths from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (attrCurrentPositionLiftPercent100ths == nil) { + VerifyOrReturn(CheckValueNull("CurrentPositionLiftPercent100ths", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("CurrentPositionLiftPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionLiftPercent100ths", actualValue, attrCurrentPositionLiftPercent100ths)); + } + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fThReadsCurrentPositionTiltPercent100thsFromDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWindowCovering alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPositionTiltPercent100thsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT: Error: %@", err); + } else { + NSLog(@"Step 3f: TH reads CurrentPositionTiltPercent100ths from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (attrCurrentPositionTiltPercent100ths == nil) { + VerifyOrReturn(CheckValueNull("CurrentPositionTiltPercent100ths", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("CurrentPositionTiltPercent100ths", actualValue)); + VerifyOrReturn(CheckValue("CurrentPositionTiltPercent100ths", actualValue, attrCurrentPositionTiltPercent100ths)); + } + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_TargetNavigatorCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_TargetNavigatorCluster() + : TestCommandBridge("TV_TargetNavigatorCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_TargetNavigatorCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_TargetNavigatorCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_TargetNavigatorCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Target Navigator list\n"); + err = TestReadAttributeTargetNavigatorList_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute current navigator target\n"); + err = TestReadAttributeCurrentNavigatorTarget_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Navigate Target Request Command\n"); + err = TestNavigateTargetRequestCommand_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAttributeTargetNavigatorList_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTargetListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute Target Navigator list: Error: %@", err); + } else { + NSLog(@"Read attribute Target Navigator list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TargetList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("Identifier", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[0]).identifier, 1U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[0]).name, @"exampleName")); + VerifyOrReturn(CheckValue("Identifier", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[1]).identifier, 2U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRTargetNavigatorClusterTargetInfoStruct *) actualValue[1]).name, @"exampleName")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCurrentNavigatorTarget_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentTargetWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute current navigator target: Error: %@", err); + } else { + NSLog(@"Read attribute current navigator target: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentTarget", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestNavigateTargetRequestCommand_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTargetNavigator alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTargetNavigatorClusterNavigateTargetParams alloc] init]; + params.target = + [NSNumber numberWithUnsignedChar:1U]; + params.data = @"1"; + [cluster navigateTargetWithParams:params completion: + ^(MTRTargetNavigatorClusterNavigateTargetResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Navigate Target Request Command: Error: %@", err); + } else { + NSLog(@"Navigate Target Request Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_AudioOutputCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_AudioOutputCluster() + : TestCommandBridge("TV_AudioOutputCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_AudioOutputCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_AudioOutputCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_AudioOutputCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Audio Output list\n"); + err = TestReadAttributeAudioOutputList_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute current audio output\n"); + err = TestReadAttributeCurrentAudioOutput_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Select Output Command\n"); + err = TestSelectOutputCommand_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Rename Output Command\n"); + err = TestRenameOutputCommand_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute Audio Output list\n"); + err = TestReadAttributeAudioOutputList_5(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 6; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAttributeAudioOutputList_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute Audio Output list: Error: %@", err); + } else { + NSLog(@"Read attribute Audio Output list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OutputList", [actualValue count], static_cast(3))); + VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).index, 1U)); + VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).outputType, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).name, @"HDMI")); + VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).index, 2U)); + VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).outputType, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).name, @"HDMI")); + VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).index, 3U)); + VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).outputType, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).name, @"HDMI")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCurrentAudioOutput_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentOutputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute current audio output: Error: %@", err); + } else { + NSLog(@"Read attribute current audio output: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentOutput", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSelectOutputCommand_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAudioOutputClusterSelectOutputParams alloc] init]; + params.index = + [NSNumber numberWithUnsignedChar:1U]; + [cluster selectOutputWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Select Output Command: Error: %@", err); + } else { + NSLog(@"Select Output Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRenameOutputCommand_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAudioOutputClusterRenameOutputParams alloc] init]; + params.index = + [NSNumber numberWithUnsignedChar:1U]; + params.name = @"HDMI Test"; + [cluster renameOutputWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Rename Output Command: Error: %@", err); + } else { + NSLog(@"Rename Output Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeAudioOutputList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAudioOutput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOutputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute Audio Output list: Error: %@", err); + } else { + NSLog(@"Read attribute Audio Output list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OutputList", [actualValue count], static_cast(3))); + VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).index, 1U)); + VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).outputType, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[0]).name, @"HDMI Test")); + VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).index, 2U)); + VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).outputType, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[1]).name, @"HDMI")); + VerifyOrReturn(CheckValue("Index", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).index, 3U)); + VerifyOrReturn(CheckValue("OutputType", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).outputType, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRAudioOutputClusterOutputInfoStruct *) actualValue[2]).name, @"HDMI")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_ApplicationLauncherCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_ApplicationLauncherCluster() + : TestCommandBridge("TV_ApplicationLauncherCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_ApplicationLauncherCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_ApplicationLauncherCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_ApplicationLauncherCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Application Launcher list\n"); + err = TestReadAttributeApplicationLauncherList_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute application launcher app\n"); + err = TestReadAttributeApplicationLauncherApp_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Launch App Command\n"); + err = TestLaunchAppCommand_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Stop App Command\n"); + err = TestStopAppCommand_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Hide App Command\n"); + err = TestHideAppCommand_5(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 6; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAttributeApplicationLauncherList_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCatalogListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute Application Launcher list: Error: %@", err); + } else { + NSLog(@"Read attribute Application Launcher list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CatalogList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("", actualValue[0], 123U)); + VerifyOrReturn(CheckValue("", actualValue[1], 456U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeApplicationLauncherApp_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentAppWithCompletion:^(MTRApplicationLauncherClusterApplicationEPStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute application launcher app: Error: %@", err); + } else { + NSLog(@"Read attribute application launcher app: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("CurrentApp", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestLaunchAppCommand_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRApplicationLauncherClusterLaunchAppParams alloc] init]; + params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; + ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = + [NSNumber numberWithUnsignedShort:123U]; + ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; + + params.data = + [[NSData alloc] initWithBytes:"data" length:4]; + [cluster launchAppWithParams:params completion: + ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Launch App Command: Error: %@", err); + } else { + NSLog(@"Launch App Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStopAppCommand_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRApplicationLauncherClusterStopAppParams alloc] init]; + params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; + ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = + [NSNumber numberWithUnsignedShort:123U]; + ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; + + [cluster stopAppWithParams:params completion: + ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Stop App Command: Error: %@", err); + } else { + NSLog(@"Stop App Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestHideAppCommand_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRApplicationLauncherClusterHideAppParams alloc] init]; + params.application = [[MTRApplicationLauncherClusterApplicationStruct alloc] init]; + ((MTRApplicationLauncherClusterApplicationStruct *) params.application).catalogVendorID = + [NSNumber numberWithUnsignedShort:123U]; + ((MTRApplicationLauncherClusterApplicationStruct *) params.application).applicationID = @"applicationId"; + + [cluster hideAppWithParams:params completion: + ^(MTRApplicationLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Hide App Command: Error: %@", err); + } else { + NSLog(@"Hide App Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, [[NSData alloc] initWithBytes:"data" length:4])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_KeypadInputCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_KeypadInputCluster() + : TestCommandBridge("TV_KeypadInputCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_KeypadInputCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_KeypadInputCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_KeypadInputCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Send Key Command\n"); + err = TestSendKeyCommand_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestSendKeyCommand_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterKeypadInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRKeypadInputClusterSendKeyParams alloc] init]; + params.keyCode = + [NSNumber numberWithUnsignedChar:3U]; + [cluster sendKeyWithParams:params completion: + ^(MTRKeypadInputClusterSendKeyResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Key Command: Error: %@", err); + } else { + NSLog(@"Send Key Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_AccountLoginCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_AccountLoginCluster() + : TestCommandBridge("TV_AccountLoginCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_AccountLoginCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_AccountLoginCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_AccountLoginCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Get Setup PIN Command\n"); + err = TestGetSetupPinCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Login Command\n"); + err = TestLoginCommand_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Logout Command\n"); + err = TestLogoutCommand_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestGetSetupPinCommand_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAccountLoginClusterGetSetupPINParams alloc] init]; + params.tempAccountIdentifier = @"asdf"; + [cluster getSetupPINWithParams:params completion: + ^(MTRAccountLoginClusterGetSetupPINResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Setup PIN Command: Error: %@", err); + } else { + NSLog(@"Get Setup PIN Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.setupPIN; + VerifyOrReturn(CheckValueAsString("SetupPIN", actualValue, @"tempPin123")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestLoginCommand_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAccountLoginClusterLoginParams alloc] init]; + params.tempAccountIdentifier = @"asdf"; + params.setupPIN = @"tempPin123"; + params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; + [cluster loginWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Login Command: Error: %@", err); + } else { + NSLog(@"Login Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestLogoutCommand_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccountLogin alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAccountLoginClusterLogoutParams alloc] init]; + params.node = mNodeId.HasValue() ? [NSNumber numberWithUnsignedLongLong:mNodeId.Value()] : [NSNumber numberWithUnsignedLongLong:305414945ULL]; + [cluster logoutWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Logout Command: Error: %@", err); + } else { + NSLog(@"Logout Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_WakeOnLanCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_WakeOnLanCluster() + : TestCommandBridge("TV_WakeOnLanCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_WakeOnLanCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_WakeOnLanCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_WakeOnLanCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read mac address\n"); + err = TestReadMacAddress_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadMacAddress_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterWakeOnLAN alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMACAddressWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read mac address: Error: %@", err); + } else { + NSLog(@"Read mac address: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinLength("MACAddress", value, 3)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_ApplicationBasicCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_ApplicationBasicCluster() + : TestCommandBridge("TV_ApplicationBasicCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_ApplicationBasicCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_ApplicationBasicCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_ApplicationBasicCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute vendor name\n"); + err = TestReadAttributeVendorName_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute vendor id\n"); + err = TestReadAttributeVendorId_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute application name\n"); + err = TestReadAttributeApplicationName_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute product id\n"); + err = TestReadAttributeProductId_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute application status\n"); + err = TestReadAttributeApplicationStatus_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute application status\n"); + err = TestReadAttributeApplicationStatus_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute application version\n"); + err = TestReadAttributeApplicationVersion_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute application allowed vendor list\n"); + err = TestReadAttributeApplicationAllowedVendorList_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAttributeVendorName_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute vendor name: Error: %@", err); + } else { + NSLog(@"Read attribute vendor name: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("VendorName", actualValue, @"exampleVendorName1")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeVendorId_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute vendor id: Error: %@", err); + } else { + NSLog(@"Read attribute vendor id: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("VendorID", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeApplicationName_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeApplicationNameWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute application name: Error: %@", err); + } else { + NSLog(@"Read attribute application name: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("ApplicationName", actualValue, @"exampleName1")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeProductId_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeProductIDWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute product id: Error: %@", err); + } else { + NSLog(@"Read attribute product id: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ProductID", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeApplicationStatus_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute application status: Error: %@", err); + } else { + NSLog(@"Read attribute application status: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeApplicationStatus_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeApplicationWithCompletion:^(MTRApplicationBasicClusterApplicationStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute application status: Error: %@", err); + } else { + NSLog(@"Read attribute application status: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CatalogVendorID", ((MTRApplicationBasicClusterApplicationStruct *) actualValue).catalogVendorID, 123U)); + VerifyOrReturn(CheckValueAsString("ApplicationID", ((MTRApplicationBasicClusterApplicationStruct *) actualValue).applicationID, @"applicationId")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeApplicationVersion_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeApplicationVersionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute application version: Error: %@", err); + } else { + NSLog(@"Read attribute application version: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("ApplicationVersion", actualValue, @"exampleVersion")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeApplicationAllowedVendorList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterApplicationBasic alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAllowedVendorListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute application allowed vendor list: Error: %@", err); + } else { + NSLog(@"Read attribute application allowed vendor list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AllowedVendorList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("", actualValue[0], 1U)); + VerifyOrReturn(CheckValue("", actualValue[1], 456U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_MediaPlaybackCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_MediaPlaybackCluster() + : TestCommandBridge("TV_MediaPlaybackCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_MediaPlaybackCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_MediaPlaybackCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_MediaPlaybackCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute playback state\n"); + err = TestReadAttributePlaybackState_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute start time\n"); + err = TestReadAttributeStartTime_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute duration\n"); + err = TestReadAttributeDuration_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute position\n"); + err = TestReadAttributePosition_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute playback speed\n"); + err = TestReadAttributePlaybackSpeed_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute seek range end\n"); + err = TestReadAttributeSeekRangeEnd_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute seek range start\n"); + err = TestReadAttributeSeekRangeStart_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Media Playback Play Command\n"); + err = TestMediaPlaybackPlayCommand_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Media Playback Pause Command\n"); + err = TestMediaPlaybackPauseCommand_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Media Playback Stop Command\n"); + err = TestMediaPlaybackStopCommand_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Media Playback Start Over Command\n"); + err = TestMediaPlaybackStartOverCommand_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Media Playback Previous Command\n"); + err = TestMediaPlaybackPreviousCommand_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Media Playback Next Command\n"); + err = TestMediaPlaybackNextCommand_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Media Playback Rewind Command\n"); + err = TestMediaPlaybackRewindCommand_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Media Playback Fast Forward Command\n"); + err = TestMediaPlaybackFastForwardCommand_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Media Playback Skip Forward Command\n"); + err = TestMediaPlaybackSkipForwardCommand_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Read attribute position after skip forward\n"); + err = TestReadAttributePositionAfterSkipForward_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Media Playback Skip Backward Command\n"); + err = TestMediaPlaybackSkipBackwardCommand_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Read attribute position after skip backward\n"); + err = TestReadAttributePositionAfterSkipBackward_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Media Playback Seek Command\n"); + err = TestMediaPlaybackSeekCommand_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute position after seek\n"); + err = TestReadAttributePositionAfterSeek_21(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 22; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAttributePlaybackState_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute playback state: Error: %@", err); + } else { + NSLog(@"Read attribute playback state: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeStartTime_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute start time: Error: %@", err); + } else { + NSLog(@"Read attribute start time: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("StartTime", actualValue)); + VerifyOrReturn(CheckValue("StartTime", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeDuration_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDurationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute duration: Error: %@", err); + } else { + NSLog(@"Read attribute duration: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("Duration", actualValue)); + VerifyOrReturn(CheckValue("Duration", actualValue, 80000ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributePosition_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute position: Error: %@", err); + } else { + NSLog(@"Read attribute position: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); + VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); + VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); + VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributePlaybackSpeed_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePlaybackSpeedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute playback speed: Error: %@", err); + } else { + NSLog(@"Read attribute playback speed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PlaybackSpeed", actualValue, 0.0f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeSeekRangeEnd_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSeekRangeEndWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute seek range end: Error: %@", err); + } else { + NSLog(@"Read attribute seek range end: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SeekRangeEnd", actualValue)); + VerifyOrReturn(CheckValue("SeekRangeEnd", actualValue, 80000ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeSeekRangeStart_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSeekRangeStartWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute seek range start: Error: %@", err); + } else { + NSLog(@"Read attribute seek range start: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SeekRangeStart", actualValue)); + VerifyOrReturn(CheckValue("SeekRangeStart", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMediaPlaybackPlayCommand_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster playWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Media Playback Play Command: Error: %@", err); + } else { + NSLog(@"Media Playback Play Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMediaPlaybackPauseCommand_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster pauseWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Media Playback Pause Command: Error: %@", err); + } else { + NSLog(@"Media Playback Pause Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMediaPlaybackStopCommand_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster stopWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Media Playback Stop Command: Error: %@", err); + } else { + NSLog(@"Media Playback Stop Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMediaPlaybackStartOverCommand_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster startOverWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Media Playback Start Over Command: Error: %@", err); + } else { + NSLog(@"Media Playback Start Over Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMediaPlaybackPreviousCommand_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster previousWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Media Playback Previous Command: Error: %@", err); + } else { + NSLog(@"Media Playback Previous Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMediaPlaybackNextCommand_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster nextWithCompletion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Media Playback Next Command: Error: %@", err); + } else { + NSLog(@"Media Playback Next Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMediaPlaybackRewindCommand_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterRewindParams alloc] init]; + [cluster rewindWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Media Playback Rewind Command: Error: %@", err); + } else { + NSLog(@"Media Playback Rewind Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMediaPlaybackFastForwardCommand_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterFastForwardParams alloc] init]; + [cluster fastForwardWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Media Playback Fast Forward Command: Error: %@", err); + } else { + NSLog(@"Media Playback Fast Forward Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMediaPlaybackSkipForwardCommand_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterSkipForwardParams alloc] init]; + params.deltaPositionMilliseconds = + [NSNumber numberWithUnsignedLongLong:500ULL]; + [cluster skipForwardWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Media Playback Skip Forward Command: Error: %@", err); + } else { + NSLog(@"Media Playback Skip Forward Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributePositionAfterSkipForward_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute position after skip forward: Error: %@", err); + } else { + NSLog(@"Read attribute position after skip forward: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); + VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); + VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); + VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 500ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMediaPlaybackSkipBackwardCommand_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterSkipBackwardParams alloc] init]; + params.deltaPositionMilliseconds = + [NSNumber numberWithUnsignedLongLong:100ULL]; + [cluster skipBackwardWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Media Playback Skip Backward Command: Error: %@", err); + } else { + NSLog(@"Media Playback Skip Backward Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributePositionAfterSkipBackward_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute position after skip backward: Error: %@", err); + } else { + NSLog(@"Read attribute position after skip backward: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); + VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); + VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); + VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 400ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMediaPlaybackSeekCommand_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaPlaybackClusterSeekParams alloc] init]; + params.position = + [NSNumber numberWithUnsignedLongLong:1000ULL]; + [cluster seekWithParams:params completion: + ^(MTRMediaPlaybackClusterPlaybackResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Media Playback Seek Command: Error: %@", err); + } else { + NSLog(@"Media Playback Seek Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributePositionAfterSeek_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaPlayback alloc] initWithDevice:device endpointID:@(3) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSampledPositionWithCompletion:^(MTRMediaPlaybackClusterPlaybackPositionStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute position after seek: Error: %@", err); + } else { + NSLog(@"Read attribute position after seek: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SampledPosition", actualValue)); + VerifyOrReturn(CheckValue("UpdatedAt", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).updatedAt, 0ULL)); + VerifyOrReturn(CheckValueNonNull("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position)); + VerifyOrReturn(CheckValue("Position", ((MTRMediaPlaybackClusterPlaybackPositionStruct *) actualValue).position, 1000ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_ChannelCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_ChannelCluster() + : TestCommandBridge("TV_ChannelCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_ChannelCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_ChannelCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_ChannelCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Channel list\n"); + err = TestReadAttributeChannelList_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute channel lineup\n"); + err = TestReadAttributeChannelLineup_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute current channel\n"); + err = TestReadAttributeCurrentChannel_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Change Channel Command\n"); + err = TestChangeChannelCommand_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Change Channel By Number Command\n"); + err = TestChangeChannelByNumberCommand_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Skip Channel Command\n"); + err = TestSkipChannelCommand_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Verify that Skip Channel Command set correct current channel\n"); + err = TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Skip Channel Command\n"); + err = TestSkipChannelCommand_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Verify that Skip Channel Command set correct current channel\n"); + err = TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Test 1.1 - Start from Channel 3\n"); + err = TestTest11StartFromChannel3_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Test 1.2 - Skip Up By 1\n"); + err = TestTest12SkipUpBy1_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Test 2.1 - Start from Channel 3\n"); + err = TestTest21StartFromChannel3_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Test 2.2 - Skip Up By 2\n"); + err = TestTest22SkipUpBy2_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Test 2.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Test 3.1 - Start from Channel 3\n"); + err = TestTest31StartFromChannel3_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Test 3.2 - Skip Up By 3\n"); + err = TestTest32SkipUpBy3_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Test 3.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Test 4.1 - Start from Channel 3\n"); + err = TestTest41StartFromChannel3_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Test 4.2 - Skip Up By 4\n"); + err = TestTest42SkipUpBy4_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Test 4.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Test 5.2 - Skip Up By 5\n"); + err = TestTest52SkipUpBy5_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Test 5.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Test 6.1 - Start from Channel 3\n"); + err = TestTest61StartFromChannel3_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Test 6.2 - Skip Up By 6\n"); + err = TestTest62SkipUpBy6_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Test 6.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Test 7.1 - Start from Channel 3\n"); + err = TestTest71StartFromChannel3_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Test 7.2 - Skip Up By 7\n"); + err = TestTest72SkipUpBy7_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Test 7.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Test 8.1 - Start from Channel 3\n"); + err = TestTest81StartFromChannel3_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Test 8.2 - Skip Up By 8\n"); + err = TestTest82SkipUpBy8_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Test 8.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Test 1.2 - Skip Down By 1\n"); + err = TestTest12SkipDownBy1_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Test 2.1 - Start from Channel 3\n"); + err = TestTest21StartFromChannel3_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Test 2.2 - Skip Down By 2\n"); + err = TestTest22SkipDownBy2_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Test 2.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Test 3.1 - Start from Channel 3\n"); + err = TestTest31StartFromChannel3_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Test 3.2 - Skip Down By 3\n"); + err = TestTest32SkipDownBy3_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Test 3.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Test 4.1 - Start from Channel 3\n"); + err = TestTest41StartFromChannel3_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Test 4.2 - Skip Down By 4\n"); + err = TestTest42SkipDownBy4_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Test 4.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Test 5.2 - Skip Down By 5\n"); + err = TestTest52SkipDownBy5_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Test 5.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Test 6.1 - Start from Channel 3\n"); + err = TestTest61StartFromChannel3_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Test 6.2 - Skip Down By 6\n"); + err = TestTest62SkipDownBy6_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Test 6.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_48(); + break; + case 49: + ChipLogProgress(chipTool, " ***** Test Step 49 : Test 7.1 - Start from Channel 3\n"); + err = TestTest71StartFromChannel3_49(); + break; + case 50: + ChipLogProgress(chipTool, " ***** Test Step 50 : Test 7.2 - Skip Down By 7\n"); + err = TestTest72SkipDownBy7_50(); + break; + case 51: + ChipLogProgress(chipTool, " ***** Test Step 51 : Test 7.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_51(); + break; + case 52: + ChipLogProgress(chipTool, " ***** Test Step 52 : Test 8.1 - Start from Channel 3\n"); + err = TestTest81StartFromChannel3_52(); + break; + case 53: + ChipLogProgress(chipTool, " ***** Test Step 53 : Test 8.2 - Skip Down By 8\n"); + err = TestTest82SkipDownBy8_53(); + break; + case 54: + ChipLogProgress(chipTool, " ***** Test Step 54 : Test 8.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_54(); + break; + case 55: + ChipLogProgress(chipTool, " ***** Test Step 55 : Test 1.2 - Skip Up By 32,767\n"); + err = TestTest12SkipUpBy32767_55(); + break; + case 56: + ChipLogProgress(chipTool, " ***** Test Step 56 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_56(); + break; + case 57: + ChipLogProgress(chipTool, " ***** Test Step 57 : Test 1.1 - Start from Channel 3\n"); + err = TestTest11StartFromChannel3_57(); + break; + case 58: + ChipLogProgress(chipTool, " ***** Test Step 58 : Test 1.2 - Skip Down By 32,768\n"); + err = TestTest12SkipDownBy32768_58(); + break; + case 59: + ChipLogProgress(chipTool, " ***** Test Step 59 : Test 1.3 - Verify that Skip Channel Command set correct current channel\n"); + err = TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_59(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 49: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 50: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 51: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 52: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 53: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 54: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 55: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 56: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 57: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 58: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 59: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 60; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAttributeChannelList_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeChannelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute Channel list: Error: %@", err); + } else { + NSLog(@"Read attribute Channel list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ChannelList", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).majorNumber, 6U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).minorNumber, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).name, @"ABC")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).callSign, @"KAAL-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[0]).affiliateCallSign, @"KAAL")); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).minorNumber, 1U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).name, @"PBS")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[1]).affiliateCallSign, @"KCTS")); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).minorNumber, 2U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).name, @"PBS Kids")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[2]).affiliateCallSign, @"KCTS")); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).minorNumber, 3U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).name, @"World Channel")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue[3]).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeChannelLineup_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLineupWithCompletion:^(MTRChannelClusterLineupInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute channel lineup: Error: %@", err); + } else { + NSLog(@"Read attribute channel lineup: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("Lineup", actualValue)); + VerifyOrReturn(CheckValueAsString("OperatorName", ((MTRChannelClusterLineupInfoStruct *) actualValue).operatorName, @"Comcast")); + VerifyOrReturn(CheckValueAsString("LineupName", ((MTRChannelClusterLineupInfoStruct *) actualValue).lineupName, @"Comcast King County")); + VerifyOrReturn(CheckValueAsString("PostalCode", ((MTRChannelClusterLineupInfoStruct *) actualValue).postalCode, @"98052")); + VerifyOrReturn(CheckValue("LineupInfoType", ((MTRChannelClusterLineupInfoStruct *) actualValue).lineupInfoType, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCurrentChannel_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute current channel: Error: %@", err); + } else { + NSLog(@"Read attribute current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestChangeChannelCommand_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelParams alloc] init]; + params.match = @"PBS"; + [cluster changeChannelWithParams:params completion: + ^(MTRChannelClusterChangeChannelResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Change Channel Command: Error: %@", err); + } else { + NSLog(@"Change Channel Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"data response")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestChangeChannelByNumberCommand_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:6U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:0U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Change Channel By Number Command: Error: %@", err); + } else { + NSLog(@"Change Channel By Number Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSkipChannelCommand_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:2]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Skip Channel Command: Error: %@", err); + } else { + NSLog(@"Skip Channel Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSkipChannelCommand_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:123]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Skip Channel Command: Error: %@", err); + } else { + NSLog(@"Skip Channel Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatSkipChannelCommandSetCorrectCurrentChannel_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest11StartFromChannel3_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 1.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 1.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest12SkipUpBy1_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:1]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 1.2 - Skip Up By 1: Error: %@", err); + } else { + NSLog(@"Test 1.2 - Skip Up By 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest21StartFromChannel3_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 2.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 2.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest22SkipUpBy2_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:2]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 2.2 - Skip Up By 2: Error: %@", err); + } else { + NSLog(@"Test 2.2 - Skip Up By 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest31StartFromChannel3_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 3.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 3.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest32SkipUpBy3_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:3]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 3.2 - Skip Up By 3: Error: %@", err); + } else { + NSLog(@"Test 3.2 - Skip Up By 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest41StartFromChannel3_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 4.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 4.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest42SkipUpBy4_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:4]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 4.2 - Skip Up By 4: Error: %@", err); + } else { + NSLog(@"Test 4.2 - Skip Up By 4: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest52SkipUpBy5_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:5]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 5.2 - Skip Up By 5: Error: %@", err); + } else { + NSLog(@"Test 5.2 - Skip Up By 5: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest61StartFromChannel3_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 6.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 6.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest62SkipUpBy6_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:6]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 6.2 - Skip Up By 6: Error: %@", err); + } else { + NSLog(@"Test 6.2 - Skip Up By 6: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest71StartFromChannel3_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 7.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 7.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest72SkipUpBy7_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:7]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 7.2 - Skip Up By 7: Error: %@", err); + } else { + NSLog(@"Test 7.2 - Skip Up By 7: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest81StartFromChannel3_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 8.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 8.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest82SkipUpBy8_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:8]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 8.2 - Skip Up By 8: Error: %@", err); + } else { + NSLog(@"Test 8.2 - Skip Up By 8: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest12SkipDownBy1_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:-1]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 1.2 - Skip Down By 1: Error: %@", err); + } else { + NSLog(@"Test 1.2 - Skip Down By 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest21StartFromChannel3_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 2.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 2.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest22SkipDownBy2_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:-2]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 2.2 - Skip Down By 2: Error: %@", err); + } else { + NSLog(@"Test 2.2 - Skip Down By 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest23VerifyThatSkipChannelCommandSetCorrectCurrentChannel_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 2.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest31StartFromChannel3_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 3.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 3.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest32SkipDownBy3_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:-3]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 3.2 - Skip Down By 3: Error: %@", err); + } else { + NSLog(@"Test 3.2 - Skip Down By 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest33VerifyThatSkipChannelCommandSetCorrectCurrentChannel_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 3.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest41StartFromChannel3_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 4.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 4.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest42SkipDownBy4_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:-4]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 4.2 - Skip Down By 4: Error: %@", err); + } else { + NSLog(@"Test 4.2 - Skip Down By 4: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest43VerifyThatSkipChannelCommandSetCorrectCurrentChannel_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 4.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest52SkipDownBy5_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:-5]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 5.2 - Skip Down By 5: Error: %@", err); + } else { + NSLog(@"Test 5.2 - Skip Down By 5: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest53VerifyThatSkipChannelCommandSetCorrectCurrentChannel_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 5.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest61StartFromChannel3_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 6.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 6.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest62SkipDownBy6_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:-6]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 6.2 - Skip Down By 6: Error: %@", err); + } else { + NSLog(@"Test 6.2 - Skip Down By 6: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest63VerifyThatSkipChannelCommandSetCorrectCurrentChannel_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 6.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 6U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 0U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"ABC")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KAAL-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KAAL")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest71StartFromChannel3_49() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 7.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 7.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest72SkipDownBy7_50() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:-7]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 7.2 - Skip Down By 7: Error: %@", err); + } else { + NSLog(@"Test 7.2 - Skip Down By 7: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest73VerifyThatSkipChannelCommandSetCorrectCurrentChannel_51() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 7.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 3U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"World Channel")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest81StartFromChannel3_52() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 8.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 8.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest82SkipDownBy8_53() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:-8]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 8.2 - Skip Down By 8: Error: %@", err); + } else { + NSLog(@"Test 8.2 - Skip Down By 8: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest83VerifyThatSkipChannelCommandSetCorrectCurrentChannel_54() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 8.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest12SkipUpBy32767_55() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:32767]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 1.2 - Skip Up By 32,767: Error: %@", err); + } else { + NSLog(@"Test 1.2 - Skip Up By 32,767: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_56() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 1U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest11StartFromChannel3_57() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterChangeChannelByNumberParams alloc] init]; + params.majorNumber = + [NSNumber numberWithUnsignedShort:9U]; + params.minorNumber = + [NSNumber numberWithUnsignedShort:2U]; + [cluster changeChannelByNumberWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 1.1 - Start from Channel 3: Error: %@", err); + } else { + NSLog(@"Test 1.1 - Start from Channel 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest12SkipDownBy32768_58() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRChannelClusterSkipChannelParams alloc] init]; + params.count = + [NSNumber numberWithShort:-32768]; + [cluster skipChannelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 1.2 - Skip Down By 32,768: Error: %@", err); + } else { + NSLog(@"Test 1.2 - Skip Down By 32,768: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTest13VerifyThatSkipChannelCommandSetCorrectCurrentChannel_59() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterChannel alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentChannelWithCompletion:^(MTRChannelClusterChannelInfoStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Error: %@", err); + } else { + NSLog(@"Test 1.3 - Verify that Skip Channel Command set correct current channel: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentChannel", actualValue)); + VerifyOrReturn(CheckValue("MajorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).majorNumber, 9U)); + VerifyOrReturn(CheckValue("MinorNumber", ((MTRChannelClusterChannelInfoStruct *) actualValue).minorNumber, 2U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRChannelClusterChannelInfoStruct *) actualValue).name, @"PBS Kids")); + VerifyOrReturn(CheckValueAsString("CallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).callSign, @"KCTS-TV")); + VerifyOrReturn(CheckValueAsString("AffiliateCallSign", ((MTRChannelClusterChannelInfoStruct *) actualValue).affiliateCallSign, @"KCTS")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_LowPowerCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_LowPowerCluster() + : TestCommandBridge("TV_LowPowerCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_LowPowerCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_LowPowerCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_LowPowerCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Sleep Input Status Command\n"); + err = TestSleepInputStatusCommand_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestSleepInputStatusCommand_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLowPower alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster sleepWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Sleep Input Status Command: Error: %@", err); + } else { + NSLog(@"Sleep Input Status Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_ContentLauncherCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_ContentLauncherCluster() + : TestCommandBridge("TV_ContentLauncherCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_ContentLauncherCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_ContentLauncherCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_ContentLauncherCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute accept header list\n"); + err = TestReadAttributeAcceptHeaderList_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute supported streaming protocols\n"); + err = TestReadAttributeSupportedStreamingProtocols_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Launch Content Command\n"); + err = TestLaunchContentCommand_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Launch URL Command\n"); + err = TestLaunchUrlCommand_4(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 5; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAttributeAcceptHeaderList_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptHeaderWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute accept header list: Error: %@", err); + } else { + NSLog(@"Read attribute accept header list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptHeader", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValueAsString("", actualValue[0], @"example")); + VerifyOrReturn(CheckValueAsString("", actualValue[1], @"example")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeSupportedStreamingProtocols_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedStreamingProtocolsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute supported streaming protocols: Error: %@", err); + } else { + NSLog(@"Read attribute supported streaming protocols: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("SupportedStreamingProtocols", actualValue, 0UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestLaunchContentCommand_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchContentParams alloc] init]; + params.search = [[MTRContentLauncherClusterContentSearchStruct alloc] init]; + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRContentLauncherClusterParameterStruct alloc] init]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).type = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).value = @"exampleValue"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = [[MTRContentLauncherClusterAdditionalInfoStruct alloc] init]; + ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).name = @"name"; + ((MTRContentLauncherClusterAdditionalInfoStruct *) temp_4[0]).value = @"value"; + + ((MTRContentLauncherClusterParameterStruct *) temp_1[0]).externalIDList = temp_4; + } + + ((MTRContentLauncherClusterContentSearchStruct *) params.search).parameterList = temp_1; + } + + params.autoPlay = + [NSNumber numberWithBool:true]; + params.data = @"exampleData"; + params.playbackPreferences = [[MTRContentLauncherClusterPlaybackPreferencesStruct alloc] init]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).playbackPosition = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_4 = [[NSMutableArray alloc] init]; + temp_4[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).characteristics = temp_4; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).textTrack).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRContentLauncherClusterTrackPreferenceStruct alloc] init]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).languageCode = @"exampleLanguageCode"; + { + NSMutableArray * temp_6 = [[NSMutableArray alloc] init]; + temp_6[0] = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).characteristics = temp_6; + } + ((MTRContentLauncherClusterTrackPreferenceStruct *) temp_3[0]).audioOutputIndex = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterPlaybackPreferencesStruct *) params.playbackPreferences).audioTracks = temp_3; + } + + params.useCurrentContext = + [NSNumber numberWithBool:true]; + [cluster launchContentWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Launch Content Command: Error: %@", err); + } else { + NSLog(@"Launch Content Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"exampleData")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestLaunchUrlCommand_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterContentLauncher alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRContentLauncherClusterLaunchURLParams alloc] init]; + params.contentURL = @"exampleUrl"; + params.displayString = @"exampleDisplayString"; + params.brandingInformation = [[MTRContentLauncherClusterBrandingInformationStruct alloc] init]; + ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).providerName = @"exampleName"; + ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).imageURL = @"exampleUrl"; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).color = @"exampleColor"; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).width = + [NSNumber numberWithDouble:0]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).height = + [NSNumber numberWithDouble:0]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).background).size).metric = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).imageURL = @"exampleUrl"; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).color = @"exampleColor"; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).width = + [NSNumber numberWithDouble:0]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).height = + [NSNumber numberWithDouble:0]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).logo).size).metric = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).imageURL = @"exampleUrl"; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).color = @"exampleColor"; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).width = + [NSNumber numberWithDouble:0]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).height = + [NSNumber numberWithDouble:0]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).progressBar).size).metric = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).imageURL = @"exampleUrl"; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).color = @"exampleColor"; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).width = + [NSNumber numberWithDouble:0]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).height = + [NSNumber numberWithDouble:0]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).splash).size).metric = + [NSNumber numberWithUnsignedChar:0U]; + + ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark = [[MTRContentLauncherClusterStyleInformationStruct alloc] init]; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).imageURL = @"exampleUrl"; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).color = @"exampleColor"; + ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size = [[MTRContentLauncherClusterDimensionStruct alloc] init]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).width = + [NSNumber numberWithDouble:0]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).height = + [NSNumber numberWithDouble:0]; + ((MTRContentLauncherClusterDimensionStruct *) ((MTRContentLauncherClusterStyleInformationStruct *) ((MTRContentLauncherClusterBrandingInformationStruct *) params.brandingInformation).waterMark).size).metric = + [NSNumber numberWithUnsignedChar:0U]; + + [cluster launchURLWithParams:params completion: + ^(MTRContentLauncherClusterLauncherResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Launch URL Command: Error: %@", err); + } else { + NSLog(@"Launch URL Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.data; + VerifyOrReturn(CheckValueAsString("Data", actualValue, @"exampleData")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TV_MediaInputCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TV_MediaInputCluster() + : TestCommandBridge("TV_MediaInputCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TV_MediaInputCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TV_MediaInputCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TV_MediaInputCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute media input list\n"); + err = TestReadAttributeMediaInputList_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read current media input\n"); + err = TestReadCurrentMediaInput_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Select Input Command\n"); + err = TestSelectInputCommand_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Hide Input Status Command\n"); + err = TestHideInputStatusCommand_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Show Input Status Command\n"); + err = TestShowInputStatusCommand_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Rename Input Command\n"); + err = TestRenameInputCommand_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute media input list\n"); + err = TestReadAttributeMediaInputList_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAttributeMediaInputList_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute media input list: Error: %@", err); + } else { + NSLog(@"Read attribute media input list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("InputList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).index, 1U)); + VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).inputType, 4U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).name, @"HDMI")); + VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).descriptionString, @"High-Definition Multimedia Interface")); + VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).index, 2U)); + VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).inputType, 4U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).name, @"HDMI")); + VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).descriptionString, @"High-Definition Multimedia Interface")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentMediaInput_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentInputWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current media input: Error: %@", err); + } else { + NSLog(@"Read current media input: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentInput", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSelectInputCommand_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaInputClusterSelectInputParams alloc] init]; + params.index = + [NSNumber numberWithUnsignedChar:1U]; + [cluster selectInputWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Select Input Command: Error: %@", err); + } else { + NSLog(@"Select Input Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestHideInputStatusCommand_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster hideInputStatusWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Hide Input Status Command: Error: %@", err); + } else { + NSLog(@"Hide Input Status Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestShowInputStatusCommand_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster showInputStatusWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Show Input Status Command: Error: %@", err); + } else { + NSLog(@"Show Input Status Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRenameInputCommand_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRMediaInputClusterRenameInputParams alloc] init]; + params.index = + [NSNumber numberWithUnsignedChar:1U]; + params.name = @"HDMI Test"; + [cluster renameInputWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Rename Input Command: Error: %@", err); + } else { + NSLog(@"Rename Input Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeMediaInputList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterMediaInput alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInputListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute media input list: Error: %@", err); + } else { + NSLog(@"Read attribute media input list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("InputList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).index, 1U)); + VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).inputType, 4U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).name, @"HDMI Test")); + VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[0]).descriptionString, @"High-Definition Multimedia Interface")); + VerifyOrReturn(CheckValue("Index", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).index, 2U)); + VerifyOrReturn(CheckValue("InputType", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).inputType, 4U)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).name, @"HDMI")); + VerifyOrReturn(CheckValueAsString("Description", ((MTRMediaInputClusterInputInfoStruct *) actualValue[1]).descriptionString, @"High-Definition Multimedia Interface")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestCASERecovery : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestCASERecovery() + : TestCommandBridge("TestCASERecovery") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestCASERecovery() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestCASERecovery\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestCASERecovery\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read an attribute\n"); + err = TestReadAnAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Reboot the server\n"); + err = TestRebootTheServer_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Re-get our session, but without expiring sesssions\n"); + err = TestReGetOurSessionButWithoutExpiringSesssions_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read an attribute again\n"); + err = TestReadAnAttributeAgain_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Re-get our session, but without expiring sesssions\n"); + err = TestReGetOurSessionButWithoutExpiringSesssions_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read an attribute a third time\n"); + err = TestReadAnAttributeAThirdTime_6(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 7; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAnAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read an attribute: Error: %@", err); + } else { + NSLog(@"Read an attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("DataModelRevision", actualValue, 17U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRebootTheServer_2() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestReGetOurSessionButWithoutExpiringSesssions_3() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + value.expireExistingSession.Emplace(); + value.expireExistingSession.Value() = false; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAnAttributeAgain_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read an attribute again: Error: %@", err); + } else { + NSLog(@"Read an attribute again: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReGetOurSessionButWithoutExpiringSesssions_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + value.expireExistingSession.Emplace(); + value.expireExistingSession.Value() = false; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAnAttributeAThirdTime_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDataModelRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read an attribute a third time: Error: %@", err); + } else { + NSLog(@"Read an attribute a third time: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("DataModelRevision", actualValue, 17U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestCluster() + : TestCommandBridge("TestCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Command\n"); + err = TestSendTestCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Not Handled Command\n"); + err = TestSendTestNotHandledCommand_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Send Test Specific Command\n"); + err = TestSendTestSpecificCommand_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Send Test Add Arguments Command\n"); + err = TestSendTestAddArgumentsCommand_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Send failing Test Add Arguments Command\n"); + err = TestSendFailingTestAddArgumentsCommand_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute BOOLEAN Default Value\n"); + err = TestReadAttributeBooleanDefaultValue_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Write attribute BOOLEAN True\n"); + err = TestWriteAttributeBooleanTrue_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BOOLEAN True\n"); + err = TestReadAttributeBooleanTrue_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Write attribute BOOLEAN False\n"); + err = TestWriteAttributeBooleanFalse_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Read attribute BOOLEAN False\n"); + err = TestReadAttributeBooleanFalse_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Read attribute BITMAP8 Default Value\n"); + err = TestReadAttributeBitmap8DefaultValue_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Write attribute BITMAP8 Max Value\n"); + err = TestWriteAttributeBitmap8MaxValue_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Read attribute BITMAP8 Max Value\n"); + err = TestReadAttributeBitmap8MaxValue_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Write attribute BITMAP8 Min Value\n"); + err = TestWriteAttributeBitmap8MinValue_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Read attribute BITMAP8 Min Value\n"); + err = TestReadAttributeBitmap8MinValue_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute BITMAP16 Default Value\n"); + err = TestReadAttributeBitmap16DefaultValue_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Write attribute BITMAP16 Max Value\n"); + err = TestWriteAttributeBitmap16MaxValue_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Read attribute BITMAP16 Max Value\n"); + err = TestReadAttributeBitmap16MaxValue_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Write attribute BITMAP16 Min Value\n"); + err = TestWriteAttributeBitmap16MinValue_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Read attribute BITMAP16 Min Value\n"); + err = TestReadAttributeBitmap16MinValue_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute BITMAP32 Default Value\n"); + err = TestReadAttributeBitmap32DefaultValue_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Write attribute BITMAP32 Max Value\n"); + err = TestWriteAttributeBitmap32MaxValue_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute BITMAP32 Max Value\n"); + err = TestReadAttributeBitmap32MaxValue_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Write attribute BITMAP32 Min Value\n"); + err = TestWriteAttributeBitmap32MinValue_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Read attribute BITMAP32 Min Value\n"); + err = TestReadAttributeBitmap32MinValue_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Read attribute BITMAP64 Default Value\n"); + err = TestReadAttributeBitmap64DefaultValue_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Write attribute BITMAP64 Max Value\n"); + err = TestWriteAttributeBitmap64MaxValue_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Read attribute BITMAP64 Max Value\n"); + err = TestReadAttributeBitmap64MaxValue_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Write attribute BITMAP64 Min Value\n"); + err = TestWriteAttributeBitmap64MinValue_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Read attribute BITMAP64 Min Value\n"); + err = TestReadAttributeBitmap64MinValue_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute INT8U Default Value\n"); + err = TestReadAttributeInt8uDefaultValue_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute INT8U Max Value\n"); + err = TestWriteAttributeInt8uMaxValue_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute INT8U Max Value\n"); + err = TestReadAttributeInt8uMaxValue_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Write attribute INT8U Min Value\n"); + err = TestWriteAttributeInt8uMinValue_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Read attribute INT8U Min Value\n"); + err = TestReadAttributeInt8uMinValue_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Read attribute INT16U Default Value\n"); + err = TestReadAttributeInt16uDefaultValue_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Write attribute INT16U Max Value\n"); + err = TestWriteAttributeInt16uMaxValue_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Read attribute INT16U Max Value\n"); + err = TestReadAttributeInt16uMaxValue_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Write attribute INT16U Min Value\n"); + err = TestWriteAttributeInt16uMinValue_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Read attribute INT16U Min Value\n"); + err = TestReadAttributeInt16uMinValue_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute INT32U Default Value\n"); + err = TestReadAttributeInt32uDefaultValue_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute INT32U Max Value\n"); + err = TestWriteAttributeInt32uMaxValue_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute INT32U Max Value\n"); + err = TestReadAttributeInt32uMaxValue_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Write attribute INT32U Min Value\n"); + err = TestWriteAttributeInt32uMinValue_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Read attribute INT32U Min Value\n"); + err = TestReadAttributeInt32uMinValue_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute INT64U Default Value\n"); + err = TestReadAttributeInt64uDefaultValue_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Write attribute INT64U Max Value\n"); + err = TestWriteAttributeInt64uMaxValue_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Read attribute INT64U Max Value\n"); + err = TestReadAttributeInt64uMaxValue_48(); + break; + case 49: + ChipLogProgress(chipTool, " ***** Test Step 49 : Write attribute INT64U Min Value\n"); + err = TestWriteAttributeInt64uMinValue_49(); + break; + case 50: + ChipLogProgress(chipTool, " ***** Test Step 50 : Read attribute INT64U Min Value\n"); + err = TestReadAttributeInt64uMinValue_50(); + break; + case 51: + ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute INT8S Default Value\n"); + err = TestReadAttributeInt8sDefaultValue_51(); + break; + case 52: + ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute INT8S Max Value\n"); + err = TestWriteAttributeInt8sMaxValue_52(); + break; + case 53: + ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute INT8S Max Value\n"); + err = TestReadAttributeInt8sMaxValue_53(); + break; + case 54: + ChipLogProgress(chipTool, " ***** Test Step 54 : Write attribute INT8S Min Value\n"); + err = TestWriteAttributeInt8sMinValue_54(); + break; + case 55: + ChipLogProgress(chipTool, " ***** Test Step 55 : Read attribute INT8S Min Value\n"); + err = TestReadAttributeInt8sMinValue_55(); + break; + case 56: + ChipLogProgress(chipTool, " ***** Test Step 56 : Write attribute INT8S Default Value\n"); + err = TestWriteAttributeInt8sDefaultValue_56(); + break; + case 57: + ChipLogProgress(chipTool, " ***** Test Step 57 : Read attribute INT8S Default Value\n"); + err = TestReadAttributeInt8sDefaultValue_57(); + break; + case 58: + ChipLogProgress(chipTool, " ***** Test Step 58 : Read attribute INT16S Default Value\n"); + err = TestReadAttributeInt16sDefaultValue_58(); + break; + case 59: + ChipLogProgress(chipTool, " ***** Test Step 59 : Write attribute INT16S Max Value\n"); + err = TestWriteAttributeInt16sMaxValue_59(); + break; + case 60: + ChipLogProgress(chipTool, " ***** Test Step 60 : Read attribute INT16S Max Value\n"); + err = TestReadAttributeInt16sMaxValue_60(); + break; + case 61: + ChipLogProgress(chipTool, " ***** Test Step 61 : Write attribute INT16S Min Value\n"); + err = TestWriteAttributeInt16sMinValue_61(); + break; + case 62: + ChipLogProgress(chipTool, " ***** Test Step 62 : Read attribute INT16S Min Value\n"); + err = TestReadAttributeInt16sMinValue_62(); + break; + case 63: + ChipLogProgress(chipTool, " ***** Test Step 63 : Write attribute INT16S Default Value\n"); + err = TestWriteAttributeInt16sDefaultValue_63(); + break; + case 64: + ChipLogProgress(chipTool, " ***** Test Step 64 : Read attribute INT16S Default Value\n"); + err = TestReadAttributeInt16sDefaultValue_64(); + break; + case 65: + ChipLogProgress(chipTool, " ***** Test Step 65 : Read attribute INT32S Default Value\n"); + err = TestReadAttributeInt32sDefaultValue_65(); + break; + case 66: + ChipLogProgress(chipTool, " ***** Test Step 66 : Write attribute INT32S Max Value\n"); + err = TestWriteAttributeInt32sMaxValue_66(); + break; + case 67: + ChipLogProgress(chipTool, " ***** Test Step 67 : Read attribute INT32S Max Value\n"); + err = TestReadAttributeInt32sMaxValue_67(); + break; + case 68: + ChipLogProgress(chipTool, " ***** Test Step 68 : Write attribute INT32S Min Value\n"); + err = TestWriteAttributeInt32sMinValue_68(); + break; + case 69: + ChipLogProgress(chipTool, " ***** Test Step 69 : Read attribute INT32S Min Value\n"); + err = TestReadAttributeInt32sMinValue_69(); + break; + case 70: + ChipLogProgress(chipTool, " ***** Test Step 70 : Write attribute INT32S Default Value\n"); + err = TestWriteAttributeInt32sDefaultValue_70(); + break; + case 71: + ChipLogProgress(chipTool, " ***** Test Step 71 : Read attribute INT32S Default Value\n"); + err = TestReadAttributeInt32sDefaultValue_71(); + break; + case 72: + ChipLogProgress(chipTool, " ***** Test Step 72 : Read attribute INT64S Default Value\n"); + err = TestReadAttributeInt64sDefaultValue_72(); + break; + case 73: + ChipLogProgress(chipTool, " ***** Test Step 73 : Write attribute INT64S Max Value\n"); + err = TestWriteAttributeInt64sMaxValue_73(); + break; + case 74: + ChipLogProgress(chipTool, " ***** Test Step 74 : Read attribute INT64S Max Value\n"); + err = TestReadAttributeInt64sMaxValue_74(); + break; + case 75: + ChipLogProgress(chipTool, " ***** Test Step 75 : Write attribute INT64S Min Value\n"); + err = TestWriteAttributeInt64sMinValue_75(); + break; + case 76: + ChipLogProgress(chipTool, " ***** Test Step 76 : Read attribute INT64S Min Value\n"); + err = TestReadAttributeInt64sMinValue_76(); + break; + case 77: + ChipLogProgress(chipTool, " ***** Test Step 77 : Write attribute INT64S Default Value\n"); + err = TestWriteAttributeInt64sDefaultValue_77(); + break; + case 78: + ChipLogProgress(chipTool, " ***** Test Step 78 : Read attribute INT64S Default Value\n"); + err = TestReadAttributeInt64sDefaultValue_78(); + break; + case 79: + ChipLogProgress(chipTool, " ***** Test Step 79 : Read attribute SINGLE Default Value\n"); + err = TestReadAttributeSingleDefaultValue_79(); + break; + case 80: + ChipLogProgress(chipTool, " ***** Test Step 80 : Write attribute SINGLE medium Value\n"); + err = TestWriteAttributeSingleMediumValue_80(); + break; + case 81: + ChipLogProgress(chipTool, " ***** Test Step 81 : Read attribute SINGLE medium Value\n"); + err = TestReadAttributeSingleMediumValue_81(); + break; + case 82: + ChipLogProgress(chipTool, " ***** Test Step 82 : Write attribute SINGLE large Value\n"); + err = TestWriteAttributeSingleLargeValue_82(); + break; + case 83: + ChipLogProgress(chipTool, " ***** Test Step 83 : Read attribute SINGLE large Value\n"); + err = TestReadAttributeSingleLargeValue_83(); + break; + case 84: + ChipLogProgress(chipTool, " ***** Test Step 84 : Write attribute SINGLE small Value\n"); + err = TestWriteAttributeSingleSmallValue_84(); + break; + case 85: + ChipLogProgress(chipTool, " ***** Test Step 85 : Read attribute SINGLE small Value\n"); + err = TestReadAttributeSingleSmallValue_85(); + break; + case 86: + ChipLogProgress(chipTool, " ***** Test Step 86 : Write attribute SINGLE Default Value\n"); + err = TestWriteAttributeSingleDefaultValue_86(); + break; + case 87: + ChipLogProgress(chipTool, " ***** Test Step 87 : Read attribute SINGLE Default Value\n"); + err = TestReadAttributeSingleDefaultValue_87(); + break; + case 88: + ChipLogProgress(chipTool, " ***** Test Step 88 : Read attribute DOUBLE Default Value\n"); + err = TestReadAttributeDoubleDefaultValue_88(); + break; + case 89: + ChipLogProgress(chipTool, " ***** Test Step 89 : Write attribute DOUBLE medium Value\n"); + err = TestWriteAttributeDoubleMediumValue_89(); + break; + case 90: + ChipLogProgress(chipTool, " ***** Test Step 90 : Read attribute DOUBLE medium Value\n"); + err = TestReadAttributeDoubleMediumValue_90(); + break; + case 91: + ChipLogProgress(chipTool, " ***** Test Step 91 : Write attribute DOUBLE large Value\n"); + err = TestWriteAttributeDoubleLargeValue_91(); + break; + case 92: + ChipLogProgress(chipTool, " ***** Test Step 92 : Read attribute DOUBLE large Value\n"); + err = TestReadAttributeDoubleLargeValue_92(); + break; + case 93: + ChipLogProgress(chipTool, " ***** Test Step 93 : Write attribute DOUBLE small Value\n"); + err = TestWriteAttributeDoubleSmallValue_93(); + break; + case 94: + ChipLogProgress(chipTool, " ***** Test Step 94 : Read attribute DOUBLE small Value\n"); + err = TestReadAttributeDoubleSmallValue_94(); + break; + case 95: + ChipLogProgress(chipTool, " ***** Test Step 95 : Write attribute DOUBLE Default Value\n"); + err = TestWriteAttributeDoubleDefaultValue_95(); + break; + case 96: + ChipLogProgress(chipTool, " ***** Test Step 96 : Read attribute DOUBLE Default Value\n"); + err = TestReadAttributeDoubleDefaultValue_96(); + break; + case 97: + ChipLogProgress(chipTool, " ***** Test Step 97 : Read attribute ENUM8 Default Value\n"); + err = TestReadAttributeEnum8DefaultValue_97(); + break; + case 98: + ChipLogProgress(chipTool, " ***** Test Step 98 : Write attribute ENUM8 Max Value\n"); + err = TestWriteAttributeEnum8MaxValue_98(); + break; + case 99: + ChipLogProgress(chipTool, " ***** Test Step 99 : Read attribute ENUM8 Max Value\n"); + err = TestReadAttributeEnum8MaxValue_99(); + break; + case 100: + ChipLogProgress(chipTool, " ***** Test Step 100 : Write attribute ENUM8 Min Value\n"); + err = TestWriteAttributeEnum8MinValue_100(); + break; + case 101: + ChipLogProgress(chipTool, " ***** Test Step 101 : Read attribute ENUM8 Min Value\n"); + err = TestReadAttributeEnum8MinValue_101(); + break; + case 102: + ChipLogProgress(chipTool, " ***** Test Step 102 : Read attribute ENUM16 Default Value\n"); + err = TestReadAttributeEnum16DefaultValue_102(); + break; + case 103: + ChipLogProgress(chipTool, " ***** Test Step 103 : Write attribute ENUM16 Max Value\n"); + err = TestWriteAttributeEnum16MaxValue_103(); + break; + case 104: + ChipLogProgress(chipTool, " ***** Test Step 104 : Read attribute ENUM16 Max Value\n"); + err = TestReadAttributeEnum16MaxValue_104(); + break; + case 105: + ChipLogProgress(chipTool, " ***** Test Step 105 : Write attribute ENUM16 Min Value\n"); + err = TestWriteAttributeEnum16MinValue_105(); + break; + case 106: + ChipLogProgress(chipTool, " ***** Test Step 106 : Read attribute ENUM16 Min Value\n"); + err = TestReadAttributeEnum16MinValue_106(); + break; + case 107: + ChipLogProgress(chipTool, " ***** Test Step 107 : Read attribute OCTET_STRING Default Value\n"); + err = TestReadAttributeOctetStringDefaultValue_107(); + break; + case 108: + ChipLogProgress(chipTool, " ***** Test Step 108 : Write attribute OCTET_STRING with embedded null\n"); + err = TestWriteAttributeOctetStringWithEmbeddedNull_108(); + break; + case 109: + ChipLogProgress(chipTool, " ***** Test Step 109 : Read attribute OCTET_STRING with embedded null\n"); + err = TestReadAttributeOctetStringWithEmbeddedNull_109(); + break; + case 110: + ChipLogProgress(chipTool, " ***** Test Step 110 : Write attribute OCTET_STRING with hex: format\n"); + err = TestWriteAttributeOctetStringWithHexFormat_110(); + break; + case 111: + ChipLogProgress(chipTool, " ***** Test Step 111 : Read attribute OCTET_STRING with hex: format\n"); + err = TestReadAttributeOctetStringWithHexFormat_111(); + break; + case 112: + ChipLogProgress(chipTool, " ***** Test Step 112 : Write attribute OCTET_STRING with weird chars\n"); + err = TestWriteAttributeOctetStringWithWeirdChars_112(); + break; + case 113: + ChipLogProgress(chipTool, " ***** Test Step 113 : Read attribute OCTET_STRING with weird chars\n"); + err = TestReadAttributeOctetStringWithWeirdChars_113(); + break; + case 114: + ChipLogProgress(chipTool, " ***** Test Step 114 : Write attribute OCTET_STRING\n"); + err = TestWriteAttributeOctetString_114(); + break; + case 115: + ChipLogProgress(chipTool, " ***** Test Step 115 : Read attribute OCTET_STRING\n"); + err = TestReadAttributeOctetString_115(); + break; + case 116: + ChipLogProgress(chipTool, " ***** Test Step 116 : Write attribute OCTET_STRING\n"); + err = TestWriteAttributeOctetString_116(); + break; + case 117: + ChipLogProgress(chipTool, " ***** Test Step 117 : Read attribute OCTET_STRING\n"); + err = TestReadAttributeOctetString_117(); + break; + case 118: + ChipLogProgress(chipTool, " ***** Test Step 118 : Write attribute OCTET_STRING\n"); + err = TestWriteAttributeOctetString_118(); + break; + case 119: + ChipLogProgress(chipTool, " ***** Test Step 119 : Read attribute LONG_OCTET_STRING Default Value\n"); + err = TestReadAttributeLongOctetStringDefaultValue_119(); + break; + case 120: + ChipLogProgress(chipTool, " ***** Test Step 120 : Write attribute LONG_OCTET_STRING\n"); + err = TestWriteAttributeLongOctetString_120(); + break; + case 121: + ChipLogProgress(chipTool, " ***** Test Step 121 : Read attribute LONG_OCTET_STRING\n"); + err = TestReadAttributeLongOctetString_121(); + break; + case 122: + ChipLogProgress(chipTool, " ***** Test Step 122 : Write attribute LONG_OCTET_STRING\n"); + err = TestWriteAttributeLongOctetString_122(); + break; + case 123: + ChipLogProgress(chipTool, " ***** Test Step 123 : Read attribute CHAR_STRING Default Value\n"); + err = TestReadAttributeCharStringDefaultValue_123(); + break; + case 124: + ChipLogProgress(chipTool, " ***** Test Step 124 : Write attribute CHAR_STRING\n"); + err = TestWriteAttributeCharString_124(); + break; + case 125: + ChipLogProgress(chipTool, " ***** Test Step 125 : Read attribute CHAR_STRING\n"); + err = TestReadAttributeCharString_125(); + break; + case 126: + ChipLogProgress(chipTool, " ***** Test Step 126 : Write attribute CHAR_STRING - Value too long\n"); + err = TestWriteAttributeCharStringValueTooLong_126(); + break; + case 127: + ChipLogProgress(chipTool, " ***** Test Step 127 : Read attribute CHAR_STRING\n"); + err = TestReadAttributeCharString_127(); + break; + case 128: + ChipLogProgress(chipTool, " ***** Test Step 128 : Write attribute CHAR_STRING - Empty\n"); + err = TestWriteAttributeCharStringEmpty_128(); + break; + case 129: + ChipLogProgress(chipTool, " ***** Test Step 129 : Read attribute LONG_CHAR_STRING Default Value\n"); + err = TestReadAttributeLongCharStringDefaultValue_129(); + break; + case 130: + ChipLogProgress(chipTool, " ***** Test Step 130 : Write attribute LONG_CHAR_STRING\n"); + err = TestWriteAttributeLongCharString_130(); + break; + case 131: + ChipLogProgress(chipTool, " ***** Test Step 131 : Read attribute LONG_CHAR_STRING\n"); + err = TestReadAttributeLongCharString_131(); + break; + case 132: + ChipLogProgress(chipTool, " ***** Test Step 132 : Write attribute LONG_CHAR_STRING\n"); + err = TestWriteAttributeLongCharString_132(); + break; + case 133: + ChipLogProgress(chipTool, " ***** Test Step 133 : Read attribute LIST_LONG_OCTET_STRING (for chunked read)\n"); + err = TestReadAttributeListLongOctetStringForChunkedRead_133(); + break; + case 134: + ChipLogProgress(chipTool, " ***** Test Step 134 : Write attribute LIST_LONG_OCTET_STRING (for chunked write)\n"); + err = TestWriteAttributeListLongOctetStringForChunkedWrite_134(); + break; + case 135: + ChipLogProgress(chipTool, " ***** Test Step 135 : Read attribute LIST_LONG_OCTET_STRING (for chunked read)\n"); + err = TestReadAttributeListLongOctetStringForChunkedRead_135(); + break; + case 136: + ChipLogProgress(chipTool, " ***** Test Step 136 : Write attribute LIST_LONG_OCTET_STRING (for chunked write)\n"); + err = TestWriteAttributeListLongOctetStringForChunkedWrite_136(); + break; + case 137: + ChipLogProgress(chipTool, " ***** Test Step 137 : Read attribute EPOCH_US Default Value\n"); + err = TestReadAttributeEpochUsDefaultValue_137(); + break; + case 138: + ChipLogProgress(chipTool, " ***** Test Step 138 : Write attribute EPOCH_US Max Value\n"); + err = TestWriteAttributeEpochUsMaxValue_138(); + break; + case 139: + ChipLogProgress(chipTool, " ***** Test Step 139 : Read attribute EPOCH_US Max Value\n"); + err = TestReadAttributeEpochUsMaxValue_139(); + break; + case 140: + ChipLogProgress(chipTool, " ***** Test Step 140 : Write attribute EPOCH_US Min Value\n"); + err = TestWriteAttributeEpochUsMinValue_140(); + break; + case 141: + ChipLogProgress(chipTool, " ***** Test Step 141 : Read attribute EPOCH_US Min Value\n"); + err = TestReadAttributeEpochUsMinValue_141(); + break; + case 142: + ChipLogProgress(chipTool, " ***** Test Step 142 : Read attribute EPOCH_S Default Value\n"); + err = TestReadAttributeEpochSDefaultValue_142(); + break; + case 143: + ChipLogProgress(chipTool, " ***** Test Step 143 : Write attribute EPOCH_S Max Value\n"); + err = TestWriteAttributeEpochSMaxValue_143(); + break; + case 144: + ChipLogProgress(chipTool, " ***** Test Step 144 : Read attribute EPOCH_S Max Value\n"); + err = TestReadAttributeEpochSMaxValue_144(); + break; + case 145: + ChipLogProgress(chipTool, " ***** Test Step 145 : Write attribute EPOCH_S Min Value\n"); + err = TestWriteAttributeEpochSMinValue_145(); + break; + case 146: + ChipLogProgress(chipTool, " ***** Test Step 146 : Read attribute EPOCH_S Min Value\n"); + err = TestReadAttributeEpochSMinValue_146(); + break; + case 147: + ChipLogProgress(chipTool, " ***** Test Step 147 : Read attribute UNSUPPORTED\n"); + err = TestReadAttributeUnsupported_147(); + break; + case 148: + ChipLogProgress(chipTool, " ***** Test Step 148 : Writeattribute UNSUPPORTED\n"); + err = TestWriteattributeUnsupported_148(); + break; + case 149: + ChipLogProgress(chipTool, " ***** Test Step 149 : Send Test Command to unsupported endpoint\n"); + err = TestSendTestCommandToUnsupportedEndpoint_149(); + break; + case 150: + ChipLogProgress(chipTool, " ***** Test Step 150 : Send Test Command to unsupported cluster\n"); + err = TestSendTestCommandToUnsupportedCluster_150(); + break; + case 151: + ChipLogProgress(chipTool, " ***** Test Step 151 : Read attribute vendor_id Default Value\n"); + err = TestReadAttributeVendorIdDefaultValue_151(); + break; + case 152: + ChipLogProgress(chipTool, " ***** Test Step 152 : Write attribute vendor_id\n"); + err = TestWriteAttributeVendorId_152(); + break; + case 153: + ChipLogProgress(chipTool, " ***** Test Step 153 : Read attribute vendor_id\n"); + err = TestReadAttributeVendorId_153(); + break; + case 154: + ChipLogProgress(chipTool, " ***** Test Step 154 : Restore attribute vendor_id\n"); + err = TestRestoreAttributeVendorId_154(); + break; + case 155: + ChipLogProgress(chipTool, " ***** Test Step 155 : Send a command with a vendor_id and enum\n"); + err = TestSendACommandWithAVendorIdAndEnum_155(); + break; + case 156: + ChipLogProgress(chipTool, " ***** Test Step 156 : Send a command with a vendor_id and invalid enum\n"); + err = TestSendACommandWithAVendorIdAndInvalidEnum_156(); + break; + case 157: + ChipLogProgress(chipTool, " ***** Test Step 157 : Send Test Command With Struct Argument and arg1.b is true\n"); + err = TestSendTestCommandWithStructArgumentAndArg1bIsTrue_157(); + break; + case 158: + ChipLogProgress(chipTool, " ***** Test Step 158 : Send Test Command With Struct Argument and arg1.b is false\n"); + err = TestSendTestCommandWithStructArgumentAndArg1bIsFalse_158(); + break; + case 159: + ChipLogProgress(chipTool, " ***** Test Step 159 : Send Test Command With Nested Struct Argument and arg1.c.b is true\n"); + err = TestSendTestCommandWithNestedStructArgumentAndArg1cbIsTrue_159(); + break; + case 160: + ChipLogProgress(chipTool, " ***** Test Step 160 : Send Test Command With Nested Struct Argument arg1.c.b is false\n"); + err = TestSendTestCommandWithNestedStructArgumentArg1cbIsFalse_160(); + break; + case 161: + ChipLogProgress(chipTool, " ***** Test Step 161 : Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true\n"); + err = TestSendTestCommandWithNestedStructListArgumentAndAllFieldsBOfArg1dAreTrue_161(); + break; + case 162: + ChipLogProgress(chipTool, " ***** Test Step 162 : Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false\n"); + err = TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfArg1dAreFalse_162(); + break; + case 163: + ChipLogProgress(chipTool, " ***** Test Step 163 : Send Test Command With Struct Argument and see what we get back\n"); + err = TestSendTestCommandWithStructArgumentAndSeeWhatWeGetBack_163(); + break; + case 164: + ChipLogProgress(chipTool, " ***** Test Step 164 : Send Test Command With List of INT8U and none of them is set to 0\n"); + err = TestSendTestCommandWithListOfInt8uAndNoneOfThemIsSetTo0_164(); + break; + case 165: + ChipLogProgress(chipTool, " ***** Test Step 165 : Send Test Command With List of INT8U and one of them is set to 0\n"); + err = TestSendTestCommandWithListOfInt8uAndOneOfThemIsSetTo0_165(); + break; + case 166: + ChipLogProgress(chipTool, " ***** Test Step 166 : Send Test Command With List of INT8U and get it reversed\n"); + err = TestSendTestCommandWithListOfInt8uAndGetItReversed_166(); + break; + case 167: + ChipLogProgress(chipTool, " ***** Test Step 167 : Send Test Command With empty List of INT8U and get an empty list back\n"); + err = TestSendTestCommandWithEmptyListOfInt8uAndGetAnEmptyListBack_167(); + break; + case 168: + ChipLogProgress(chipTool, " ***** Test Step 168 : Send Test Command With List of Struct Argument and arg1.b of first item is true\n"); + err = TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsTrue_168(); + break; + case 169: + ChipLogProgress(chipTool, " ***** Test Step 169 : Send Test Command With List of Struct Argument and arg1.b of first item is false\n"); + err = TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsFalse_169(); + break; + case 170: + ChipLogProgress(chipTool, " ***** Test Step 170 : Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true\n"); + err = TestSendTestCommandWithListOfNestedStructListArgumentAndAllFieldsBOfElementsOfArg1dAreTrue_170(); + break; + case 171: + ChipLogProgress(chipTool, " ***** Test Step 171 : Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false\n"); + err = TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfElementsOfArg1dAreFalse_171(); + break; + case 172: + ChipLogProgress(chipTool, " ***** Test Step 172 : Write attribute LIST With List of INT8U and none of them is set to 0\n"); + err = TestWriteAttributeListWithListOfInt8uAndNoneOfThemIsSetTo0_172(); + break; + case 173: + ChipLogProgress(chipTool, " ***** Test Step 173 : Read attribute LIST With List of INT8U\n"); + err = TestReadAttributeListWithListOfInt8u_173(); + break; + case 174: + ChipLogProgress(chipTool, " ***** Test Step 174 : Write attribute LIST With List of OCTET_STRING\n"); + err = TestWriteAttributeListWithListOfOctetString_174(); + break; + case 175: + ChipLogProgress(chipTool, " ***** Test Step 175 : Read attribute LIST With List of OCTET_STRING\n"); + err = TestReadAttributeListWithListOfOctetString_175(); + break; + case 176: + ChipLogProgress(chipTool, " ***** Test Step 176 : Write attribute LIST With List of LIST_STRUCT_OCTET_STRING\n"); + err = TestWriteAttributeListWithListOfListStructOctetString_176(); + break; + case 177: + ChipLogProgress(chipTool, " ***** Test Step 177 : Read attribute LIST With List of LIST_STRUCT_OCTET_STRING\n"); + err = TestReadAttributeListWithListOfListStructOctetString_177(); + break; + case 178: + ChipLogProgress(chipTool, " ***** Test Step 178 : Send Test Command with optional arg set.\n"); + err = TestSendTestCommandWithOptionalArgSet_178(); + break; + case 179: + ChipLogProgress(chipTool, " ***** Test Step 179 : Send Test Command without its optional arg.\n"); + err = TestSendTestCommandWithoutItsOptionalArg_179(); + break; + case 180: + ChipLogProgress(chipTool, " ***** Test Step 180 : Read list of structs containing nullables and optionals\n"); + err = TestReadListOfStructsContainingNullablesAndOptionals_180(); + break; + case 181: + ChipLogProgress(chipTool, " ***** Test Step 181 : Write list of structs containing nullables and optionals\n"); + err = TestWriteListOfStructsContainingNullablesAndOptionals_181(); + break; + case 182: + ChipLogProgress(chipTool, " ***** Test Step 182 : Read list of structs containing nullables and optionals after writing\n"); + err = TestReadListOfStructsContainingNullablesAndOptionalsAfterWriting_182(); + break; + case 183: + ChipLogProgress(chipTool, " ***** Test Step 183 : Write attribute NULLABLE_BOOLEAN null\n"); + err = TestWriteAttributeNullableBooleanNull_183(); + break; + case 184: + ChipLogProgress(chipTool, " ***** Test Step 184 : Read attribute NULLABLE_BOOLEAN null\n"); + err = TestReadAttributeNullableBooleanNull_184(); + break; + case 185: + ChipLogProgress(chipTool, " ***** Test Step 185 : Write attribute NULLABLE_BOOLEAN True\n"); + err = TestWriteAttributeNullableBooleanTrue_185(); + break; + case 186: + ChipLogProgress(chipTool, " ***** Test Step 186 : Read attribute NULLABLE_BOOLEAN True\n"); + err = TestReadAttributeNullableBooleanTrue_186(); + break; + case 187: + ChipLogProgress(chipTool, " ***** Test Step 187 : Read attribute NULLABLE_BOOLEAN not null\n"); + err = TestReadAttributeNullableBooleanNotNull_187(); + break; + case 188: + ChipLogProgress(chipTool, " ***** Test Step 188 : Write attribute NULLABLE_BITMAP8 Max Value\n"); + err = TestWriteAttributeNullableBitmap8MaxValue_188(); + break; + case 189: + ChipLogProgress(chipTool, " ***** Test Step 189 : Read attribute NULLABLE_BITMAP8 Max Value\n"); + err = TestReadAttributeNullableBitmap8MaxValue_189(); + break; + case 190: + ChipLogProgress(chipTool, " ***** Test Step 190 : Write attribute NULLABLE_BITMAP8 Invalid Value\n"); + err = TestWriteAttributeNullableBitmap8InvalidValue_190(); + break; + case 191: + ChipLogProgress(chipTool, " ***** Test Step 191 : Read attribute NULLABLE_BITMAP8 unchanged Value\n"); + err = TestReadAttributeNullableBitmap8UnchangedValue_191(); + break; + case 192: + ChipLogProgress(chipTool, " ***** Test Step 192 : Write attribute NULLABLE_BITMAP8 null Value\n"); + err = TestWriteAttributeNullableBitmap8NullValue_192(); + break; + case 193: + ChipLogProgress(chipTool, " ***** Test Step 193 : Read attribute NULLABLE_BITMAP8 null Value\n"); + err = TestReadAttributeNullableBitmap8NullValue_193(); + break; + case 194: + ChipLogProgress(chipTool, " ***** Test Step 194 : Read attribute NULLABLE_BITMAP8 not 254 Value\n"); + err = TestReadAttributeNullableBitmap8Not254Value_194(); + break; + case 195: + ChipLogProgress(chipTool, " ***** Test Step 195 : Write attribute NULLABLE_BITMAP16 Max Value\n"); + err = TestWriteAttributeNullableBitmap16MaxValue_195(); + break; + case 196: + ChipLogProgress(chipTool, " ***** Test Step 196 : Read attribute NULLABLE_BITMAP16 Max Value\n"); + err = TestReadAttributeNullableBitmap16MaxValue_196(); + break; + case 197: + ChipLogProgress(chipTool, " ***** Test Step 197 : Write attribute NULLABLE_BITMAP16 Invalid Value\n"); + err = TestWriteAttributeNullableBitmap16InvalidValue_197(); + break; + case 198: + ChipLogProgress(chipTool, " ***** Test Step 198 : Read attribute NULLABLE_BITMAP16 unchanged Value\n"); + err = TestReadAttributeNullableBitmap16UnchangedValue_198(); + break; + case 199: + ChipLogProgress(chipTool, " ***** Test Step 199 : Write attribute NULLABLE_BITMAP16 null Value\n"); + err = TestWriteAttributeNullableBitmap16NullValue_199(); + break; + case 200: + ChipLogProgress(chipTool, " ***** Test Step 200 : Read attribute NULLABLE_BITMAP16 null Value\n"); + err = TestReadAttributeNullableBitmap16NullValue_200(); + break; + case 201: + ChipLogProgress(chipTool, " ***** Test Step 201 : Write attribute NULLABLE_BITMAP32 Max Value\n"); + err = TestWriteAttributeNullableBitmap32MaxValue_201(); + break; + case 202: + ChipLogProgress(chipTool, " ***** Test Step 202 : Read attribute NULLABLE_BITMAP32 Max Value\n"); + err = TestReadAttributeNullableBitmap32MaxValue_202(); + break; + case 203: + ChipLogProgress(chipTool, " ***** Test Step 203 : Write attribute NULLABLE_BITMAP32 Invalid Value\n"); + err = TestWriteAttributeNullableBitmap32InvalidValue_203(); + break; + case 204: + ChipLogProgress(chipTool, " ***** Test Step 204 : Read attribute NULLABLE_BITMAP32 unchanged Value\n"); + err = TestReadAttributeNullableBitmap32UnchangedValue_204(); + break; + case 205: + ChipLogProgress(chipTool, " ***** Test Step 205 : Write attribute NULLABLE_BITMAP32 null Value\n"); + err = TestWriteAttributeNullableBitmap32NullValue_205(); + break; + case 206: + ChipLogProgress(chipTool, " ***** Test Step 206 : Read attribute NULLABLE_BITMAP32 null Value\n"); + err = TestReadAttributeNullableBitmap32NullValue_206(); + break; + case 207: + ChipLogProgress(chipTool, " ***** Test Step 207 : Write attribute NULLABLE_BITMAP64 Max Value\n"); + err = TestWriteAttributeNullableBitmap64MaxValue_207(); + break; + case 208: + ChipLogProgress(chipTool, " ***** Test Step 208 : Read attribute NULLABLE_BITMAP64 Max Value\n"); + err = TestReadAttributeNullableBitmap64MaxValue_208(); + break; + case 209: + ChipLogProgress(chipTool, " ***** Test Step 209 : Write attribute NULLABLE_BITMAP64 Invalid Value\n"); + err = TestWriteAttributeNullableBitmap64InvalidValue_209(); + break; + case 210: + ChipLogProgress(chipTool, " ***** Test Step 210 : Read attribute NULLABLE_BITMAP64 unchanged Value\n"); + err = TestReadAttributeNullableBitmap64UnchangedValue_210(); + break; + case 211: + ChipLogProgress(chipTool, " ***** Test Step 211 : Write attribute NULLABLE_BITMAP64 null Value\n"); + err = TestWriteAttributeNullableBitmap64NullValue_211(); + break; + case 212: + ChipLogProgress(chipTool, " ***** Test Step 212 : Read attribute NULLABLE_BITMAP64 null Value\n"); + err = TestReadAttributeNullableBitmap64NullValue_212(); + break; + case 213: + ChipLogProgress(chipTool, " ***** Test Step 213 : Write attribute NULLABLE_INT8U Min Value\n"); + err = TestWriteAttributeNullableInt8uMinValue_213(); + break; + case 214: + ChipLogProgress(chipTool, " ***** Test Step 214 : Read attribute NULLABLE_INT8U Min Value\n"); + err = TestReadAttributeNullableInt8uMinValue_214(); + break; + case 215: + ChipLogProgress(chipTool, " ***** Test Step 215 : Write attribute NULLABLE_INT8U Max Value\n"); + err = TestWriteAttributeNullableInt8uMaxValue_215(); + break; + case 216: + ChipLogProgress(chipTool, " ***** Test Step 216 : Read attribute NULLABLE_INT8U Max Value\n"); + err = TestReadAttributeNullableInt8uMaxValue_216(); + break; + case 217: + ChipLogProgress(chipTool, " ***** Test Step 217 : Write attribute NULLABLE_INT8U Invalid Value\n"); + err = TestWriteAttributeNullableInt8uInvalidValue_217(); + break; + case 218: + ChipLogProgress(chipTool, " ***** Test Step 218 : Read attribute NULLABLE_INT8U unchanged Value\n"); + err = TestReadAttributeNullableInt8uUnchangedValue_218(); + break; + case 219: + ChipLogProgress(chipTool, " ***** Test Step 219 : Read attribute NULLABLE_INT8U unchanged Value with constraint\n"); + err = TestReadAttributeNullableInt8uUnchangedValueWithConstraint_219(); + break; + case 220: + ChipLogProgress(chipTool, " ***** Test Step 220 : Write attribute NULLABLE_INT8U null Value\n"); + err = TestWriteAttributeNullableInt8uNullValue_220(); + break; + case 221: + ChipLogProgress(chipTool, " ***** Test Step 221 : Read attribute NULLABLE_INT8U null Value\n"); + err = TestReadAttributeNullableInt8uNullValue_221(); + break; + case 222: + ChipLogProgress(chipTool, " ***** Test Step 222 : Read attribute NULLABLE_INT8U null Value & range\n"); + err = TestReadAttributeNullableInt8uNullValueRange_222(); + break; + case 223: + ChipLogProgress(chipTool, " ***** Test Step 223 : Read attribute NULLABLE_INT8U null Value & not\n"); + err = TestReadAttributeNullableInt8uNullValueNot_223(); + break; + case 224: + ChipLogProgress(chipTool, " ***** Test Step 224 : Write attribute NULLABLE_INT8U Value\n"); + err = TestWriteAttributeNullableInt8uValue_224(); + break; + case 225: + ChipLogProgress(chipTool, " ***** Test Step 225 : Read attribute NULLABLE_INT8U Value in range\n"); + err = TestReadAttributeNullableInt8uValueInRange_225(); + break; + case 226: + ChipLogProgress(chipTool, " ***** Test Step 226 : Read attribute NULLABLE_INT8U notValue OK\n"); + err = TestReadAttributeNullableInt8uNotValueOk_226(); + break; + case 227: + ChipLogProgress(chipTool, " ***** Test Step 227 : Write attribute NULLABLE_INT16U Min Value\n"); + err = TestWriteAttributeNullableInt16uMinValue_227(); + break; + case 228: + ChipLogProgress(chipTool, " ***** Test Step 228 : Read attribute NULLABLE_INT16U Min Value\n"); + err = TestReadAttributeNullableInt16uMinValue_228(); + break; + case 229: + ChipLogProgress(chipTool, " ***** Test Step 229 : Write attribute NULLABLE_INT16U Max Value\n"); + err = TestWriteAttributeNullableInt16uMaxValue_229(); + break; + case 230: + ChipLogProgress(chipTool, " ***** Test Step 230 : Read attribute NULLABLE_INT16U Max Value\n"); + err = TestReadAttributeNullableInt16uMaxValue_230(); + break; + case 231: + ChipLogProgress(chipTool, " ***** Test Step 231 : Write attribute NULLABLE_INT16U Invalid Value\n"); + err = TestWriteAttributeNullableInt16uInvalidValue_231(); + break; + case 232: + ChipLogProgress(chipTool, " ***** Test Step 232 : Read attribute NULLABLE_INT16U unchanged Value\n"); + err = TestReadAttributeNullableInt16uUnchangedValue_232(); + break; + case 233: + ChipLogProgress(chipTool, " ***** Test Step 233 : Write attribute NULLABLE_INT16U null Value\n"); + err = TestWriteAttributeNullableInt16uNullValue_233(); + break; + case 234: + ChipLogProgress(chipTool, " ***** Test Step 234 : Read attribute NULLABLE_INT16U null Value\n"); + err = TestReadAttributeNullableInt16uNullValue_234(); + break; + case 235: + ChipLogProgress(chipTool, " ***** Test Step 235 : Read attribute NULLABLE_INT16U null Value & range\n"); + err = TestReadAttributeNullableInt16uNullValueRange_235(); + break; + case 236: + ChipLogProgress(chipTool, " ***** Test Step 236 : Read attribute NULLABLE_INT16U null Value & not\n"); + err = TestReadAttributeNullableInt16uNullValueNot_236(); + break; + case 237: + ChipLogProgress(chipTool, " ***** Test Step 237 : Write attribute NULLABLE_INT16U Value\n"); + err = TestWriteAttributeNullableInt16uValue_237(); + break; + case 238: + ChipLogProgress(chipTool, " ***** Test Step 238 : Read attribute NULLABLE_INT16U Value in range\n"); + err = TestReadAttributeNullableInt16uValueInRange_238(); + break; + case 239: + ChipLogProgress(chipTool, " ***** Test Step 239 : Read attribute NULLABLE_INT16U notValue OK\n"); + err = TestReadAttributeNullableInt16uNotValueOk_239(); + break; + case 240: + ChipLogProgress(chipTool, " ***** Test Step 240 : Write attribute NULLABLE_INT32U Min Value\n"); + err = TestWriteAttributeNullableInt32uMinValue_240(); + break; + case 241: + ChipLogProgress(chipTool, " ***** Test Step 241 : Read attribute NULLABLE_INT32U Min Value\n"); + err = TestReadAttributeNullableInt32uMinValue_241(); + break; + case 242: + ChipLogProgress(chipTool, " ***** Test Step 242 : Write attribute NULLABLE_INT32U Max Value\n"); + err = TestWriteAttributeNullableInt32uMaxValue_242(); + break; + case 243: + ChipLogProgress(chipTool, " ***** Test Step 243 : Read attribute NULLABLE_INT32U Max Value\n"); + err = TestReadAttributeNullableInt32uMaxValue_243(); + break; + case 244: + ChipLogProgress(chipTool, " ***** Test Step 244 : Write attribute NULLABLE_INT32U Invalid Value\n"); + err = TestWriteAttributeNullableInt32uInvalidValue_244(); + break; + case 245: + ChipLogProgress(chipTool, " ***** Test Step 245 : Read attribute NULLABLE_INT32U unchanged Value\n"); + err = TestReadAttributeNullableInt32uUnchangedValue_245(); + break; + case 246: + ChipLogProgress(chipTool, " ***** Test Step 246 : Write attribute NULLABLE_INT32U null Value\n"); + err = TestWriteAttributeNullableInt32uNullValue_246(); + break; + case 247: + ChipLogProgress(chipTool, " ***** Test Step 247 : Read attribute NULLABLE_INT32U null Value\n"); + err = TestReadAttributeNullableInt32uNullValue_247(); + break; + case 248: + ChipLogProgress(chipTool, " ***** Test Step 248 : Read attribute NULLABLE_INT32U null Value & range\n"); + err = TestReadAttributeNullableInt32uNullValueRange_248(); + break; + case 249: + ChipLogProgress(chipTool, " ***** Test Step 249 : Read attribute NULLABLE_INT32U null Value & not\n"); + err = TestReadAttributeNullableInt32uNullValueNot_249(); + break; + case 250: + ChipLogProgress(chipTool, " ***** Test Step 250 : Write attribute NULLABLE_INT32U Value\n"); + err = TestWriteAttributeNullableInt32uValue_250(); + break; + case 251: + ChipLogProgress(chipTool, " ***** Test Step 251 : Read attribute NULLABLE_INT32U Value in range\n"); + err = TestReadAttributeNullableInt32uValueInRange_251(); + break; + case 252: + ChipLogProgress(chipTool, " ***** Test Step 252 : Read attribute NULLABLE_INT32U notValue OK\n"); + err = TestReadAttributeNullableInt32uNotValueOk_252(); + break; + case 253: + ChipLogProgress(chipTool, " ***** Test Step 253 : Write attribute NULLABLE_INT64U Min Value\n"); + err = TestWriteAttributeNullableInt64uMinValue_253(); + break; + case 254: + ChipLogProgress(chipTool, " ***** Test Step 254 : Read attribute NULLABLE_INT64U Min Value\n"); + err = TestReadAttributeNullableInt64uMinValue_254(); + break; + case 255: + ChipLogProgress(chipTool, " ***** Test Step 255 : Write attribute NULLABLE_INT64U Max Value\n"); + err = TestWriteAttributeNullableInt64uMaxValue_255(); + break; + case 256: + ChipLogProgress(chipTool, " ***** Test Step 256 : Read attribute NULLABLE_INT64U Max Value\n"); + err = TestReadAttributeNullableInt64uMaxValue_256(); + break; + case 257: + ChipLogProgress(chipTool, " ***** Test Step 257 : Write attribute NULLABLE_INT64U Invalid Value\n"); + err = TestWriteAttributeNullableInt64uInvalidValue_257(); + break; + case 258: + ChipLogProgress(chipTool, " ***** Test Step 258 : Read attribute NULLABLE_INT64U unchanged Value\n"); + err = TestReadAttributeNullableInt64uUnchangedValue_258(); + break; + case 259: + ChipLogProgress(chipTool, " ***** Test Step 259 : Write attribute NULLABLE_INT64U null Value\n"); + err = TestWriteAttributeNullableInt64uNullValue_259(); + break; + case 260: + ChipLogProgress(chipTool, " ***** Test Step 260 : Read attribute NULLABLE_INT64U null Value\n"); + err = TestReadAttributeNullableInt64uNullValue_260(); + break; + case 261: + ChipLogProgress(chipTool, " ***** Test Step 261 : Read attribute NULLABLE_INT64U null Value & range\n"); + err = TestReadAttributeNullableInt64uNullValueRange_261(); + break; + case 262: + ChipLogProgress(chipTool, " ***** Test Step 262 : Read attribute NULLABLE_INT64U null Value & not\n"); + err = TestReadAttributeNullableInt64uNullValueNot_262(); + break; + case 263: + ChipLogProgress(chipTool, " ***** Test Step 263 : Write attribute NULLABLE_INT64U Value\n"); + err = TestWriteAttributeNullableInt64uValue_263(); + break; + case 264: + ChipLogProgress(chipTool, " ***** Test Step 264 : Read attribute NULLABLE_INT64U Value in range\n"); + err = TestReadAttributeNullableInt64uValueInRange_264(); + break; + case 265: + ChipLogProgress(chipTool, " ***** Test Step 265 : Read attribute NULLABLE_INT64U notValue OK\n"); + err = TestReadAttributeNullableInt64uNotValueOk_265(); + break; + case 266: + ChipLogProgress(chipTool, " ***** Test Step 266 : Write attribute NULLABLE_INT8S Min Value\n"); + err = TestWriteAttributeNullableInt8sMinValue_266(); + break; + case 267: + ChipLogProgress(chipTool, " ***** Test Step 267 : Read attribute NULLABLE_INT8S Min Value\n"); + err = TestReadAttributeNullableInt8sMinValue_267(); + break; + case 268: + ChipLogProgress(chipTool, " ***** Test Step 268 : Write attribute NULLABLE_INT8S Invalid Value\n"); + err = TestWriteAttributeNullableInt8sInvalidValue_268(); + break; + case 269: + ChipLogProgress(chipTool, " ***** Test Step 269 : Read attribute NULLABLE_INT8S unchanged Value\n"); + err = TestReadAttributeNullableInt8sUnchangedValue_269(); + break; + case 270: + ChipLogProgress(chipTool, " ***** Test Step 270 : Write attribute NULLABLE_INT8S null Value\n"); + err = TestWriteAttributeNullableInt8sNullValue_270(); + break; + case 271: + ChipLogProgress(chipTool, " ***** Test Step 271 : Read attribute NULLABLE_INT8S null Value\n"); + err = TestReadAttributeNullableInt8sNullValue_271(); + break; + case 272: + ChipLogProgress(chipTool, " ***** Test Step 272 : Read attribute NULLABLE_INT8S null Value & range\n"); + err = TestReadAttributeNullableInt8sNullValueRange_272(); + break; + case 273: + ChipLogProgress(chipTool, " ***** Test Step 273 : Read attribute NULLABLE_INT8S null Value & not\n"); + err = TestReadAttributeNullableInt8sNullValueNot_273(); + break; + case 274: + ChipLogProgress(chipTool, " ***** Test Step 274 : Write attribute NULLABLE_INT8S Value\n"); + err = TestWriteAttributeNullableInt8sValue_274(); + break; + case 275: + ChipLogProgress(chipTool, " ***** Test Step 275 : Read attribute NULLABLE_INT8S Value in range\n"); + err = TestReadAttributeNullableInt8sValueInRange_275(); + break; + case 276: + ChipLogProgress(chipTool, " ***** Test Step 276 : Read attribute NULLABLE_INT8S notValue OK\n"); + err = TestReadAttributeNullableInt8sNotValueOk_276(); + break; + case 277: + ChipLogProgress(chipTool, " ***** Test Step 277 : Write attribute NULLABLE_INT16S Min Value\n"); + err = TestWriteAttributeNullableInt16sMinValue_277(); + break; + case 278: + ChipLogProgress(chipTool, " ***** Test Step 278 : Read attribute NULLABLE_INT16S Min Value\n"); + err = TestReadAttributeNullableInt16sMinValue_278(); + break; + case 279: + ChipLogProgress(chipTool, " ***** Test Step 279 : Write attribute NULLABLE_INT16S Invalid Value\n"); + err = TestWriteAttributeNullableInt16sInvalidValue_279(); + break; + case 280: + ChipLogProgress(chipTool, " ***** Test Step 280 : Read attribute NULLABLE_INT16S unchanged Value\n"); + err = TestReadAttributeNullableInt16sUnchangedValue_280(); + break; + case 281: + ChipLogProgress(chipTool, " ***** Test Step 281 : Write attribute NULLABLE_INT16S null Value\n"); + err = TestWriteAttributeNullableInt16sNullValue_281(); + break; + case 282: + ChipLogProgress(chipTool, " ***** Test Step 282 : Read attribute NULLABLE_INT16S null Value\n"); + err = TestReadAttributeNullableInt16sNullValue_282(); + break; + case 283: + ChipLogProgress(chipTool, " ***** Test Step 283 : Read attribute NULLABLE_INT16S null Value & range\n"); + err = TestReadAttributeNullableInt16sNullValueRange_283(); + break; + case 284: + ChipLogProgress(chipTool, " ***** Test Step 284 : Read attribute NULLABLE_INT16S null Value & not\n"); + err = TestReadAttributeNullableInt16sNullValueNot_284(); + break; + case 285: + ChipLogProgress(chipTool, " ***** Test Step 285 : Write attribute NULLABLE_INT16S Value\n"); + err = TestWriteAttributeNullableInt16sValue_285(); + break; + case 286: + ChipLogProgress(chipTool, " ***** Test Step 286 : Read attribute NULLABLE_INT16S Value in range\n"); + err = TestReadAttributeNullableInt16sValueInRange_286(); + break; + case 287: + ChipLogProgress(chipTool, " ***** Test Step 287 : Read attribute NULLABLE_INT16S notValue OK\n"); + err = TestReadAttributeNullableInt16sNotValueOk_287(); + break; + case 288: + ChipLogProgress(chipTool, " ***** Test Step 288 : Write attribute NULLABLE_INT32S Min Value\n"); + err = TestWriteAttributeNullableInt32sMinValue_288(); + break; + case 289: + ChipLogProgress(chipTool, " ***** Test Step 289 : Read attribute NULLABLE_INT32S Min Value\n"); + err = TestReadAttributeNullableInt32sMinValue_289(); + break; + case 290: + ChipLogProgress(chipTool, " ***** Test Step 290 : Write attribute NULLABLE_INT32S Invalid Value\n"); + err = TestWriteAttributeNullableInt32sInvalidValue_290(); + break; + case 291: + ChipLogProgress(chipTool, " ***** Test Step 291 : Read attribute NULLABLE_INT32S unchanged Value\n"); + err = TestReadAttributeNullableInt32sUnchangedValue_291(); + break; + case 292: + ChipLogProgress(chipTool, " ***** Test Step 292 : Write attribute NULLABLE_INT32S null Value\n"); + err = TestWriteAttributeNullableInt32sNullValue_292(); + break; + case 293: + ChipLogProgress(chipTool, " ***** Test Step 293 : Read attribute NULLABLE_INT32S null Value\n"); + err = TestReadAttributeNullableInt32sNullValue_293(); + break; + case 294: + ChipLogProgress(chipTool, " ***** Test Step 294 : Read attribute NULLABLE_INT32S null Value & range\n"); + err = TestReadAttributeNullableInt32sNullValueRange_294(); + break; + case 295: + ChipLogProgress(chipTool, " ***** Test Step 295 : Read attribute NULLABLE_INT32S null Value & not\n"); + err = TestReadAttributeNullableInt32sNullValueNot_295(); + break; + case 296: + ChipLogProgress(chipTool, " ***** Test Step 296 : Write attribute NULLABLE_INT32S Value\n"); + err = TestWriteAttributeNullableInt32sValue_296(); + break; + case 297: + ChipLogProgress(chipTool, " ***** Test Step 297 : Read attribute NULLABLE_INT32S Value in range\n"); + err = TestReadAttributeNullableInt32sValueInRange_297(); + break; + case 298: + ChipLogProgress(chipTool, " ***** Test Step 298 : Read attribute NULLABLE_INT32S notValue OK\n"); + err = TestReadAttributeNullableInt32sNotValueOk_298(); + break; + case 299: + ChipLogProgress(chipTool, " ***** Test Step 299 : Write attribute NULLABLE_INT64S Min Value\n"); + err = TestWriteAttributeNullableInt64sMinValue_299(); + break; + case 300: + ChipLogProgress(chipTool, " ***** Test Step 300 : Read attribute NULLABLE_INT64S Min Value\n"); + err = TestReadAttributeNullableInt64sMinValue_300(); + break; + case 301: + ChipLogProgress(chipTool, " ***** Test Step 301 : Write attribute NULLABLE_INT64S Invalid Value\n"); + err = TestWriteAttributeNullableInt64sInvalidValue_301(); + break; + case 302: + ChipLogProgress(chipTool, " ***** Test Step 302 : Read attribute NULLABLE_INT64S unchanged Value\n"); + err = TestReadAttributeNullableInt64sUnchangedValue_302(); + break; + case 303: + ChipLogProgress(chipTool, " ***** Test Step 303 : Write attribute NULLABLE_INT64S null Value\n"); + err = TestWriteAttributeNullableInt64sNullValue_303(); + break; + case 304: + ChipLogProgress(chipTool, " ***** Test Step 304 : Read attribute NULLABLE_INT64S null Value\n"); + err = TestReadAttributeNullableInt64sNullValue_304(); + break; + case 305: + ChipLogProgress(chipTool, " ***** Test Step 305 : Read attribute NULLABLE_INT64S null Value & range\n"); + err = TestReadAttributeNullableInt64sNullValueRange_305(); + break; + case 306: + ChipLogProgress(chipTool, " ***** Test Step 306 : Read attribute NULLABLE_INT64S null Value & not\n"); + err = TestReadAttributeNullableInt64sNullValueNot_306(); + break; + case 307: + ChipLogProgress(chipTool, " ***** Test Step 307 : Write attribute NULLABLE_INT64S Value\n"); + err = TestWriteAttributeNullableInt64sValue_307(); + break; + case 308: + ChipLogProgress(chipTool, " ***** Test Step 308 : Read attribute NULLABLE_INT64S Value in range\n"); + err = TestReadAttributeNullableInt64sValueInRange_308(); + break; + case 309: + ChipLogProgress(chipTool, " ***** Test Step 309 : Read attribute NULLABLE_INT64S notValue OK\n"); + err = TestReadAttributeNullableInt64sNotValueOk_309(); + break; + case 310: + ChipLogProgress(chipTool, " ***** Test Step 310 : Write attribute NULLABLE_SINGLE medium Value\n"); + err = TestWriteAttributeNullableSingleMediumValue_310(); + break; + case 311: + ChipLogProgress(chipTool, " ***** Test Step 311 : Read attribute NULLABLE_SINGLE medium Value\n"); + err = TestReadAttributeNullableSingleMediumValue_311(); + break; + case 312: + ChipLogProgress(chipTool, " ***** Test Step 312 : Write attribute NULLABLE_SINGLE largest Value\n"); + err = TestWriteAttributeNullableSingleLargestValue_312(); + break; + case 313: + ChipLogProgress(chipTool, " ***** Test Step 313 : Read attribute NULLABLE_SINGLE largest Value\n"); + err = TestReadAttributeNullableSingleLargestValue_313(); + break; + case 314: + ChipLogProgress(chipTool, " ***** Test Step 314 : Write attribute NULLABLE_SINGLE smallest Value\n"); + err = TestWriteAttributeNullableSingleSmallestValue_314(); + break; + case 315: + ChipLogProgress(chipTool, " ***** Test Step 315 : Read attribute NULLABLE_SINGLE smallest Value\n"); + err = TestReadAttributeNullableSingleSmallestValue_315(); + break; + case 316: + ChipLogProgress(chipTool, " ***** Test Step 316 : Write attribute NULLABLE_SINGLE null Value\n"); + err = TestWriteAttributeNullableSingleNullValue_316(); + break; + case 317: + ChipLogProgress(chipTool, " ***** Test Step 317 : Read attribute NULLABLE_SINGLE null Value\n"); + err = TestReadAttributeNullableSingleNullValue_317(); + break; + case 318: + ChipLogProgress(chipTool, " ***** Test Step 318 : Write attribute NULLABLE_SINGLE 0 Value\n"); + err = TestWriteAttributeNullableSingle0Value_318(); + break; + case 319: + ChipLogProgress(chipTool, " ***** Test Step 319 : Read attribute NULLABLE_SINGLE 0 Value\n"); + err = TestReadAttributeNullableSingle0Value_319(); + break; + case 320: + ChipLogProgress(chipTool, " ***** Test Step 320 : Write attribute NULLABLE_DOUBLE medium Value\n"); + err = TestWriteAttributeNullableDoubleMediumValue_320(); + break; + case 321: + ChipLogProgress(chipTool, " ***** Test Step 321 : Read attribute NULLABLE_DOUBLE medium Value\n"); + err = TestReadAttributeNullableDoubleMediumValue_321(); + break; + case 322: + ChipLogProgress(chipTool, " ***** Test Step 322 : Write attribute NULLABLE_DOUBLE largest Value\n"); + err = TestWriteAttributeNullableDoubleLargestValue_322(); + break; + case 323: + ChipLogProgress(chipTool, " ***** Test Step 323 : Read attribute NULLABLE_DOUBLE largest Value\n"); + err = TestReadAttributeNullableDoubleLargestValue_323(); + break; + case 324: + ChipLogProgress(chipTool, " ***** Test Step 324 : Write attribute NULLABLE_DOUBLE smallest Value\n"); + err = TestWriteAttributeNullableDoubleSmallestValue_324(); + break; + case 325: + ChipLogProgress(chipTool, " ***** Test Step 325 : Read attribute NULLABLE_DOUBLE smallest Value\n"); + err = TestReadAttributeNullableDoubleSmallestValue_325(); + break; + case 326: + ChipLogProgress(chipTool, " ***** Test Step 326 : Write attribute NULLABLE_DOUBLE null Value\n"); + err = TestWriteAttributeNullableDoubleNullValue_326(); + break; + case 327: + ChipLogProgress(chipTool, " ***** Test Step 327 : Read attribute NULLABLE_DOUBLE null Value\n"); + err = TestReadAttributeNullableDoubleNullValue_327(); + break; + case 328: + ChipLogProgress(chipTool, " ***** Test Step 328 : Write attribute NULLABLE_DOUBLE 0 Value\n"); + err = TestWriteAttributeNullableDouble0Value_328(); + break; + case 329: + ChipLogProgress(chipTool, " ***** Test Step 329 : Read attribute NULLABLE_DOUBLE 0 Value\n"); + err = TestReadAttributeNullableDouble0Value_329(); + break; + case 330: + ChipLogProgress(chipTool, " ***** Test Step 330 : Write attribute NULLABLE_ENUM8 Min Value\n"); + err = TestWriteAttributeNullableEnum8MinValue_330(); + break; + case 331: + ChipLogProgress(chipTool, " ***** Test Step 331 : Read attribute NULLABLE_ENUM8 Min Value\n"); + err = TestReadAttributeNullableEnum8MinValue_331(); + break; + case 332: + ChipLogProgress(chipTool, " ***** Test Step 332 : Write attribute NULLABLE_ENUM8 Max Value\n"); + err = TestWriteAttributeNullableEnum8MaxValue_332(); + break; + case 333: + ChipLogProgress(chipTool, " ***** Test Step 333 : Read attribute NULLABLE_ENUM8 Max Value\n"); + err = TestReadAttributeNullableEnum8MaxValue_333(); + break; + case 334: + ChipLogProgress(chipTool, " ***** Test Step 334 : Write attribute NULLABLE_ENUM8 Invalid Value\n"); + err = TestWriteAttributeNullableEnum8InvalidValue_334(); + break; + case 335: + ChipLogProgress(chipTool, " ***** Test Step 335 : Read attribute NULLABLE_ENUM8 unchanged Value\n"); + err = TestReadAttributeNullableEnum8UnchangedValue_335(); + break; + case 336: + ChipLogProgress(chipTool, " ***** Test Step 336 : Write attribute NULLABLE_ENUM8 null Value\n"); + err = TestWriteAttributeNullableEnum8NullValue_336(); + break; + case 337: + ChipLogProgress(chipTool, " ***** Test Step 337 : Read attribute NULLABLE_ENUM8 null Value\n"); + err = TestReadAttributeNullableEnum8NullValue_337(); + break; + case 338: + ChipLogProgress(chipTool, " ***** Test Step 338 : Write attribute NULLABLE_ENUM16 Min Value\n"); + err = TestWriteAttributeNullableEnum16MinValue_338(); + break; + case 339: + ChipLogProgress(chipTool, " ***** Test Step 339 : Read attribute NULLABLE_ENUM16 Min Value\n"); + err = TestReadAttributeNullableEnum16MinValue_339(); + break; + case 340: + ChipLogProgress(chipTool, " ***** Test Step 340 : Write attribute NULLABLE_ENUM16 Max Value\n"); + err = TestWriteAttributeNullableEnum16MaxValue_340(); + break; + case 341: + ChipLogProgress(chipTool, " ***** Test Step 341 : Read attribute NULLABLE_ENUM16 Max Value\n"); + err = TestReadAttributeNullableEnum16MaxValue_341(); + break; + case 342: + ChipLogProgress(chipTool, " ***** Test Step 342 : Write attribute NULLABLE_ENUM16 Invalid Value\n"); + err = TestWriteAttributeNullableEnum16InvalidValue_342(); + break; + case 343: + ChipLogProgress(chipTool, " ***** Test Step 343 : Read attribute NULLABLE_ENUM16 unchanged Value\n"); + err = TestReadAttributeNullableEnum16UnchangedValue_343(); + break; + case 344: + ChipLogProgress(chipTool, " ***** Test Step 344 : Write attribute NULLABLE_ENUM16 null Value\n"); + err = TestWriteAttributeNullableEnum16NullValue_344(); + break; + case 345: + ChipLogProgress(chipTool, " ***** Test Step 345 : Read attribute NULLABLE_ENUM16 null Value\n"); + err = TestReadAttributeNullableEnum16NullValue_345(); + break; + case 346: + ChipLogProgress(chipTool, " ***** Test Step 346 : Write attribute NULLABLE_SIMPLE_ENUM Min Value\n"); + err = TestWriteAttributeNullableSimpleEnumMinValue_346(); + break; + case 347: + ChipLogProgress(chipTool, " ***** Test Step 347 : Read attribute NULLABLE_SIMPLE_ENUM Min Value\n"); + err = TestReadAttributeNullableSimpleEnumMinValue_347(); + break; + case 348: + ChipLogProgress(chipTool, " ***** Test Step 348 : Write attribute NULLABLE_SIMPLE_ENUM Max Value\n"); + err = TestWriteAttributeNullableSimpleEnumMaxValue_348(); + break; + case 349: + ChipLogProgress(chipTool, " ***** Test Step 349 : Read attribute NULLABLE_SIMPLE_ENUM Max Value\n"); + err = TestReadAttributeNullableSimpleEnumMaxValue_349(); + break; + case 350: + ChipLogProgress(chipTool, " ***** Test Step 350 : Write attribute NULLABLE_SIMPLE_ENUM Invalid Value\n"); + err = TestWriteAttributeNullableSimpleEnumInvalidValue_350(); + break; + case 351: + ChipLogProgress(chipTool, " ***** Test Step 351 : Read attribute NULLABLE_SIMPLE_ENUM unchanged Value\n"); + err = TestReadAttributeNullableSimpleEnumUnchangedValue_351(); + break; + case 352: + ChipLogProgress(chipTool, " ***** Test Step 352 : Write attribute NULLABLE_SIMPLE_ENUM null Value\n"); + err = TestWriteAttributeNullableSimpleEnumNullValue_352(); + break; + case 353: + ChipLogProgress(chipTool, " ***** Test Step 353 : Read attribute NULLABLE_SIMPLE_ENUM null Value\n"); + err = TestReadAttributeNullableSimpleEnumNullValue_353(); + break; + case 354: + ChipLogProgress(chipTool, " ***** Test Step 354 : Read attribute NULLABLE_SIMPLE_ENUM not 3 Value\n"); + err = TestReadAttributeNullableSimpleEnumNot3Value_354(); + break; + case 355: + ChipLogProgress(chipTool, " ***** Test Step 355 : Read attribute NULLABLE_OCTET_STRING Default Value\n"); + err = TestReadAttributeNullableOctetStringDefaultValue_355(); + break; + case 356: + ChipLogProgress(chipTool, " ***** Test Step 356 : Write attribute NULLABLE_OCTET_STRING\n"); + err = TestWriteAttributeNullableOctetString_356(); + break; + case 357: + ChipLogProgress(chipTool, " ***** Test Step 357 : Read attribute NULLABLE_OCTET_STRING\n"); + err = TestReadAttributeNullableOctetString_357(); + break; + case 358: + ChipLogProgress(chipTool, " ***** Test Step 358 : Write attribute NULLABLE_OCTET_STRING\n"); + err = TestWriteAttributeNullableOctetString_358(); + break; + case 359: + ChipLogProgress(chipTool, " ***** Test Step 359 : Read attribute NULLABLE_OCTET_STRING\n"); + err = TestReadAttributeNullableOctetString_359(); + break; + case 360: + ChipLogProgress(chipTool, " ***** Test Step 360 : Write attribute NULLABLE_OCTET_STRING\n"); + err = TestWriteAttributeNullableOctetString_360(); + break; + case 361: + ChipLogProgress(chipTool, " ***** Test Step 361 : Read attribute NULLABLE_OCTET_STRING\n"); + err = TestReadAttributeNullableOctetString_361(); + break; + case 362: + ChipLogProgress(chipTool, " ***** Test Step 362 : Read attribute NULLABLE_OCTET_STRING not TestValue\n"); + err = TestReadAttributeNullableOctetStringNotTestValue_362(); + break; + case 363: + ChipLogProgress(chipTool, " ***** Test Step 363 : Read attribute NULLABLE_CHAR_STRING Default Value\n"); + err = TestReadAttributeNullableCharStringDefaultValue_363(); + break; + case 364: + ChipLogProgress(chipTool, " ***** Test Step 364 : Write attribute NULLABLE_CHAR_STRING\n"); + err = TestWriteAttributeNullableCharString_364(); + break; + case 365: + ChipLogProgress(chipTool, " ***** Test Step 365 : Read attribute NULLABLE_CHAR_STRING\n"); + err = TestReadAttributeNullableCharString_365(); + break; + case 366: + ChipLogProgress(chipTool, " ***** Test Step 366 : Read attribute NULLABLE_CHAR_STRING\n"); + err = TestReadAttributeNullableCharString_366(); + break; + case 367: + ChipLogProgress(chipTool, " ***** Test Step 367 : Write attribute NULLABLE_CHAR_STRING - Value too long\n"); + err = TestWriteAttributeNullableCharStringValueTooLong_367(); + break; + case 368: + ChipLogProgress(chipTool, " ***** Test Step 368 : Read attribute NULLABLE_CHAR_STRING\n"); + err = TestReadAttributeNullableCharString_368(); + break; + case 369: + ChipLogProgress(chipTool, " ***** Test Step 369 : Write attribute NULLABLE_CHAR_STRING - Empty\n"); + err = TestWriteAttributeNullableCharStringEmpty_369(); + break; + case 370: + ChipLogProgress(chipTool, " ***** Test Step 370 : Read attribute NULLABLE_CHAR_STRING\n"); + err = TestReadAttributeNullableCharString_370(); + break; + case 371: + ChipLogProgress(chipTool, " ***** Test Step 371 : Read attribute NULLABLE_CHAR_STRING not ☉T☉\n"); + err = TestReadAttributeNullableCharStringNott_371(); + break; + case 372: + ChipLogProgress(chipTool, " ***** Test Step 372 : Read attribute from nonexistent endpoint.\n"); + err = TestReadAttributeFromNonexistentEndpoint_372(); + break; + case 373: + ChipLogProgress(chipTool, " ***** Test Step 373 : Read attribute from nonexistent cluster.\n"); + err = TestReadAttributeFromNonexistentCluster_373(); + break; + case 374: + ChipLogProgress(chipTool, " ***** Test Step 374 : Send a command that takes an optional parameter but do not set it.\n"); + err = TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_374(); + break; + case 375: + ChipLogProgress(chipTool, " ***** Test Step 375 : Send a command that takes an optional parameter but do not set it.\n"); + err = TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_375(); + break; + case 376: + ChipLogProgress(chipTool, " ***** Test Step 376 : Report: Subscribe to list attribute\n"); + err = TestReportSubscribeToListAttribute_376(); + break; + case 377: + ChipLogProgress(chipTool, " ***** Test Step 377 : Subscribe to list attribute\n"); + err = TestSubscribeToListAttribute_377(); + break; + case 378: + ChipLogProgress(chipTool, " ***** Test Step 378 : Write subscribed-to list attribute\n"); + err = TestWriteSubscribedToListAttribute_378(); + break; + case 379: + ChipLogProgress(chipTool, " ***** Test Step 379 : Check for list attribute report\n"); + err = TestCheckForListAttributeReport_379(); + break; + case 380: + ChipLogProgress(chipTool, " ***** Test Step 380 : Read range-restricted unsigned 8-bit integer\n"); + err = TestReadRangeRestrictedUnsigned8BitInteger_380(); + break; + case 381: + ChipLogProgress(chipTool, " ***** Test Step 381 : Write min value to a range-restricted unsigned 8-bit integer\n"); + err = TestWriteMinValueToARangeRestrictedUnsigned8BitInteger_381(); + break; + case 382: + ChipLogProgress(chipTool, " ***** Test Step 382 : Write just-below-range value to a range-restricted unsigned 8-bit integer\n"); + err = TestWriteJustBelowRangeValueToARangeRestrictedUnsigned8BitInteger_382(); + break; + case 383: + ChipLogProgress(chipTool, " ***** Test Step 383 : Write just-above-range value to a range-restricted unsigned 8-bit integer\n"); + err = TestWriteJustAboveRangeValueToARangeRestrictedUnsigned8BitInteger_383(); + break; + case 384: + ChipLogProgress(chipTool, " ***** Test Step 384 : Write max value to a range-restricted unsigned 8-bit integer\n"); + err = TestWriteMaxValueToARangeRestrictedUnsigned8BitInteger_384(); + break; + case 385: + ChipLogProgress(chipTool, " ***** Test Step 385 : Verify range-restricted unsigned 8-bit integer value has not changed\n"); + err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_385(); + break; + case 386: + ChipLogProgress(chipTool, " ***** Test Step 386 : Write min valid value to a range-restricted unsigned 8-bit integer\n"); + err = TestWriteMinValidValueToARangeRestrictedUnsigned8BitInteger_386(); + break; + case 387: + ChipLogProgress(chipTool, " ***** Test Step 387 : Verify range-restricted unsigned 8-bit integer value is at min valid\n"); + err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_387(); + break; + case 388: + ChipLogProgress(chipTool, " ***** Test Step 388 : Write max valid value to a range-restricted unsigned 8-bit integer\n"); + err = TestWriteMaxValidValueToARangeRestrictedUnsigned8BitInteger_388(); + break; + case 389: + ChipLogProgress(chipTool, " ***** Test Step 389 : Verify range-restricted unsigned 8-bit integer value is at max valid\n"); + err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_389(); + break; + case 390: + ChipLogProgress(chipTool, " ***** Test Step 390 : Write middle valid value to a range-restricted unsigned 8-bit integer\n"); + err = TestWriteMiddleValidValueToARangeRestrictedUnsigned8BitInteger_390(); + break; + case 391: + ChipLogProgress(chipTool, " ***** Test Step 391 : Verify range-restricted unsigned 8-bit integer value is at mid valid\n"); + err = TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_391(); + break; + case 392: + ChipLogProgress(chipTool, " ***** Test Step 392 : Read range-restricted unsigned 16-bit integer\n"); + err = TestReadRangeRestrictedUnsigned16BitInteger_392(); + break; + case 393: + ChipLogProgress(chipTool, " ***** Test Step 393 : Write min value to a range-restricted unsigned 16-bit integer\n"); + err = TestWriteMinValueToARangeRestrictedUnsigned16BitInteger_393(); + break; + case 394: + ChipLogProgress(chipTool, " ***** Test Step 394 : Write just-below-range value to a range-restricted unsigned 16-bit integer\n"); + err = TestWriteJustBelowRangeValueToARangeRestrictedUnsigned16BitInteger_394(); + break; + case 395: + ChipLogProgress(chipTool, " ***** Test Step 395 : Write just-above-range value to a range-restricted unsigned 16-bit integer\n"); + err = TestWriteJustAboveRangeValueToARangeRestrictedUnsigned16BitInteger_395(); + break; + case 396: + ChipLogProgress(chipTool, " ***** Test Step 396 : Write max value to a range-restricted unsigned 16-bit integer\n"); + err = TestWriteMaxValueToARangeRestrictedUnsigned16BitInteger_396(); + break; + case 397: + ChipLogProgress(chipTool, " ***** Test Step 397 : Verify range-restricted unsigned 16-bit integer value has not changed\n"); + err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_397(); + break; + case 398: + ChipLogProgress(chipTool, " ***** Test Step 398 : Write min valid value to a range-restricted unsigned 16-bit integer\n"); + err = TestWriteMinValidValueToARangeRestrictedUnsigned16BitInteger_398(); + break; + case 399: + ChipLogProgress(chipTool, " ***** Test Step 399 : Verify range-restricted unsigned 16-bit integer value is at min valid\n"); + err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_399(); + break; + case 400: + ChipLogProgress(chipTool, " ***** Test Step 400 : Write max valid value to a range-restricted unsigned 16-bit integer\n"); + err = TestWriteMaxValidValueToARangeRestrictedUnsigned16BitInteger_400(); + break; + case 401: + ChipLogProgress(chipTool, " ***** Test Step 401 : Verify range-restricted unsigned 16-bit integer value is at max valid\n"); + err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_401(); + break; + case 402: + ChipLogProgress(chipTool, " ***** Test Step 402 : Write middle valid value to a range-restricted unsigned 16-bit integer\n"); + err = TestWriteMiddleValidValueToARangeRestrictedUnsigned16BitInteger_402(); + break; + case 403: + ChipLogProgress(chipTool, " ***** Test Step 403 : Verify range-restricted unsigned 16-bit integer value is at mid valid\n"); + err = TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_403(); + break; + case 404: + ChipLogProgress(chipTool, " ***** Test Step 404 : Read range-restricted signed 8-bit integer\n"); + err = TestReadRangeRestrictedSigned8BitInteger_404(); + break; + case 405: + ChipLogProgress(chipTool, " ***** Test Step 405 : Write min value to a range-restricted signed 8-bit integer\n"); + err = TestWriteMinValueToARangeRestrictedSigned8BitInteger_405(); + break; + case 406: + ChipLogProgress(chipTool, " ***** Test Step 406 : Write just-below-range value to a range-restricted signed 8-bit integer\n"); + err = TestWriteJustBelowRangeValueToARangeRestrictedSigned8BitInteger_406(); + break; + case 407: + ChipLogProgress(chipTool, " ***** Test Step 407 : Write just-above-range value to a range-restricted signed 8-bit integer\n"); + err = TestWriteJustAboveRangeValueToARangeRestrictedSigned8BitInteger_407(); + break; + case 408: + ChipLogProgress(chipTool, " ***** Test Step 408 : Write max value to a range-restricted signed 8-bit integer\n"); + err = TestWriteMaxValueToARangeRestrictedSigned8BitInteger_408(); + break; + case 409: + ChipLogProgress(chipTool, " ***** Test Step 409 : Verify range-restricted signed 8-bit integer value has not changed\n"); + err = TestVerifyRangeRestrictedSigned8BitIntegerValueHasNotChanged_409(); + break; + case 410: + ChipLogProgress(chipTool, " ***** Test Step 410 : Write min valid value to a range-restricted signed 8-bit integer\n"); + err = TestWriteMinValidValueToARangeRestrictedSigned8BitInteger_410(); + break; + case 411: + ChipLogProgress(chipTool, " ***** Test Step 411 : Verify range-restricted signed 8-bit integer value is at min valid\n"); + err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMinValid_411(); + break; + case 412: + ChipLogProgress(chipTool, " ***** Test Step 412 : Write max valid value to a range-restricted signed 8-bit integer\n"); + err = TestWriteMaxValidValueToARangeRestrictedSigned8BitInteger_412(); + break; + case 413: + ChipLogProgress(chipTool, " ***** Test Step 413 : Verify range-restricted signed 8-bit integer value is at max valid\n"); + err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_413(); + break; + case 414: + ChipLogProgress(chipTool, " ***** Test Step 414 : Write middle valid value to a range-restricted signed 8-bit integer\n"); + err = TestWriteMiddleValidValueToARangeRestrictedSigned8BitInteger_414(); + break; + case 415: + ChipLogProgress(chipTool, " ***** Test Step 415 : Verify range-restricted signed 8-bit integer value is at mid valid\n"); + err = TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMidValid_415(); + break; + case 416: + ChipLogProgress(chipTool, " ***** Test Step 416 : Read range-restricted signed 16-bit integer\n"); + err = TestReadRangeRestrictedSigned16BitInteger_416(); + break; + case 417: + ChipLogProgress(chipTool, " ***** Test Step 417 : Write min value to a range-restricted signed 16-bit integer\n"); + err = TestWriteMinValueToARangeRestrictedSigned16BitInteger_417(); + break; + case 418: + ChipLogProgress(chipTool, " ***** Test Step 418 : Write just-below-range value to a range-restricted signed 16-bit integer\n"); + err = TestWriteJustBelowRangeValueToARangeRestrictedSigned16BitInteger_418(); + break; + case 419: + ChipLogProgress(chipTool, " ***** Test Step 419 : Write just-above-range value to a range-restricted signed 16-bit integer\n"); + err = TestWriteJustAboveRangeValueToARangeRestrictedSigned16BitInteger_419(); + break; + case 420: + ChipLogProgress(chipTool, " ***** Test Step 420 : Write max value to a range-restricted signed 16-bit integer\n"); + err = TestWriteMaxValueToARangeRestrictedSigned16BitInteger_420(); + break; + case 421: + ChipLogProgress(chipTool, " ***** Test Step 421 : Verify range-restricted signed 16-bit integer value has not changed\n"); + err = TestVerifyRangeRestrictedSigned16BitIntegerValueHasNotChanged_421(); + break; + case 422: + ChipLogProgress(chipTool, " ***** Test Step 422 : Write min valid value to a range-restricted signed 16-bit integer\n"); + err = TestWriteMinValidValueToARangeRestrictedSigned16BitInteger_422(); + break; + case 423: + ChipLogProgress(chipTool, " ***** Test Step 423 : Verify range-restricted signed 16-bit integer value is at min valid\n"); + err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMinValid_423(); + break; + case 424: + ChipLogProgress(chipTool, " ***** Test Step 424 : Write max valid value to a range-restricted signed 16-bit integer\n"); + err = TestWriteMaxValidValueToARangeRestrictedSigned16BitInteger_424(); + break; + case 425: + ChipLogProgress(chipTool, " ***** Test Step 425 : Verify range-restricted signed 16-bit integer value is at max valid\n"); + err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_425(); + break; + case 426: + ChipLogProgress(chipTool, " ***** Test Step 426 : Write middle valid value to a range-restricted signed 16-bit integer\n"); + err = TestWriteMiddleValidValueToARangeRestrictedSigned16BitInteger_426(); + break; + case 427: + ChipLogProgress(chipTool, " ***** Test Step 427 : Verify range-restricted signed 16-bit integer value is at mid valid\n"); + err = TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMidValid_427(); + break; + case 428: + ChipLogProgress(chipTool, " ***** Test Step 428 : Read nullable range-restricted unsigned 8-bit integer\n"); + err = TestReadNullableRangeRestrictedUnsigned8BitInteger_428(); + break; + case 429: + ChipLogProgress(chipTool, " ***** Test Step 429 : Write min value to a nullable range-restricted unsigned 8-bit integer\n"); + err = TestWriteMinValueToANullableRangeRestrictedUnsigned8BitInteger_429(); + break; + case 430: + ChipLogProgress(chipTool, " ***** Test Step 430 : Write just-below-range value to a nullable range-restricted unsigned 8-bit integer\n"); + err = TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned8BitInteger_430(); + break; + case 431: + ChipLogProgress(chipTool, " ***** Test Step 431 : Write just-above-range value to a nullable range-restricted unsigned 8-bit integer\n"); + err = TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned8BitInteger_431(); + break; + case 432: + ChipLogProgress(chipTool, " ***** Test Step 432 : Write max value to a nullable range-restricted unsigned 8-bit integer\n"); + err = TestWriteMaxValueToANullableRangeRestrictedUnsigned8BitInteger_432(); + break; + case 433: + ChipLogProgress(chipTool, " ***** Test Step 433 : Verify nullable range-restricted unsigned 8-bit integer value has not changed\n"); + err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_433(); + break; + case 434: + ChipLogProgress(chipTool, " ***** Test Step 434 : Write min valid value to a nullable range-restricted unsigned 8-bit integer\n"); + err = TestWriteMinValidValueToANullableRangeRestrictedUnsigned8BitInteger_434(); + break; + case 435: + ChipLogProgress(chipTool, " ***** Test Step 435 : Verify nullable range-restricted unsigned 8-bit integer value is at min valid\n"); + err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_435(); + break; + case 436: + ChipLogProgress(chipTool, " ***** Test Step 436 : Write max valid value to a nullable range-restricted unsigned 8-bit integer\n"); + err = TestWriteMaxValidValueToANullableRangeRestrictedUnsigned8BitInteger_436(); + break; + case 437: + ChipLogProgress(chipTool, " ***** Test Step 437 : Verify nullable range-restricted unsigned 8-bit integer value is at max valid\n"); + err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_437(); + break; + case 438: + ChipLogProgress(chipTool, " ***** Test Step 438 : Write middle valid value to a nullable range-restricted unsigned 8-bit integer\n"); + err = TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned8BitInteger_438(); + break; + case 439: + ChipLogProgress(chipTool, " ***** Test Step 439 : Verify nullable range-restricted unsigned 8-bit integer value is at mid valid\n"); + err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_439(); + break; + case 440: + ChipLogProgress(chipTool, " ***** Test Step 440 : Write null value to a nullable range-restricted unsigned 8-bit integer\n"); + err = TestWriteNullValueToANullableRangeRestrictedUnsigned8BitInteger_440(); + break; + case 441: + ChipLogProgress(chipTool, " ***** Test Step 441 : Verify nullable range-restricted unsigned 8-bit integer value is null\n"); + err = TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsNull_441(); + break; + case 442: + ChipLogProgress(chipTool, " ***** Test Step 442 : Read nullable range-restricted unsigned 16-bit integer\n"); + err = TestReadNullableRangeRestrictedUnsigned16BitInteger_442(); + break; + case 443: + ChipLogProgress(chipTool, " ***** Test Step 443 : Write min value to a nullable range-restricted unsigned 16-bit integer\n"); + err = TestWriteMinValueToANullableRangeRestrictedUnsigned16BitInteger_443(); + break; + case 444: + ChipLogProgress(chipTool, " ***** Test Step 444 : Write just-below-range value to a nullable range-restricted unsigned 16-bit integer\n"); + err = TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned16BitInteger_444(); + break; + case 445: + ChipLogProgress(chipTool, " ***** Test Step 445 : Write just-above-range value to a nullable range-restricted unsigned 16-bit integer\n"); + err = TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned16BitInteger_445(); + break; + case 446: + ChipLogProgress(chipTool, " ***** Test Step 446 : Write max value to a nullable range-restricted unsigned 16-bit integer\n"); + err = TestWriteMaxValueToANullableRangeRestrictedUnsigned16BitInteger_446(); + break; + case 447: + ChipLogProgress(chipTool, " ***** Test Step 447 : Verify nullable range-restricted unsigned 16-bit integer value has not changed\n"); + err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_447(); + break; + case 448: + ChipLogProgress(chipTool, " ***** Test Step 448 : Write min valid value to a nullable range-restricted unsigned 16-bit integer\n"); + err = TestWriteMinValidValueToANullableRangeRestrictedUnsigned16BitInteger_448(); + break; + case 449: + ChipLogProgress(chipTool, " ***** Test Step 449 : Verify nullable range-restricted unsigned 16-bit integer value is at min valid\n"); + err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_449(); + break; + case 450: + ChipLogProgress(chipTool, " ***** Test Step 450 : Write max valid value to a nullable range-restricted unsigned 16-bit integer\n"); + err = TestWriteMaxValidValueToANullableRangeRestrictedUnsigned16BitInteger_450(); + break; + case 451: + ChipLogProgress(chipTool, " ***** Test Step 451 : Verify nullable range-restricted unsigned 16-bit integer value is at max valid\n"); + err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_451(); + break; + case 452: + ChipLogProgress(chipTool, " ***** Test Step 452 : Write middle valid value to a nullable range-restricted unsigned 16-bit integer\n"); + err = TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned16BitInteger_452(); + break; + case 453: + ChipLogProgress(chipTool, " ***** Test Step 453 : Verify nullable range-restricted unsigned 16-bit integer value is at mid valid\n"); + err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_453(); + break; + case 454: + ChipLogProgress(chipTool, " ***** Test Step 454 : Write null value to a nullable range-restricted unsigned 16-bit integer\n"); + err = TestWriteNullValueToANullableRangeRestrictedUnsigned16BitInteger_454(); + break; + case 455: + ChipLogProgress(chipTool, " ***** Test Step 455 : Verify nullable range-restricted unsigned 16-bit integer value is null\n"); + err = TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsNull_455(); + break; + case 456: + ChipLogProgress(chipTool, " ***** Test Step 456 : Read nullable range-restricted signed 8-bit integer\n"); + err = TestReadNullableRangeRestrictedSigned8BitInteger_456(); + break; + case 457: + ChipLogProgress(chipTool, " ***** Test Step 457 : Write min value to a nullable range-restricted signed 8-bit integer\n"); + err = TestWriteMinValueToANullableRangeRestrictedSigned8BitInteger_457(); + break; + case 458: + ChipLogProgress(chipTool, " ***** Test Step 458 : Write just-below-range value to a nullable range-restricted signed 8-bit integer\n"); + err = TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned8BitInteger_458(); + break; + case 459: + ChipLogProgress(chipTool, " ***** Test Step 459 : Write just-above-range value to a nullable range-restricted signed 8-bit integer\n"); + err = TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned8BitInteger_459(); + break; + case 460: + ChipLogProgress(chipTool, " ***** Test Step 460 : Write max value to a nullable range-restricted signed 8-bit integer\n"); + err = TestWriteMaxValueToANullableRangeRestrictedSigned8BitInteger_460(); + break; + case 461: + ChipLogProgress(chipTool, " ***** Test Step 461 : Verify nullable range-restricted signed 8-bit integer value has not changed\n"); + err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueHasNotChanged_461(); + break; + case 462: + ChipLogProgress(chipTool, " ***** Test Step 462 : Write min valid value to a nullable range-restricted signed 8-bit integer\n"); + err = TestWriteMinValidValueToANullableRangeRestrictedSigned8BitInteger_462(); + break; + case 463: + ChipLogProgress(chipTool, " ***** Test Step 463 : Verify nullable range-restricted signed 8-bit integer value is at min valid\n"); + err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMinValid_463(); + break; + case 464: + ChipLogProgress(chipTool, " ***** Test Step 464 : Write max valid value to a nullable range-restricted signed 8-bit integer\n"); + err = TestWriteMaxValidValueToANullableRangeRestrictedSigned8BitInteger_464(); + break; + case 465: + ChipLogProgress(chipTool, " ***** Test Step 465 : Verify nullable range-restricted signed 8-bit integer value is at max valid\n"); + err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_465(); + break; + case 466: + ChipLogProgress(chipTool, " ***** Test Step 466 : Write middle valid value to a nullable range-restricted signed 8-bit integer\n"); + err = TestWriteMiddleValidValueToANullableRangeRestrictedSigned8BitInteger_466(); + break; + case 467: + ChipLogProgress(chipTool, " ***** Test Step 467 : Verify nullable range-restricted signed 8-bit integer value is at mid valid\n"); + err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMidValid_467(); + break; + case 468: + ChipLogProgress(chipTool, " ***** Test Step 468 : Write null value to a nullable range-restricted signed 8-bit integer\n"); + err = TestWriteNullValueToANullableRangeRestrictedSigned8BitInteger_468(); + break; + case 469: + ChipLogProgress(chipTool, " ***** Test Step 469 : Verify nullable range-restricted signed 8-bit integer value is at null\n"); + err = TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtNull_469(); + break; + case 470: + ChipLogProgress(chipTool, " ***** Test Step 470 : Read nullable range-restricted signed 16-bit integer\n"); + err = TestReadNullableRangeRestrictedSigned16BitInteger_470(); + break; + case 471: + ChipLogProgress(chipTool, " ***** Test Step 471 : Write min value to a nullable range-restricted signed 16-bit integer\n"); + err = TestWriteMinValueToANullableRangeRestrictedSigned16BitInteger_471(); + break; + case 472: + ChipLogProgress(chipTool, " ***** Test Step 472 : Write just-below-range value to a nullable range-restricted signed 16-bit integer\n"); + err = TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned16BitInteger_472(); + break; + case 473: + ChipLogProgress(chipTool, " ***** Test Step 473 : Write just-above-range value to a nullable range-restricted signed 16-bit integer\n"); + err = TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned16BitInteger_473(); + break; + case 474: + ChipLogProgress(chipTool, " ***** Test Step 474 : Write max value to a nullable range-restricted signed 16-bit integer\n"); + err = TestWriteMaxValueToANullableRangeRestrictedSigned16BitInteger_474(); + break; + case 475: + ChipLogProgress(chipTool, " ***** Test Step 475 : Verify nullable range-restricted signed 16-bit integer value has not changed\n"); + err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueHasNotChanged_475(); + break; + case 476: + ChipLogProgress(chipTool, " ***** Test Step 476 : Write min valid value to a nullable range-restricted signed 16-bit integer\n"); + err = TestWriteMinValidValueToANullableRangeRestrictedSigned16BitInteger_476(); + break; + case 477: + ChipLogProgress(chipTool, " ***** Test Step 477 : Verify nullable range-restricted signed 16-bit integer value is at min valid\n"); + err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMinValid_477(); + break; + case 478: + ChipLogProgress(chipTool, " ***** Test Step 478 : Write max valid value to a nullable range-restricted signed 16-bit integer\n"); + err = TestWriteMaxValidValueToANullableRangeRestrictedSigned16BitInteger_478(); + break; + case 479: + ChipLogProgress(chipTool, " ***** Test Step 479 : Verify nullable range-restricted signed 16-bit integer value is at max valid\n"); + err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_479(); + break; + case 480: + ChipLogProgress(chipTool, " ***** Test Step 480 : Write middle valid value to a nullable range-restricted signed 16-bit integer\n"); + err = TestWriteMiddleValidValueToANullableRangeRestrictedSigned16BitInteger_480(); + break; + case 481: + ChipLogProgress(chipTool, " ***** Test Step 481 : Verify nullable range-restricted signed 16-bit integer value is at mid valid\n"); + err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMidValid_481(); + break; + case 482: + ChipLogProgress(chipTool, " ***** Test Step 482 : Write null value to a nullable range-restricted signed 16-bit integer\n"); + err = TestWriteNullValueToANullableRangeRestrictedSigned16BitInteger_482(); + break; + case 483: + ChipLogProgress(chipTool, " ***** Test Step 483 : Verify nullable range-restricted signed 16-bit integer value is null\n"); + err = TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsNull_483(); + break; + case 484: + ChipLogProgress(chipTool, " ***** Test Step 484 : Write attribute that returns general status on write\n"); + err = TestWriteAttributeThatReturnsGeneralStatusOnWrite_484(); + break; + case 485: + ChipLogProgress(chipTool, " ***** Test Step 485 : Write attribute that returns cluster-specific status on write\n"); + err = TestWriteAttributeThatReturnsClusterSpecificStatusOnWrite_485(); + break; + case 486: + ChipLogProgress(chipTool, " ***** Test Step 486 : Read attribute that returns general status on read\n"); + err = TestReadAttributeThatReturnsGeneralStatusOnRead_486(); + break; + case 487: + ChipLogProgress(chipTool, " ***** Test Step 487 : read attribute that returns cluster-specific status on read\n"); + err = TestReadAttributeThatReturnsClusterSpecificStatusOnRead_487(); + break; + case 488: + ChipLogProgress(chipTool, " ***** Test Step 488 : read AcceptedCommandList attribute\n"); + err = TestReadAcceptedCommandListAttribute_488(); + break; + case 489: + ChipLogProgress(chipTool, " ***** Test Step 489 : read GeneratedCommandList attribute\n"); + err = TestReadGeneratedCommandListAttribute_489(); + break; + case 490: + ChipLogProgress(chipTool, " ***** Test Step 490 : Write struct-typed attribute\n"); + err = TestWriteStructTypedAttribute_490(); + break; + case 491: + ChipLogProgress(chipTool, " ***** Test Step 491 : Read struct-typed attribute\n"); + err = TestReadStructTypedAttribute_491(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 49: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 50: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 51: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 52: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 53: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 54: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 55: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 56: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 57: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 58: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 59: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 60: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 61: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 62: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 63: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 64: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 65: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 66: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 67: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 68: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 69: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 70: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 71: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 72: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 73: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 74: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 75: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 76: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 77: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 78: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 79: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 80: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 81: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 82: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 83: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 84: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 85: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 86: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 87: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 88: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 89: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 90: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 91: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 92: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 93: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 94: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 95: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 96: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 97: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 98: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 99: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 100: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 101: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 102: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 103: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 104: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 105: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 106: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 107: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 108: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 109: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 110: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 111: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 112: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 113: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 114: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 115: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 116: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 117: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 118: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 119: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 120: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 121: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 122: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 123: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 124: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 125: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 126: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 127: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 128: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 129: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 130: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 131: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 132: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 133: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 134: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 135: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 136: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 137: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 138: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 139: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 140: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 141: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 142: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 143: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 144: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 145: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 146: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 147: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); + break; + case 148: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); + break; + case 149: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); + break; + case 150: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); + break; + case 151: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 152: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 153: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 154: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 155: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 156: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 157: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 158: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 159: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 160: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 161: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 162: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 163: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 164: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 165: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 166: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 167: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 168: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 169: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 170: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 171: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 172: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 173: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 174: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 175: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 176: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 177: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 178: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 179: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 180: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 181: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 182: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 183: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 184: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 185: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 186: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 187: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 188: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 189: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 190: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 191: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 192: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 193: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 194: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 195: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 196: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 197: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 198: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 199: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 200: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 201: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 202: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 203: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 204: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 205: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 206: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 207: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 208: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 209: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 210: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 211: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 212: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 213: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 214: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 215: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 216: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 217: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 218: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 219: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 220: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 221: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 222: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 223: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 224: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 225: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 226: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 227: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 228: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 229: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 230: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 231: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 232: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 233: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 234: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 235: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 236: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 237: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 238: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 239: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 240: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 241: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 242: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 243: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 244: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 245: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 246: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 247: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 248: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 249: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 250: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 251: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 252: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 253: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 254: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 255: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 256: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 257: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 258: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 259: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 260: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 261: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 262: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 263: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 264: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 265: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 266: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 267: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 268: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 269: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 270: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 271: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 272: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 273: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 274: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 275: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 276: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 277: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 278: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 279: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 280: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 281: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 282: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 283: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 284: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 285: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 286: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 287: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 288: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 289: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 290: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 291: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 292: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 293: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 294: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 295: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 296: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 297: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 298: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 299: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 300: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 301: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 302: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 303: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 304: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 305: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 306: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 307: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 308: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 309: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 310: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 311: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 312: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 313: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 314: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 315: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 316: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 317: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 318: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 319: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 320: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 321: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 322: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 323: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 324: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 325: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 326: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 327: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 328: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 329: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 330: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 331: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 332: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 333: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 334: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 335: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 336: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 337: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 338: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 339: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 340: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 341: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 342: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 343: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 344: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 345: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 346: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 347: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 348: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 349: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 350: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 351: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 352: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 353: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 354: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 355: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 356: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 357: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 358: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 359: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 360: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 361: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 362: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 363: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 364: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 365: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 366: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 367: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 368: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 369: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 370: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 371: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 372: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); + break; + case 373: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); + break; + case 374: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 375: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 376: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 377: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 378: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 379: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 380: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 381: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 382: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 383: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 384: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 385: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 386: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 387: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 388: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 389: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 390: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 391: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 392: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 393: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 394: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 395: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 396: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 397: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 398: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 399: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 400: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 401: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 402: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 403: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 404: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 405: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 406: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 407: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 408: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 409: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 410: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 411: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 412: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 413: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 414: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 415: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 416: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 417: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 418: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 419: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 420: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 421: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 422: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 423: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 424: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 425: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 426: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 427: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 428: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 429: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 430: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 431: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 432: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 433: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 434: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 435: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 436: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 437: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 438: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 439: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 440: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 441: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 442: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 443: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 444: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 445: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 446: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 447: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 448: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 449: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 450: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 451: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 452: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 453: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 454: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 455: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 456: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 457: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 458: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 459: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 460: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 461: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 462: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 463: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 464: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 465: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 466: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 467: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 468: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 469: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 470: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 471: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 472: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 473: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 474: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 475: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 476: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 477: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 478: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 479: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 480: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 481: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 482: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 483: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 484: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); + break; + case 485: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 486: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); + break; + case 487: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 488: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 489: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 490: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 491: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 492; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestSendTestCommand_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster testWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command: Error: %@", err); + } else { + NSLog(@"Send Test Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestNotHandledCommand_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster testNotHandledWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Not Handled Command: Error: %@", err); + } else { + NSLog(@"Send Test Not Handled Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestSpecificCommand_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster testSpecificWithCompletion: + ^(MTRUnitTestingClusterTestSpecificResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Specific Command: Error: %@", err); + } else { + NSLog(@"Send Test Specific Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.returnValue; + VerifyOrReturn(CheckValue("returnValue", actualValue, 7U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestAddArgumentsCommand_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; + params.arg1 = + [NSNumber numberWithUnsignedChar:3U]; + params.arg2 = + [NSNumber numberWithUnsignedChar:17U]; + [cluster testAddArgumentsWithParams:params completion: + ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Add Arguments Command: Error: %@", err); + } else { + NSLog(@"Send Test Add Arguments Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.returnValue; + VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendFailingTestAddArgumentsCommand_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; + params.arg1 = + [NSNumber numberWithUnsignedChar:250U]; + params.arg2 = + [NSNumber numberWithUnsignedChar:6U]; + [cluster testAddArgumentsWithParams:params completion: + ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send failing Test Add Arguments Command: Error: %@", err); + } else { + NSLog(@"Send failing Test Add Arguments Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBooleanDefaultValue_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BOOLEAN Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BOOLEAN Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("boolean", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBooleanTrue_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id booleanArgument; + booleanArgument = + [NSNumber numberWithBool:1]; + [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BOOLEAN True: Error: %@", err); + } else { + NSLog(@"Write attribute BOOLEAN True: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBooleanTrue_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BOOLEAN True: Error: %@", err); + } else { + NSLog(@"Read attribute BOOLEAN True: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("boolean", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBooleanFalse_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id booleanArgument; + booleanArgument = + [NSNumber numberWithBool:0]; + [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BOOLEAN False: Error: %@", err); + } else { + NSLog(@"Write attribute BOOLEAN False: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBooleanFalse_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BOOLEAN False: Error: %@", err); + } else { + NSLog(@"Read attribute BOOLEAN False: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("boolean", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap8DefaultValue_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP8 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap8MaxValue_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap8Argument; + bitmap8Argument = + [NSNumber numberWithUnsignedChar:255U]; + [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP8 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP8 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap8MaxValue_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP8 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP8 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, 255U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap8MinValue_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap8Argument; + bitmap8Argument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP8 Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP8 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap8MinValue_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP8 Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP8 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap16DefaultValue_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP16 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap16MaxValue_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap16Argument; + bitmap16Argument = + [NSNumber numberWithUnsignedShort:65535U]; + [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP16 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP16 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap16MaxValue_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP16 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP16 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap16", actualValue, 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap16MinValue_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap16Argument; + bitmap16Argument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP16 Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP16 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap16MinValue_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP16 Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP16 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap32DefaultValue_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap32MaxValue_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap32Argument; + bitmap32Argument = + [NSNumber numberWithUnsignedInt:4294967295UL]; + [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP32 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP32 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap32MaxValue_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap32", actualValue, 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap32MinValue_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap32Argument; + bitmap32Argument = + [NSNumber numberWithUnsignedInt:0UL]; + [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP32 Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP32 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap32MinValue_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap64DefaultValue_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP64 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap64MaxValue_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap64Argument; + bitmap64Argument = + [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; + [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP64 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP64 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap64MaxValue_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP64 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP64 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap64", actualValue, 18446744073709551615ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap64MinValue_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap64Argument; + bitmap64Argument = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP64 Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP64 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap64MinValue_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP64 Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP64 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt8uDefaultValue_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt8uMaxValue_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int8uArgument; + int8uArgument = + [NSNumber numberWithUnsignedChar:255U]; + [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT8U Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT8U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt8uMaxValue_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8U Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int8u", actualValue, 255U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt8uMinValue_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int8uArgument; + int8uArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT8U Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT8U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt8uMinValue_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8U Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt16uDefaultValue_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt16uMaxValue_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int16uArgument; + int16uArgument = + [NSNumber numberWithUnsignedShort:65535U]; + [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT16U Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT16U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt16uMaxValue_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16U Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int16u", actualValue, 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt16uMinValue_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int16uArgument; + int16uArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT16U Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT16U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt16uMinValue_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16U Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32uDefaultValue_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt32uMaxValue_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int32uArgument; + int32uArgument = + [NSNumber numberWithUnsignedInt:4294967295UL]; + [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT32U Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT32U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32uMaxValue_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32U Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int32u", actualValue, 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt32uMinValue_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int32uArgument; + int32uArgument = + [NSNumber numberWithUnsignedInt:0UL]; + [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT32U Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT32U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32uMinValue_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32U Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt64uDefaultValue_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt64uMaxValue_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int64uArgument; + int64uArgument = + [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; + [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT64U Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT64U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt64uMaxValue_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64U Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int64u", actualValue, 18446744073709551615ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt64uMinValue_49() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int64uArgument; + int64uArgument = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT64U Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT64U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt64uMinValue_50() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64U Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt8sDefaultValue_51() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int8s", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt8sMaxValue_52() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int8sArgument; + int8sArgument = + [NSNumber numberWithChar:127]; + [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT8S Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT8S Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt8sMaxValue_53() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8S Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8S Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int8s", actualValue, 127)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt8sMinValue_54() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int8sArgument; + int8sArgument = + [NSNumber numberWithChar:-128]; + [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT8S Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT8S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt8sMinValue_55() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8S Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int8s", actualValue, -128)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt8sDefaultValue_56() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int8sArgument; + int8sArgument = + [NSNumber numberWithChar:0]; + [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT8S Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT8S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt8sDefaultValue_57() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int8s", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt16sDefaultValue_58() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int16s", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt16sMaxValue_59() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int16sArgument; + int16sArgument = + [NSNumber numberWithShort:32767]; + [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT16S Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT16S Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt16sMaxValue_60() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16S Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16S Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int16s", actualValue, 32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt16sMinValue_61() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int16sArgument; + int16sArgument = + [NSNumber numberWithShort:-32768]; + [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT16S Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT16S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt16sMinValue_62() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16S Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int16s", actualValue, -32768)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt16sDefaultValue_63() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int16sArgument; + int16sArgument = + [NSNumber numberWithShort:0]; + [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT16S Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT16S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt16sDefaultValue_64() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int16s", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32sDefaultValue_65() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt32sMaxValue_66() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int32sArgument; + int32sArgument = + [NSNumber numberWithInt:2147483647L]; + [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT32S Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT32S Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32sMaxValue_67() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32S Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32S Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int32s", actualValue, 2147483647L)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt32sMinValue_68() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int32sArgument; + int32sArgument = + [NSNumber numberWithInt:-2147483648L]; + [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT32S Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT32S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32sMinValue_69() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32S Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int32s", actualValue, -2147483648L)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt32sDefaultValue_70() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int32sArgument; + int32sArgument = + [NSNumber numberWithInt:0L]; + [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT32S Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT32S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32sDefaultValue_71() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt64sDefaultValue_72() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt64sMaxValue_73() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int64sArgument; + int64sArgument = + [NSNumber numberWithLongLong:9223372036854775807LL]; + [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT64S Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT64S Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt64sMaxValue_74() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64S Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64S Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int64s", actualValue, 9223372036854775807LL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt64sMinValue_75() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int64sArgument; + int64sArgument = + [NSNumber numberWithLongLong:-9223372036854775807LL]; + [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT64S Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT64S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt64sMinValue_76() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64S Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int64s", actualValue, -9223372036854775807LL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt64sDefaultValue_77() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int64sArgument; + int64sArgument = + [NSNumber numberWithLongLong:0LL]; + [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT64S Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT64S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt64sDefaultValue_78() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeSingleDefaultValue_79() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute SINGLE Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute SINGLE Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("float_single", actualValue, 0.0f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeSingleMediumValue_80() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id floatSingleArgument; + floatSingleArgument = + [NSNumber numberWithFloat:0.1f]; + [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute SINGLE medium Value: Error: %@", err); + } else { + NSLog(@"Write attribute SINGLE medium Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeSingleMediumValue_81() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute SINGLE medium Value: Error: %@", err); + } else { + NSLog(@"Read attribute SINGLE medium Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("float_single", actualValue, 0.1f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeSingleLargeValue_82() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id floatSingleArgument; + floatSingleArgument = + [NSNumber numberWithFloat:17000000000.0f]; + [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute SINGLE large Value: Error: %@", err); + } else { + NSLog(@"Write attribute SINGLE large Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeSingleLargeValue_83() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute SINGLE large Value: Error: %@", err); + } else { + NSLog(@"Read attribute SINGLE large Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("float_single", actualValue, 17000000000.0f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeSingleSmallValue_84() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id floatSingleArgument; + floatSingleArgument = + [NSNumber numberWithFloat:1.7e-10f]; + [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute SINGLE small Value: Error: %@", err); + } else { + NSLog(@"Write attribute SINGLE small Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeSingleSmallValue_85() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute SINGLE small Value: Error: %@", err); + } else { + NSLog(@"Read attribute SINGLE small Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("float_single", actualValue, 1.7e-10f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeSingleDefaultValue_86() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id floatSingleArgument; + floatSingleArgument = + [NSNumber numberWithFloat:0.0f]; + [cluster writeAttributeFloatSingleWithValue:floatSingleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute SINGLE Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute SINGLE Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeSingleDefaultValue_87() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute SINGLE Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute SINGLE Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("float_single", actualValue, 0.0f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeDoubleDefaultValue_88() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute DOUBLE Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute DOUBLE Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("float_double", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeDoubleMediumValue_89() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id floatDoubleArgument; + floatDoubleArgument = + [NSNumber numberWithDouble:0.1234567890123]; + [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute DOUBLE medium Value: Error: %@", err); + } else { + NSLog(@"Write attribute DOUBLE medium Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeDoubleMediumValue_90() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute DOUBLE medium Value: Error: %@", err); + } else { + NSLog(@"Read attribute DOUBLE medium Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("float_double", actualValue, 0.1234567890123)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeDoubleLargeValue_91() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id floatDoubleArgument; + floatDoubleArgument = + [NSNumber numberWithDouble:1.7e+200]; + [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute DOUBLE large Value: Error: %@", err); + } else { + NSLog(@"Write attribute DOUBLE large Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeDoubleLargeValue_92() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute DOUBLE large Value: Error: %@", err); + } else { + NSLog(@"Read attribute DOUBLE large Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("float_double", actualValue, 1.7e+200)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeDoubleSmallValue_93() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id floatDoubleArgument; + floatDoubleArgument = + [NSNumber numberWithDouble:1.7e-200]; + [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute DOUBLE small Value: Error: %@", err); + } else { + NSLog(@"Write attribute DOUBLE small Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeDoubleSmallValue_94() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute DOUBLE small Value: Error: %@", err); + } else { + NSLog(@"Read attribute DOUBLE small Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("float_double", actualValue, 1.7e-200)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeDoubleDefaultValue_95() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id floatDoubleArgument; + floatDoubleArgument = + [NSNumber numberWithDouble:0]; + [cluster writeAttributeFloatDoubleWithValue:floatDoubleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute DOUBLE Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute DOUBLE Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeDoubleDefaultValue_96() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute DOUBLE Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute DOUBLE Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("float_double", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEnum8DefaultValue_97() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM8 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEnum8MaxValue_98() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id enum8Argument; + enum8Argument = + [NSNumber numberWithUnsignedChar:255U]; + [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute ENUM8 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute ENUM8 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEnum8MaxValue_99() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM8 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM8 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("enum8", actualValue, 255U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEnum8MinValue_100() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id enum8Argument; + enum8Argument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute ENUM8 Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute ENUM8 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEnum8MinValue_101() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM8 Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM8 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEnum16DefaultValue_102() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM16 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEnum16MaxValue_103() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id enum16Argument; + enum16Argument = + [NSNumber numberWithUnsignedShort:65535U]; + [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute ENUM16 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute ENUM16 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEnum16MaxValue_104() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM16 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM16 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("enum16", actualValue, 65535U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEnum16MinValue_105() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id enum16Argument; + enum16Argument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute ENUM16 Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute ENUM16 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEnum16MinValue_106() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM16 Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM16 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeOctetStringDefaultValue_107() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute OCTET_STRING Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute OCTET_STRING Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeOctetStringWithEmbeddedNull_108() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id octetStringArgument; + octetStringArgument = + [[NSData alloc] initWithBytes:"Tes\000ti\000ng" length:9]; + [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute OCTET_STRING with embedded null: Error: %@", err); + } else { + NSLog(@"Write attribute OCTET_STRING with embedded null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeOctetStringWithEmbeddedNull_109() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute OCTET_STRING with embedded null: Error: %@", err); + } else { + NSLog(@"Read attribute OCTET_STRING with embedded null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"Tes\000ti\000ng" length:9])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeOctetStringWithHexFormat_110() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id octetStringArgument; + octetStringArgument = + [[NSData alloc] initWithBytes:"\x00\x01\x02\x03\x04\x05" length:6]; + [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute OCTET_STRING with hex: format: Error: %@", err); + } else { + NSLog(@"Write attribute OCTET_STRING with hex: format: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeOctetStringWithHexFormat_111() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute OCTET_STRING with hex: format: Error: %@", err); + } else { + NSLog(@"Read attribute OCTET_STRING with hex: format: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"\x00\x01\x02\x03\x04\x05" length:6])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeOctetStringWithWeirdChars_112() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id octetStringArgument; + octetStringArgument = + [[NSData alloc] initWithBytes:"\015\012\377\042\240" length:5]; + [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute OCTET_STRING with weird chars: Error: %@", err); + } else { + NSLog(@"Write attribute OCTET_STRING with weird chars: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeOctetStringWithWeirdChars_113() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute OCTET_STRING with weird chars: Error: %@", err); + } else { + NSLog(@"Read attribute OCTET_STRING with weird chars: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"\x0d\x0a\xff\x22\xa0" length:5])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeOctetString_114() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id octetStringArgument; + octetStringArgument = + [[NSData alloc] initWithBytes:"TestValue" length:9]; + [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeOctetString_115() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeOctetString_116() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id octetStringArgument; + octetStringArgument = + [[NSData alloc] initWithBytes:"TestValueLongerThan10" length:21]; + [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeOctetString_117() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeOctetString_118() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id octetStringArgument; + octetStringArgument = + [[NSData alloc] initWithBytes:"" length:0]; + [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeLongOctetStringDefaultValue_119() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLongOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute LONG_OCTET_STRING Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute LONG_OCTET_STRING Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("long_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeLongOctetString_120() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id longOctetStringArgument; + longOctetStringArgument = + [[NSData alloc] initWithBytes:"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" length:300]; + [cluster writeAttributeLongOctetStringWithValue:longOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute LONG_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute LONG_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeLongOctetString_121() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLongOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute LONG_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute LONG_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("long_octet_string", actualValue, [[NSData alloc] initWithBytes:"111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111" length:300])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeLongOctetString_122() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id longOctetStringArgument; + longOctetStringArgument = + [[NSData alloc] initWithBytes:"" length:0]; + [cluster writeAttributeLongOctetStringWithValue:longOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute LONG_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute LONG_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringDefaultValue_123() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharString_124() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"☉T☉"; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharString_125() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"☉T☉")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValueTooLong_126() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"☉TestValueLongerThan10☉"; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING - Value too long: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING - Value too long: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharString_127() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"☉T☉")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringEmpty_128() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @""; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING - Empty: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING - Empty: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeLongCharStringDefaultValue_129() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLongCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute LONG_CHAR_STRING Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute LONG_CHAR_STRING Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("long_char_string", actualValue, @"")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeLongCharString_130() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id longCharStringArgument; + longCharStringArgument = @"☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉"; + [cluster writeAttributeLongCharStringWithValue:longCharStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute LONG_CHAR_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute LONG_CHAR_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeLongCharString_131() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLongCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute LONG_CHAR_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute LONG_CHAR_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("long_char_string", actualValue, @"☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉☉")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeLongCharString_132() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id longCharStringArgument; + longCharStringArgument = @""; + [cluster writeAttributeLongCharStringWithValue:longCharStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute LONG_CHAR_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute LONG_CHAR_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeListLongOctetStringForChunkedRead_133() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeListLongOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Error: %@", err); + } else { + NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("list_long_octet_string", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); + VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); + VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); + VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeListLongOctetStringForChunkedWrite_134() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id listLongOctetStringArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; + temp_0[1] = + [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; + temp_0[2] = + [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; + temp_0[3] = + [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; + temp_0[4] = + [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; + listLongOctetStringArgument = temp_0; + } + [cluster writeAttributeListLongOctetStringWithValue:listLongOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Error: %@", err); + } else { + NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeListLongOctetStringForChunkedRead_135() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeListLongOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Error: %@", err); + } else { + NSLog(@"Read attribute LIST_LONG_OCTET_STRING (for chunked read): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("list_long_octet_string", [actualValue count], static_cast(5))); + VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); + VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); + VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); + VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); + VerifyOrReturn(CheckValueAsString("", actualValue[4], [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeListLongOctetStringForChunkedWrite_136() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id listLongOctetStringArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; + temp_0[1] = + [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; + temp_0[2] = + [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; + temp_0[3] = + [[NSData alloc] initWithBytes:"0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef" length:512]; + listLongOctetStringArgument = temp_0; + } + [cluster writeAttributeListLongOctetStringWithValue:listLongOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Error: %@", err); + } else { + NSLog(@"Write attribute LIST_LONG_OCTET_STRING (for chunked write): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEpochUsDefaultValue_137() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_US Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEpochUsMaxValue_138() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id epochUsArgument; + epochUsArgument = + [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; + [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute EPOCH_US Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute EPOCH_US Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEpochUsMaxValue_139() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_US Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_US Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("epoch_us", actualValue, 18446744073709551615ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEpochUsMinValue_140() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id epochUsArgument; + epochUsArgument = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute EPOCH_US Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute EPOCH_US Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEpochUsMinValue_141() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_US Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_US Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEpochSDefaultValue_142() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEpochSMaxValue_143() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id epochSArgument; + epochSArgument = + [NSNumber numberWithUnsignedInt:4294967295UL]; + [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute EPOCH_S Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute EPOCH_S Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEpochSMaxValue_144() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_S Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_S Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("epoch_s", actualValue, 4294967295UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEpochSMinValue_145() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id epochSArgument; + epochSArgument = + [NSNumber numberWithUnsignedInt:0UL]; + [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute EPOCH_S Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute EPOCH_S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEpochSMinValue_146() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_S Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeUnsupported_147() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeUnsupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute UNSUPPORTED: Error: %@", err); + } else { + NSLog(@"Read attribute UNSUPPORTED: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteattributeUnsupported_148() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id unsupportedArgument; + unsupportedArgument = + [NSNumber numberWithBool:0]; + [cluster writeAttributeUnsupportedWithValue:unsupportedArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Writeattribute UNSUPPORTED: Error: %@", err); + } else { + NSLog(@"Writeattribute UNSUPPORTED: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ATTRIBUTE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandToUnsupportedEndpoint_149() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(200) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster testWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command to unsupported endpoint: Error: %@", err); + } else { + NSLog(@"Send Test Command to unsupported endpoint: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandToUnsupportedCluster_150() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster testWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command to unsupported cluster: Error: %@", err); + } else { + NSLog(@"Send Test Command to unsupported cluster: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeVendorIdDefaultValue_151() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute vendor_id Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("vendor_id", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeVendorId_152() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id vendorIdArgument; + vendorIdArgument = + [NSNumber numberWithUnsignedShort:17U]; + [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute vendor_id: Error: %@", err); + } else { + NSLog(@"Write attribute vendor_id: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeVendorId_153() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute vendor_id: Error: %@", err); + } else { + NSLog(@"Read attribute vendor_id: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("vendor_id", actualValue, 17U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRestoreAttributeVendorId_154() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id vendorIdArgument; + vendorIdArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Restore attribute vendor_id: Error: %@", err); + } else { + NSLog(@"Restore attribute vendor_id: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendACommandWithAVendorIdAndEnum_155() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestEnumsRequestParams alloc] init]; + params.arg1 = + [NSNumber numberWithUnsignedShort:20003U]; + params.arg2 = + [NSNumber numberWithUnsignedChar:1U]; + [cluster testEnumsRequestWithParams:params completion: + ^(MTRUnitTestingClusterTestEnumsResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send a command with a vendor_id and enum: Error: %@", err); + } else { + NSLog(@"Send a command with a vendor_id and enum: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.arg1; + VerifyOrReturn(CheckValue("arg1", actualValue, 20003U)); + } + + { + id actualValue = values.arg2; + VerifyOrReturn(CheckValue("arg2", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendACommandWithAVendorIdAndInvalidEnum_156() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestEnumsRequestParams alloc] init]; + params.arg1 = + [NSNumber numberWithUnsignedShort:20003U]; + params.arg2 = + [NSNumber numberWithUnsignedChar:101U]; + [cluster testEnumsRequestWithParams:params completion: + ^(MTRUnitTestingClusterTestEnumsResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send a command with a vendor_id and invalid enum: Error: %@", err); + } else { + NSLog(@"Send a command with a vendor_id and invalid enum: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithStructArgumentAndArg1bIsTrue_157() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestStructArgumentRequestParams alloc] init]; + params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = + [[NSData alloc] initWithBytes:"octet_string" length:12]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = + [NSNumber numberWithDouble:0]; + + [cluster testStructArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With Struct Argument and arg1.b is true: Error: %@", err); + } else { + NSLog(@"Send Test Command With Struct Argument and arg1.b is true: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, true)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithStructArgumentAndArg1bIsFalse_158() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestStructArgumentRequestParams alloc] init]; + params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = + [NSNumber numberWithBool:false]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = + [[NSData alloc] initWithBytes:"octet_string" length:12]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = + [NSNumber numberWithDouble:0]; + + [cluster testStructArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With Struct Argument and arg1.b is false: Error: %@", err); + } else { + NSLog(@"Send Test Command With Struct Argument and arg1.b is false: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, false)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithNestedStructArgumentAndArg1cbIsTrue_159() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestNestedStructArgumentRequestParams alloc] init]; + params.arg1 = [[MTRUnitTestingClusterNestedStruct alloc] init]; + ((MTRUnitTestingClusterNestedStruct *) params.arg1).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterNestedStruct *) params.arg1).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterNestedStruct *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).d = + [[NSData alloc] initWithBytes:"octet_string" length:12]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).e = @"char_string"; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).h = + [NSNumber numberWithDouble:0]; + + [cluster testNestedStructArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With Nested Struct Argument and arg1.c.b is true: Error: %@", err); + } else { + NSLog(@"Send Test Command With Nested Struct Argument and arg1.c.b is true: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, true)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithNestedStructArgumentArg1cbIsFalse_160() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestNestedStructArgumentRequestParams alloc] init]; + params.arg1 = [[MTRUnitTestingClusterNestedStruct alloc] init]; + ((MTRUnitTestingClusterNestedStruct *) params.arg1).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterNestedStruct *) params.arg1).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterNestedStruct *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).b = + [NSNumber numberWithBool:false]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).d = + [[NSData alloc] initWithBytes:"octet_string" length:12]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).e = @"char_string"; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStruct *) params.arg1).c).h = + [NSNumber numberWithDouble:0]; + + [cluster testNestedStructArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With Nested Struct Argument arg1.c.b is false: Error: %@", err); + } else { + NSLog(@"Send Test Command With Nested Struct Argument arg1.c.b is false: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, false)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndAllFieldsBOfArg1dAreTrue_161() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestNestedStructListArgumentRequestParams alloc] init]; + params.arg1 = [[MTRUnitTestingClusterNestedStructList alloc] init]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).d = + [[NSData alloc] initWithBytes:"octet_string" length:12]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).e = @"char_string"; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).h = + [NSNumber numberWithDouble:0]; + + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).a = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).c = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).d = + [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).e = @"nested_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).h = + [NSNumber numberWithDouble:0]; + + temp_1[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).a = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).c = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).d = + [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).e = @"nested_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).h = + [NSNumber numberWithDouble:0]; + + ((MTRUnitTestingClusterNestedStructList *) params.arg1).d = temp_1; + } + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = + [NSNumber numberWithUnsignedInt:1UL]; + temp_1[1] = + [NSNumber numberWithUnsignedInt:2UL]; + temp_1[2] = + [NSNumber numberWithUnsignedInt:3UL]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).e = temp_1; + } + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = + [[NSData alloc] initWithBytes:"octet_string_1" length:14]; + temp_1[1] = + [[NSData alloc] initWithBytes:"octect_string_2" length:15]; + temp_1[2] = + [[NSData alloc] initWithBytes:"octet_string_3" length:14]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).f = temp_1; + } + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = + [NSNumber numberWithUnsignedChar:0U]; + temp_1[1] = + [NSNumber numberWithUnsignedChar:255U]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).g = temp_1; + } + + [cluster testNestedStructListArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true: Error: %@", err); + } else { + NSLog(@"Send Test Command With Nested Struct List Argument and all fields b of arg1.d are true: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, true)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfArg1dAreFalse_162() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestNestedStructListArgumentRequestParams alloc] init]; + params.arg1 = [[MTRUnitTestingClusterNestedStructList alloc] init]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).d = + [[NSData alloc] initWithBytes:"octet_string" length:12]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).e = @"char_string"; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) params.arg1).c).h = + [NSNumber numberWithDouble:0]; + + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).a = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).c = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).d = + [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).e = @"nested_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[0]).h = + [NSNumber numberWithDouble:0]; + + temp_1[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).a = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).b = + [NSNumber numberWithBool:false]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).c = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).d = + [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).e = @"nested_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_1[1]).h = + [NSNumber numberWithDouble:0]; + + ((MTRUnitTestingClusterNestedStructList *) params.arg1).d = temp_1; + } + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = + [NSNumber numberWithUnsignedInt:1UL]; + temp_1[1] = + [NSNumber numberWithUnsignedInt:2UL]; + temp_1[2] = + [NSNumber numberWithUnsignedInt:3UL]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).e = temp_1; + } + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = + [[NSData alloc] initWithBytes:"octet_string_1" length:14]; + temp_1[1] = + [[NSData alloc] initWithBytes:"octect_string_2" length:15]; + temp_1[2] = + [[NSData alloc] initWithBytes:"octet_string_3" length:14]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).f = temp_1; + } + { + NSMutableArray * temp_1 = [[NSMutableArray alloc] init]; + temp_1[0] = + [NSNumber numberWithUnsignedChar:0U]; + temp_1[1] = + [NSNumber numberWithUnsignedChar:255U]; + ((MTRUnitTestingClusterNestedStructList *) params.arg1).g = temp_1; + } + + [cluster testNestedStructListArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false: Error: %@", err); + } else { + NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of arg1.d are false: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, false)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithStructArgumentAndSeeWhatWeGetBack_163() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterSimpleStructEchoRequestParams alloc] init]; + params.arg1 = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).a = + [NSNumber numberWithUnsignedChar:17U]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).b = + [NSNumber numberWithBool:false]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).d = + [[NSData alloc] initWithBytes:"octet_string" length:12]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).e = @"char_string"; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).g = + [NSNumber numberWithFloat:0.1f]; + ((MTRUnitTestingClusterSimpleStruct *) params.arg1).h = + [NSNumber numberWithDouble:0.1]; + + [cluster simpleStructEchoRequestWithParams:params completion: + ^(MTRUnitTestingClusterSimpleStructResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With Struct Argument and see what we get back: Error: %@", err); + } else { + NSLog(@"Send Test Command With Struct Argument and see what we get back: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.arg1; + VerifyOrReturn(CheckValue("a", ((MTRUnitTestingClusterSimpleStruct *) actualValue).a, 17U)); + VerifyOrReturn(CheckValue("b", ((MTRUnitTestingClusterSimpleStruct *) actualValue).b, false)); + VerifyOrReturn(CheckValue("c", ((MTRUnitTestingClusterSimpleStruct *) actualValue).c, 2U)); + VerifyOrReturn(CheckValueAsString("d", ((MTRUnitTestingClusterSimpleStruct *) actualValue).d, [[NSData alloc] initWithBytes:"octet_string" length:12])); + VerifyOrReturn(CheckValueAsString("e", ((MTRUnitTestingClusterSimpleStruct *) actualValue).e, @"char_string")); + VerifyOrReturn(CheckValue("f", ((MTRUnitTestingClusterSimpleStruct *) actualValue).f, 1U)); + VerifyOrReturn(CheckValue("g", ((MTRUnitTestingClusterSimpleStruct *) actualValue).g, 0.1f)); + VerifyOrReturn(CheckValue("h", ((MTRUnitTestingClusterSimpleStruct *) actualValue).h, 0.1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithListOfInt8uAndNoneOfThemIsSetTo0_164() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestListInt8UArgumentRequestParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [NSNumber numberWithUnsignedChar:1U]; + temp_0[1] = + [NSNumber numberWithUnsignedChar:2U]; + temp_0[2] = + [NSNumber numberWithUnsignedChar:3U]; + temp_0[3] = + [NSNumber numberWithUnsignedChar:4U]; + temp_0[4] = + [NSNumber numberWithUnsignedChar:5U]; + temp_0[5] = + [NSNumber numberWithUnsignedChar:6U]; + temp_0[6] = + [NSNumber numberWithUnsignedChar:7U]; + temp_0[7] = + [NSNumber numberWithUnsignedChar:8U]; + temp_0[8] = + [NSNumber numberWithUnsignedChar:9U]; + params.arg1 = temp_0; + } + [cluster testListInt8UArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With List of INT8U and none of them is set to 0: Error: %@", err); + } else { + NSLog(@"Send Test Command With List of INT8U and none of them is set to 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, true)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithListOfInt8uAndOneOfThemIsSetTo0_165() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestListInt8UArgumentRequestParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [NSNumber numberWithUnsignedChar:1U]; + temp_0[1] = + [NSNumber numberWithUnsignedChar:2U]; + temp_0[2] = + [NSNumber numberWithUnsignedChar:3U]; + temp_0[3] = + [NSNumber numberWithUnsignedChar:4U]; + temp_0[4] = + [NSNumber numberWithUnsignedChar:5U]; + temp_0[5] = + [NSNumber numberWithUnsignedChar:6U]; + temp_0[6] = + [NSNumber numberWithUnsignedChar:7U]; + temp_0[7] = + [NSNumber numberWithUnsignedChar:8U]; + temp_0[8] = + [NSNumber numberWithUnsignedChar:9U]; + temp_0[9] = + [NSNumber numberWithUnsignedChar:0U]; + params.arg1 = temp_0; + } + [cluster testListInt8UArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With List of INT8U and one of them is set to 0: Error: %@", err); + } else { + NSLog(@"Send Test Command With List of INT8U and one of them is set to 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, false)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithListOfInt8uAndGetItReversed_166() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestListInt8UReverseRequestParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [NSNumber numberWithUnsignedChar:1U]; + temp_0[1] = + [NSNumber numberWithUnsignedChar:2U]; + temp_0[2] = + [NSNumber numberWithUnsignedChar:3U]; + temp_0[3] = + [NSNumber numberWithUnsignedChar:4U]; + temp_0[4] = + [NSNumber numberWithUnsignedChar:5U]; + temp_0[5] = + [NSNumber numberWithUnsignedChar:6U]; + temp_0[6] = + [NSNumber numberWithUnsignedChar:7U]; + temp_0[7] = + [NSNumber numberWithUnsignedChar:8U]; + temp_0[8] = + [NSNumber numberWithUnsignedChar:9U]; + params.arg1 = temp_0; + } + [cluster testListInt8UReverseRequestWithParams:params completion: + ^(MTRUnitTestingClusterTestListInt8UReverseResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With List of INT8U and get it reversed: Error: %@", err); + } else { + NSLog(@"Send Test Command With List of INT8U and get it reversed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.arg1; + VerifyOrReturn(CheckValue("arg1", [actualValue count], static_cast(9))); + VerifyOrReturn(CheckValue("", actualValue[0], 9U)); + VerifyOrReturn(CheckValue("", actualValue[1], 8U)); + VerifyOrReturn(CheckValue("", actualValue[2], 7U)); + VerifyOrReturn(CheckValue("", actualValue[3], 6U)); + VerifyOrReturn(CheckValue("", actualValue[4], 5U)); + VerifyOrReturn(CheckValue("", actualValue[5], 4U)); + VerifyOrReturn(CheckValue("", actualValue[6], 3U)); + VerifyOrReturn(CheckValue("", actualValue[7], 2U)); + VerifyOrReturn(CheckValue("", actualValue[8], 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithEmptyListOfInt8uAndGetAnEmptyListBack_167() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestListInt8UReverseRequestParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + params.arg1 = temp_0; + } + [cluster testListInt8UReverseRequestWithParams:params completion: + ^(MTRUnitTestingClusterTestListInt8UReverseResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With empty List of INT8U and get an empty list back: Error: %@", err); + } else { + NSLog(@"Send Test Command With empty List of INT8U and get an empty list back: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.arg1; + VerifyOrReturn(CheckValue("arg1", [actualValue count], static_cast(0))); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsTrue_168() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestListStructArgumentRequestParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).d = + [[NSData alloc] initWithBytes:"first_octet_string" length:18]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).e = @"first_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).h = + [NSNumber numberWithDouble:0]; + + temp_0[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).a = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).c = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).d = + [[NSData alloc] initWithBytes:"second_octet_string" length:19]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).e = @"second_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).h = + [NSNumber numberWithDouble:0]; + + params.arg1 = temp_0; + } + [cluster testListStructArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is true: Error: %@", err); + } else { + NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is true: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, true)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithListOfStructArgumentAndArg1bOfFirstItemIsFalse_169() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestListStructArgumentRequestParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).a = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).c = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).d = + [[NSData alloc] initWithBytes:"second_octet_string" length:19]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).e = @"second_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[0]).h = + [NSNumber numberWithDouble:0]; + + temp_0[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).b = + [NSNumber numberWithBool:false]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).d = + [[NSData alloc] initWithBytes:"first_octet_string" length:18]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).e = @"first_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_0[1]).h = + [NSNumber numberWithDouble:0]; + + params.arg1 = temp_0; + } + [cluster testListStructArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is false: Error: %@", err); + } else { + NSLog(@"Send Test Command With List of Struct Argument and arg1.b of first item is false: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, false)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithListOfNestedStructListArgumentAndAllFieldsBOfElementsOfArg1dAreTrue_170() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestListNestedStructListArgumentRequestParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUnitTestingClusterNestedStructList alloc] init]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).d = + [[NSData alloc] initWithBytes:"octet_string" length:12]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).e = @"char_string"; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).h = + [NSNumber numberWithDouble:0]; + + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).a = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).c = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).d = + [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).e = @"nested_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).h = + [NSNumber numberWithDouble:0]; + + temp_2[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).a = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).c = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).d = + [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).e = @"nested_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).h = + [NSNumber numberWithDouble:0]; + + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).d = temp_2; + } + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = + [NSNumber numberWithUnsignedInt:1UL]; + temp_2[1] = + [NSNumber numberWithUnsignedInt:2UL]; + temp_2[2] = + [NSNumber numberWithUnsignedInt:3UL]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).e = temp_2; + } + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = + [[NSData alloc] initWithBytes:"octet_string_1" length:14]; + temp_2[1] = + [[NSData alloc] initWithBytes:"octect_string_2" length:15]; + temp_2[2] = + [[NSData alloc] initWithBytes:"octet_string_3" length:14]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).f = temp_2; + } + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = + [NSNumber numberWithUnsignedChar:0U]; + temp_2[1] = + [NSNumber numberWithUnsignedChar:255U]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).g = temp_2; + } + + params.arg1 = temp_0; + } + [cluster testListNestedStructListArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true: Error: %@", err); + } else { + NSLog(@"Send Test Command With List of Nested Struct List Argument and all fields b of elements of arg1.d are true: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, true)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithNestedStructListArgumentAndSomeFieldsBOfElementsOfArg1dAreFalse_171() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestListNestedStructListArgumentRequestParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUnitTestingClusterNestedStructList alloc] init]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).a = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).d = + [[NSData alloc] initWithBytes:"octet_string" length:12]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).e = @"char_string"; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).c).h = + [NSNumber numberWithDouble:0]; + + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).a = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).c = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).d = + [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).e = @"nested_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[0]).h = + [NSNumber numberWithDouble:0]; + + temp_2[1] = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).a = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).b = + [NSNumber numberWithBool:false]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).c = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).d = + [[NSData alloc] initWithBytes:"nested_octet_string" length:19]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).e = @"nested_char_string"; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).f = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).g = + [NSNumber numberWithFloat:0.0f]; + ((MTRUnitTestingClusterSimpleStruct *) temp_2[1]).h = + [NSNumber numberWithDouble:0]; + + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).d = temp_2; + } + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = + [NSNumber numberWithUnsignedInt:1UL]; + temp_2[1] = + [NSNumber numberWithUnsignedInt:2UL]; + temp_2[2] = + [NSNumber numberWithUnsignedInt:3UL]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).e = temp_2; + } + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = + [[NSData alloc] initWithBytes:"octet_string_1" length:14]; + temp_2[1] = + [[NSData alloc] initWithBytes:"octect_string_2" length:15]; + temp_2[2] = + [[NSData alloc] initWithBytes:"octet_string_3" length:14]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).f = temp_2; + } + { + NSMutableArray * temp_2 = [[NSMutableArray alloc] init]; + temp_2[0] = + [NSNumber numberWithUnsignedChar:0U]; + temp_2[1] = + [NSNumber numberWithUnsignedChar:255U]; + ((MTRUnitTestingClusterNestedStructList *) temp_0[0]).g = temp_2; + } + + params.arg1 = temp_0; + } + [cluster testListNestedStructListArgumentRequestWithParams:params completion: + ^(MTRUnitTestingClusterBooleanResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false: Error: %@", err); + } else { + NSLog(@"Send Test Command With Nested Struct List Argument and some fields b of elements of arg1.d are false: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, false)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeListWithListOfInt8uAndNoneOfThemIsSetTo0_172() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id listInt8uArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [NSNumber numberWithUnsignedChar:1U]; + temp_0[1] = + [NSNumber numberWithUnsignedChar:2U]; + temp_0[2] = + [NSNumber numberWithUnsignedChar:3U]; + temp_0[3] = + [NSNumber numberWithUnsignedChar:4U]; + listInt8uArgument = temp_0; + } + [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute LIST With List of INT8U and none of them is set to 0: Error: %@", err); + } else { + NSLog(@"Write attribute LIST With List of INT8U and none of them is set to 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeListWithListOfInt8u_173() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute LIST With List of INT8U: Error: %@", err); + } else { + NSLog(@"Read attribute LIST With List of INT8U: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("", actualValue[0], 1U)); + VerifyOrReturn(CheckValue("", actualValue[1], 2U)); + VerifyOrReturn(CheckValue("", actualValue[2], 3U)); + VerifyOrReturn(CheckValue("", actualValue[3], 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeListWithListOfOctetString_174() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id listOctetStringArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [[NSData alloc] initWithBytes:"Test0" length:5]; + temp_0[1] = + [[NSData alloc] initWithBytes:"Test1" length:5]; + temp_0[2] = + [[NSData alloc] initWithBytes:"Test2" length:5]; + temp_0[3] = + [[NSData alloc] initWithBytes:"Test3" length:5]; + listOctetStringArgument = temp_0; + } + [cluster writeAttributeListOctetStringWithValue:listOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute LIST With List of OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute LIST With List of OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeListWithListOfOctetString_175() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeListOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute LIST With List of OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute LIST With List of OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("list_octet_string", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValueAsString("", actualValue[0], [[NSData alloc] initWithBytes:"Test0" length:5])); + VerifyOrReturn(CheckValueAsString("", actualValue[1], [[NSData alloc] initWithBytes:"Test1" length:5])); + VerifyOrReturn(CheckValueAsString("", actualValue[2], [[NSData alloc] initWithBytes:"Test2" length:5])); + VerifyOrReturn(CheckValueAsString("", actualValue[3], [[NSData alloc] initWithBytes:"Test3" length:5])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeListWithListOfListStructOctetString_176() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id listStructOctetStringArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; + ((MTRUnitTestingClusterTestListStructOctet *) temp_0[0]).member1 = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRUnitTestingClusterTestListStructOctet *) temp_0[0]).member2 = + [[NSData alloc] initWithBytes:"Test0" length:5]; + + temp_0[1] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; + ((MTRUnitTestingClusterTestListStructOctet *) temp_0[1]).member1 = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRUnitTestingClusterTestListStructOctet *) temp_0[1]).member2 = + [[NSData alloc] initWithBytes:"Test1" length:5]; + + temp_0[2] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; + ((MTRUnitTestingClusterTestListStructOctet *) temp_0[2]).member1 = + [NSNumber numberWithUnsignedLongLong:2ULL]; + ((MTRUnitTestingClusterTestListStructOctet *) temp_0[2]).member2 = + [[NSData alloc] initWithBytes:"Test2" length:5]; + + temp_0[3] = [[MTRUnitTestingClusterTestListStructOctet alloc] init]; + ((MTRUnitTestingClusterTestListStructOctet *) temp_0[3]).member1 = + [NSNumber numberWithUnsignedLongLong:3ULL]; + ((MTRUnitTestingClusterTestListStructOctet *) temp_0[3]).member2 = + [[NSData alloc] initWithBytes:"Test3" length:5]; + + listStructOctetStringArgument = temp_0; + } + [cluster writeAttributeListStructOctetStringWithValue:listStructOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute LIST With List of LIST_STRUCT_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute LIST With List of LIST_STRUCT_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeListWithListOfListStructOctetString_177() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeListStructOctetStringWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute LIST With List of LIST_STRUCT_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute LIST With List of LIST_STRUCT_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("list_struct_octet_string", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[0]).member1, 0ULL)); + VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[0]).member2, [[NSData alloc] initWithBytes:"Test0" length:5])); + VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[1]).member1, 1ULL)); + VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[1]).member2, [[NSData alloc] initWithBytes:"Test1" length:5])); + VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[2]).member1, 2ULL)); + VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[2]).member2, [[NSData alloc] initWithBytes:"Test2" length:5])); + VerifyOrReturn(CheckValue("member1", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[3]).member1, 3ULL)); + VerifyOrReturn(CheckValueAsString("member2", ((MTRUnitTestingClusterTestListStructOctet *) actualValue[3]).member2, [[NSData alloc] initWithBytes:"Test3" length:5])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithOptionalArgSet_178() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestNullableOptionalRequestParams alloc] init]; + params.arg1 = + [NSNumber numberWithUnsignedChar:5U]; + [cluster testNullableOptionalRequestWithParams:params completion: + ^(MTRUnitTestingClusterTestNullableOptionalResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command with optional arg set.: Error: %@", err); + } else { + NSLog(@"Send Test Command with optional arg set.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.wasPresent; + VerifyOrReturn(CheckValue("wasPresent", actualValue, true)); + } + + { + id actualValue = values.wasNull; + VerifyOrReturn(CheckValue("wasNull", actualValue, false)); + } + + { + id actualValue = values.value; + VerifyOrReturn(CheckValue("value", actualValue, 5U)); + } + + { + id actualValue = values.originalValue; + VerifyOrReturn(CheckValueNonNull("originalValue", actualValue)); + VerifyOrReturn(CheckValue("originalValue", actualValue, 5U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestCommandWithoutItsOptionalArg_179() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestNullableOptionalRequestParams alloc] init]; + [cluster testNullableOptionalRequestWithParams:params completion: + ^(MTRUnitTestingClusterTestNullableOptionalResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Command without its optional arg.: Error: %@", err); + } else { + NSLog(@"Send Test Command without its optional arg.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.wasPresent; + VerifyOrReturn(CheckValue("wasPresent", actualValue, false)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadListOfStructsContainingNullablesAndOptionals_180() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeListNullablesAndOptionalsStructWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read list of structs containing nullables and optionals: Error: %@", err); + } else { + NSLog(@"Read list of structs containing nullables and optionals: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("list_nullables_and_optionals_struct", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValueNull("NullableInt", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableInt)); + VerifyOrReturn(CheckValueNull("NullableString", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableString)); + VerifyOrReturn(CheckValueNull("NullableStruct", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableStruct)); + VerifyOrReturn(CheckValueNull("NullableList", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteListOfStructsContainingNullablesAndOptionals_181() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id listNullablesAndOptionalsStructArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUnitTestingClusterNullablesAndOptionalsStruct alloc] init]; + ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableInt = nil; + ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableString = nil; + ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableStruct = nil; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedChar:1U]; + temp_3[1] = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) temp_0[0]).nullableList = temp_3; + } + + listNullablesAndOptionalsStructArgument = temp_0; + } + [cluster writeAttributeListNullablesAndOptionalsStructWithValue:listNullablesAndOptionalsStructArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write list of structs containing nullables and optionals: Error: %@", err); + } else { + NSLog(@"Write list of structs containing nullables and optionals: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadListOfStructsContainingNullablesAndOptionalsAfterWriting_182() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeListNullablesAndOptionalsStructWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read list of structs containing nullables and optionals after writing: Error: %@", err); + } else { + NSLog(@"Read list of structs containing nullables and optionals after writing: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("list_nullables_and_optionals_struct", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValueNull("NullableInt", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableInt)); + VerifyOrReturn(CheckValueNull("NullableString", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableString)); + VerifyOrReturn(CheckValueNull("NullableStruct", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableStruct)); + VerifyOrReturn(CheckValueNonNull("NullableList", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList)); + VerifyOrReturn(CheckValue("NullableList", [((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList count], static_cast(2))); + VerifyOrReturn(CheckValue("", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList[0], 1U)); + VerifyOrReturn(CheckValue("", ((MTRUnitTestingClusterNullablesAndOptionalsStruct *) actualValue[0]).nullableList[1], 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBooleanNull_183() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBooleanArgument; + nullableBooleanArgument = nil; + [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BOOLEAN null: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BOOLEAN null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable booValueNull; + + CHIP_ERROR TestReadAttributeNullableBooleanNull_184() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BOOLEAN null: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BOOLEAN null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); + } + { + booValueNull = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBooleanTrue_185() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBooleanArgument; + nullableBooleanArgument = + [NSNumber numberWithBool:true]; + [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BOOLEAN True: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BOOLEAN True: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBooleanTrue_186() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BOOLEAN True: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BOOLEAN True: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); + VerifyOrReturn(CheckValue("nullable_boolean", actualValue, true)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBooleanNotNull_187() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BOOLEAN not null: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BOOLEAN not null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableBoolean", value, booValueNull)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap8MaxValue_188() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap8Argument; + nullableBitmap8Argument = + [NSNumber numberWithUnsignedChar:254U]; + [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP8 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP8 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap8MaxValue_189() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP8 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP8 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_bitmap8", actualValue)); + VerifyOrReturn(CheckValue("nullable_bitmap8", actualValue, 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap8InvalidValue_190() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap8Argument; + nullableBitmap8Argument = + [NSNumber numberWithUnsignedChar:255U]; + [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP8 Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP8 Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable nullableValue254; + + CHIP_ERROR TestReadAttributeNullableBitmap8UnchangedValue_191() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP8 unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP8 unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_bitmap8", actualValue)); + VerifyOrReturn(CheckValue("nullable_bitmap8", actualValue, 254U)); + } + { + nullableValue254 = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap8NullValue_192() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap8Argument; + nullableBitmap8Argument = nil; + [cluster writeAttributeNullableBitmap8WithValue:nullableBitmap8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP8 null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP8 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap8NullValue_193() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP8 null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP8 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_bitmap8", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap8Not254Value_194() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP8 not 254 Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP8 not 254 Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableBitmap8", value, nullableValue254)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap16MaxValue_195() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap16Argument; + nullableBitmap16Argument = + [NSNumber numberWithUnsignedShort:65534U]; + [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP16 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP16 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap16MaxValue_196() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP16 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP16 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_bitmap16", actualValue)); + VerifyOrReturn(CheckValue("nullable_bitmap16", actualValue, 65534U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap16InvalidValue_197() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap16Argument; + nullableBitmap16Argument = + [NSNumber numberWithUnsignedShort:65535U]; + [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP16 Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP16 Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap16UnchangedValue_198() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP16 unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP16 unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_bitmap16", actualValue)); + VerifyOrReturn(CheckValue("nullable_bitmap16", actualValue, 65534U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap16NullValue_199() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap16Argument; + nullableBitmap16Argument = nil; + [cluster writeAttributeNullableBitmap16WithValue:nullableBitmap16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP16 null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP16 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap16NullValue_200() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP16 null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP16 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_bitmap16", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap32MaxValue_201() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap32Argument; + nullableBitmap32Argument = + [NSNumber numberWithUnsignedInt:4294967294UL]; + [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP32 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP32 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap32MaxValue_202() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP32 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP32 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_bitmap32", actualValue)); + VerifyOrReturn(CheckValue("nullable_bitmap32", actualValue, 4294967294UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap32InvalidValue_203() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap32Argument; + nullableBitmap32Argument = + [NSNumber numberWithUnsignedInt:4294967295UL]; + [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP32 Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP32 Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap32UnchangedValue_204() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP32 unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP32 unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_bitmap32", actualValue)); + VerifyOrReturn(CheckValue("nullable_bitmap32", actualValue, 4294967294UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap32NullValue_205() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap32Argument; + nullableBitmap32Argument = nil; + [cluster writeAttributeNullableBitmap32WithValue:nullableBitmap32Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP32 null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP32 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap32NullValue_206() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP32 null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP32 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_bitmap32", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap64MaxValue_207() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap64Argument; + nullableBitmap64Argument = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP64 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP64 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap64MaxValue_208() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP64 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP64 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_bitmap64", actualValue)); + VerifyOrReturn(CheckValue("nullable_bitmap64", actualValue, 18446744073709551614ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap64InvalidValue_209() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap64Argument; + nullableBitmap64Argument = + [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; + [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP64 Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP64 Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap64UnchangedValue_210() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP64 unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP64 unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_bitmap64", actualValue)); + VerifyOrReturn(CheckValue("nullable_bitmap64", actualValue, 18446744073709551614ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBitmap64NullValue_211() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBitmap64Argument; + nullableBitmap64Argument = nil; + [cluster writeAttributeNullableBitmap64WithValue:nullableBitmap64Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_BITMAP64 null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_BITMAP64 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBitmap64NullValue_212() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_BITMAP64 null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_BITMAP64 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_bitmap64", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8uMinValue_213() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8uArgument; + nullableInt8uArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8U Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uMinValue_214() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8uMaxValue_215() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8uArgument; + nullableInt8uArgument = + [NSNumber numberWithUnsignedChar:254U]; + [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8U Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uMaxValue_216() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8uInvalidValue_217() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8uArgument; + nullableInt8uArgument = + [NSNumber numberWithUnsignedChar:255U]; + [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8U Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8U Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uUnchangedValue_218() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uUnchangedValueWithConstraint_219() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U unchanged Value with constraint: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U unchanged Value with constraint: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckValueNonNull("nullableInt8u", value)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8uNullValue_220() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8uArgument; + nullableInt8uArgument = nil; + [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8U null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8U null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uNullValue_221() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_int8u", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uNullValueRange_222() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U null Value & range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U null Value & range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt8u", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt8u", [value unsignedCharValue], 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uNullValueNot_223() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U null Value & not: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U null Value & not: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt8u", value, 254U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8uValue_224() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8uArgument; + nullableInt8uArgument = + [NSNumber numberWithUnsignedChar:128U]; + [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8U Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8U Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uValueInRange_225() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U Value in range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U Value in range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt8u", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt8u", [value unsignedCharValue], 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uNotValueOk_226() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U notValue OK: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U notValue OK: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt8u", value, 129U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt16uMinValue_227() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt16uArgument; + nullableInt16uArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT16U Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT16U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16uMinValue_228() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16U Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt16uMaxValue_229() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt16uArgument; + nullableInt16uArgument = + [NSNumber numberWithUnsignedShort:65534U]; + [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT16U Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT16U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16uMaxValue_230() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16U Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 65534U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt16uInvalidValue_231() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt16uArgument; + nullableInt16uArgument = + [NSNumber numberWithUnsignedShort:65535U]; + [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT16U Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT16U Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16uUnchangedValue_232() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16U unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16U unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int16u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int16u", actualValue, 65534U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt16uNullValue_233() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt16uArgument; + nullableInt16uArgument = nil; + [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT16U null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT16U null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16uNullValue_234() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16U null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16U null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_int16u", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16uNullValueRange_235() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16U null Value & range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16U null Value & range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt16u", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt16u", [value unsignedShortValue], 65534U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16uNullValueNot_236() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16U null Value & not: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16U null Value & not: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt16u", value, 65534U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt16uValue_237() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt16uArgument; + nullableInt16uArgument = + [NSNumber numberWithUnsignedShort:32000U]; + [cluster writeAttributeNullableInt16uWithValue:nullableInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT16U Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT16U Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16uValueInRange_238() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16U Value in range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16U Value in range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt16u", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt16u", [value unsignedShortValue], 65534U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16uNotValueOk_239() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16U notValue OK: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16U notValue OK: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt16u", value, 32001U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt32uMinValue_240() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt32uArgument; + nullableInt32uArgument = + [NSNumber numberWithUnsignedInt:0UL]; + [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT32U Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT32U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32uMinValue_241() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32U Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 0UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt32uMaxValue_242() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt32uArgument; + nullableInt32uArgument = + [NSNumber numberWithUnsignedInt:4294967294UL]; + [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT32U Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT32U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32uMaxValue_243() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32U Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 4294967294UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt32uInvalidValue_244() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt32uArgument; + nullableInt32uArgument = + [NSNumber numberWithUnsignedInt:4294967295UL]; + [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT32U Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT32U Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32uUnchangedValue_245() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32U unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32U unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int32u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int32u", actualValue, 4294967294UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt32uNullValue_246() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt32uArgument; + nullableInt32uArgument = nil; + [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT32U null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT32U null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32uNullValue_247() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32U null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32U null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_int32u", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32uNullValueRange_248() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32U null Value & range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32U null Value & range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt32u", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt32u", [value unsignedIntValue], 4294967294UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32uNullValueNot_249() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32U null Value & not: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32U null Value & not: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt32u", value, 4294967294UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt32uValue_250() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt32uArgument; + nullableInt32uArgument = + [NSNumber numberWithUnsignedInt:2147483647UL]; + [cluster writeAttributeNullableInt32uWithValue:nullableInt32uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT32U Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT32U Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32uValueInRange_251() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32U Value in range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32U Value in range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt32u", [value unsignedIntValue], 0UL)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt32u", [value unsignedIntValue], 4294967294UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32uNotValueOk_252() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32U notValue OK: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32U notValue OK: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt32u", value, 2147483648UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt64uMinValue_253() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt64uArgument; + nullableInt64uArgument = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT64U Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT64U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64uMinValue_254() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64U Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64U Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt64uMaxValue_255() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt64uArgument; + nullableInt64uArgument = + [NSNumber numberWithUnsignedLongLong:18446744073709551614ULL]; + [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT64U Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT64U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64uMaxValue_256() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64U Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64U Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 18446744073709551614ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt64uInvalidValue_257() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt64uArgument; + nullableInt64uArgument = + [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; + [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT64U Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT64U Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64uUnchangedValue_258() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64U unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64U unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int64u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int64u", actualValue, 18446744073709551614ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt64uNullValue_259() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt64uArgument; + nullableInt64uArgument = nil; + [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT64U null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT64U null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64uNullValue_260() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64U null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64U null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_int64u", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64uNullValueRange_261() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64U null Value & range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64U null Value & range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt64u", [value unsignedLongLongValue], 0ULL)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt64u", [value unsignedLongLongValue], 18446744073709551614ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64uNullValueNot_262() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64U null Value & not: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64U null Value & not: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt64u", value, 18446744073709551614ULL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt64uValue_263() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt64uArgument; + nullableInt64uArgument = + [NSNumber numberWithUnsignedLongLong:18000000000000000000ULL]; + [cluster writeAttributeNullableInt64uWithValue:nullableInt64uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT64U Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT64U Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64uValueInRange_264() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64U Value in range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64U Value in range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt64u", [value unsignedLongLongValue], 0ULL)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt64u", [value unsignedLongLongValue], 18446744073709551614ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64uNotValueOk_265() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64U notValue OK: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64U notValue OK: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt64u", value, 18000000000000000001ULL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8sMinValue_266() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8sArgument; + nullableInt8sArgument = + [NSNumber numberWithChar:-127]; + [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8S Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8sMinValue_267() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8S Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int8s", actualValue)); + VerifyOrReturn(CheckValue("nullable_int8s", actualValue, -127)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8sInvalidValue_268() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8sArgument; + nullableInt8sArgument = + [NSNumber numberWithChar:-128]; + [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8S Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8S Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8sUnchangedValue_269() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8S unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8S unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int8s", actualValue)); + VerifyOrReturn(CheckValue("nullable_int8s", actualValue, -127)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8sNullValue_270() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8sArgument; + nullableInt8sArgument = nil; + [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8S null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8S null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8sNullValue_271() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8S null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8S null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_int8s", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8sNullValueRange_272() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8S null Value & range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8S null Value & range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt8s", [value charValue], -127)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt8s", [value charValue], 127)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8sNullValueNot_273() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8S null Value & not: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8S null Value & not: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt8s", value, -127)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8sValue_274() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8sArgument; + nullableInt8sArgument = + [NSNumber numberWithChar:-127]; + [cluster writeAttributeNullableInt8sWithValue:nullableInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8S Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8S Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8sValueInRange_275() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8S Value in range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8S Value in range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt8s", [value charValue], -127)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt8s", [value charValue], 127)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8sNotValueOk_276() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8S notValue OK: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8S notValue OK: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt8s", value, -126)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt16sMinValue_277() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt16sArgument; + nullableInt16sArgument = + [NSNumber numberWithShort:-32767]; + [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT16S Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT16S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16sMinValue_278() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16S Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int16s", actualValue)); + VerifyOrReturn(CheckValue("nullable_int16s", actualValue, -32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt16sInvalidValue_279() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt16sArgument; + nullableInt16sArgument = + [NSNumber numberWithShort:-32768]; + [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT16S Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT16S Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16sUnchangedValue_280() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16S unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16S unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int16s", actualValue)); + VerifyOrReturn(CheckValue("nullable_int16s", actualValue, -32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt16sNullValue_281() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt16sArgument; + nullableInt16sArgument = nil; + [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT16S null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT16S null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16sNullValue_282() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16S null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16S null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_int16s", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16sNullValueRange_283() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16S null Value & range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16S null Value & range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt16s", [value shortValue], -32767)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt16s", [value shortValue], 32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16sNullValueNot_284() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16S null Value & not: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16S null Value & not: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt16s", value, -32767)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt16sValue_285() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt16sArgument; + nullableInt16sArgument = + [NSNumber numberWithShort:-32767]; + [cluster writeAttributeNullableInt16sWithValue:nullableInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT16S Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT16S Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16sValueInRange_286() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16S Value in range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16S Value in range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt16s", [value shortValue], -32767)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt16s", [value shortValue], 32767)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt16sNotValueOk_287() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT16S notValue OK: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT16S notValue OK: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt16s", value, -32766)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt32sMinValue_288() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt32sArgument; + nullableInt32sArgument = + [NSNumber numberWithInt:-2147483647L]; + [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT32S Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT32S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32sMinValue_289() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32S Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int32s", actualValue)); + VerifyOrReturn(CheckValue("nullable_int32s", actualValue, -2147483647L)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt32sInvalidValue_290() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt32sArgument; + nullableInt32sArgument = + [NSNumber numberWithInt:-2147483648L]; + [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT32S Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT32S Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32sUnchangedValue_291() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32S unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32S unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int32s", actualValue)); + VerifyOrReturn(CheckValue("nullable_int32s", actualValue, -2147483647L)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt32sNullValue_292() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt32sArgument; + nullableInt32sArgument = nil; + [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT32S null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT32S null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32sNullValue_293() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32S null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32S null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_int32s", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32sNullValueRange_294() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32S null Value & range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32S null Value & range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt32s", [value intValue], -2147483647L)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt32s", [value intValue], 2147483647L)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32sNullValueNot_295() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32S null Value & not: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32S null Value & not: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt32s", value, -2147483647L)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt32sValue_296() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt32sArgument; + nullableInt32sArgument = + [NSNumber numberWithInt:-2147483647L]; + [cluster writeAttributeNullableInt32sWithValue:nullableInt32sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT32S Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT32S Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32sValueInRange_297() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32S Value in range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32S Value in range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt32s", [value intValue], -2147483647L)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt32s", [value intValue], 2147483647L)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt32sNotValueOk_298() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT32S notValue OK: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT32S notValue OK: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt32s", value, -2147483646L)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt64sMinValue_299() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt64sArgument; + nullableInt64sArgument = + [NSNumber numberWithLongLong:-9223372036854775807LL]; + [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT64S Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT64S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64sMinValue_300() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64S Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64S Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int64s", actualValue)); + VerifyOrReturn(CheckValue("nullable_int64s", actualValue, -9223372036854775807LL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt64sInvalidValue_301() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt64sArgument; + nullableInt64sArgument = + [NSNumber numberWithLongLong:-9223372036854775807LL - 1LL]; + [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT64S Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT64S Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64sUnchangedValue_302() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64S unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64S unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int64s", actualValue)); + VerifyOrReturn(CheckValue("nullable_int64s", actualValue, -9223372036854775807LL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt64sNullValue_303() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt64sArgument; + nullableInt64sArgument = nil; + [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT64S null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT64S null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64sNullValue_304() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64S null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64S null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_int64s", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64sNullValueRange_305() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64S null Value & range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64S null Value & range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt64s", [value longLongValue], -9223372036854775807LL)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt64s", [value longLongValue], 9223372036854775807LL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64sNullValueNot_306() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64S null Value & not: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64S null Value & not: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt64s", value, -9223372036854775807LL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt64sValue_307() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt64sArgument; + nullableInt64sArgument = + [NSNumber numberWithLongLong:-9223372036854775807LL]; + [cluster writeAttributeNullableInt64sWithValue:nullableInt64sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT64S Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT64S Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64sValueInRange_308() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64S Value in range: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64S Value in range: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinValue("nullableInt64s", [value longLongValue], -9223372036854775807LL)); + VerifyOrReturn(CheckConstraintMaxValue("nullableInt64s", [value longLongValue], 9223372036854775807LL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt64sNotValueOk_309() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT64S notValue OK: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT64S notValue OK: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableInt64s", value, -9223372036854775806LL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableSingleMediumValue_310() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableFloatSingleArgument; + nullableFloatSingleArgument = + [NSNumber numberWithFloat:0.1f]; + [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_SINGLE medium Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_SINGLE medium Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableSingleMediumValue_311() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_SINGLE medium Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_SINGLE medium Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); + VerifyOrReturn(CheckValue("nullable_float_single", actualValue, 0.1f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableSingleLargestValue_312() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableFloatSingleArgument; + nullableFloatSingleArgument = + [NSNumber numberWithFloat:INFINITY]; + [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_SINGLE largest Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_SINGLE largest Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableSingleLargestValue_313() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_SINGLE largest Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_SINGLE largest Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); + VerifyOrReturn(CheckValue("nullable_float_single", actualValue, INFINITY)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableSingleSmallestValue_314() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableFloatSingleArgument; + nullableFloatSingleArgument = + [NSNumber numberWithFloat:-INFINITY]; + [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_SINGLE smallest Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_SINGLE smallest Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableSingleSmallestValue_315() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_SINGLE smallest Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_SINGLE smallest Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); + VerifyOrReturn(CheckValue("nullable_float_single", actualValue, -INFINITY)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableSingleNullValue_316() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableFloatSingleArgument; + nullableFloatSingleArgument = nil; + [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_SINGLE null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_SINGLE null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableSingleNullValue_317() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_SINGLE null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_SINGLE null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_float_single", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableSingle0Value_318() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableFloatSingleArgument; + nullableFloatSingleArgument = + [NSNumber numberWithFloat:0.0f]; + [cluster writeAttributeNullableFloatSingleWithValue:nullableFloatSingleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_SINGLE 0 Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_SINGLE 0 Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableSingle0Value_319() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableFloatSingleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_SINGLE 0 Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_SINGLE 0 Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_float_single", actualValue)); + VerifyOrReturn(CheckValue("nullable_float_single", actualValue, 0.0f)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableDoubleMediumValue_320() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableFloatDoubleArgument; + nullableFloatDoubleArgument = + [NSNumber numberWithDouble:0.1234567890123]; + [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_DOUBLE medium Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_DOUBLE medium Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableDoubleMediumValue_321() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_DOUBLE medium Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_DOUBLE medium Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); + VerifyOrReturn(CheckValue("nullable_float_double", actualValue, 0.1234567890123)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableDoubleLargestValue_322() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableFloatDoubleArgument; + nullableFloatDoubleArgument = + [NSNumber numberWithDouble:INFINITY]; + [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_DOUBLE largest Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_DOUBLE largest Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableDoubleLargestValue_323() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_DOUBLE largest Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_DOUBLE largest Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); + VerifyOrReturn(CheckValue("nullable_float_double", actualValue, INFINITY)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableDoubleSmallestValue_324() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableFloatDoubleArgument; + nullableFloatDoubleArgument = + [NSNumber numberWithDouble:-INFINITY]; + [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_DOUBLE smallest Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_DOUBLE smallest Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableDoubleSmallestValue_325() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_DOUBLE smallest Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_DOUBLE smallest Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); + VerifyOrReturn(CheckValue("nullable_float_double", actualValue, -INFINITY)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableDoubleNullValue_326() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableFloatDoubleArgument; + nullableFloatDoubleArgument = nil; + [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_DOUBLE null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_DOUBLE null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableDoubleNullValue_327() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_DOUBLE null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_DOUBLE null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_float_double", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableDouble0Value_328() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableFloatDoubleArgument; + nullableFloatDoubleArgument = + [NSNumber numberWithDouble:0]; + [cluster writeAttributeNullableFloatDoubleWithValue:nullableFloatDoubleArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_DOUBLE 0 Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_DOUBLE 0 Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableDouble0Value_329() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableFloatDoubleWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_DOUBLE 0 Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_DOUBLE 0 Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_float_double", actualValue)); + VerifyOrReturn(CheckValue("nullable_float_double", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableEnum8MinValue_330() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnum8Argument; + nullableEnum8Argument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_ENUM8 Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_ENUM8 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableEnum8MinValue_331() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_ENUM8 Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_ENUM8 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); + VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableEnum8MaxValue_332() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnum8Argument; + nullableEnum8Argument = + [NSNumber numberWithUnsignedChar:254U]; + [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_ENUM8 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_ENUM8 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableEnum8MaxValue_333() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_ENUM8 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_ENUM8 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); + VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableEnum8InvalidValue_334() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnum8Argument; + nullableEnum8Argument = + [NSNumber numberWithUnsignedChar:255U]; + [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_ENUM8 Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_ENUM8 Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableEnum8UnchangedValue_335() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_ENUM8 unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_ENUM8 unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_enum8", actualValue)); + VerifyOrReturn(CheckValue("nullable_enum8", actualValue, 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableEnum8NullValue_336() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnum8Argument; + nullableEnum8Argument = nil; + [cluster writeAttributeNullableEnum8WithValue:nullableEnum8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_ENUM8 null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_ENUM8 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableEnum8NullValue_337() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_ENUM8 null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_ENUM8 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_enum8", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableEnum16MinValue_338() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnum16Argument; + nullableEnum16Argument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_ENUM16 Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_ENUM16 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableEnum16MinValue_339() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_ENUM16 Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_ENUM16 Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); + VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableEnum16MaxValue_340() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnum16Argument; + nullableEnum16Argument = + [NSNumber numberWithUnsignedShort:65534U]; + [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_ENUM16 Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_ENUM16 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableEnum16MaxValue_341() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_ENUM16 Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_ENUM16 Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); + VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 65534U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableEnum16InvalidValue_342() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnum16Argument; + nullableEnum16Argument = + [NSNumber numberWithUnsignedShort:65535U]; + [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_ENUM16 Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_ENUM16 Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableEnum16UnchangedValue_343() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_ENUM16 unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_ENUM16 unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_enum16", actualValue)); + VerifyOrReturn(CheckValue("nullable_enum16", actualValue, 65534U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableEnum16NullValue_344() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnum16Argument; + nullableEnum16Argument = nil; + [cluster writeAttributeNullableEnum16WithValue:nullableEnum16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_ENUM16 null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_ENUM16 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableEnum16NullValue_345() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_ENUM16 null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_ENUM16 null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_enum16", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableSimpleEnumMinValue_346() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnumAttrArgument; + nullableEnumAttrArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Min Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableSimpleEnumMinValue_347() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Min Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Min Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); + VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableSimpleEnumMaxValue_348() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnumAttrArgument; + nullableEnumAttrArgument = + [NSNumber numberWithUnsignedChar:3U]; + [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Max Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableSimpleEnumMaxValue_349() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Max Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM Max Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); + VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableSimpleEnumInvalidValue_350() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnumAttrArgument; + nullableEnumAttrArgument = + [NSNumber numberWithUnsignedChar:255U]; + [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Invalid Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM Invalid Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable nullableEnumAttr3; + + CHIP_ERROR TestReadAttributeNullableSimpleEnumUnchangedValue_351() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM unchanged Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM unchanged Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_enum_attr", actualValue)); + VerifyOrReturn(CheckValue("nullable_enum_attr", actualValue, 3U)); + } + { + nullableEnumAttr3 = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableSimpleEnumNullValue_352() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableEnumAttrArgument; + nullableEnumAttrArgument = nil; + [cluster writeAttributeNullableEnumAttrWithValue:nullableEnumAttrArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM null Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_SIMPLE_ENUM null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableSimpleEnumNullValue_353() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM null Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_enum_attr", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableSimpleEnumNot3Value_354() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableEnumAttrWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM not 3 Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_SIMPLE_ENUM not 3 Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableEnumAttr", value, nullableEnumAttr3)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableOctetStringDefaultValue_355() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); + VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableOctetString_356() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableOctetStringArgument; + nullableOctetStringArgument = + [[NSData alloc] initWithBytes:"TestValue" length:9]; + [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSData * _Nullable nullableOctetStrTestValue; + + CHIP_ERROR TestReadAttributeNullableOctetString_357() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); + VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"TestValue" length:9])); + } + { + nullableOctetStrTestValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableOctetString_358() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableOctetStringArgument; + nullableOctetStringArgument = nil; + [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableOctetString_359() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_octet_string", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableOctetString_360() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableOctetStringArgument; + nullableOctetStringArgument = + [[NSData alloc] initWithBytes:"" length:0]; + [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableOctetString_361() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); + VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableOctetStringNotTestValue_362() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_OCTET_STRING not TestValue: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_OCTET_STRING not TestValue: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableOctetString", value, nullableOctetStrTestValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableCharStringDefaultValue_363() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_CHAR_STRING Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_CHAR_STRING Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); + VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableCharString_364() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableCharStringArgument; + nullableCharStringArgument = @"☉T☉"; + [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_CHAR_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_CHAR_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSString * _Nullable nullableCharStringSave; + + CHIP_ERROR TestReadAttributeNullableCharString_365() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); + VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"☉T☉")); + } + { + nullableCharStringSave = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableCharString_366() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (nullableCharStringSave == nil) { + VerifyOrReturn(CheckValueNull("nullable_char_string", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); + VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, nullableCharStringSave)); + } + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableCharStringValueTooLong_367() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableCharStringArgument; + nullableCharStringArgument = nil; + [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_CHAR_STRING - Value too long: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_CHAR_STRING - Value too long: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableCharString_368() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_char_string", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableCharStringEmpty_369() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableCharStringArgument; + nullableCharStringArgument = @""; + [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_CHAR_STRING - Empty: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_CHAR_STRING - Empty: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableCharString_370() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_CHAR_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_CHAR_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_char_string", actualValue)); + VerifyOrReturn(CheckValueAsString("nullable_char_string", actualValue, @"")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableCharStringNott_371() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_CHAR_STRING not ☉T☉: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_CHAR_STRING not ☉T☉: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckConstraintNotValue("nullableCharString", value, nullableCharStringSave)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeFromNonexistentEndpoint_372() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(200) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute from nonexistent endpoint.: Error: %@", err); + } else { + NSLog(@"Read attribute from nonexistent endpoint.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_ENDPOINT)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeFromNonexistentCluster_373() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute from nonexistent cluster.: Error: %@", err); + } else { + NSLog(@"Read attribute from nonexistent cluster.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_CLUSTER)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_374() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestSimpleOptionalArgumentRequestParams alloc] init]; + [cluster testSimpleOptionalArgumentRequestWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send a command that takes an optional parameter but do not set it.: Error: %@", err); + } else { + NSLog(@"Send a command that takes an optional parameter but do not set it.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendACommandThatTakesAnOptionalParameterButDoNotSetIt_375() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestSimpleOptionalArgumentRequestParams alloc] init]; + params.arg1 = + [NSNumber numberWithBool:1]; + [cluster testSimpleOptionalArgumentRequestWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send a command that takes an optional parameter but do not set it.: Error: %@", err); + } else { + NSLog(@"Send a command that takes an optional parameter but do not set it.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + bool testSendClusterTestCluster_376_WaitForReport_Fulfilled = false; + ResponseHandler _Nullable test_TestCluster_list_int8u_Reported + = nil; + + CHIP_ERROR TestReportSubscribeToListAttribute_376() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestCluster_list_int8u_Reported + = ^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Report: Subscribe to list attribute: Error: %@", err); + } else { + NSLog(@"Report: Subscribe to list attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("", actualValue[0], 1U)); + VerifyOrReturn(CheckValue("", actualValue[1], 2U)); + VerifyOrReturn(CheckValue("", actualValue[2], 3U)); + VerifyOrReturn(CheckValue("", actualValue[3], 4U)); + } + + testSendClusterTestCluster_376_WaitForReport_Fulfilled = true; + }; + + NextTest(); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSubscribeToListAttribute_377() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + uint16_t minIntervalArgument = 2U; + uint16_t maxIntervalArgument = 5U; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; + params.filterByFabric = true; + params.replaceExistingSubscriptions = true; + [cluster subscribeAttributeListInt8uWithParams:params + subscriptionEstablished:^{ + VerifyOrReturn(testSendClusterTestCluster_376_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); + NextTest(); + } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Subscribe to list attribute: Error: %@", err); + } else { + NSLog(@"Subscribe to list attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + if (test_TestCluster_list_int8u_Reported + != nil) { + ResponseHandler callback = test_TestCluster_list_int8u_Reported; + test_TestCluster_list_int8u_Reported + = nil; + callback(value, err); + } + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteSubscribedToListAttribute_378() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id listInt8uArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [NSNumber numberWithUnsignedChar:5U]; + temp_0[1] = + [NSNumber numberWithUnsignedChar:6U]; + temp_0[2] = + [NSNumber numberWithUnsignedChar:7U]; + temp_0[3] = + [NSNumber numberWithUnsignedChar:8U]; + listInt8uArgument = temp_0; + } + [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write subscribed-to list attribute: Error: %@", err); + } else { + NSLog(@"Write subscribed-to list attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckForListAttributeReport_379() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestCluster_list_int8u_Reported + = ^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check for list attribute report: Error: %@", err); + } else { + NSLog(@"Check for list attribute report: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("list_int8u", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("", actualValue[0], 5U)); + VerifyOrReturn(CheckValue("", actualValue[1], 6U)); + VerifyOrReturn(CheckValue("", actualValue[2], 7U)); + VerifyOrReturn(CheckValue("", actualValue[3], 8U)); + } + + NextTest(); + }; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadRangeRestrictedUnsigned8BitInteger_380() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Read range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 70U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValueToARangeRestrictedUnsigned8BitInteger_381() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8uArgument; + rangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min value to a range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write min value to a range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedUnsigned8BitInteger_382() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8uArgument; + rangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:19U]; + [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-below-range value to a range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-below-range value to a range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedUnsigned8BitInteger_383() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8uArgument; + rangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:101U]; + [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-above-range value to a range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-above-range value to a range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValueToARangeRestrictedUnsigned8BitInteger_384() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8uArgument; + rangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:255U]; + [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max value to a range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write max value to a range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_385() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted unsigned 8-bit integer value has not changed: Error: %@", err); + } else { + NSLog(@"Verify range-restricted unsigned 8-bit integer value has not changed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 70U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValidValueToARangeRestrictedUnsigned8BitInteger_386() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8uArgument; + rangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:20U]; + [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write min valid value to a range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_387() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted unsigned 8-bit integer value is at min valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted unsigned 8-bit integer value is at min valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 20U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedUnsigned8BitInteger_388() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8uArgument; + rangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:100U]; + [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write max valid value to a range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_389() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted unsigned 8-bit integer value is at max valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted unsigned 8-bit integer value is at max valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedUnsigned8BitInteger_390() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8uArgument; + rangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:50U]; + [cluster writeAttributeRangeRestrictedInt8uWithValue:rangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write middle valid value to a range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write middle valid value to a range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_391() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted unsigned 8-bit integer value is at mid valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted unsigned 8-bit integer value is at mid valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int8u", actualValue, 50U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadRangeRestrictedUnsigned16BitInteger_392() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Read range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValueToARangeRestrictedUnsigned16BitInteger_393() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16uArgument; + rangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min value to a range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write min value to a range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedUnsigned16BitInteger_394() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16uArgument; + rangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:99U]; + [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-below-range value to a range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-below-range value to a range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedUnsigned16BitInteger_395() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16uArgument; + rangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:1001U]; + [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-above-range value to a range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-above-range value to a range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValueToARangeRestrictedUnsigned16BitInteger_396() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16uArgument; + rangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:65535U]; + [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max value to a range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write max value to a range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_397() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted unsigned 16-bit integer value has not changed: Error: %@", err); + } else { + NSLog(@"Verify range-restricted unsigned 16-bit integer value has not changed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValidValueToARangeRestrictedUnsigned16BitInteger_398() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16uArgument; + rangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:100U]; + [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write min valid value to a range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_399() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted unsigned 16-bit integer value is at min valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted unsigned 16-bit integer value is at min valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedUnsigned16BitInteger_400() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16uArgument; + rangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:1000U]; + [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write max valid value to a range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_401() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted unsigned 16-bit integer value is at max valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted unsigned 16-bit integer value is at max valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 1000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedUnsigned16BitInteger_402() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16uArgument; + rangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:500U]; + [cluster writeAttributeRangeRestrictedInt16uWithValue:rangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write middle valid value to a range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write middle valid value to a range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_403() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted unsigned 16-bit integer value is at mid valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted unsigned 16-bit integer value is at mid valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int16u", actualValue, 500U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadRangeRestrictedSigned8BitInteger_404() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Read range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -20)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValueToARangeRestrictedSigned8BitInteger_405() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8sArgument; + rangeRestrictedInt8sArgument = + [NSNumber numberWithChar:-128]; + [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min value to a range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write min value to a range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedSigned8BitInteger_406() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8sArgument; + rangeRestrictedInt8sArgument = + [NSNumber numberWithChar:-41]; + [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-below-range value to a range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-below-range value to a range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedSigned8BitInteger_407() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8sArgument; + rangeRestrictedInt8sArgument = + [NSNumber numberWithChar:51]; + [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-above-range value to a range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-above-range value to a range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValueToARangeRestrictedSigned8BitInteger_408() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8sArgument; + rangeRestrictedInt8sArgument = + [NSNumber numberWithChar:127]; + [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max value to a range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write max value to a range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueHasNotChanged_409() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted signed 8-bit integer value has not changed: Error: %@", err); + } else { + NSLog(@"Verify range-restricted signed 8-bit integer value has not changed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -20)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValidValueToARangeRestrictedSigned8BitInteger_410() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8sArgument; + rangeRestrictedInt8sArgument = + [NSNumber numberWithChar:-40]; + [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min valid value to a range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write min valid value to a range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMinValid_411() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted signed 8-bit integer value is at min valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted signed 8-bit integer value is at min valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, -40)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedSigned8BitInteger_412() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8sArgument; + rangeRestrictedInt8sArgument = + [NSNumber numberWithChar:50]; + [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max valid value to a range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write max valid value to a range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_413() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted signed 8-bit integer value is at max valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted signed 8-bit integer value is at max valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, 50)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedSigned8BitInteger_414() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt8sArgument; + rangeRestrictedInt8sArgument = + [NSNumber numberWithChar:6]; + [cluster writeAttributeRangeRestrictedInt8sWithValue:rangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write middle valid value to a range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write middle valid value to a range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedSigned8BitIntegerValueIsAtMidValid_415() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted signed 8-bit integer value is at mid valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted signed 8-bit integer value is at mid valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int8s", actualValue, 6)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadRangeRestrictedSigned16BitInteger_416() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Read range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -100)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValueToARangeRestrictedSigned16BitInteger_417() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16sArgument; + rangeRestrictedInt16sArgument = + [NSNumber numberWithShort:-32768]; + [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min value to a range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write min value to a range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustBelowRangeValueToARangeRestrictedSigned16BitInteger_418() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16sArgument; + rangeRestrictedInt16sArgument = + [NSNumber numberWithShort:-151]; + [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-below-range value to a range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-below-range value to a range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustAboveRangeValueToARangeRestrictedSigned16BitInteger_419() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16sArgument; + rangeRestrictedInt16sArgument = + [NSNumber numberWithShort:201]; + [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-above-range value to a range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-above-range value to a range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValueToARangeRestrictedSigned16BitInteger_420() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16sArgument; + rangeRestrictedInt16sArgument = + [NSNumber numberWithShort:32767]; + [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max value to a range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write max value to a range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueHasNotChanged_421() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted signed 16-bit integer value has not changed: Error: %@", err); + } else { + NSLog(@"Verify range-restricted signed 16-bit integer value has not changed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -100)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValidValueToARangeRestrictedSigned16BitInteger_422() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16sArgument; + rangeRestrictedInt16sArgument = + [NSNumber numberWithShort:-150]; + [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min valid value to a range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write min valid value to a range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMinValid_423() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted signed 16-bit integer value is at min valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted signed 16-bit integer value is at min valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, -150)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValidValueToARangeRestrictedSigned16BitInteger_424() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16sArgument; + rangeRestrictedInt16sArgument = + [NSNumber numberWithShort:200]; + [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max valid value to a range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write max valid value to a range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_425() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted signed 16-bit integer value is at max valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted signed 16-bit integer value is at max valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, 200)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMiddleValidValueToARangeRestrictedSigned16BitInteger_426() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id rangeRestrictedInt16sArgument; + rangeRestrictedInt16sArgument = + [NSNumber numberWithShort:7]; + [cluster writeAttributeRangeRestrictedInt16sWithValue:rangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write middle valid value to a range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write middle valid value to a range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyRangeRestrictedSigned16BitIntegerValueIsAtMidValid_427() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify range-restricted signed 16-bit integer value is at mid valid: Error: %@", err); + } else { + NSLog(@"Verify range-restricted signed 16-bit integer value is at mid valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("range_restricted_int16s", actualValue, 7)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadNullableRangeRestrictedUnsigned8BitInteger_428() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read nullable range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Read nullable range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 70U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedUnsigned8BitInteger_429() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8uArgument; + nullableRangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write min value to a nullable range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned8BitInteger_430() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8uArgument; + nullableRangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:19U]; + [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned8BitInteger_431() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8uArgument; + nullableRangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:101U]; + [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedUnsigned8BitInteger_432() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8uArgument; + nullableRangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:254U]; + [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write max value to a nullable range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueHasNotChanged_433() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value has not changed: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value has not changed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 70U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedUnsigned8BitInteger_434() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8uArgument; + nullableRangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:20U]; + [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write min valid value to a nullable range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMinValid_435() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at min valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at min valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 20U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedUnsigned8BitInteger_436() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8uArgument; + nullableRangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:100U]; + [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write max valid value to a nullable range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMaxValid_437() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at max valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at max valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned8BitInteger_438() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8uArgument; + nullableRangeRestrictedInt8uArgument = + [NSNumber numberWithUnsignedChar:50U]; + [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write middle valid value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write middle valid value to a nullable range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsAtMidValid_439() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at mid valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is at mid valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8u", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int8u", actualValue, 50U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedUnsigned8BitInteger_440() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8uArgument; + nullableRangeRestrictedInt8uArgument = nil; + [cluster writeAttributeNullableRangeRestrictedInt8uWithValue:nullableRangeRestrictedInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write null value to a nullable range-restricted unsigned 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write null value to a nullable range-restricted unsigned 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned8BitIntegerValueIsNull_441() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is null: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted unsigned 8-bit integer value is null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_range_restricted_int8u", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadNullableRangeRestrictedUnsigned16BitInteger_442() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read nullable range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Read nullable range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedUnsigned16BitInteger_443() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16uArgument; + nullableRangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write min value to a nullable range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedUnsigned16BitInteger_444() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16uArgument; + nullableRangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:99U]; + [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-below-range value to a nullable range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedUnsigned16BitInteger_445() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16uArgument; + nullableRangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:1001U]; + [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-above-range value to a nullable range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedUnsigned16BitInteger_446() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16uArgument; + nullableRangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:65534U]; + [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write max value to a nullable range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueHasNotChanged_447() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value has not changed: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value has not changed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedUnsigned16BitInteger_448() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16uArgument; + nullableRangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:100U]; + [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write min valid value to a nullable range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMinValid_449() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at min valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at min valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedUnsigned16BitInteger_450() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16uArgument; + nullableRangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:1000U]; + [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write max valid value to a nullable range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMaxValid_451() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at max valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at max valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 1000U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedUnsigned16BitInteger_452() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16uArgument; + nullableRangeRestrictedInt16uArgument = + [NSNumber numberWithUnsignedShort:500U]; + [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write middle valid value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write middle valid value to a nullable range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsAtMidValid_453() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at mid valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is at mid valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16u", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int16u", actualValue, 500U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedUnsigned16BitInteger_454() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16uArgument; + nullableRangeRestrictedInt16uArgument = nil; + [cluster writeAttributeNullableRangeRestrictedInt16uWithValue:nullableRangeRestrictedInt16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write null value to a nullable range-restricted unsigned 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write null value to a nullable range-restricted unsigned 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedUnsigned16BitIntegerValueIsNull_455() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is null: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted unsigned 16-bit integer value is null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_range_restricted_int16u", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadNullableRangeRestrictedSigned8BitInteger_456() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read nullable range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Read nullable range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -20)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedSigned8BitInteger_457() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8sArgument; + nullableRangeRestrictedInt8sArgument = + [NSNumber numberWithChar:-127]; + [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min value to a nullable range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write min value to a nullable range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned8BitInteger_458() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8sArgument; + nullableRangeRestrictedInt8sArgument = + [NSNumber numberWithChar:-41]; + [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-below-range value to a nullable range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-below-range value to a nullable range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned8BitInteger_459() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8sArgument; + nullableRangeRestrictedInt8sArgument = + [NSNumber numberWithChar:51]; + [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-above-range value to a nullable range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-above-range value to a nullable range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedSigned8BitInteger_460() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8sArgument; + nullableRangeRestrictedInt8sArgument = + [NSNumber numberWithChar:127]; + [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max value to a nullable range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write max value to a nullable range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueHasNotChanged_461() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted signed 8-bit integer value has not changed: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted signed 8-bit integer value has not changed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -20)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedSigned8BitInteger_462() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8sArgument; + nullableRangeRestrictedInt8sArgument = + [NSNumber numberWithChar:-40]; + [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write min valid value to a nullable range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMinValid_463() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at min valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at min valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, -40)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedSigned8BitInteger_464() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8sArgument; + nullableRangeRestrictedInt8sArgument = + [NSNumber numberWithChar:50]; + [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write max valid value to a nullable range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMaxValid_465() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at max valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at max valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, 50)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedSigned8BitInteger_466() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8sArgument; + nullableRangeRestrictedInt8sArgument = + [NSNumber numberWithChar:6]; + [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write middle valid value to a nullable range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write middle valid value to a nullable range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtMidValid_467() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at mid valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at mid valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int8s", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int8s", actualValue, 6)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedSigned8BitInteger_468() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt8sArgument; + nullableRangeRestrictedInt8sArgument = nil; + [cluster writeAttributeNullableRangeRestrictedInt8sWithValue:nullableRangeRestrictedInt8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write null value to a nullable range-restricted signed 8-bit integer: Error: %@", err); + } else { + NSLog(@"Write null value to a nullable range-restricted signed 8-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedSigned8BitIntegerValueIsAtNull_469() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at null: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted signed 8-bit integer value is at null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_range_restricted_int8s", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadNullableRangeRestrictedSigned16BitInteger_470() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read nullable range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Read nullable range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -100)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValueToANullableRangeRestrictedSigned16BitInteger_471() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16sArgument; + nullableRangeRestrictedInt16sArgument = + [NSNumber numberWithShort:-32767]; + [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min value to a nullable range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write min value to a nullable range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustBelowRangeValueToANullableRangeRestrictedSigned16BitInteger_472() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16sArgument; + nullableRangeRestrictedInt16sArgument = + [NSNumber numberWithShort:-151]; + [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-below-range value to a nullable range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-below-range value to a nullable range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteJustAboveRangeValueToANullableRangeRestrictedSigned16BitInteger_473() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16sArgument; + nullableRangeRestrictedInt16sArgument = + [NSNumber numberWithShort:201]; + [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write just-above-range value to a nullable range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write just-above-range value to a nullable range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValueToANullableRangeRestrictedSigned16BitInteger_474() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16sArgument; + nullableRangeRestrictedInt16sArgument = + [NSNumber numberWithShort:32767]; + [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max value to a nullable range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write max value to a nullable range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueHasNotChanged_475() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted signed 16-bit integer value has not changed: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted signed 16-bit integer value has not changed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -100)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMinValidValueToANullableRangeRestrictedSigned16BitInteger_476() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16sArgument; + nullableRangeRestrictedInt16sArgument = + [NSNumber numberWithShort:-150]; + [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write min valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write min valid value to a nullable range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMinValid_477() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at min valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at min valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, -150)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMaxValidValueToANullableRangeRestrictedSigned16BitInteger_478() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16sArgument; + nullableRangeRestrictedInt16sArgument = + [NSNumber numberWithShort:200]; + [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write max valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write max valid value to a nullable range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMaxValid_479() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at max valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at max valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, 200)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteMiddleValidValueToANullableRangeRestrictedSigned16BitInteger_480() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16sArgument; + nullableRangeRestrictedInt16sArgument = + [NSNumber numberWithShort:7]; + [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write middle valid value to a nullable range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write middle valid value to a nullable range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsAtMidValid_481() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at mid valid: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted signed 16-bit integer value is at mid valid: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_range_restricted_int16s", actualValue)); + VerifyOrReturn(CheckValue("nullable_range_restricted_int16s", actualValue, 7)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteNullValueToANullableRangeRestrictedSigned16BitInteger_482() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableRangeRestrictedInt16sArgument; + nullableRangeRestrictedInt16sArgument = nil; + [cluster writeAttributeNullableRangeRestrictedInt16sWithValue:nullableRangeRestrictedInt16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write null value to a nullable range-restricted signed 16-bit integer: Error: %@", err); + } else { + NSLog(@"Write null value to a nullable range-restricted signed 16-bit integer: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyNullableRangeRestrictedSigned16BitIntegerValueIsNull_483() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableRangeRestrictedInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify nullable range-restricted signed 16-bit integer value is null: Error: %@", err); + } else { + NSLog(@"Verify nullable range-restricted signed 16-bit integer value is null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_range_restricted_int16s", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeThatReturnsGeneralStatusOnWrite_484() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id generalErrorBooleanArgument; + generalErrorBooleanArgument = + [NSNumber numberWithBool:false]; + [cluster writeAttributeGeneralErrorBooleanWithValue:generalErrorBooleanArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute that returns general status on write: Error: %@", err); + } else { + NSLog(@"Write attribute that returns general status on write: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeThatReturnsClusterSpecificStatusOnWrite_485() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id clusterErrorBooleanArgument; + clusterErrorBooleanArgument = + [NSNumber numberWithBool:false]; + [cluster writeAttributeClusterErrorBooleanWithValue:clusterErrorBooleanArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute that returns cluster-specific status on write: Error: %@", err); + } else { + NSLog(@"Write attribute that returns cluster-specific status on write: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeThatReturnsGeneralStatusOnRead_486() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneralErrorBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute that returns general status on read: Error: %@", err); + } else { + NSLog(@"Read attribute that returns general status on read: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_DATA_TYPE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeThatReturnsClusterSpecificStatusOnRead_487() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterErrorBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"read attribute that returns cluster-specific status on read: Error: %@", err); + } else { + NSLog(@"read attribute that returns cluster-specific status on read: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAcceptedCommandListAttribute_488() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"read AcceptedCommandList attribute: Error: %@", err); + } else { + NSLog(@"read AcceptedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(20))); + VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); + VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); + VerifyOrReturn(CheckValue("", actualValue[2], 2UL)); + VerifyOrReturn(CheckValue("", actualValue[3], 4UL)); + VerifyOrReturn(CheckValue("", actualValue[4], 7UL)); + VerifyOrReturn(CheckValue("", actualValue[5], 8UL)); + VerifyOrReturn(CheckValue("", actualValue[6], 9UL)); + VerifyOrReturn(CheckValue("", actualValue[7], 10UL)); + VerifyOrReturn(CheckValue("", actualValue[8], 11UL)); + VerifyOrReturn(CheckValue("", actualValue[9], 12UL)); + VerifyOrReturn(CheckValue("", actualValue[10], 13UL)); + VerifyOrReturn(CheckValue("", actualValue[11], 14UL)); + VerifyOrReturn(CheckValue("", actualValue[12], 15UL)); + VerifyOrReturn(CheckValue("", actualValue[13], 17UL)); + VerifyOrReturn(CheckValue("", actualValue[14], 18UL)); + VerifyOrReturn(CheckValue("", actualValue[15], 19UL)); + VerifyOrReturn(CheckValue("", actualValue[16], 20UL)); + VerifyOrReturn(CheckValue("", actualValue[17], 21UL)); + VerifyOrReturn(CheckValue("", actualValue[18], 22UL)); + VerifyOrReturn(CheckValue("", actualValue[19], 23UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadGeneratedCommandListAttribute_489() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"read GeneratedCommandList attribute: Error: %@", err); + } else { + NSLog(@"read GeneratedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(10))); + VerifyOrReturn(CheckValue("", actualValue[0], 0UL)); + VerifyOrReturn(CheckValue("", actualValue[1], 1UL)); + VerifyOrReturn(CheckValue("", actualValue[2], 4UL)); + VerifyOrReturn(CheckValue("", actualValue[3], 5UL)); + VerifyOrReturn(CheckValue("", actualValue[4], 6UL)); + VerifyOrReturn(CheckValue("", actualValue[5], 8UL)); + VerifyOrReturn(CheckValue("", actualValue[6], 9UL)); + VerifyOrReturn(CheckValue("", actualValue[7], 10UL)); + VerifyOrReturn(CheckValue("", actualValue[8], 11UL)); + VerifyOrReturn(CheckValue("", actualValue[9], 12UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteStructTypedAttribute_490() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id structAttrArgument; + structAttrArgument = [[MTRUnitTestingClusterSimpleStruct alloc] init]; + ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).a = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).b = + [NSNumber numberWithBool:true]; + ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).c = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).d = + [[NSData alloc] initWithBytes:"abc" length:3]; + ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).e = @""; + ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).f = + [NSNumber numberWithUnsignedChar:17U]; + ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).g = + [NSNumber numberWithFloat:1.5f]; + ((MTRUnitTestingClusterSimpleStruct *) structAttrArgument).h = + [NSNumber numberWithDouble:3.14159265358979]; + + [cluster writeAttributeStructAttrWithValue:structAttrArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write struct-typed attribute: Error: %@", err); + } else { + NSLog(@"Write struct-typed attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadStructTypedAttribute_491() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStructAttrWithCompletion:^(MTRUnitTestingClusterSimpleStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read struct-typed attribute: Error: %@", err); + } else { + NSLog(@"Read struct-typed attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("a", ((MTRUnitTestingClusterSimpleStruct *) actualValue).a, 5U)); + VerifyOrReturn(CheckValue("b", ((MTRUnitTestingClusterSimpleStruct *) actualValue).b, true)); + VerifyOrReturn(CheckValue("c", ((MTRUnitTestingClusterSimpleStruct *) actualValue).c, 2U)); + VerifyOrReturn(CheckValueAsString("d", ((MTRUnitTestingClusterSimpleStruct *) actualValue).d, [[NSData alloc] initWithBytes:"abc" length:3])); + VerifyOrReturn(CheckValueAsString("e", ((MTRUnitTestingClusterSimpleStruct *) actualValue).e, @"")); + VerifyOrReturn(CheckValue("f", ((MTRUnitTestingClusterSimpleStruct *) actualValue).f, 17U)); + VerifyOrReturn(CheckValue("g", ((MTRUnitTestingClusterSimpleStruct *) actualValue).g, 1.5f)); + VerifyOrReturn(CheckValue("h", ((MTRUnitTestingClusterSimpleStruct *) actualValue).h, 3.14159265358979)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestConstraints : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestConstraints() + : TestCommandBridge("TestConstraints") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestConstraints() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestConstraints\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestConstraints\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Write attribute LIST With List of INT8U\n"); + err = TestWriteAttributeListWithListOfInt8u_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute LIST With Partial List of INT8U that should be in it\n"); + err = TestReadAttributeListWithPartialListOfInt8uThatShouldBeInIt_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute LIST With Partial List of INT8U that should not be included\n"); + err = TestReadAttributeListWithPartialListOfInt8uThatShouldNotBeIncluded_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Write attribute LIST Back to Default Value\n"); + err = TestWriteAttributeListBackToDefaultValue_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute BITMAP32 Default Value\n"); + err = TestReadAttributeBitmap32DefaultValue_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Write attribute BITMAP32 with MaskVal1 and MaskVal3\n"); + err = TestWriteAttributeBitmap32WithMaskVal1AndMaskVal3_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set\n"); + err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal2IsNotSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set\n"); + err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal1IsSet_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set\n"); + err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal3IsSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set\n"); + err = TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskval1AndMaskVal3AreSet_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Write attribute BITMAP32 with MaskVal1\n"); + err = TestWriteAttributeBitmap32WithMaskVal1_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set\n"); + err = TestReadAttributeBitmap32WithMaskVal1AndEnsureMaskval1OrMaskVal3AreSet_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Write attribute BITMAP32 Back to Default Value\n"); + err = TestWriteAttributeBitmap32BackToDefaultValue_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Write attribute INT32U Value\n"); + err = TestWriteAttributeInt32uValue_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Read attribute INT32U Value MinValue Constraints\n"); + err = TestReadAttributeInt32uValueMinValueConstraints_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute INT32U Value MaxValue Constraints\n"); + err = TestReadAttributeInt32uValueMaxValueConstraints_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Read attribute INT32U Value NotValue Constraints\n"); + err = TestReadAttributeInt32uValueNotValueConstraints_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Write attribute INT32U Value Back to Default Value\n"); + err = TestWriteAttributeInt32uValueBackToDefaultValue_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Write attribute CHAR_STRING Value\n"); + err = TestWriteAttributeCharStringValue_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Read attribute CHAR_STRING Value MinLength Constraints\n"); + err = TestReadAttributeCharStringValueMinLengthConstraints_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute CHAR_STRING Value MaxLength Constraints\n"); + err = TestReadAttributeCharStringValueMaxLengthConstraints_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Read attribute CHAR_STRING Value StartsWith Constraints\n"); + err = TestReadAttributeCharStringValueStartsWithConstraints_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute CHAR_STRING Value EndsWith Constraints\n"); + err = TestReadAttributeCharStringValueEndsWithConstraints_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Write attribute CHAR_STRING Value\n"); + err = TestWriteAttributeCharStringValue_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); + err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Write attribute CHAR_STRING Value\n"); + err = TestWriteAttributeCharStringValue_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); + err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Write attribute CHAR_STRING Value\n"); + err = TestWriteAttributeCharStringValue_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); + err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Write attribute CHAR_STRING Value with only digits\n"); + err = TestWriteAttributeCharStringValueWithOnlyDigits_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); + err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute CHAR_STRING Value with only non-letters\n"); + err = TestWriteAttributeCharStringValueWithOnlyNonLetters_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); + err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Write attribute CHAR_STRING Value with uppercase letters and symbols\n"); + err = TestWriteAttributeCharStringValueWithUppercaseLettersAndSymbols_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); + err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Write attribute CHAR_STRING Value with lowercase letters and symbols\n"); + err = TestWriteAttributeCharStringValueWithLowercaseLettersAndSymbols_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); + err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Write attribute CHAR_STRING Value which is empty\n"); + err = TestWriteAttributeCharStringValueWhichIsEmpty_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints\n"); + err = TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Write attribute CHAR_STRING Value\n"); + err = TestWriteAttributeCharStringValue_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute CHAR_STRING Value isHexString Constraints\n"); + err = TestReadAttributeCharStringValueIsHexStringConstraints_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute CHAR_STRING Value\n"); + err = TestWriteAttributeCharStringValue_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute CHAR_STRING Value isHexString Constraints\n"); + err = TestReadAttributeCharStringValueIsHexStringConstraints_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Write attribute CHAR_STRING Value Back to Default Value\n"); + err = TestWriteAttributeCharStringValueBackToDefaultValue_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Write attribute NULLABLE_CHAR_STRING Value\n"); + err = TestWriteAttributeNullableCharStringValue_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints\n"); + err = TestReadAttributeNullableCharStringValueMinLengthConstraints_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints\n"); + err = TestReadAttributeNullableCharStringValueMaxLengthConstraints_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Write attribute NULLABLE_CHAR_STRING Value Back to Default Value\n"); + err = TestWriteAttributeNullableCharStringValueBackToDefaultValue_48(); + break; + case 49: + ChipLogProgress(chipTool, " ***** Test Step 49 : Read attribute NULLABLE_INT8U Default Value\n"); + err = TestReadAttributeNullableInt8uDefaultValue_49(); + break; + case 50: + ChipLogProgress(chipTool, " ***** Test Step 50 : Write attribute NULLABLE_INT8U with a value\n"); + err = TestWriteAttributeNullableInt8uWithAValue_50(); + break; + case 51: + ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute NULLABLE_INT8U with a value\n"); + err = TestReadAttributeNullableInt8uWithAValue_51(); + break; + case 52: + ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute NULLABLE_INT8U without a value\n"); + err = TestWriteAttributeNullableInt8uWithoutAValue_52(); + break; + case 53: + ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute NULLABLE_INT8U with a value\n"); + err = TestReadAttributeNullableInt8uWithAValue_53(); + break; + case 54: + ChipLogProgress(chipTool, " ***** Test Step 54 : Write attribute NULLABLE_INT8U back to Default Value\n"); + err = TestWriteAttributeNullableInt8uBackToDefaultValue_54(); + break; + case 55: + ChipLogProgress(chipTool, " ***** Test Step 55 : Read attribute NULLABLE_OCTET_STRING Default Value\n"); + err = TestReadAttributeNullableOctetStringDefaultValue_55(); + break; + case 56: + ChipLogProgress(chipTool, " ***** Test Step 56 : Write attribute NULLABLE_OCTET_STRING\n"); + err = TestWriteAttributeNullableOctetString_56(); + break; + case 57: + ChipLogProgress(chipTool, " ***** Test Step 57 : Read attribute NULLABLE_OCTET_STRING\n"); + err = TestReadAttributeNullableOctetString_57(); + break; + case 58: + ChipLogProgress(chipTool, " ***** Test Step 58 : Write attribute NULLABLE_OCTET_STRING\n"); + err = TestWriteAttributeNullableOctetString_58(); + break; + case 59: + ChipLogProgress(chipTool, " ***** Test Step 59 : Read attribute NULLABLE_OCTET_STRING\n"); + err = TestReadAttributeNullableOctetString_59(); + break; + case 60: + ChipLogProgress(chipTool, " ***** Test Step 60 : Write attribute NULLABLE_OCTET_STRING back to Default Value\n"); + err = TestWriteAttributeNullableOctetStringBackToDefaultValue_60(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 49: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 50: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 51: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 52: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 53: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 54: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 55: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 56: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 57: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 58: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 59: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 60: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 61; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestWriteAttributeListWithListOfInt8u_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id listInt8uArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [NSNumber numberWithUnsignedChar:1U]; + temp_0[1] = + [NSNumber numberWithUnsignedChar:2U]; + temp_0[2] = + [NSNumber numberWithUnsignedChar:3U]; + temp_0[3] = + [NSNumber numberWithUnsignedChar:4U]; + listInt8uArgument = temp_0; + } + [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute LIST With List of INT8U: Error: %@", err); + } else { + NSLog(@"Write attribute LIST With List of INT8U: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeListWithPartialListOfInt8uThatShouldBeInIt_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute LIST With Partial List of INT8U that should be in it: Error: %@", err); + } else { + NSLog(@"Read attribute LIST With Partial List of INT8U that should be in it: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintContains("listInt8u", value, 2U)); + VerifyOrReturn(CheckConstraintContains("listInt8u", value, 3U)); + VerifyOrReturn(CheckConstraintContains("listInt8u", value, 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeListWithPartialListOfInt8uThatShouldNotBeIncluded_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeListInt8uWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute LIST With Partial List of INT8U that should not be included: Error: %@", err); + } else { + NSLog(@"Read attribute LIST With Partial List of INT8U that should not be included: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintExcludes("listInt8u", value, 0U)); + VerifyOrReturn(CheckConstraintExcludes("listInt8u", value, 5U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeListBackToDefaultValue_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id listInt8uArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + listInt8uArgument = temp_0; + } + [cluster writeAttributeListInt8uWithValue:listInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute LIST Back to Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute LIST Back to Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap32DefaultValue_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap32WithMaskVal1AndMaskVal3_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap32Argument; + bitmap32Argument = + [NSNumber numberWithUnsignedInt:5UL]; + [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP32 with MaskVal1 and MaskVal3: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP32 with MaskVal1 and MaskVal3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal2IsNotSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal2 is not set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal1IsSet_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal1 is set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskVal3IsSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure MaskVal3 is set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndMaskVal3AndEnsureMaskval1AndMaskVal3AreSet_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 with MaskVal1 and MaskVal3 and ensure Maskval1 and MaskVal3 are set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap32", actualValue, 5UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap32WithMaskVal1_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap32Argument; + bitmap32Argument = + [NSNumber numberWithUnsignedInt:1UL]; + [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP32 with MaskVal1: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP32 with MaskVal1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap32WithMaskVal1AndEnsureMaskval1OrMaskVal3AreSet_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 with MaskVal1 and ensure Maskval1 or MaskVal3 are set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap32", actualValue, 1UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap32BackToDefaultValue_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap32Argument; + bitmap32Argument = + [NSNumber numberWithUnsignedInt:0UL]; + [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP32 Back to Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP32 Back to Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt32uValue_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int32uArgument; + int32uArgument = + [NSNumber numberWithUnsignedInt:5UL]; + [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT32U Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT32U Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32uValueMinValueConstraints_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32U Value MinValue Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute INT32U Value MinValue Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("int32u", [value unsignedIntValue], 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32uValueMaxValueConstraints_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32U Value MaxValue Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute INT32U Value MaxValue Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMaxValue("int32u", [value unsignedIntValue], 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32uValueNotValueConstraints_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32U Value NotValue Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute INT32U Value NotValue Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("int32u", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt32uValueBackToDefaultValue_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int32uArgument; + int32uArgument = + [NSNumber numberWithUnsignedInt:0UL]; + [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT32U Value Back to Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT32U Value Back to Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValue_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"** Test **"; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueMinLengthConstraints_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value MinLength Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value MinLength Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinLength("charString", value, 5)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueMaxLengthConstraints_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value MaxLength Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value MaxLength Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMaxLength("charString", value, 20)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueStartsWithConstraints_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value StartsWith Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value StartsWith Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintStartsWith("charString", value, "**")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueEndsWithConstraints_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value EndsWith Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value EndsWith Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintEndsWith("charString", value, "**")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValue_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"lowercase"; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); + VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValue_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"UPPERCASE"; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); + VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValue_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"lowUPPER"; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); + VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValueWithOnlyDigits_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"1234567890"; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value with only digits: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value with only digits: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); + VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValueWithOnlyNonLetters_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"12.4,76:"; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value with only non-letters: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value with only non-letters: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); + VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValueWithUppercaseLettersAndSymbols_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"ABC;.* "; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value with uppercase letters and symbols: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value with uppercase letters and symbols: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); + VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, false)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValueWithLowercaseLettersAndSymbols_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"abc;.* "; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value with lowercase letters and symbols: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value with lowercase letters and symbols: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, false)); + VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValueWhichIsEmpty_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @""; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value which is empty: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value which is empty: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueIsLowerCaseIsUpperCaseConstraints_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value isLowerCase/isUpperCase Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintIsUpperCase("charString", value, true)); + VerifyOrReturn(CheckConstraintIsLowerCase("charString", value, true)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValue_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"ABCDEF012V"; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueIsHexStringConstraints_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintIsHexString("charString", value, false)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValue_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"ABCDEF0123"; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringValueIsHexStringConstraints_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute CHAR_STRING Value isHexString Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintIsHexString("charString", value, true)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringValueBackToDefaultValue_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @""; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute CHAR_STRING Value Back to Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute CHAR_STRING Value Back to Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableCharStringValue_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableCharStringArgument; + nullableCharStringArgument = nil; + [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_CHAR_STRING Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_CHAR_STRING Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableCharStringValueMinLengthConstraints_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MinLength Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMinLength("nullableCharString", value, 5)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableCharStringValueMaxLengthConstraints_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_CHAR_STRING Value MaxLength Constraints: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintMaxLength("nullableCharString", value, 20)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableCharStringValueBackToDefaultValue_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableCharStringArgument; + nullableCharStringArgument = @""; + [cluster writeAttributeNullableCharStringWithValue:nullableCharStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_CHAR_STRING Value Back to Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_CHAR_STRING Value Back to Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uDefaultValue_49() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_int8u", actualValue)); + VerifyOrReturn(CheckValue("nullable_int8u", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8uWithAValue_50() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8uArgument; + nullableInt8uArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8U with a value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8U with a value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uWithAValue_51() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U with a value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U with a value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8uWithoutAValue_52() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8uArgument; + nullableInt8uArgument = nil; + [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8U without a value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8U without a value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableInt8uWithAValue_53() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_INT8U with a value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_INT8U with a value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableInt8uBackToDefaultValue_54() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableInt8uArgument; + nullableInt8uArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeNullableInt8uWithValue:nullableInt8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_INT8U back to Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_INT8U back to Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableOctetStringDefaultValue_55() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_OCTET_STRING Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_octet_string", actualValue)); + VerifyOrReturn(CheckValueAsString("nullable_octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableOctetString_56() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableOctetStringArgument; + nullableOctetStringArgument = + [[NSData alloc] initWithBytes:"TestValue" length:9]; + [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableOctetString_57() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableOctetString_58() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableOctetStringArgument; + nullableOctetStringArgument = nil; + [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableOctetString_59() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute NULLABLE_OCTET_STRING: Error: %@", err); + } else { + NSLog(@"Read attribute NULLABLE_OCTET_STRING: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableOctetStringBackToDefaultValue_60() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableOctetStringArgument; + nullableOctetStringArgument = + [[NSData alloc] initWithBytes:"" length:0]; + [cluster writeAttributeNullableOctetStringWithValue:nullableOctetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute NULLABLE_OCTET_STRING back to Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute NULLABLE_OCTET_STRING back to Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestDelayCommands : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestDelayCommands() + : TestCommandBridge("TestDelayCommands") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestDelayCommands() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestDelayCommands\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestDelayCommands\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Wait 100ms\n"); + err = TestWait100ms_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestWait100ms_1() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } +}; + +class TestLogCommands : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestLogCommands() + : TestCommandBridge("TestLogCommands") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestLogCommands() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestLogCommands\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestLogCommands\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Log a simple message\n"); + err = TestLogASimpleMessage_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Do a simple user prompt message\n"); + err = TestDoASimpleUserPromptMessage_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestLogASimpleMessage_1() + { + + chip::app::Clusters::LogCommands::Commands::Log::Type value; + value.message = chip::Span("This is a simple messagegarbage: not in length on purpose", 24); + return Log("alpha", value); + } + + CHIP_ERROR TestDoASimpleUserPromptMessage_2() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("This is a simple messagegarbage: not in length on purpose", 24); + return UserPrompt("alpha", value); + } +}; + +class TestSaveAs : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestSaveAs() + : TestCommandBridge("TestSaveAs") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestSaveAs() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestSaveAs\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestSaveAs\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Add Arguments Command\n"); + err = TestSendTestAddArgumentsCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Add Arguments Command\n"); + err = TestSendTestAddArgumentsCommand_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Send Test Add Arguments Command\n"); + err = TestSendTestAddArgumentsCommand_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute BOOLEAN Default Value\n"); + err = TestReadAttributeBooleanDefaultValue_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Write attribute BOOLEAN Not Default Value\n"); + err = TestWriteAttributeBooleanNotDefaultValue_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute BOOLEAN Not Default Value\n"); + err = TestReadAttributeBooleanNotDefaultValue_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Write attribute BOOLEAN DefaultValue\n"); + err = TestWriteAttributeBooleanDefaultValue_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Read attribute BOOLEAN False\n"); + err = TestReadAttributeBooleanFalse_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Read attribute BITMAP8 Default Value\n"); + err = TestReadAttributeBitmap8DefaultValue_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Write attribute BITMAP8 Not Default Value\n"); + err = TestWriteAttributeBitmap8NotDefaultValue_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Read attribute BITMAP8 Not Default Value\n"); + err = TestReadAttributeBitmap8NotDefaultValue_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Write attribute BITMAP8 Default Value\n"); + err = TestWriteAttributeBitmap8DefaultValue_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Read attribute BITMAP8 Default Value\n"); + err = TestReadAttributeBitmap8DefaultValue_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Read attribute BITMAP16 Default Value\n"); + err = TestReadAttributeBitmap16DefaultValue_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Write attribute BITMAP16 Not Default Value\n"); + err = TestWriteAttributeBitmap16NotDefaultValue_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Read attribute BITMAP16 Not Default Value\n"); + err = TestReadAttributeBitmap16NotDefaultValue_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Write attribute BITMAP16 Default Value\n"); + err = TestWriteAttributeBitmap16DefaultValue_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Read attribute BITMAP16 Default Value\n"); + err = TestReadAttributeBitmap16DefaultValue_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Read attribute BITMAP32 Default Value\n"); + err = TestReadAttributeBitmap32DefaultValue_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Write attribute BITMAP32 Not Default Value\n"); + err = TestWriteAttributeBitmap32NotDefaultValue_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Read attribute BITMAP32 Not Default Value\n"); + err = TestReadAttributeBitmap32NotDefaultValue_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Write attribute BITMAP32 Default Value\n"); + err = TestWriteAttributeBitmap32DefaultValue_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Read attribute BITMAP32 Default Value\n"); + err = TestReadAttributeBitmap32DefaultValue_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Read attribute BITMAP64 Default Value\n"); + err = TestReadAttributeBitmap64DefaultValue_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Write attribute BITMAP64 Not Default Value\n"); + err = TestWriteAttributeBitmap64NotDefaultValue_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Read attribute BITMAP64 Default Value\n"); + err = TestReadAttributeBitmap64DefaultValue_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Write attribute BITMAP64 Default Value\n"); + err = TestWriteAttributeBitmap64DefaultValue_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Read attribute BITMAP64 Default Value\n"); + err = TestReadAttributeBitmap64DefaultValue_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Read attribute INT8U Default Value\n"); + err = TestReadAttributeInt8uDefaultValue_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Write attribute INT8U Not Default Value\n"); + err = TestWriteAttributeInt8uNotDefaultValue_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Read attribute INT8U Not Default Value\n"); + err = TestReadAttributeInt8uNotDefaultValue_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Write attribute INT8U Default Value\n"); + err = TestWriteAttributeInt8uDefaultValue_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Read attribute INT8U Default Value\n"); + err = TestReadAttributeInt8uDefaultValue_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Read attribute INT16U Default Value\n"); + err = TestReadAttributeInt16uDefaultValue_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Write attribute INT16U Not Default Value\n"); + err = TestWriteAttributeInt16uNotDefaultValue_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Read attribute INT16U Not Default Value\n"); + err = TestReadAttributeInt16uNotDefaultValue_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Write attribute INT16U Default Value\n"); + err = TestWriteAttributeInt16uDefaultValue_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Read attribute INT16U Default Value\n"); + err = TestReadAttributeInt16uDefaultValue_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Read attribute INT32U Default Value\n"); + err = TestReadAttributeInt32uDefaultValue_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Write attribute INT32U Not Default Value\n"); + err = TestWriteAttributeInt32uNotDefaultValue_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Read attribute INT32U Not Default Value\n"); + err = TestReadAttributeInt32uNotDefaultValue_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Write attribute INT32U Default Value\n"); + err = TestWriteAttributeInt32uDefaultValue_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Read attribute INT32U Default Value\n"); + err = TestReadAttributeInt32uDefaultValue_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Read attribute INT64U Default Value\n"); + err = TestReadAttributeInt64uDefaultValue_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Write attribute INT64U Not Default Value\n"); + err = TestWriteAttributeInt64uNotDefaultValue_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Read attribute INT64U Not Default Value\n"); + err = TestReadAttributeInt64uNotDefaultValue_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Write attribute INT64U Default Value\n"); + err = TestWriteAttributeInt64uDefaultValue_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Read attribute INT64U Default Value\n"); + err = TestReadAttributeInt64uDefaultValue_48(); + break; + case 49: + ChipLogProgress(chipTool, " ***** Test Step 49 : Read attribute INT8S Default Value\n"); + err = TestReadAttributeInt8sDefaultValue_49(); + break; + case 50: + ChipLogProgress(chipTool, " ***** Test Step 50 : Write attribute INT8S Not Default Value\n"); + err = TestWriteAttributeInt8sNotDefaultValue_50(); + break; + case 51: + ChipLogProgress(chipTool, " ***** Test Step 51 : Read attribute INT8S Not Default Value\n"); + err = TestReadAttributeInt8sNotDefaultValue_51(); + break; + case 52: + ChipLogProgress(chipTool, " ***** Test Step 52 : Write attribute INT8S Default Value\n"); + err = TestWriteAttributeInt8sDefaultValue_52(); + break; + case 53: + ChipLogProgress(chipTool, " ***** Test Step 53 : Read attribute INT8S Default Value\n"); + err = TestReadAttributeInt8sDefaultValue_53(); + break; + case 54: + ChipLogProgress(chipTool, " ***** Test Step 54 : Read attribute INT16S Default Value\n"); + err = TestReadAttributeInt16sDefaultValue_54(); + break; + case 55: + ChipLogProgress(chipTool, " ***** Test Step 55 : Write attribute INT16S Not Default Value\n"); + err = TestWriteAttributeInt16sNotDefaultValue_55(); + break; + case 56: + ChipLogProgress(chipTool, " ***** Test Step 56 : Read attribute INT16S Not Default Value\n"); + err = TestReadAttributeInt16sNotDefaultValue_56(); + break; + case 57: + ChipLogProgress(chipTool, " ***** Test Step 57 : Write attribute INT16S Default Value\n"); + err = TestWriteAttributeInt16sDefaultValue_57(); + break; + case 58: + ChipLogProgress(chipTool, " ***** Test Step 58 : Read attribute INT16S Default Value\n"); + err = TestReadAttributeInt16sDefaultValue_58(); + break; + case 59: + ChipLogProgress(chipTool, " ***** Test Step 59 : Read attribute INT32S Default Value\n"); + err = TestReadAttributeInt32sDefaultValue_59(); + break; + case 60: + ChipLogProgress(chipTool, " ***** Test Step 60 : Write attribute INT32S Not Default Value\n"); + err = TestWriteAttributeInt32sNotDefaultValue_60(); + break; + case 61: + ChipLogProgress(chipTool, " ***** Test Step 61 : Read attribute INT32S Not Default Value\n"); + err = TestReadAttributeInt32sNotDefaultValue_61(); + break; + case 62: + ChipLogProgress(chipTool, " ***** Test Step 62 : Write attribute INT32S Default Value\n"); + err = TestWriteAttributeInt32sDefaultValue_62(); + break; + case 63: + ChipLogProgress(chipTool, " ***** Test Step 63 : Read attribute INT32S Default Value\n"); + err = TestReadAttributeInt32sDefaultValue_63(); + break; + case 64: + ChipLogProgress(chipTool, " ***** Test Step 64 : Read attribute INT64S Default Value\n"); + err = TestReadAttributeInt64sDefaultValue_64(); + break; + case 65: + ChipLogProgress(chipTool, " ***** Test Step 65 : Write attribute INTS Not Default Value\n"); + err = TestWriteAttributeIntsNotDefaultValue_65(); + break; + case 66: + ChipLogProgress(chipTool, " ***** Test Step 66 : Read attribute INT64S Not Default Value\n"); + err = TestReadAttributeInt64sNotDefaultValue_66(); + break; + case 67: + ChipLogProgress(chipTool, " ***** Test Step 67 : Write attribute INT64S Default Value\n"); + err = TestWriteAttributeInt64sDefaultValue_67(); + break; + case 68: + ChipLogProgress(chipTool, " ***** Test Step 68 : Read attribute INT64S Default Value\n"); + err = TestReadAttributeInt64sDefaultValue_68(); + break; + case 69: + ChipLogProgress(chipTool, " ***** Test Step 69 : Read attribute ENUM8 Default Value\n"); + err = TestReadAttributeEnum8DefaultValue_69(); + break; + case 70: + ChipLogProgress(chipTool, " ***** Test Step 70 : Write attribute ENUM8 Not Default Value\n"); + err = TestWriteAttributeEnum8NotDefaultValue_70(); + break; + case 71: + ChipLogProgress(chipTool, " ***** Test Step 71 : Read attribute ENUM8 Not Default Value\n"); + err = TestReadAttributeEnum8NotDefaultValue_71(); + break; + case 72: + ChipLogProgress(chipTool, " ***** Test Step 72 : Write attribute ENUM8 Default Value\n"); + err = TestWriteAttributeEnum8DefaultValue_72(); + break; + case 73: + ChipLogProgress(chipTool, " ***** Test Step 73 : Read attribute ENUM8 Default Value\n"); + err = TestReadAttributeEnum8DefaultValue_73(); + break; + case 74: + ChipLogProgress(chipTool, " ***** Test Step 74 : Read attribute ENUM16 Default Value\n"); + err = TestReadAttributeEnum16DefaultValue_74(); + break; + case 75: + ChipLogProgress(chipTool, " ***** Test Step 75 : Write attribute ENUM16 Not Default Value\n"); + err = TestWriteAttributeEnum16NotDefaultValue_75(); + break; + case 76: + ChipLogProgress(chipTool, " ***** Test Step 76 : Read attribute ENUM16 Not Default Value\n"); + err = TestReadAttributeEnum16NotDefaultValue_76(); + break; + case 77: + ChipLogProgress(chipTool, " ***** Test Step 77 : Write attribute ENUM16 Default Value\n"); + err = TestWriteAttributeEnum16DefaultValue_77(); + break; + case 78: + ChipLogProgress(chipTool, " ***** Test Step 78 : Read attribute ENUM16 Default Value\n"); + err = TestReadAttributeEnum16DefaultValue_78(); + break; + case 79: + ChipLogProgress(chipTool, " ***** Test Step 79 : Read attribute EPOCH_US Default Value\n"); + err = TestReadAttributeEpochUsDefaultValue_79(); + break; + case 80: + ChipLogProgress(chipTool, " ***** Test Step 80 : Write attribute EPOCH_US Not Default Value\n"); + err = TestWriteAttributeEpochUsNotDefaultValue_80(); + break; + case 81: + ChipLogProgress(chipTool, " ***** Test Step 81 : Read attribute EPOCH_US Not Default Value\n"); + err = TestReadAttributeEpochUsNotDefaultValue_81(); + break; + case 82: + ChipLogProgress(chipTool, " ***** Test Step 82 : Write attribute EPOCH_US Default Value\n"); + err = TestWriteAttributeEpochUsDefaultValue_82(); + break; + case 83: + ChipLogProgress(chipTool, " ***** Test Step 83 : Read attribute EPOCH_US Default Value\n"); + err = TestReadAttributeEpochUsDefaultValue_83(); + break; + case 84: + ChipLogProgress(chipTool, " ***** Test Step 84 : Read attribute EPOCH_S Default Value\n"); + err = TestReadAttributeEpochSDefaultValue_84(); + break; + case 85: + ChipLogProgress(chipTool, " ***** Test Step 85 : Write attribute EPOCH_S Not Default Value\n"); + err = TestWriteAttributeEpochSNotDefaultValue_85(); + break; + case 86: + ChipLogProgress(chipTool, " ***** Test Step 86 : Read attribute EPOCH_S Not Default Value\n"); + err = TestReadAttributeEpochSNotDefaultValue_86(); + break; + case 87: + ChipLogProgress(chipTool, " ***** Test Step 87 : Write attribute EPOCH_S Default Value\n"); + err = TestWriteAttributeEpochSDefaultValue_87(); + break; + case 88: + ChipLogProgress(chipTool, " ***** Test Step 88 : Read attribute EPOCH_S Default Value\n"); + err = TestReadAttributeEpochSDefaultValue_88(); + break; + case 89: + ChipLogProgress(chipTool, " ***** Test Step 89 : Read attribute vendor_id Default Value\n"); + err = TestReadAttributeVendorIdDefaultValue_89(); + break; + case 90: + ChipLogProgress(chipTool, " ***** Test Step 90 : Write attribute vendor_id Not Default Value\n"); + err = TestWriteAttributeVendorIdNotDefaultValue_90(); + break; + case 91: + ChipLogProgress(chipTool, " ***** Test Step 91 : Read attribute vendor_id Not Default Value\n"); + err = TestReadAttributeVendorIdNotDefaultValue_91(); + break; + case 92: + ChipLogProgress(chipTool, " ***** Test Step 92 : Write attribute vendor_id Default Value\n"); + err = TestWriteAttributeVendorIdDefaultValue_92(); + break; + case 93: + ChipLogProgress(chipTool, " ***** Test Step 93 : Read attribute vendor_id Default Value\n"); + err = TestReadAttributeVendorIdDefaultValue_93(); + break; + case 94: + ChipLogProgress(chipTool, " ***** Test Step 94 : Read attribute char_string Default Value\n"); + err = TestReadAttributeCharStringDefaultValue_94(); + break; + case 95: + ChipLogProgress(chipTool, " ***** Test Step 95 : Read attribute char_string Default Value and compare to saved value\n"); + err = TestReadAttributeCharStringDefaultValueAndCompareToSavedValue_95(); + break; + case 96: + ChipLogProgress(chipTool, " ***** Test Step 96 : Write attribute char_string Not Default Value\n"); + err = TestWriteAttributeCharStringNotDefaultValue_96(); + break; + case 97: + ChipLogProgress(chipTool, " ***** Test Step 97 : Read attribute char_string Not Default Value\n"); + err = TestReadAttributeCharStringNotDefaultValue_97(); + break; + case 98: + ChipLogProgress(chipTool, " ***** Test Step 98 : Read attribute char_string Not Default Value and compare to saved value\n"); + err = TestReadAttributeCharStringNotDefaultValueAndCompareToSavedValue_98(); + break; + case 99: + ChipLogProgress(chipTool, " ***** Test Step 99 : Write attribute char_string Not Default Value from saved value\n"); + err = TestWriteAttributeCharStringNotDefaultValueFromSavedValue_99(); + break; + case 100: + ChipLogProgress(chipTool, " ***** Test Step 100 : Read attribute char_string Not Default Value and compare to expected value\n"); + err = TestReadAttributeCharStringNotDefaultValueAndCompareToExpectedValue_100(); + break; + case 101: + ChipLogProgress(chipTool, " ***** Test Step 101 : Write attribute char_string Default Value\n"); + err = TestWriteAttributeCharStringDefaultValue_101(); + break; + case 102: + ChipLogProgress(chipTool, " ***** Test Step 102 : Read attribute octet_string Default Value\n"); + err = TestReadAttributeOctetStringDefaultValue_102(); + break; + case 103: + ChipLogProgress(chipTool, " ***** Test Step 103 : Read attribute octet_string Default Value and compare to saved value\n"); + err = TestReadAttributeOctetStringDefaultValueAndCompareToSavedValue_103(); + break; + case 104: + ChipLogProgress(chipTool, " ***** Test Step 104 : Write attribute octet_string Not Default Value\n"); + err = TestWriteAttributeOctetStringNotDefaultValue_104(); + break; + case 105: + ChipLogProgress(chipTool, " ***** Test Step 105 : Read attribute octet_string Not Default Value\n"); + err = TestReadAttributeOctetStringNotDefaultValue_105(); + break; + case 106: + ChipLogProgress(chipTool, " ***** Test Step 106 : Read attribute octet_string Not Default Value and compare to saved value\n"); + err = TestReadAttributeOctetStringNotDefaultValueAndCompareToSavedValue_106(); + break; + case 107: + ChipLogProgress(chipTool, " ***** Test Step 107 : Write attribute octet_string Not Default Value from saved value\n"); + err = TestWriteAttributeOctetStringNotDefaultValueFromSavedValue_107(); + break; + case 108: + ChipLogProgress(chipTool, " ***** Test Step 108 : Read attribute octet_string Not Default Value and compare to expected value\n"); + err = TestReadAttributeOctetStringNotDefaultValueAndCompareToExpectedValue_108(); + break; + case 109: + ChipLogProgress(chipTool, " ***** Test Step 109 : Write attribute octet_string Default Value\n"); + err = TestWriteAttributeOctetStringDefaultValue_109(); + break; + case 110: + ChipLogProgress(chipTool, " ***** Test Step 110 : Read attribute nullable_boolean Default Value\n"); + err = TestReadAttributeNullableBooleanDefaultValue_110(); + break; + case 111: + ChipLogProgress(chipTool, " ***** Test Step 111 : Write attribute nullable_boolean to null\n"); + err = TestWriteAttributeNullableBooleanToNull_111(); + break; + case 112: + ChipLogProgress(chipTool, " ***** Test Step 112 : Read attribute nullable_boolean null Value\n"); + err = TestReadAttributeNullableBooleanNullValue_112(); + break; + case 113: + ChipLogProgress(chipTool, " ***** Test Step 113 : Read attribute nullable_boolean null Value again and compare it to the previously saved value\n"); + err = TestReadAttributeNullableBooleanNullValueAgainAndCompareItToThePreviouslySavedValue_113(); + break; + case 114: + ChipLogProgress(chipTool, " ***** Test Step 114 : Write attribute nullable_boolean Default Value\n"); + err = TestWriteAttributeNullableBooleanDefaultValue_114(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 49: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 50: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 51: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 52: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 53: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 54: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 55: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 56: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 57: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 58: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 59: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 60: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 61: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 62: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 63: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 64: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 65: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 66: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 67: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 68: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 69: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 70: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 71: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 72: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 73: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 74: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 75: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 76: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 77: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 78: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 79: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 80: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 81: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 82: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 83: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 84: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 85: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 86: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 87: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 88: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 89: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 90: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 91: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 92: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 93: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 94: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 95: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 96: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 97: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 98: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 99: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 100: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 101: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 102: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 103: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 104: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 105: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 106: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 107: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 108: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 109: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 110: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 111: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 112: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 113: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 114: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 115; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull TestAddArgumentDefaultValue; + + CHIP_ERROR TestSendTestAddArgumentsCommand_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; + params.arg1 = + [NSNumber numberWithUnsignedChar:3U]; + params.arg2 = + [NSNumber numberWithUnsignedChar:17U]; + [cluster testAddArgumentsWithParams:params completion: + ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Add Arguments Command: Error: %@", err); + } else { + NSLog(@"Send Test Add Arguments Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.returnValue; + VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); + } + { + TestAddArgumentDefaultValue = values.returnValue; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestAddArgumentsCommand_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; + params.arg1 = + [NSNumber numberWithUnsignedChar:3U]; + params.arg2 = + [NSNumber numberWithUnsignedChar:17U]; + [cluster testAddArgumentsWithParams:params completion: + ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Add Arguments Command: Error: %@", err); + } else { + NSLog(@"Send Test Add Arguments Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.returnValue; + VerifyOrReturn(CheckValue("returnValue", actualValue, TestAddArgumentDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestAddArgumentsCommand_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; + params.arg1 = + [NSNumber numberWithUnsignedChar:3U]; + params.arg2 = + [TestAddArgumentDefaultValue copy]; + [cluster testAddArgumentsWithParams:params completion: + ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Add Arguments Command: Error: %@", err); + } else { + NSLog(@"Send Test Add Arguments Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("returnValue", values.returnValue, TestAddArgumentDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeBooleanDefaultValue; + + CHIP_ERROR TestReadAttributeBooleanDefaultValue_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BOOLEAN Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BOOLEAN Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("boolean", actualValue, 0)); + } + { + readAttributeBooleanDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBooleanNotDefaultValue_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id booleanArgument; + booleanArgument = + [NSNumber numberWithBool:1]; + [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BOOLEAN Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute BOOLEAN Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBooleanNotDefaultValue_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BOOLEAN Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BOOLEAN Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("boolean", value, readAttributeBooleanDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBooleanDefaultValue_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id booleanArgument; + booleanArgument = + [readAttributeBooleanDefaultValue copy]; + [cluster writeAttributeBooleanWithValue:booleanArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BOOLEAN DefaultValue: Error: %@", err); + } else { + NSLog(@"Write attribute BOOLEAN DefaultValue: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBooleanFalse_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BOOLEAN False: Error: %@", err); + } else { + NSLog(@"Read attribute BOOLEAN False: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("boolean", actualValue, readAttributeBooleanDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeBitmap8DefaultValue; + + CHIP_ERROR TestReadAttributeBitmap8DefaultValue_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP8 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, 0U)); + } + { + readAttributeBitmap8DefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap8NotDefaultValue_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap8Argument; + bitmap8Argument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP8 Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP8 Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap8NotDefaultValue_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP8 Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP8 Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("bitmap8", value, readAttributeBitmap8DefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap8DefaultValue_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap8Argument; + bitmap8Argument = + [readAttributeBitmap8DefaultValue copy]; + [cluster writeAttributeBitmap8WithValue:bitmap8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP8 Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP8 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap8DefaultValue_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP8 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP8 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap8", actualValue, readAttributeBitmap8DefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeBitmap16DefaultValue; + + CHIP_ERROR TestReadAttributeBitmap16DefaultValue_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP16 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap16", actualValue, 0U)); + } + { + readAttributeBitmap16DefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap16NotDefaultValue_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap16Argument; + bitmap16Argument = + [NSNumber numberWithUnsignedShort:1U]; + [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP16 Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP16 Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap16NotDefaultValue_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP16 Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP16 Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("bitmap16", value, readAttributeBitmap16DefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap16DefaultValue_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap16Argument; + bitmap16Argument = + [readAttributeBitmap16DefaultValue copy]; + [cluster writeAttributeBitmap16WithValue:bitmap16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP16 Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP16 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap16DefaultValue_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP16 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP16 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap16", actualValue, readAttributeBitmap16DefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeBitmap32DefaultValue; + + CHIP_ERROR TestReadAttributeBitmap32DefaultValue_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap32", actualValue, 0UL)); + } + { + readAttributeBitmap32DefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap32NotDefaultValue_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap32Argument; + bitmap32Argument = + [NSNumber numberWithUnsignedInt:1UL]; + [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP32 Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP32 Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap32NotDefaultValue_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("bitmap32", value, readAttributeBitmap32DefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap32DefaultValue_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap32Argument; + bitmap32Argument = + [readAttributeBitmap32DefaultValue copy]; + [cluster writeAttributeBitmap32WithValue:bitmap32Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP32 Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP32 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap32DefaultValue_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap32WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP32 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP32 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap32", actualValue, readAttributeBitmap32DefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeBitmap64DefaultValue; + + CHIP_ERROR TestReadAttributeBitmap64DefaultValue_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP64 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap64", actualValue, 0ULL)); + } + { + readAttributeBitmap64DefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap64NotDefaultValue_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap64Argument; + bitmap64Argument = + [NSNumber numberWithUnsignedLongLong:1ULL]; + [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP64 Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP64 Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap64DefaultValue_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP64 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("bitmap64", value, readAttributeBitmap64DefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeBitmap64DefaultValue_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bitmap64Argument; + bitmap64Argument = + [readAttributeBitmap64DefaultValue copy]; + [cluster writeAttributeBitmap64WithValue:bitmap64Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute BITMAP64 Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute BITMAP64 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeBitmap64DefaultValue_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBitmap64WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute BITMAP64 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute BITMAP64 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("bitmap64", actualValue, readAttributeBitmap64DefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeInt8uDefaultValue; + + CHIP_ERROR TestReadAttributeInt8uDefaultValue_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int8u", actualValue, 0U)); + } + { + readAttributeInt8uDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt8uNotDefaultValue_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int8uArgument; + int8uArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT8U Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT8U Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt8uNotDefaultValue_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8U Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8U Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("int8u", value, readAttributeInt8uDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt8uDefaultValue_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int8uArgument; + int8uArgument = + [readAttributeInt8uDefaultValue copy]; + [cluster writeAttributeInt8uWithValue:int8uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT8U Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT8U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt8uDefaultValue_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int8u", actualValue, readAttributeInt8uDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeInt16uDefaultValue; + + CHIP_ERROR TestReadAttributeInt16uDefaultValue_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int16u", actualValue, 0U)); + } + { + readAttributeInt16uDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt16uNotDefaultValue_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int16uArgument; + int16uArgument = + [NSNumber numberWithUnsignedShort:1U]; + [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT16U Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT16U Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt16uNotDefaultValue_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16U Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16U Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("int16u", value, readAttributeInt16uDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt16uDefaultValue_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int16uArgument; + int16uArgument = + [readAttributeInt16uDefaultValue copy]; + [cluster writeAttributeInt16uWithValue:int16uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT16U Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT16U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt16uDefaultValue_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int16u", actualValue, readAttributeInt16uDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeInt32uDefaultValue; + + CHIP_ERROR TestReadAttributeInt32uDefaultValue_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int32u", actualValue, 0UL)); + } + { + readAttributeInt32uDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt32uNotDefaultValue_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int32uArgument; + int32uArgument = + [NSNumber numberWithUnsignedInt:1UL]; + [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT32U Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT32U Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32uNotDefaultValue_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32U Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32U Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("int32u", value, readAttributeInt32uDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt32uDefaultValue_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int32uArgument; + int32uArgument = + [readAttributeInt32uDefaultValue copy]; + [cluster writeAttributeInt32uWithValue:int32uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT32U Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT32U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32uDefaultValue_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int32u", actualValue, readAttributeInt32uDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeInt64uDefaultValue; + + CHIP_ERROR TestReadAttributeInt64uDefaultValue_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int64u", actualValue, 0ULL)); + } + { + readAttributeInt64uDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt64uNotDefaultValue_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int64uArgument; + int64uArgument = + [NSNumber numberWithUnsignedLongLong:1ULL]; + [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT64U Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT64U Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt64uNotDefaultValue_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64U Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64U Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("int64u", value, readAttributeInt64uDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt64uDefaultValue_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int64uArgument; + int64uArgument = + [readAttributeInt64uDefaultValue copy]; + [cluster writeAttributeInt64uWithValue:int64uArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT64U Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT64U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt64uDefaultValue_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64uWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64U Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64U Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int64u", actualValue, readAttributeInt64uDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeInt8sDefaultValue; + + CHIP_ERROR TestReadAttributeInt8sDefaultValue_49() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int8s", actualValue, 0)); + } + { + readAttributeInt8sDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt8sNotDefaultValue_50() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int8sArgument; + int8sArgument = + [NSNumber numberWithChar:1]; + [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT8S Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT8S Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt8sNotDefaultValue_51() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8S Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8S Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("int8s", value, readAttributeInt8sDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt8sDefaultValue_52() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int8sArgument; + int8sArgument = + [readAttributeInt8sDefaultValue copy]; + [cluster writeAttributeInt8sWithValue:int8sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT8S Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT8S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt8sDefaultValue_53() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt8sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT8S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT8S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int8s", actualValue, readAttributeInt8sDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeInt16sDefaultValue; + + CHIP_ERROR TestReadAttributeInt16sDefaultValue_54() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int16s", actualValue, 0)); + } + { + readAttributeInt16sDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt16sNotDefaultValue_55() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int16sArgument; + int16sArgument = + [NSNumber numberWithShort:1]; + [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT16S Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT16S Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt16sNotDefaultValue_56() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16S Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16S Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("int16s", value, readAttributeInt16sDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt16sDefaultValue_57() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int16sArgument; + int16sArgument = + [readAttributeInt16sDefaultValue copy]; + [cluster writeAttributeInt16sWithValue:int16sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT16S Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT16S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt16sDefaultValue_58() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt16sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT16S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT16S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int16s", actualValue, readAttributeInt16sDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeInt32sDefaultValue; + + CHIP_ERROR TestReadAttributeInt32sDefaultValue_59() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int32s", actualValue, 0L)); + } + { + readAttributeInt32sDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt32sNotDefaultValue_60() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int32sArgument; + int32sArgument = + [NSNumber numberWithInt:1L]; + [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT32S Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT32S Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32sNotDefaultValue_61() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32S Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32S Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("int32s", value, readAttributeInt32sDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt32sDefaultValue_62() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int32sArgument; + int32sArgument = + [readAttributeInt32sDefaultValue copy]; + [cluster writeAttributeInt32sWithValue:int32sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT32S Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT32S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt32sDefaultValue_63() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt32sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT32S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT32S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int32s", actualValue, readAttributeInt32sDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeInt64sDefaultValue; + + CHIP_ERROR TestReadAttributeInt64sDefaultValue_64() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int64s", actualValue, 0LL)); + } + { + readAttributeInt64sDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeIntsNotDefaultValue_65() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int64sArgument; + int64sArgument = + [NSNumber numberWithLongLong:1LL]; + [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INTS Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INTS Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt64sNotDefaultValue_66() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64S Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64S Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("int64s", value, readAttributeInt64sDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeInt64sDefaultValue_67() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id int64sArgument; + int64sArgument = + [readAttributeInt64sDefaultValue copy]; + [cluster writeAttributeInt64sWithValue:int64sArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute INT64S Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute INT64S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeInt64sDefaultValue_68() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInt64sWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute INT64S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute INT64S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("int64s", actualValue, readAttributeInt64sDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeEnum8DefaultValue; + + CHIP_ERROR TestReadAttributeEnum8DefaultValue_69() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM8 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("enum8", actualValue, 0U)); + } + { + readAttributeEnum8DefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEnum8NotDefaultValue_70() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id enum8Argument; + enum8Argument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute ENUM8 Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute ENUM8 Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEnum8NotDefaultValue_71() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM8 Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM8 Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("enum8", value, readAttributeEnum8DefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEnum8DefaultValue_72() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id enum8Argument; + enum8Argument = + [readAttributeEnum8DefaultValue copy]; + [cluster writeAttributeEnum8WithValue:enum8Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute ENUM8 Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute ENUM8 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEnum8DefaultValue_73() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum8WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM8 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM8 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("enum8", actualValue, readAttributeEnum8DefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeEnum16DefaultValue; + + CHIP_ERROR TestReadAttributeEnum16DefaultValue_74() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM16 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("enum16", actualValue, 0U)); + } + { + readAttributeEnum16DefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEnum16NotDefaultValue_75() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id enum16Argument; + enum16Argument = + [NSNumber numberWithUnsignedShort:1U]; + [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute ENUM16 Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute ENUM16 Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEnum16NotDefaultValue_76() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM16 Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM16 Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("enum16", value, readAttributeEnum16DefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEnum16DefaultValue_77() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id enum16Argument; + enum16Argument = + [readAttributeEnum16DefaultValue copy]; + [cluster writeAttributeEnum16WithValue:enum16Argument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute ENUM16 Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute ENUM16 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEnum16DefaultValue_78() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEnum16WithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ENUM16 Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute ENUM16 Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("enum16", actualValue, readAttributeEnum16DefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeEpochUSDefaultValue; + + CHIP_ERROR TestReadAttributeEpochUsDefaultValue_79() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_US Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("epoch_us", actualValue, 0ULL)); + } + { + readAttributeEpochUSDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEpochUsNotDefaultValue_80() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id epochUsArgument; + epochUsArgument = + [NSNumber numberWithUnsignedLongLong:1ULL]; + [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute EPOCH_US Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute EPOCH_US Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEpochUsNotDefaultValue_81() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_US Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_US Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("epochUs", value, readAttributeEpochUSDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEpochUsDefaultValue_82() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id epochUsArgument; + epochUsArgument = + [readAttributeEpochUSDefaultValue copy]; + [cluster writeAttributeEpochUsWithValue:epochUsArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute EPOCH_US Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute EPOCH_US Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEpochUsDefaultValue_83() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochUsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_US Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_US Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("epoch_us", actualValue, readAttributeEpochUSDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeEpochSDefaultValue; + + CHIP_ERROR TestReadAttributeEpochSDefaultValue_84() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("epoch_s", actualValue, 0UL)); + } + { + readAttributeEpochSDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEpochSNotDefaultValue_85() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id epochSArgument; + epochSArgument = + [NSNumber numberWithUnsignedInt:1UL]; + [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute EPOCH_S Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute EPOCH_S Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEpochSNotDefaultValue_86() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_S Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_S Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("epochS", value, readAttributeEpochSDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeEpochSDefaultValue_87() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id epochSArgument; + epochSArgument = + [readAttributeEpochSDefaultValue copy]; + [cluster writeAttributeEpochSWithValue:epochSArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute EPOCH_S Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute EPOCH_S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeEpochSDefaultValue_88() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeEpochSWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute EPOCH_S Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute EPOCH_S Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("epoch_s", actualValue, readAttributeEpochSDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull readAttributeVendorIdDefaultValue; + + CHIP_ERROR TestReadAttributeVendorIdDefaultValue_89() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute vendor_id Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("vendor_id", actualValue, 0U)); + } + { + readAttributeVendorIdDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeVendorIdNotDefaultValue_90() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id vendorIdArgument; + vendorIdArgument = + [NSNumber numberWithUnsignedShort:1U]; + [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute vendor_id Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute vendor_id Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeVendorIdNotDefaultValue_91() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute vendor_id Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute vendor_id Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("vendorId", value, readAttributeVendorIdDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeVendorIdDefaultValue_92() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id vendorIdArgument; + vendorIdArgument = + [readAttributeVendorIdDefaultValue copy]; + [cluster writeAttributeVendorIdWithValue:vendorIdArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute vendor_id Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute vendor_id Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeVendorIdDefaultValue_93() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute vendor_id Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute vendor_id Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("vendor_id", actualValue, readAttributeVendorIdDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSString * _Nonnull readAttributeCharStringDefaultValue; + + CHIP_ERROR TestReadAttributeCharStringDefaultValue_94() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute char_string Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute char_string Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"")); + } + { + readAttributeCharStringDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringDefaultValueAndCompareToSavedValue_95() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute char_string Default Value and compare to saved value: Error: %@", err); + } else { + NSLog(@"Read attribute char_string Default Value and compare to saved value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("char_string", actualValue, readAttributeCharStringDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringNotDefaultValue_96() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = @"NotDefault"; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute char_string Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute char_string Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSString * _Nonnull readAttributeCharStringNotDefaultValue; + + CHIP_ERROR TestReadAttributeCharStringNotDefaultValue_97() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute char_string Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute char_string Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"NotDefault")); + } + + VerifyOrReturn(CheckConstraintNotValue("charString", value, readAttributeCharStringDefaultValue)); + { + readAttributeCharStringNotDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringNotDefaultValueAndCompareToSavedValue_98() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute char_string Not Default Value and compare to saved value: Error: %@", err); + } else { + NSLog(@"Read attribute char_string Not Default Value and compare to saved value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("char_string", actualValue, readAttributeCharStringNotDefaultValue)); + } + + VerifyOrReturn(CheckConstraintNotValue("charString", value, readAttributeCharStringDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringNotDefaultValueFromSavedValue_99() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = + [readAttributeCharStringNotDefaultValue copy]; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute char_string Not Default Value from saved value: Error: %@", err); + } else { + NSLog(@"Write attribute char_string Not Default Value from saved value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeCharStringNotDefaultValueAndCompareToExpectedValue_100() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCharStringWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute char_string Not Default Value and compare to expected value: Error: %@", err); + } else { + NSLog(@"Read attribute char_string Not Default Value and compare to expected value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("char_string", actualValue, @"NotDefault")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeCharStringDefaultValue_101() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id charStringArgument; + charStringArgument = + [readAttributeCharStringDefaultValue copy]; + [cluster writeAttributeCharStringWithValue:charStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute char_string Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute char_string Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSData * _Nonnull readAttributeOctetStringDefaultValue; + + CHIP_ERROR TestReadAttributeOctetStringDefaultValue_102() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute octet_string Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute octet_string Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"" length:0])); + } + { + readAttributeOctetStringDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeOctetStringDefaultValueAndCompareToSavedValue_103() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute octet_string Default Value and compare to saved value: Error: %@", err); + } else { + NSLog(@"Read attribute octet_string Default Value and compare to saved value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("octet_string", actualValue, readAttributeOctetStringDefaultValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeOctetStringNotDefaultValue_104() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id octetStringArgument; + octetStringArgument = + [[NSData alloc] initWithBytes:"NotDefault" length:10]; + [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute octet_string Not Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute octet_string Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSData * _Nonnull readAttributeOctetStringNotDefaultValue; + + CHIP_ERROR TestReadAttributeOctetStringNotDefaultValue_105() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute octet_string Not Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute octet_string Not Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"NotDefault" length:10])); + } + + VerifyOrReturn(CheckConstraintNotValue("octetString", value, readAttributeOctetStringDefaultValue)); + { + readAttributeOctetStringNotDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeOctetStringNotDefaultValueAndCompareToSavedValue_106() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute octet_string Not Default Value and compare to saved value: Error: %@", err); + } else { + NSLog(@"Read attribute octet_string Not Default Value and compare to saved value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("octet_string", actualValue, readAttributeOctetStringNotDefaultValue)); + } + + VerifyOrReturn(CheckConstraintNotValue("octetString", value, readAttributeOctetStringDefaultValue)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeOctetStringNotDefaultValueFromSavedValue_107() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id octetStringArgument; + octetStringArgument = + [readAttributeOctetStringNotDefaultValue copy]; + [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute octet_string Not Default Value from saved value: Error: %@", err); + } else { + NSLog(@"Write attribute octet_string Not Default Value from saved value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeOctetStringNotDefaultValueAndCompareToExpectedValue_108() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOctetStringWithCompletion:^(NSData * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute octet_string Not Default Value and compare to expected value: Error: %@", err); + } else { + NSLog(@"Read attribute octet_string Not Default Value and compare to expected value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("octet_string", actualValue, [[NSData alloc] initWithBytes:"NotDefault" length:10])); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeOctetStringDefaultValue_109() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id octetStringArgument; + octetStringArgument = + [readAttributeOctetStringDefaultValue copy]; + [cluster writeAttributeOctetStringWithValue:octetStringArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute octet_string Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute octet_string Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable readAttributeNullableBooleanDefaultValue; + + CHIP_ERROR TestReadAttributeNullableBooleanDefaultValue_110() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute nullable_boolean Default Value: Error: %@", err); + } else { + NSLog(@"Read attribute nullable_boolean Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); + VerifyOrReturn(CheckValue("nullable_boolean", actualValue, false)); + } + { + readAttributeNullableBooleanDefaultValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBooleanToNull_111() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBooleanArgument; + nullableBooleanArgument = nil; + [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute nullable_boolean to null: Error: %@", err); + } else { + NSLog(@"Write attribute nullable_boolean to null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable readAttributeNullableBooleanNullValue; + + CHIP_ERROR TestReadAttributeNullableBooleanNullValue_112() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute nullable_boolean null Value: Error: %@", err); + } else { + NSLog(@"Read attribute nullable_boolean null Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); + } + { + readAttributeNullableBooleanNullValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeNullableBooleanNullValueAgainAndCompareItToThePreviouslySavedValue_113() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNullableBooleanWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute nullable_boolean null Value again and compare it to the previously saved value: Error: %@", err); + } else { + NSLog(@"Read attribute nullable_boolean null Value again and compare it to the previously saved value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (readAttributeNullableBooleanNullValue == nil) { + VerifyOrReturn(CheckValueNull("nullable_boolean", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("nullable_boolean", actualValue)); + VerifyOrReturn(CheckValue("nullable_boolean", actualValue, readAttributeNullableBooleanNullValue)); + } + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteAttributeNullableBooleanDefaultValue_114() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nullableBooleanArgument; + nullableBooleanArgument = + [readAttributeNullableBooleanDefaultValue copy]; + [cluster writeAttributeNullableBooleanWithValue:nullableBooleanArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write attribute nullable_boolean Default Value: Error: %@", err); + } else { + NSLog(@"Write attribute nullable_boolean Default Value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestConfigVariables : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestConfigVariables() + : TestCommandBridge("TestConfigVariables") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("arg1", 0, UINT8_MAX, &mArg1); + AddArgument("returnValueWithArg1", 0, UINT8_MAX, &mReturnValueWithArg1); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestConfigVariables() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestConfigVariables\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestConfigVariables\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Send Test Add Arguments Command\n"); + err = TestSendTestAddArgumentsCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Send Test Add Arguments Command\n"); + err = TestSendTestAddArgumentsCommand_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mArg1; + chip::Optional mReturnValueWithArg1; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull TestAddArgumentDefaultValue; + + CHIP_ERROR TestSendTestAddArgumentsCommand_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; + params.arg1 = + [NSNumber numberWithUnsignedChar:3U]; + params.arg2 = + [NSNumber numberWithUnsignedChar:17U]; + [cluster testAddArgumentsWithParams:params completion: + ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Add Arguments Command: Error: %@", err); + } else { + NSLog(@"Send Test Add Arguments Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.returnValue; + VerifyOrReturn(CheckValue("returnValue", actualValue, 20U)); + } + { + TestAddArgumentDefaultValue = values.returnValue; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendTestAddArgumentsCommand_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUnitTesting alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRUnitTestingClusterTestAddArgumentsParams alloc] init]; + params.arg1 = mArg1.HasValue() ? [NSNumber numberWithUnsignedChar:mArg1.Value()] : [NSNumber numberWithUnsignedChar:5U]; + params.arg2 = + [TestAddArgumentDefaultValue copy]; + [cluster testAddArgumentsWithParams:params completion: + ^(MTRUnitTestingClusterTestAddArgumentsResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Test Add Arguments Command: Error: %@", err); + } else { + NSLog(@"Send Test Add Arguments Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.returnValue; + VerifyOrReturn(CheckValue("returnValue", actualValue, mReturnValueWithArg1.HasValue() ? mReturnValueWithArg1.Value() : 25U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestDescriptorCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestDescriptorCluster() + : TestCommandBridge("TestDescriptorCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestDescriptorCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestDescriptorCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestDescriptorCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read attribute Device list\n"); + err = TestReadAttributeDeviceList_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read attribute Server list\n"); + err = TestReadAttributeServerList_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read attribute Client list\n"); + err = TestReadAttributeClientList_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read attribute Parts list\n"); + err = TestReadAttributePartsList_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read attribute ClusterRevision\n"); + err = TestReadAttributeClusterRevision_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read attribute Tag list\n"); + err = TestReadAttributeTagList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Read feature map Attribute\n"); + err = TestReadFeatureMapAttribute_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAttributeDeviceList_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDeviceTypeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute Device list: Error: %@", err); + } else { + NSLog(@"Read attribute Device list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("DeviceTypeList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("DeviceType", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[0]).deviceType, 17UL)); + VerifyOrReturn(CheckValue("Revision", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[0]).revision, 1U)); + VerifyOrReturn(CheckValue("DeviceType", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[1]).deviceType, 22UL)); + VerifyOrReturn(CheckValue("Revision", ((MTRDescriptorClusterDeviceTypeStruct *) actualValue[1]).revision, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeServerList_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeServerListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute Server list: Error: %@", err); + } else { + NSLog(@"Read attribute Server list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ServerList", [actualValue count], static_cast(28))); + VerifyOrReturn(CheckValue("", actualValue[0], 3UL)); + VerifyOrReturn(CheckValue("", actualValue[1], 4UL)); + VerifyOrReturn(CheckValue("", actualValue[2], 29UL)); + VerifyOrReturn(CheckValue("", actualValue[3], 30UL)); + VerifyOrReturn(CheckValue("", actualValue[4], 31UL)); + VerifyOrReturn(CheckValue("", actualValue[5], 40UL)); + VerifyOrReturn(CheckValue("", actualValue[6], 42UL)); + VerifyOrReturn(CheckValue("", actualValue[7], 43UL)); + VerifyOrReturn(CheckValue("", actualValue[8], 44UL)); + VerifyOrReturn(CheckValue("", actualValue[9], 45UL)); + VerifyOrReturn(CheckValue("", actualValue[10], 46UL)); + VerifyOrReturn(CheckValue("", actualValue[11], 47UL)); + VerifyOrReturn(CheckValue("", actualValue[12], 48UL)); + VerifyOrReturn(CheckValue("", actualValue[13], 49UL)); + VerifyOrReturn(CheckValue("", actualValue[14], 50UL)); + VerifyOrReturn(CheckValue("", actualValue[15], 51UL)); + VerifyOrReturn(CheckValue("", actualValue[16], 52UL)); + VerifyOrReturn(CheckValue("", actualValue[17], 53UL)); + VerifyOrReturn(CheckValue("", actualValue[18], 54UL)); + VerifyOrReturn(CheckValue("", actualValue[19], 55UL)); + VerifyOrReturn(CheckValue("", actualValue[20], 56UL)); + VerifyOrReturn(CheckValue("", actualValue[21], 60UL)); + VerifyOrReturn(CheckValue("", actualValue[22], 62UL)); + VerifyOrReturn(CheckValue("", actualValue[23], 63UL)); + VerifyOrReturn(CheckValue("", actualValue[24], 64UL)); + VerifyOrReturn(CheckValue("", actualValue[25], 65UL)); + VerifyOrReturn(CheckValue("", actualValue[26], 1029UL)); + VerifyOrReturn(CheckValue("", actualValue[27], 4294048774UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeClientList_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClientListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute Client list: Error: %@", err); + } else { + NSLog(@"Read attribute Client list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClientList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 41UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributePartsList_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePartsListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute Parts list: Error: %@", err); + } else { + NSLog(@"Read attribute Parts list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PartsList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("", actualValue[0], 1U)); + VerifyOrReturn(CheckValue("", actualValue[1], 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeClusterRevision_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute ClusterRevision: Error: %@", err); + } else { + NSLog(@"Read attribute ClusterRevision: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 2U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadAttributeTagList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTagListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read attribute Tag list: Error: %@", err); + } else { + NSLog(@"Read attribute Tag list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TagList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValueNull("MfgCode", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).mfgCode)); + VerifyOrReturn(CheckValue("NamespaceID", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).namespaceID, 7U)); + VerifyOrReturn(CheckValue("Tag", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[0]).tag, 0U)); + VerifyOrReturn(CheckValueNull("MfgCode", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).mfgCode)); + VerifyOrReturn(CheckValue("NamespaceID", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).namespaceID, 8U)); + VerifyOrReturn(CheckValue("Tag", ((MTRDescriptorClusterSemanticTagStruct *) actualValue[1]).tag, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadFeatureMapAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDescriptor alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read feature map Attribute: Error: %@", err); + } else { + NSLog(@"Read feature map Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestFabricRemovalWhileSubscribed : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestFabricRemovalWhileSubscribed() + : TestCommandBridge("TestFabricRemovalWhileSubscribed") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("payload", &mPayload); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestFabricRemovalWhileSubscribed() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestFabricRemovalWhileSubscribed\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestFabricRemovalWhileSubscribed\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of commissioned fabrics\n"); + err = TestReadNumberOfCommissionedFabrics_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read current fabric index\n"); + err = TestReadCurrentFabricIndex_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Open commissioning window from alpha\n"); + err = TestOpenCommissioningWindowFromAlpha_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Commission from beta\n"); + err = TestCommissionFromBeta_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved for beta\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Report: Subscribe Fabrics Attribute from beta\n"); + err = TestReportSubscribeFabricsAttributeFromBeta_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Subscribe Fabrics Attribute from beta\n"); + err = TestSubscribeFabricsAttributeFromBeta_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Remove single own fabric\n"); + err = TestRemoveSingleOwnFabric_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mDiscriminator; + chip::Optional mPayload; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadNumberOfCommissionedFabrics_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read number of commissioned fabrics: Error: %@", err); + } else { + NSLog(@"Read number of commissioned fabrics: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CommissionedFabrics", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull ourFabricIndex; + + CHIP_ERROR TestReadCurrentFabricIndex_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current fabric index: Error: %@", err); + } else { + NSLog(@"Read current fabric index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); + { + ourFabricIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestOpenCommissioningWindowFromAlpha_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open commissioning window from alpha: Error: %@", err); + } else { + NSLog(@"Open commissioning window from alpha: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCommissionFromBeta_4() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = 74565ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = 74565ULL; + return WaitForCommissionee("beta", value); + } + bool testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled = false; + ResponseHandler _Nullable test_TestFabricRemovalWhileSubscribed_Fabrics_Reported + = nil; + + CHIP_ERROR TestReportSubscribeFabricsAttributeFromBeta_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestFabricRemovalWhileSubscribed_Fabrics_Reported + = ^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Report: Subscribe Fabrics Attribute from beta: Error: %@", err); + } else { + NSLog(@"Report: Subscribe Fabrics Attribute from beta: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("fabrics", "list", "list")); + testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled = true; + }; + + NextTest(); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSubscribeFabricsAttributeFromBeta_7() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + uint16_t minIntervalArgument = 2U; + uint16_t maxIntervalArgument = 5U; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; + params.filterByFabric = true; + params.replaceExistingSubscriptions = true; + [cluster subscribeAttributeFabricsWithParams:params + subscriptionEstablished:^{ + VerifyOrReturn(testSendClusterTestFabricRemovalWhileSubscribed_6_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); + NextTest(); + } + reportHandler:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Subscribe Fabrics Attribute from beta: Error: %@", err); + } else { + NSLog(@"Subscribe Fabrics Attribute from beta: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + if (test_TestFabricRemovalWhileSubscribed_Fabrics_Reported + != nil) { + ResponseHandler callback = test_TestFabricRemovalWhileSubscribed_Fabrics_Reported; + test_TestFabricRemovalWhileSubscribed_Fabrics_Reported + = nil; + callback(value, err); + } + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveSingleOwnFabric_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; + params.fabricIndex = + [ourFabricIndex copy]; + [cluster removeFabricWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Remove single own fabric: Error: %@", err); + } else { + NSLog(@"Remove single own fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestGeneralCommissioning : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestGeneralCommissioning() + : TestCommandBridge("TestGeneralCommissioning") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("payload", &mPayload); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestGeneralCommissioning() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestGeneralCommissioning\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestGeneralCommissioning\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Write Breadcrumb (1/2)\n"); + err = TestWriteBreadcrumb12_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read back Breadcrumb (1/2)\n"); + err = TestReadBackBreadcrumb12_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Write Breadcrumb (2/2)\n"); + err = TestWriteBreadcrumb22_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read back Breadcrumb (2/2)\n"); + err = TestReadBackBreadcrumb22_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Reboot to reset Breadcrumb\n"); + err = TestRebootToResetBreadcrumb_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Connect to the device again\n"); + err = TestConnectToTheDeviceAgain_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Read back Breadcrumb after reboot and ensure it was not persisted\n"); + err = TestReadBackBreadcrumbAfterRebootAndEnsureItWasNotPersisted_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Set Breadcrumb to nonzero value\n"); + err = TestSetBreadcrumbToNonzeroValue_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Check Breadcrumb set worked\n"); + err = TestCheckBreadcrumbSetWorked_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Send CommissioningComplete without armed fail-safe\n"); + err = TestSendCommissioningCompleteWithoutArmedFailSafe_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Check Breadcrumb was not touched by invalid CommissioningComplete\n"); + err = TestCheckBreadcrumbWasNotTouchedByInvalidCommissioningComplete_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Open Commissioning Window from alpha\n"); + err = TestOpenCommissioningWindowFromAlpha_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Try to arm fail-safe\n"); + err = TestTryToArmFailSafe_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Check Breadcrumb was not touched by ArmFailSafe with commissioning window open\n"); + err = TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithCommissioningWindowOpen_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Reset Breadcrumb to 0 so we can commission\n"); + err = TestResetBreadcrumbTo0SoWeCanCommission_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Commission from beta\n"); + err = TestCommissionFromBeta_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Wait for the commissioned device to be retrieved for beta\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Arm fail-safe\n"); + err = TestArmFailSafe_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Check Breadcrumb was properly set by ArmFailSafe\n"); + err = TestCheckBreadcrumbWasProperlySetByArmFailSafe_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Try to arm fail-safe from wrong fabric\n"); + err = TestTryToArmFailSafeFromWrongFabric_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed\n"); + err = TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithExistingFailSafeArmed_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Send CommissioningComplete from wrong fabric\n"); + err = TestSendCommissioningCompleteFromWrongFabric_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Check Breadcrumb was not touched by CommissioningComplete from wrong fabric\n"); + err = TestCheckBreadcrumbWasNotTouchedByCommissioningCompleteFromWrongFabric_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Close out the fail-safe gracefully\n"); + err = TestCloseOutTheFailSafeGracefully_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Check Breadcrumb was reset to 0 by CommissioningComplete\n"); + err = TestCheckBreadcrumbWasResetTo0ByCommissioningComplete_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Arm fail-safe again\n"); + err = TestArmFailSafeAgain_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Check Breadcrumb was set by arming fail-safe again\n"); + err = TestCheckBreadcrumbWasSetByArmingFailSafeAgain_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Force-expire the fail-safe\n"); + err = TestForceExpireTheFailSafe_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Check Breadcrumb was reset by expiring the fail-safe\n"); + err = TestCheckBreadcrumbWasResetByExpiringTheFailSafe_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Validate presence of SupportsConcurrentConnection\n"); + err = TestValidatePresenceOfSupportsConcurrentConnection_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Read original regulatory location\n"); + err = TestReadOriginalRegulatoryLocation_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Read original location\n"); + err = TestReadOriginalLocation_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Try to SetRegulatoryConfig with 0-length country code\n"); + err = TestTryToSetRegulatoryConfigWith0LengthCountryCode_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Read back location\n"); + err = TestReadBackLocation_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Try to SetRegulatoryConfig with length-1 country code\n"); + err = TestTryToSetRegulatoryConfigWithLength1CountryCode_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Read back location second time\n"); + err = TestReadBackLocationSecondTime_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Try to SetRegulatoryConfig with length-2 country code\n"); + err = TestTryToSetRegulatoryConfigWithLength2CountryCode_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Read back location third time\n"); + err = TestReadBackLocationThirdTime_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Restore initial values\n"); + err = TestRestoreInitialValues_39(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 40; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mDiscriminator; + chip::Optional mPayload; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestWriteBreadcrumb12_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id breadcrumbArgument; + breadcrumbArgument = + [NSNumber numberWithUnsignedLongLong:137438953472ULL]; + [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write Breadcrumb (1/2): Error: %@", err); + } else { + NSLog(@"Write Breadcrumb (1/2): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackBreadcrumb12_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back Breadcrumb (1/2): Error: %@", err); + } else { + NSLog(@"Read back Breadcrumb (1/2): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 137438953472ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteBreadcrumb22_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id breadcrumbArgument; + breadcrumbArgument = + [NSNumber numberWithUnsignedLongLong:81ULL]; + [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write Breadcrumb (2/2): Error: %@", err); + } else { + NSLog(@"Write Breadcrumb (2/2): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackBreadcrumb22_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back Breadcrumb (2/2): Error: %@", err); + } else { + NSLog(@"Read back Breadcrumb (2/2): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 81ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRebootToResetBreadcrumb_5() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestConnectToTheDeviceAgain_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadBackBreadcrumbAfterRebootAndEnsureItWasNotPersisted_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back Breadcrumb after reboot and ensure it was not persisted: Error: %@", err); + } else { + NSLog(@"Read back Breadcrumb after reboot and ensure it was not persisted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetBreadcrumbToNonzeroValue_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id breadcrumbArgument; + breadcrumbArgument = + [NSNumber numberWithUnsignedLongLong:1ULL]; + [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set Breadcrumb to nonzero value: Error: %@", err); + } else { + NSLog(@"Set Breadcrumb to nonzero value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckBreadcrumbSetWorked_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check Breadcrumb set worked: Error: %@", err); + } else { + NSLog(@"Check Breadcrumb set worked: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendCommissioningCompleteWithoutArmedFailSafe_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster commissioningCompleteWithCompletion: + ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send CommissioningComplete without armed fail-safe: Error: %@", err); + } else { + NSLog(@"Send CommissioningComplete without armed fail-safe: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.errorCode; + VerifyOrReturn(CheckValue("ErrorCode", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByInvalidCommissioningComplete_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check Breadcrumb was not touched by invalid CommissioningComplete: Error: %@", err); + } else { + NSLog(@"Check Breadcrumb was not touched by invalid CommissioningComplete: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestOpenCommissioningWindowFromAlpha_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open Commissioning Window from alpha: Error: %@", err); + } else { + NSLog(@"Open Commissioning Window from alpha: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToArmFailSafe_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; + params.expiryLengthSeconds = + [NSNumber numberWithUnsignedShort:10U]; + params.breadcrumb = + [NSNumber numberWithUnsignedLongLong:5000ULL]; + [cluster armFailSafeWithParams:params completion: + ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Try to arm fail-safe: Error: %@", err); + } else { + NSLog(@"Try to arm fail-safe: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.errorCode; + VerifyOrReturn(CheckValue("ErrorCode", actualValue, 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithCommissioningWindowOpen_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with commissioning window open: Error: %@", err); + } else { + NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with commissioning window open: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 1ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestResetBreadcrumbTo0SoWeCanCommission_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id breadcrumbArgument; + breadcrumbArgument = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster writeAttributeBreadcrumbWithValue:breadcrumbArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Reset Breadcrumb to 0 so we can commission: Error: %@", err); + } else { + NSLog(@"Reset Breadcrumb to 0 so we can commission: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCommissionFromBeta_16() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = 74565ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_17() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = 74565ULL; + return WaitForCommissionee("beta", value); + } + + CHIP_ERROR TestArmFailSafe_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; + params.expiryLengthSeconds = + [NSNumber numberWithUnsignedShort:500U]; + params.breadcrumb = + [NSNumber numberWithUnsignedLongLong:2ULL]; + [cluster armFailSafeWithParams:params completion: + ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Arm fail-safe: Error: %@", err); + } else { + NSLog(@"Arm fail-safe: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.errorCode; + VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckBreadcrumbWasProperlySetByArmFailSafe_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check Breadcrumb was properly set by ArmFailSafe: Error: %@", err); + } else { + NSLog(@"Check Breadcrumb was properly set by ArmFailSafe: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToArmFailSafeFromWrongFabric_20() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; + params.expiryLengthSeconds = + [NSNumber numberWithUnsignedShort:10U]; + params.breadcrumb = + [NSNumber numberWithUnsignedLongLong:5000ULL]; + [cluster armFailSafeWithParams:params completion: + ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Try to arm fail-safe from wrong fabric: Error: %@", err); + } else { + NSLog(@"Try to arm fail-safe from wrong fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.errorCode; + VerifyOrReturn(CheckValue("ErrorCode", actualValue, 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByArmFailSafeWithExistingFailSafeArmed_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed: Error: %@", err); + } else { + NSLog(@"Check Breadcrumb was not touched by ArmFailSafe with existing fail-safe armed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendCommissioningCompleteFromWrongFabric_22() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster commissioningCompleteWithCompletion: + ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send CommissioningComplete from wrong fabric: Error: %@", err); + } else { + NSLog(@"Send CommissioningComplete from wrong fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.errorCode; + VerifyOrReturn(CheckValue("ErrorCode", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckBreadcrumbWasNotTouchedByCommissioningCompleteFromWrongFabric_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check Breadcrumb was not touched by CommissioningComplete from wrong fabric: Error: %@", err); + } else { + NSLog(@"Check Breadcrumb was not touched by CommissioningComplete from wrong fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 2ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCloseOutTheFailSafeGracefully_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster commissioningCompleteWithCompletion: + ^(MTRGeneralCommissioningClusterCommissioningCompleteResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Close out the fail-safe gracefully: Error: %@", err); + } else { + NSLog(@"Close out the fail-safe gracefully: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.errorCode; + VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckBreadcrumbWasResetTo0ByCommissioningComplete_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check Breadcrumb was reset to 0 by CommissioningComplete: Error: %@", err); + } else { + NSLog(@"Check Breadcrumb was reset to 0 by CommissioningComplete: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestArmFailSafeAgain_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; + params.expiryLengthSeconds = + [NSNumber numberWithUnsignedShort:500U]; + params.breadcrumb = + [NSNumber numberWithUnsignedLongLong:3ULL]; + [cluster armFailSafeWithParams:params completion: + ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Arm fail-safe again: Error: %@", err); + } else { + NSLog(@"Arm fail-safe again: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.errorCode; + VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckBreadcrumbWasSetByArmingFailSafeAgain_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check Breadcrumb was set by arming fail-safe again: Error: %@", err); + } else { + NSLog(@"Check Breadcrumb was set by arming fail-safe again: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 3ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestForceExpireTheFailSafe_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; + params.expiryLengthSeconds = + [NSNumber numberWithUnsignedShort:0U]; + params.breadcrumb = + [NSNumber numberWithUnsignedLongLong:4ULL]; + [cluster armFailSafeWithParams:params completion: + ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Force-expire the fail-safe: Error: %@", err); + } else { + NSLog(@"Force-expire the fail-safe: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.errorCode; + VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckBreadcrumbWasResetByExpiringTheFailSafe_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeBreadcrumbWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check Breadcrumb was reset by expiring the fail-safe: Error: %@", err); + } else { + NSLog(@"Check Breadcrumb was reset by expiring the fail-safe: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Breadcrumb", actualValue, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestValidatePresenceOfSupportsConcurrentConnection_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportsConcurrentConnectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Validate presence of SupportsConcurrentConnection: Error: %@", err); + } else { + NSLog(@"Validate presence of SupportsConcurrentConnection: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("supportsConcurrentConnection", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull originalRegulatoryConfig; + + CHIP_ERROR TestReadOriginalRegulatoryLocation_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeRegulatoryConfigWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read original regulatory location: Error: %@", err); + } else { + NSLog(@"Read original regulatory location: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + originalRegulatoryConfig = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSString * _Nonnull originalLocation; + + CHIP_ERROR TestReadOriginalLocation_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read original location: Error: %@", err); + } else { + NSLog(@"Read original location: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("Location", actualValue, @"XX")); + } + { + originalLocation = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToSetRegulatoryConfigWith0LengthCountryCode_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; + params.newRegulatoryConfig = + [NSNumber numberWithUnsignedChar:0U]; + params.countryCode = @""; + params.breadcrumb = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster setRegulatoryConfigWithParams:params completion: + ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Try to SetRegulatoryConfig with 0-length country code: Error: %@", err); + } else { + NSLog(@"Try to SetRegulatoryConfig with 0-length country code: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackLocation_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back location: Error: %@", err); + } else { + NSLog(@"Read back location: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("Location", actualValue, originalLocation)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToSetRegulatoryConfigWithLength1CountryCode_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; + params.newRegulatoryConfig = + [NSNumber numberWithUnsignedChar:0U]; + params.countryCode = @"U"; + params.breadcrumb = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster setRegulatoryConfigWithParams:params completion: + ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Try to SetRegulatoryConfig with length-1 country code: Error: %@", err); + } else { + NSLog(@"Try to SetRegulatoryConfig with length-1 country code: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackLocationSecondTime_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back location second time: Error: %@", err); + } else { + NSLog(@"Read back location second time: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("Location", actualValue, originalLocation)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToSetRegulatoryConfigWithLength2CountryCode_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; + params.newRegulatoryConfig = + [NSNumber numberWithUnsignedChar:0U]; + params.countryCode = @"US"; + params.breadcrumb = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster setRegulatoryConfigWithParams:params completion: + ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Try to SetRegulatoryConfig with length-2 country code: Error: %@", err); + } else { + NSLog(@"Try to SetRegulatoryConfig with length-2 country code: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.errorCode; + VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); + } + + { + id actualValue = values.debugText; + VerifyOrReturn(CheckValueAsString("DebugText", actualValue, @"")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackLocationThirdTime_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLocationWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back location third time: Error: %@", err); + } else { + NSLog(@"Read back location third time: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("Location", actualValue, @"US")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRestoreInitialValues_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterSetRegulatoryConfigParams alloc] init]; + params.newRegulatoryConfig = + [originalRegulatoryConfig copy]; + params.countryCode = + [originalLocation copy]; + params.breadcrumb = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster setRegulatoryConfigWithParams:params completion: + ^(MTRGeneralCommissioningClusterSetRegulatoryConfigResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Restore initial values: Error: %@", err); + } else { + NSLog(@"Restore initial values: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestIdentifyCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestIdentifyCluster() + : TestCommandBridge("TestIdentifyCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestIdentifyCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestIdentifyCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestIdentifyCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Send Identify command and expect success response\n"); + err = TestSendIdentifyCommandAndExpectSuccessResponse_1(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 2; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestSendIdentifyCommandAndExpectSuccessResponse_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterIdentify alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRIdentifyClusterIdentifyParams alloc] init]; + params.identifyTime = + [NSNumber numberWithUnsignedShort:0U]; + [cluster identifyWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Identify command and expect success response: Error: %@", err); + } else { + NSLog(@"Send Identify command and expect success response: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestOperationalCredentialsCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestOperationalCredentialsCluster() + : TestCommandBridge("TestOperationalCredentialsCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestOperationalCredentialsCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestOperationalCredentialsCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestOperationalCredentialsCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of supported fabrics\n"); + err = TestReadNumberOfSupportedFabrics_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read number of commissioned fabrics\n"); + err = TestReadNumberOfCommissionedFabrics_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read current fabric index\n"); + err = TestReadCurrentFabricIndex_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Remove nonexistent fabric\n"); + err = TestRemoveNonexistentFabric_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read fabric list before setting label\n"); + err = TestReadFabricListBeforeSettingLabel_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Set the fabric label\n"); + err = TestSetTheFabricLabel_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Read fabric list after setting label\n"); + err = TestReadFabricListAfterSettingLabel_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadNumberOfSupportedFabrics_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read number of supported fabrics: Error: %@", err); + } else { + NSLog(@"Read number of supported fabrics: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("supportedFabrics", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("supportedFabrics", [value unsignedCharValue], 4U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadNumberOfCommissionedFabrics_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read number of commissioned fabrics: Error: %@", err); + } else { + NSLog(@"Read number of commissioned fabrics: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("commissionedFabrics", [value unsignedCharValue], 1U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull ourFabricIndex; + + CHIP_ERROR TestReadCurrentFabricIndex_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current fabric index: Error: %@", err); + } else { + NSLog(@"Read current fabric index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); + { + ourFabricIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveNonexistentFabric_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; + params.fabricIndex = + [NSNumber numberWithUnsignedChar:243U]; + [cluster removeFabricWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Remove nonexistent fabric: Error: %@", err); + } else { + NSLog(@"Remove nonexistent fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.statusCode; + VerifyOrReturn(CheckValue("StatusCode", actualValue, 11U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadFabricListBeforeSettingLabel_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read fabric list before setting label: Error: %@", err); + } else { + NSLog(@"Read fabric list before setting label: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"")); + VerifyOrReturn(CheckValue("FabricIndex", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).fabricIndex, ourFabricIndex)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetTheFabricLabel_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterUpdateFabricLabelParams alloc] init]; + params.label = @"Batcave"; + [cluster updateFabricLabelWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set the fabric label: Error: %@", err); + } else { + NSLog(@"Set the fabric label: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.statusCode; + VerifyOrReturn(CheckValue("StatusCode", actualValue, 0U)); + } + + { + id actualValue = values.fabricIndex; + VerifyOrReturn(CheckValue("FabricIndex", actualValue, ourFabricIndex)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadFabricListAfterSettingLabel_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read fabric list after setting label: Error: %@", err); + } else { + NSLog(@"Read fabric list after setting label: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"Batcave")); + VerifyOrReturn(CheckValue("FabricIndex", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).fabricIndex, ourFabricIndex)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestModeSelectCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestModeSelectCluster() + : TestCommandBridge("TestModeSelectCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestModeSelectCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestModeSelectCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestModeSelectCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read Description\n"); + err = TestReadDescription_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read StandardNamespace\n"); + err = TestReadStandardNamespace_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read SupportedModes\n"); + err = TestReadSupportedModes_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read CurrentMode\n"); + err = TestReadCurrentMode_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read StartUpMode\n"); + err = TestReadStartUpMode_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read OnMode\n"); + err = TestReadOnMode_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Change to Supported Mode\n"); + err = TestChangeToSupportedMode_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Verify Current Mode Change\n"); + err = TestVerifyCurrentModeChange_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Change to Unsupported Mode\n"); + err = TestChangeToUnsupportedMode_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Toggle OnOff\n"); + err = TestToggleOnOff_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Toggle OnOff\n"); + err = TestToggleOnOff_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Verify Current Mode does not change when OnMode is null\n"); + err = TestVerifyCurrentModeDoesNotChangeWhenOnModeIsNull_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Change to Unsupported OnMode\n"); + err = TestChangeToUnsupportedOnMode_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Change OnMode\n"); + err = TestChangeOnMode_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Verify OnMode\n"); + err = TestVerifyOnMode_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Toggle OnOff\n"); + err = TestToggleOnOff_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Toggle OnOff\n"); + err = TestToggleOnOff_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Verify Current Mode Changes if OnMode is not null\n"); + err = TestVerifyCurrentModeChangesIfOnModeIsNotNull_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Change to Unsupported StartUp Mode\n"); + err = TestChangeToUnsupportedStartUpMode_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Change to Supported StartUp Mode\n"); + err = TestChangeToSupportedStartUpMode_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Verify StartUp Mode Change\n"); + err = TestVerifyStartUpModeChange_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Change CurrentMode to another value\n"); + err = TestChangeCurrentModeToAnotherValue_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Change On Mode\n"); + err = TestChangeOnMode_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Set StartUpOnOff\n"); + err = TestSetStartUpOnOff_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Reboot target device\n"); + err = TestRebootTargetDevice_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Verify Current Mode Change based on OnMode, as it overwrites StartUpMode\n"); + err = TestVerifyCurrentModeChangeBasedOnOnModeAsItOverwritesStartUpMode_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Change On Mode to Null\n"); + err = TestChangeOnModeToNull_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Reboot target device\n"); + err = TestRebootTargetDevice_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Verify Current Mode Change based on new StartUp Mode\n"); + err = TestVerifyCurrentModeChangeBasedOnNewStartUpMode_31(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 32; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadDescription_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDescriptionWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Description: Error: %@", err); + } else { + NSLog(@"Read Description: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("Description", actualValue, @"Coffee")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadStandardNamespace_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStandardNamespaceWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read StandardNamespace: Error: %@", err); + } else { + NSLog(@"Read StandardNamespace: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("StandardNamespace", actualValue)); + VerifyOrReturn(CheckValue("StandardNamespace", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadSupportedModes_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedModesWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read SupportedModes: Error: %@", err); + } else { + NSLog(@"Read SupportedModes: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("SupportedModes", [actualValue count], static_cast(3))); + VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).label, @"Black")); + VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).mode, 0U)); + VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).semanticTags count], static_cast(1))); + VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[0]).semanticTags[0]).value, 0U)); + VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).label, @"Cappuccino")); + VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).mode, 4U)); + VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).semanticTags count], static_cast(1))); + VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[1]).semanticTags[0]).value, 0U)); + VerifyOrReturn(CheckValueAsString("Label", ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).label, @"Espresso")); + VerifyOrReturn(CheckValue("Mode", ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).mode, 7U)); + VerifyOrReturn(CheckValue("SemanticTags", [((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).semanticTags count], static_cast(1))); + VerifyOrReturn(CheckValue("Value", ((MTRModeSelectClusterSemanticTagStruct *) ((MTRModeSelectClusterModeOptionStruct *) actualValue[2]).semanticTags[0]).value, 0U)); + } + + VerifyOrReturn(CheckConstraintType("supportedModes", "list", "list")); + VerifyOrReturn(CheckConstraintMinLength("supportedModes", value, 3)); + VerifyOrReturn(CheckConstraintMaxLength("supportedModes", value, 3)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentMode_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read CurrentMode: Error: %@", err); + } else { + NSLog(@"Read CurrentMode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadStartUpMode_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartUpModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read StartUpMode: Error: %@", err); + } else { + NSLog(@"Read StartUpMode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("StartUpMode", actualValue)); + VerifyOrReturn(CheckValue("StartUpMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadOnMode_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read OnMode: Error: %@", err); + } else { + NSLog(@"Read OnMode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("OnMode", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestChangeToSupportedMode_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; + params.newMode = + [NSNumber numberWithUnsignedChar:4U]; + [cluster changeToModeWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Change to Supported Mode: Error: %@", err); + } else { + NSLog(@"Change to Supported Mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull currentModeBeforeToggle; + + CHIP_ERROR TestVerifyCurrentModeChange_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify Current Mode Change: Error: %@", err); + } else { + NSLog(@"Verify Current Mode Change: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentMode", actualValue, 4U)); + } + { + currentModeBeforeToggle = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestChangeToUnsupportedMode_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; + params.newMode = + [NSNumber numberWithUnsignedChar:2U]; + [cluster changeToModeWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Change to Unsupported Mode: Error: %@", err); + } else { + NSLog(@"Change to Unsupported Mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestToggleOnOff_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Toggle OnOff: Error: %@", err); + } else { + NSLog(@"Toggle OnOff: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestToggleOnOff_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Toggle OnOff: Error: %@", err); + } else { + NSLog(@"Toggle OnOff: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCurrentModeDoesNotChangeWhenOnModeIsNull_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify Current Mode does not change when OnMode is null: Error: %@", err); + } else { + NSLog(@"Verify Current Mode does not change when OnMode is null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentMode", actualValue, currentModeBeforeToggle)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestChangeToUnsupportedOnMode_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onModeArgument; + onModeArgument = + [NSNumber numberWithUnsignedChar:2U]; + [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Change to Unsupported OnMode: Error: %@", err); + } else { + NSLog(@"Change to Unsupported OnMode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestChangeOnMode_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onModeArgument; + onModeArgument = + [NSNumber numberWithUnsignedChar:7U]; + [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Change OnMode: Error: %@", err); + } else { + NSLog(@"Change OnMode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable OnModeValue; + + CHIP_ERROR TestVerifyOnMode_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify OnMode: Error: %@", err); + } else { + NSLog(@"Verify OnMode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("OnMode", actualValue)); + VerifyOrReturn(CheckValue("OnMode", actualValue, 7U)); + } + { + OnModeValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestToggleOnOff_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Toggle OnOff: Error: %@", err); + } else { + NSLog(@"Toggle OnOff: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestToggleOnOff_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Toggle OnOff: Error: %@", err); + } else { + NSLog(@"Toggle OnOff: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCurrentModeChangesIfOnModeIsNotNull_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify Current Mode Changes if OnMode is not null: Error: %@", err); + } else { + NSLog(@"Verify Current Mode Changes if OnMode is not null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentMode", actualValue, OnModeValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestChangeToUnsupportedStartUpMode_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id startUpModeArgument; + startUpModeArgument = + [NSNumber numberWithUnsignedChar:2U]; + [cluster writeAttributeStartUpModeWithValue:startUpModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Change to Unsupported StartUp Mode: Error: %@", err); + } else { + NSLog(@"Change to Unsupported StartUp Mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestChangeToSupportedStartUpMode_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id startUpModeArgument; + startUpModeArgument = + [NSNumber numberWithUnsignedChar:7U]; + [cluster writeAttributeStartUpModeWithValue:startUpModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Change to Supported StartUp Mode: Error: %@", err); + } else { + NSLog(@"Change to Supported StartUp Mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyStartUpModeChange_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStartUpModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify StartUp Mode Change: Error: %@", err); + } else { + NSLog(@"Verify StartUp Mode Change: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("StartUpMode", actualValue)); + VerifyOrReturn(CheckValue("StartUpMode", actualValue, 7U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestChangeCurrentModeToAnotherValue_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRModeSelectClusterChangeToModeParams alloc] init]; + params.newMode = + [NSNumber numberWithUnsignedChar:0U]; + [cluster changeToModeWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Change CurrentMode to another value: Error: %@", err); + } else { + NSLog(@"Change CurrentMode to another value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestChangeOnMode_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onModeArgument; + onModeArgument = + [NSNumber numberWithUnsignedChar:4U]; + [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Change On Mode: Error: %@", err); + } else { + NSLog(@"Change On Mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetStartUpOnOff_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id startUpOnOffArgument; + startUpOnOffArgument = + [NSNumber numberWithUnsignedChar:1U]; + [cluster writeAttributeStartUpOnOffWithValue:startUpOnOffArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set StartUpOnOff: Error: %@", err); + } else { + NSLog(@"Set StartUpOnOff: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRebootTargetDevice_25() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_26() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestVerifyCurrentModeChangeBasedOnOnModeAsItOverwritesStartUpMode_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify Current Mode Change based on OnMode, as it overwrites StartUpMode: Error: %@", err); + } else { + NSLog(@"Verify Current Mode Change based on OnMode, as it overwrites StartUpMode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentMode", actualValue, 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestChangeOnModeToNull_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onModeArgument; + onModeArgument = nil; + [cluster writeAttributeOnModeWithValue:onModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Change On Mode to Null: Error: %@", err); + } else { + NSLog(@"Change On Mode to Null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRebootTargetDevice_29() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_30() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestVerifyCurrentModeChangeBasedOnNewStartUpMode_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterModeSelect alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify Current Mode Change based on new StartUp Mode: Error: %@", err); + } else { + NSLog(@"Verify Current Mode Change based on new StartUp Mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CurrentMode", actualValue, 7U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestTemperatureControl : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestTemperatureControl() + : TestCommandBridge("TestTemperatureControl") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestTemperatureControl() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestTemperatureControl\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestTemperatureControl\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read supported temperature levels\n"); + err = TestReadSupportedTemperatureLevels_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read selected temperature level\n"); + err = TestReadSelectedTemperatureLevel_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Set temperature level to different level\n"); + err = TestSetTemperatureLevelToDifferentLevel_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read back selected temperature level\n"); + err = TestReadBackSelectedTemperatureLevel_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Set temperature level to different level\n"); + err = TestSetTemperatureLevelToDifferentLevel_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read back selected temperature level\n"); + err = TestReadBackSelectedTemperatureLevel_6(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 7; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadSupportedTemperatureLevels_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedTemperatureLevelsWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read supported temperature levels: Error: %@", err); + } else { + NSLog(@"Read supported temperature levels: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("SupportedTemperatureLevels", [actualValue count], static_cast(3))); + VerifyOrReturn(CheckValueAsString("", actualValue[0], @"Hot")); + VerifyOrReturn(CheckValueAsString("", actualValue[1], @"Warm")); + VerifyOrReturn(CheckValueAsString("", actualValue[2], @"Freezing")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadSelectedTemperatureLevel_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read selected temperature level: Error: %@", err); + } else { + NSLog(@"Read selected temperature level: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetTemperatureLevelToDifferentLevel_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; + params.targetTemperatureLevel = + [NSNumber numberWithUnsignedChar:1U]; + [cluster setTemperatureWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set temperature level to different level: Error: %@", err); + } else { + NSLog(@"Set temperature level to different level: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackSelectedTemperatureLevel_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back selected temperature level: Error: %@", err); + } else { + NSLog(@"Read back selected temperature level: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetTemperatureLevelToDifferentLevel_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTemperatureControlClusterSetTemperatureParams alloc] init]; + params.targetTemperatureLevel = + [NSNumber numberWithUnsignedChar:3U]; + [cluster setTemperatureWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set temperature level to different level: Error: %@", err); + } else { + NSLog(@"Set temperature level to different level: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackSelectedTemperatureLevel_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTemperatureControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSelectedTemperatureLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back selected temperature level: Error: %@", err); + } else { + NSLog(@"Read back selected temperature level: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("SelectedTemperatureLevel", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestSelfFabricRemoval : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestSelfFabricRemoval() + : TestCommandBridge("TestSelfFabricRemoval") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestSelfFabricRemoval() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestSelfFabricRemoval\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestSelfFabricRemoval\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read number of commissioned fabrics\n"); + err = TestReadNumberOfCommissionedFabrics_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read current fabric index\n"); + err = TestReadCurrentFabricIndex_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Remove single own fabric\n"); + err = TestRemoveSingleOwnFabric_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadNumberOfCommissionedFabrics_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCommissionedFabricsWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read number of commissioned fabrics: Error: %@", err); + } else { + NSLog(@"Read number of commissioned fabrics: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("CommissionedFabrics", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("commissionedFabrics", "int8u", "int8u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull ourFabricIndex; + + CHIP_ERROR TestReadCurrentFabricIndex_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current fabric index: Error: %@", err); + } else { + NSLog(@"Read current fabric index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentFabricIndex", "int8u", "int8u")); + VerifyOrReturn(CheckConstraintMinValue("currentFabricIndex", [value unsignedCharValue], 1U)); + { + ourFabricIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveSingleOwnFabric_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; + params.fabricIndex = + [ourFabricIndex copy]; + [cluster removeFabricWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Remove single own fabric: Error: %@", err); + } else { + NSLog(@"Remove single own fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestSystemCommands : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestSystemCommands() + : TestCommandBridge("TestSystemCommands") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("payload", &mPayload); + AddArgument("secondNodeId", 0, UINT64_MAX, &mSecondNodeId); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestSystemCommands() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestSystemCommands\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestSystemCommands\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Stop the default accessory\n"); + err = TestStopTheDefaultAccessory_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Start the default accessory with no command line options\n"); + err = TestStartTheDefaultAccessoryWithNoCommandLineOptions_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Stop the default accessory by key\n"); + err = TestStopTheDefaultAccessoryByKey_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Start the default accessory with discriminator command line option\n"); + err = TestStartTheDefaultAccessoryWithDiscriminatorCommandLineOption_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Stop the default accessory\n"); + err = TestStopTheDefaultAccessory_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Start the default accessory with discriminator and port command line options\n"); + err = TestStartTheDefaultAccessoryWithDiscriminatorAndPortCommandLineOptions_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Stop the default accessory\n"); + err = TestStopTheDefaultAccessory_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Start the default accessory with minCommissioningTimeout only\n"); + err = TestStartTheDefaultAccessoryWithMinCommissioningTimeoutOnly_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Stop the default accessory\n"); + err = TestStopTheDefaultAccessory_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Start the default accessory by key with all command line options\n"); + err = TestStartTheDefaultAccessoryByKeyWithAllCommandLineOptions_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Start a second accessory with all command line options\n"); + err = TestStartASecondAccessoryWithAllCommandLineOptions_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Commission second accessory from alpha\n"); + err = TestCommissionSecondAccessoryFromAlpha_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for the second commissioned device to be retrieved for alpha\n"); + err = TestWaitForTheSecondCommissionedDeviceToBeRetrievedForAlpha_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Stop the second accessory\n"); + err = TestStopTheSecondAccessory_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Start a second accessory with different KVS\n"); + err = TestStartASecondAccessoryWithDifferentKvs_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Commission second accessory with new KVS from alpha\n"); + err = TestCommissionSecondAccessoryWithNewKvsFromAlpha_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Wait for the second commissioned device with new KVS to be retrieved for alpha\n"); + err = TestWaitForTheSecondCommissionedDeviceWithNewKvsToBeRetrievedForAlpha_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Reboot the default accessory\n"); + err = TestRebootTheDefaultAccessory_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Reboot the default accessory by key\n"); + err = TestRebootTheDefaultAccessoryByKey_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Reboot the second accessory\n"); + err = TestRebootTheSecondAccessory_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Factory Reset the default accessory\n"); + err = TestFactoryResetTheDefaultAccessory_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Factory Reset the default accessory by key\n"); + err = TestFactoryResetTheDefaultAccessoryByKey_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Factory Reset the second accessory\n"); + err = TestFactoryResetTheSecondAccessory_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Commission the now-reset second accessory from alpha\n"); + err = TestCommissionTheNowResetSecondAccessoryFromAlpha_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Wait for the second commissioned device (after reset) to be retrieved for alpha\n"); + err = TestWaitForTheSecondCommissionedDeviceAfterResetToBeRetrievedForAlpha_25(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 26; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mPayload; + chip::Optional mSecondNodeId; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStopTheDefaultAccessory_1() + { + + chip::app::Clusters::SystemCommands::Commands::Stop::Type value; + return Stop("alpha", value); + } + + CHIP_ERROR TestStartTheDefaultAccessoryWithNoCommandLineOptions_2() + { + + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + return Start("alpha", value); + } + + CHIP_ERROR TestStopTheDefaultAccessoryByKey_3() + { + + chip::app::Clusters::SystemCommands::Commands::Stop::Type value; + value.registerKey.Emplace(); + value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); + return Stop("alpha", value); + } + + CHIP_ERROR TestStartTheDefaultAccessoryWithDiscriminatorCommandLineOption_4() + { + + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + value.discriminator.Emplace(); + value.discriminator.Value() = 1111U; + return Start("alpha", value); + } + + CHIP_ERROR TestStopTheDefaultAccessory_5() + { + + chip::app::Clusters::SystemCommands::Commands::Stop::Type value; + return Stop("alpha", value); + } + + CHIP_ERROR TestStartTheDefaultAccessoryWithDiscriminatorAndPortCommandLineOptions_6() + { + + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + value.discriminator.Emplace(); + value.discriminator.Value() = 1111U; + value.port.Emplace(); + value.port.Value() = 5560U; + return Start("alpha", value); + } + + CHIP_ERROR TestStopTheDefaultAccessory_7() + { + + chip::app::Clusters::SystemCommands::Commands::Stop::Type value; + return Stop("alpha", value); + } + + CHIP_ERROR TestStartTheDefaultAccessoryWithMinCommissioningTimeoutOnly_8() + { + + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + value.minCommissioningTimeout.Emplace(); + value.minCommissioningTimeout.Value() = 10U; + return Start("alpha", value); + } + + CHIP_ERROR TestStopTheDefaultAccessory_9() + { + + chip::app::Clusters::SystemCommands::Commands::Stop::Type value; + return Stop("alpha", value); + } + + CHIP_ERROR TestStartTheDefaultAccessoryByKeyWithAllCommandLineOptions_10() + { + + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + value.registerKey.Emplace(); + value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); + value.discriminator.Emplace(); + value.discriminator.Value() = 1111U; + value.port.Emplace(); + value.port.Value() = 5560U; + value.kvs.Emplace(); + value.kvs.Value() = chip::Span("/tmp/chip_kvs_defaultgarbage: not in length on purpose", 21); + value.minCommissioningTimeout.Emplace(); + value.minCommissioningTimeout.Value() = 10U; + return Start("alpha", value); + } + + CHIP_ERROR TestStartASecondAccessoryWithAllCommandLineOptions_11() + { + + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + value.registerKey.Emplace(); + value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); + value.discriminator.Emplace(); + value.discriminator.Value() = 50U; + value.port.Emplace(); + value.port.Value() = 5561U; + value.kvs.Emplace(); + value.kvs.Value() = chip::Span("/tmp/chip_kvs_lockgarbage: not in length on purpose", 18); + return Start("alpha", value); + } + + CHIP_ERROR TestCommissionSecondAccessoryFromAlpha_12() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); + return PairWithCode("alpha", value); + } + + CHIP_ERROR TestWaitForTheSecondCommissionedDeviceToBeRetrievedForAlpha_13() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStopTheSecondAccessory_14() + { + + chip::app::Clusters::SystemCommands::Commands::Stop::Type value; + value.registerKey.Emplace(); + value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); + return Stop("alpha", value); + } + + CHIP_ERROR TestStartASecondAccessoryWithDifferentKvs_15() + { + + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + value.registerKey.Emplace(); + value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); + value.discriminator.Emplace(); + value.discriminator.Value() = 50U; + value.port.Emplace(); + value.port.Value() = 5561U; + value.kvs.Emplace(); + value.kvs.Value() = chip::Span("/tmp/chip_kvs_lock2garbage: not in length on purpose", 19); + return Start("alpha", value); + } + + CHIP_ERROR TestCommissionSecondAccessoryWithNewKvsFromAlpha_16() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); + return PairWithCode("alpha", value); + } + + CHIP_ERROR TestWaitForTheSecondCommissionedDeviceWithNewKvsToBeRetrievedForAlpha_17() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestRebootTheDefaultAccessory_18() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestRebootTheDefaultAccessoryByKey_19() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + value.registerKey.Emplace(); + value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); + return Reboot("alpha", value); + } + + CHIP_ERROR TestRebootTheSecondAccessory_20() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + value.registerKey.Emplace(); + value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); + return Reboot("alpha", value); + } + + CHIP_ERROR TestFactoryResetTheDefaultAccessory_21() + { + + chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; + return FactoryReset("alpha", value); + } + + CHIP_ERROR TestFactoryResetTheDefaultAccessoryByKey_22() + { + + chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; + value.registerKey.Emplace(); + value.registerKey.Value() = chip::Span("defaultgarbage: not in length on purpose", 7); + return FactoryReset("alpha", value); + } + + CHIP_ERROR TestFactoryResetTheSecondAccessory_23() + { + + chip::app::Clusters::SystemCommands::Commands::FactoryReset::Type value; + value.registerKey.Emplace(); + value.registerKey.Value() = chip::Span("chip-lock-appgarbage: not in length on purpose", 13); + return FactoryReset("alpha", value); + } + + CHIP_ERROR TestCommissionTheNowResetSecondAccessoryFromAlpha_24() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0IX4122-.548G00", 22); + return PairWithCode("alpha", value); + } + + CHIP_ERROR TestWaitForTheSecondCommissionedDeviceAfterResetToBeRetrievedForAlpha_25() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mSecondNodeId.HasValue() ? mSecondNodeId.Value() : 3735928559ULL; + return WaitForCommissionee("alpha", value); + } +}; + +class TestBinding : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestBinding() + : TestCommandBridge("TestBinding") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestBinding() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestBinding\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestBinding\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Write empty binding table\n"); + err = TestWriteEmptyBindingTable_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read empty binding table\n"); + err = TestReadEmptyBindingTable_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Write invalid binding table\n"); + err = TestWriteInvalidBindingTable_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Write binding table (endpoint 1)\n"); + err = TestWriteBindingTableEndpoint1_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read binding table (endpoint 1)\n"); + err = TestReadBindingTableEndpoint1_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Write binding table (endpoint 0)\n"); + err = TestWriteBindingTableEndpoint0_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Read binding table (endpoint 0)\n"); + err = TestReadBindingTableEndpoint0_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Verify endpoint 1 not changed\n"); + err = TestVerifyEndpoint1NotChanged_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Write over-long binding table on endpoint 1\n"); + err = TestWriteOverLongBindingTableOnEndpoint1_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestWriteEmptyBindingTable_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bindingArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + bindingArgument = temp_0; + } + [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write empty binding table: Error: %@", err); + } else { + NSLog(@"Write empty binding table: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadEmptyBindingTable_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read empty binding table: Error: %@", err); + } else { + NSLog(@"Read empty binding table: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(0))); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteInvalidBindingTable_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bindingArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).node = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).group = + [NSNumber numberWithUnsignedShort:1U]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = + [NSNumber numberWithUnsignedShort:1U]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + bindingArgument = temp_0; + } + [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write invalid binding table: Error: %@", err); + } else { + NSLog(@"Write invalid binding table: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteBindingTableEndpoint1_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bindingArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[0]).group = + [NSNumber numberWithUnsignedShort:1U]; + ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).node = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = + [NSNumber numberWithUnsignedShort:1U]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[2] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[2]).node = + [NSNumber numberWithUnsignedLongLong:2ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[2]).endpoint = + [NSNumber numberWithUnsignedShort:1U]; + ((MTRBindingClusterTargetStruct *) temp_0[2]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + bindingArgument = temp_0; + } + [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write binding table (endpoint 1): Error: %@", err); + } else { + NSLog(@"Write binding table (endpoint 1): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBindingTableEndpoint1_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read binding table (endpoint 1): Error: %@", err); + } else { + NSLog(@"Read binding table (endpoint 1): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(3))); + VerifyOrReturn(CheckValue("Group", ((MTRBindingClusterTargetStruct *) actualValue[0]).group, 1U)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[1]).node, 1ULL)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[1]).endpoint, 1U)); + VerifyOrReturn(CheckValue("Cluster", ((MTRBindingClusterTargetStruct *) actualValue[1]).cluster, 6UL)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[1]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[2]).node, 2ULL)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[2]).endpoint, 1U)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[2]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteBindingTableEndpoint0_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bindingArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[0]).node = + [NSNumber numberWithUnsignedLongLong:3ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[0]).endpoint = + [NSNumber numberWithUnsignedShort:1U]; + ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + bindingArgument = temp_0; + } + [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write binding table (endpoint 0): Error: %@", err); + } else { + NSLog(@"Write binding table (endpoint 0): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBindingTableEndpoint0_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read binding table (endpoint 0): Error: %@", err); + } else { + NSLog(@"Read binding table (endpoint 0): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[0]).node, 3ULL)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[0]).endpoint, 1U)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyEndpoint1NotChanged_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeBindingWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify endpoint 1 not changed: Error: %@", err); + } else { + NSLog(@"Verify endpoint 1 not changed: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Binding", [actualValue count], static_cast(3))); + VerifyOrReturn(CheckValue("Group", ((MTRBindingClusterTargetStruct *) actualValue[0]).group, 1U)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[0]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[1]).node, 1ULL)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[1]).endpoint, 1U)); + VerifyOrReturn(CheckValue("Cluster", ((MTRBindingClusterTargetStruct *) actualValue[1]).cluster, 6UL)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[1]).fabricIndex, 1U)); + VerifyOrReturn(CheckValue("Node", ((MTRBindingClusterTargetStruct *) actualValue[2]).node, 2ULL)); + VerifyOrReturn(CheckValue("Endpoint", ((MTRBindingClusterTargetStruct *) actualValue[2]).endpoint, 1U)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRBindingClusterTargetStruct *) actualValue[2]).fabricIndex, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteOverLongBindingTableOnEndpoint1_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBinding alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id bindingArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[0]).node = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[0]).endpoint = + [NSNumber numberWithUnsignedShort:1U]; + ((MTRBindingClusterTargetStruct *) temp_0[0]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[1] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).node = + [NSNumber numberWithUnsignedLongLong:2ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).endpoint = + [NSNumber numberWithUnsignedShort:2U]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[2] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[2]).node = + [NSNumber numberWithUnsignedLongLong:3ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[2]).endpoint = + [NSNumber numberWithUnsignedShort:3U]; + ((MTRBindingClusterTargetStruct *) temp_0[2]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[2]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[3] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[3]).node = + [NSNumber numberWithUnsignedLongLong:4ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[3]).endpoint = + [NSNumber numberWithUnsignedShort:4U]; + ((MTRBindingClusterTargetStruct *) temp_0[3]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[3]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[4] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[4]).node = + [NSNumber numberWithUnsignedLongLong:5ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[4]).endpoint = + [NSNumber numberWithUnsignedShort:5U]; + ((MTRBindingClusterTargetStruct *) temp_0[4]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[4]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[5] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[5]).node = + [NSNumber numberWithUnsignedLongLong:6ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[5]).endpoint = + [NSNumber numberWithUnsignedShort:6U]; + ((MTRBindingClusterTargetStruct *) temp_0[5]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[5]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[6] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[6]).node = + [NSNumber numberWithUnsignedLongLong:7ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[6]).endpoint = + [NSNumber numberWithUnsignedShort:7U]; + ((MTRBindingClusterTargetStruct *) temp_0[6]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[6]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[7] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[7]).node = + [NSNumber numberWithUnsignedLongLong:8ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[7]).endpoint = + [NSNumber numberWithUnsignedShort:8U]; + ((MTRBindingClusterTargetStruct *) temp_0[7]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[7]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[8] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[8]).node = + [NSNumber numberWithUnsignedLongLong:9ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[8]).endpoint = + [NSNumber numberWithUnsignedShort:9U]; + ((MTRBindingClusterTargetStruct *) temp_0[8]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[8]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[9] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[9]).node = + [NSNumber numberWithUnsignedLongLong:10ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[9]).endpoint = + [NSNumber numberWithUnsignedShort:10U]; + ((MTRBindingClusterTargetStruct *) temp_0[9]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[9]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + temp_0[10] = [[MTRBindingClusterTargetStruct alloc] init]; + ((MTRBindingClusterTargetStruct *) temp_0[10]).node = + [NSNumber numberWithUnsignedLongLong:11ULL]; + ((MTRBindingClusterTargetStruct *) temp_0[10]).endpoint = + [NSNumber numberWithUnsignedShort:11U]; + ((MTRBindingClusterTargetStruct *) temp_0[10]).cluster = + [NSNumber numberWithUnsignedInt:6UL]; + ((MTRBindingClusterTargetStruct *) temp_0[10]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + bindingArgument = temp_0; + } + [cluster writeAttributeBindingWithValue:bindingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write over-long binding table on endpoint 1: Error: %@", err); + } else { + NSLog(@"Write over-long binding table on endpoint 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestUserLabelCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestUserLabelCluster() + : TestCommandBridge("TestUserLabelCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestUserLabelCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestUserLabelCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestUserLabelCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Commit User Label List\n"); + err = TestCommitUserLabelList_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Verify committed User Label List\n"); + err = TestVerifyCommittedUserLabelList_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Clear User Label List\n"); + err = TestClearUserLabelList_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read User Label List\n"); + err = TestReadUserLabelList_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Write User Label List\n"); + err = TestWriteUserLabelList_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Reboot target device\n"); + err = TestRebootTargetDevice_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Verify User Label List after reboot\n"); + err = TestVerifyUserLabelListAfterReboot_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestCommitUserLabelList_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id labelListArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 1"; + + temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"orientation"; + ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"South"; + + temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; + ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"2"; + + temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"direction"; + ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"down"; + + labelListArgument = temp_0; + } + [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Commit User Label List: Error: %@", err); + } else { + NSLog(@"Commit User Label List: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCommittedUserLabelList_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify committed User Label List: Error: %@", err); + } else { + NSLog(@"Verify committed User Label List: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 1")); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"orientation")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"South")); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"2")); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"direction")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"down")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearUserLabelList_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id labelListArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + labelListArgument = temp_0; + } + [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear User Label List: Error: %@", err); + } else { + NSLog(@"Clear User Label List: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadUserLabelList_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read User Label List: Error: %@", err); + } else { + NSLog(@"Read User Label List: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(0))); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteUserLabelList_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id labelListArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"room"; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 2"; + + temp_0[1] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[1]).label = @"orientation"; + ((MTRUserLabelClusterLabelStruct *) temp_0[1]).value = @"North"; + + temp_0[2] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[2]).label = @"floor"; + ((MTRUserLabelClusterLabelStruct *) temp_0[2]).value = @"5"; + + temp_0[3] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[3]).label = @"direction"; + ((MTRUserLabelClusterLabelStruct *) temp_0[3]).value = @"up"; + + labelListArgument = temp_0; + } + [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write User Label List: Error: %@", err); + } else { + NSLog(@"Write User Label List: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRebootTargetDevice_6() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_7() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestVerifyUserLabelListAfterReboot_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLabelListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify User Label List after reboot: Error: %@", err); + } else { + NSLog(@"Verify User Label List after reboot: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("LabelList", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).label, @"room")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[0]).value, @"bedroom 2")); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).label, @"orientation")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[1]).value, @"North")); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).label, @"floor")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[2]).value, @"5")); + VerifyOrReturn(CheckValueAsString("Label", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).label, @"direction")); + VerifyOrReturn(CheckValueAsString("Value", ((MTRUserLabelClusterLabelStruct *) actualValue[3]).value, @"up")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestUserLabelClusterConstraints : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestUserLabelClusterConstraints() + : TestCommandBridge("TestUserLabelClusterConstraints") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestUserLabelClusterConstraints() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestUserLabelClusterConstraints\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestUserLabelClusterConstraints\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Attempt to write overly long item for label\n"); + err = TestAttemptToWriteOverlyLongItemForLabel_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Attempt to write overly long item for value\n"); + err = TestAttemptToWriteOverlyLongItemForValue_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestAttemptToWriteOverlyLongItemForLabel_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id labelListArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"this is longer than sixteen characters"; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"bedroom 2"; + + labelListArgument = temp_0; + } + [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Attempt to write overly long item for label: Error: %@", err); + } else { + NSLog(@"Attempt to write overly long item for label: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestAttemptToWriteOverlyLongItemForValue_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterUserLabel alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id labelListArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRUserLabelClusterLabelStruct alloc] init]; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).label = @"test"; + ((MTRUserLabelClusterLabelStruct *) temp_0[0]).value = @"this is longer than sixteen characters"; + + labelListArgument = temp_0; + } + [cluster writeAttributeLabelListWithValue:labelListArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Attempt to write overly long item for value: Error: %@", err); + } else { + NSLog(@"Attempt to write overly long item for value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestArmFailSafe : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestArmFailSafe() + : TestCommandBridge("TestArmFailSafe") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestArmFailSafe() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestArmFailSafe\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestArmFailSafe\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Reboot target device\n"); + err = TestRebootTargetDevice_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Wait for the alpha device to be retrieved \n"); + err = TestWaitForTheAlphaDeviceToBeRetrieved_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Query fabrics list\n"); + err = TestQueryFabricsList_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : ArmFailSafe on target device with timeout 0\n"); + err = TestArmFailSafeOnTargetDeviceWithTimeout0_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Reads NodeLabel mandatory attribute of target device\n"); + err = TestReadsNodeLabelMandatoryAttributeOfTargetDevice_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Invoke AddTrustedRootCertificate without fail-safe\n"); + err = TestInvokeAddTrustedRootCertificateWithoutFailSafe_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Invoke AddNOC without fail-safe\n"); + err = TestInvokeAddNOCWithoutFailSafe_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Invoke UpdateNOC without fail-safe\n"); + err = TestInvokeUpdateNOCWithoutFailSafe_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Invoke CSRRequest without fail-safe\n"); + err = TestInvokeCSRRequestWithoutFailSafe_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestRebootTargetDevice_0() + { + + chip::app::Clusters::SystemCommands::Commands::Reboot::Type value; + return Reboot("alpha", value); + } + + CHIP_ERROR TestWaitForTheAlphaDeviceToBeRetrieved_1() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestQueryFabricsList_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Query fabrics list: Error: %@", err); + } else { + NSLog(@"Query fabrics list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("NodeID", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).nodeID, mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL)); + VerifyOrReturn(CheckValueAsString("Label", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).label, @"")); + } + + VerifyOrReturn(CheckConstraintType("fabrics", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestArmFailSafeOnTargetDeviceWithTimeout0_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGeneralCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGeneralCommissioningClusterArmFailSafeParams alloc] init]; + params.expiryLengthSeconds = + [NSNumber numberWithUnsignedShort:0U]; + params.breadcrumb = + [NSNumber numberWithUnsignedLongLong:0ULL]; + [cluster armFailSafeWithParams:params completion: + ^(MTRGeneralCommissioningClusterArmFailSafeResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"ArmFailSafe on target device with timeout 0: Error: %@", err); + } else { + NSLog(@"ArmFailSafe on target device with timeout 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.errorCode; + VerifyOrReturn(CheckValue("ErrorCode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadsNodeLabelMandatoryAttributeOfTargetDevice_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Reads NodeLabel mandatory attribute of target device: Error: %@", err); + } else { + NSLog(@"Reads NodeLabel mandatory attribute of target device: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestInvokeAddTrustedRootCertificateWithoutFailSafe_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterAddTrustedRootCertificateParams alloc] init]; + params.rootCACertificate = + [[NSData alloc] initWithBytes:"00000000" length:8]; + [cluster addTrustedRootCertificateWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Invoke AddTrustedRootCertificate without fail-safe: Error: %@", err); + } else { + NSLog(@"Invoke AddTrustedRootCertificate without fail-safe: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestInvokeAddNOCWithoutFailSafe_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterAddNOCParams alloc] init]; + params.nocValue = + [[NSData alloc] initWithBytes:"00112233" length:8]; + params.ipkValue = + [[NSData alloc] initWithBytes:"\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007" length:16]; + params.caseAdminSubject = + [NSNumber numberWithUnsignedLongLong:1234ULL]; + params.adminVendorId = + [NSNumber numberWithUnsignedShort:65521U]; + [cluster addNOCWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Invoke AddNOC without fail-safe: Error: %@", err); + } else { + NSLog(@"Invoke AddNOC without fail-safe: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestInvokeUpdateNOCWithoutFailSafe_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterUpdateNOCParams alloc] init]; + params.nocValue = + [[NSData alloc] initWithBytes:"00112233" length:8]; + [cluster updateNOCWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Invoke UpdateNOC without fail-safe: Error: %@", err); + } else { + NSLog(@"Invoke UpdateNOC without fail-safe: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestInvokeCSRRequestWithoutFailSafe_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterCSRRequestParams alloc] init]; + params.csrNonce = + [[NSData alloc] initWithBytes:"\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007\000\001\002\003\004\005\006\007" length:32]; + [cluster CSRRequestWithParams:params completion: + ^(MTROperationalCredentialsClusterCSRResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Invoke CSRRequest without fail-safe: Error: %@", err); + } else { + NSLog(@"Invoke CSRRequest without fail-safe: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILSAFE_REQUIRED)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestFanControl : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestFanControl() + : TestCommandBridge("TestFanControl") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestFanControl() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestFanControl\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestFanControl\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Write fan mode\n"); + err = TestWriteFanMode_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read back fan mode\n"); + err = TestReadBackFanMode_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Write percent setting\n"); + err = TestWritePercentSetting_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read back percent setting\n"); + err = TestReadBackPercentSetting_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read back speed setting\n"); + err = TestReadBackSpeedSetting_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read back speed current\n"); + err = TestReadBackSpeedCurrent_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Write percent setting\n"); + err = TestWritePercentSetting_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Read back percent setting\n"); + err = TestReadBackPercentSetting_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Write speed setting\n"); + err = TestWriteSpeedSetting_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Read back speed setting\n"); + err = TestReadBackSpeedSetting_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Read back percent setting\n"); + err = TestReadBackPercentSetting_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Read back percent current\n"); + err = TestReadBackPercentCurrent_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Write speed setting\n"); + err = TestWriteSpeedSetting_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Read back speed setting\n"); + err = TestReadBackSpeedSetting_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Write fan mode\n"); + err = TestWriteFanMode_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Read back percent setting\n"); + err = TestReadBackPercentSetting_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Read back percent current\n"); + err = TestReadBackPercentCurrent_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Read back speed setting\n"); + err = TestReadBackSpeedSetting_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Read back speed current\n"); + err = TestReadBackSpeedCurrent_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Write fan mode\n"); + err = TestWriteFanMode_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Read back percent setting\n"); + err = TestReadBackPercentSetting_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Read back speed setting\n"); + err = TestReadBackSpeedSetting_22(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 23; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestWriteFanMode_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id fanModeArgument; + fanModeArgument = + [NSNumber numberWithUnsignedChar:3U]; + [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write fan mode: Error: %@", err); + } else { + NSLog(@"Write fan mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackFanMode_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFanModeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back fan mode: Error: %@", err); + } else { + NSLog(@"Read back fan mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FanMode", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWritePercentSetting_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id percentSettingArgument; + percentSettingArgument = + [NSNumber numberWithUnsignedChar:84U]; + [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write percent setting: Error: %@", err); + } else { + NSLog(@"Write percent setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackPercentSetting_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back percent setting: Error: %@", err); + } else { + NSLog(@"Read back percent setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); + VerifyOrReturn(CheckValue("PercentSetting", actualValue, 84U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackSpeedSetting_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back speed setting: Error: %@", err); + } else { + NSLog(@"Read back speed setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); + VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 84U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackSpeedCurrent_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back speed current: Error: %@", err); + } else { + NSLog(@"Read back speed current: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("SpeedCurrent", actualValue, 84U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWritePercentSetting_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id percentSettingArgument; + percentSettingArgument = nil; + [cluster writeAttributePercentSettingWithValue:percentSettingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write percent setting: Error: %@", err); + } else { + NSLog(@"Write percent setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackPercentSetting_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back percent setting: Error: %@", err); + } else { + NSLog(@"Read back percent setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); + VerifyOrReturn(CheckValue("PercentSetting", actualValue, 84U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteSpeedSetting_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id speedSettingArgument; + speedSettingArgument = + [NSNumber numberWithUnsignedChar:73U]; + [cluster writeAttributeSpeedSettingWithValue:speedSettingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write speed setting: Error: %@", err); + } else { + NSLog(@"Write speed setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackSpeedSetting_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back speed setting: Error: %@", err); + } else { + NSLog(@"Read back speed setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); + VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 73U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackPercentSetting_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back percent setting: Error: %@", err); + } else { + NSLog(@"Read back percent setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); + VerifyOrReturn(CheckValue("PercentSetting", actualValue, 73U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackPercentCurrent_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back percent current: Error: %@", err); + } else { + NSLog(@"Read back percent current: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PercentCurrent", actualValue, 73U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteSpeedSetting_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id speedSettingArgument; + speedSettingArgument = nil; + [cluster writeAttributeSpeedSettingWithValue:speedSettingArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write speed setting: Error: %@", err); + } else { + NSLog(@"Write speed setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackSpeedSetting_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back speed setting: Error: %@", err); + } else { + NSLog(@"Read back speed setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); + VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 73U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteFanMode_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id fanModeArgument; + fanModeArgument = + [NSNumber numberWithUnsignedChar:0U]; + [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write fan mode: Error: %@", err); + } else { + NSLog(@"Write fan mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackPercentSetting_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back percent setting: Error: %@", err); + } else { + NSLog(@"Read back percent setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("PercentSetting", actualValue)); + VerifyOrReturn(CheckValue("PercentSetting", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackPercentCurrent_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back percent current: Error: %@", err); + } else { + NSLog(@"Read back percent current: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("PercentCurrent", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackSpeedSetting_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back speed setting: Error: %@", err); + } else { + NSLog(@"Read back speed setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("SpeedSetting", actualValue)); + VerifyOrReturn(CheckValue("SpeedSetting", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackSpeedCurrent_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedCurrentWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back speed current: Error: %@", err); + } else { + NSLog(@"Read back speed current: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("SpeedCurrent", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteFanMode_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id fanModeArgument; + fanModeArgument = + [NSNumber numberWithUnsignedChar:5U]; + [cluster writeAttributeFanModeWithValue:fanModeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write fan mode: Error: %@", err); + } else { + NSLog(@"Write fan mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackPercentSetting_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePercentSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back percent setting: Error: %@", err); + } else { + NSLog(@"Read back percent setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("PercentSetting", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackSpeedSetting_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterFanControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSpeedSettingWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back speed setting: Error: %@", err); + } else { + NSLog(@"Read back speed setting: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("SpeedSetting", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestAccessControlConstraints : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestAccessControlConstraints() + : TestCommandBridge("TestAccessControlConstraints") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestAccessControlConstraints() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestAccessControlConstraints\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestAccessControlConstraints\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Constraint error: PASE reserved for future (TC-ACL-2.4 step 29)\n"); + err = TestConstraintErrorPaseReservedForFutureTcAcl24Step29_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31)\n"); + err = TestConstraintErrorInvalidCombinationAdministerGroupTcAcl24Step31_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Constraint error: Invalid auth mode (TC-ACL-2.4 step 33)\n"); + err = TestConstraintErrorInvalidAuthModeTcAcl24Step33_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Constraint error: Invalid subject (TC-ACL-2.4 step 34)\n"); + err = TestConstraintErrorInvalidSubjectTcAcl24Step34_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Constraint error: Invalid target (TC-ACL-2.4 step 38)\n"); + err = TestConstraintErrorInvalidTargetTcAcl24Step38_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42)\n"); + err = TestConstraintErrorTargetHasBothEndpointAndDeviceTypeTcAcl24Step42_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Constraint error: Invalid privilege value step 32)\n"); + err = TestConstraintErrorInvalidPrivilegeValueStep32_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35)\n"); + err = TestConstraintErrorInvalidSubject0xFFFFFfffFfffFfffTcAcl24Step35_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36)\n"); + err = TestConstraintErrorInvalidSubject0xFFFFFffd00000000TcAcl24Step36_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37)\n"); + err = TestConstraintErrorInvalidSubject0xFFFFFfffFfff0000TcAcl24Step37_10(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 11; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestConstraintErrorPaseReservedForFutureTcAcl24Step29_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:112233ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:1U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Constraint error: PASE reserved for future (TC-ACL-2.4 step 29): Error: %@", err); + } else { + NSLog(@"Constraint error: PASE reserved for future (TC-ACL-2.4 step 29): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestConstraintErrorInvalidCombinationAdministerGroupTcAcl24Step31_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:112233ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:3U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31): Error: %@", err); + } else { + NSLog(@"Constraint error: Invalid combination administer + group (TC-ACL-2.4 step 31): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestConstraintErrorInvalidAuthModeTcAcl24Step33_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:112233ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:4U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Constraint error: Invalid auth mode (TC-ACL-2.4 step 33): Error: %@", err); + } else { + NSLog(@"Constraint error: Invalid auth mode (TC-ACL-2.4 step 33): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestConstraintErrorInvalidSubjectTcAcl24Step34_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:112233ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Constraint error: Invalid subject (TC-ACL-2.4 step 34): Error: %@", err); + } else { + NSLog(@"Constraint error: Invalid subject (TC-ACL-2.4 step 34): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestConstraintErrorInvalidTargetTcAcl24Step38_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:112233ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = nil; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Constraint error: Invalid target (TC-ACL-2.4 step 38): Error: %@", err); + } else { + NSLog(@"Constraint error: Invalid target (TC-ACL-2.4 step 38): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestConstraintErrorTargetHasBothEndpointAndDeviceTypeTcAcl24Step42_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:112233ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = [[MTRAccessControlClusterAccessControlTargetStruct alloc] init]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).cluster = nil; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).endpoint = + [NSNumber numberWithUnsignedShort:22U]; + ((MTRAccessControlClusterAccessControlTargetStruct *) temp_3[0]).deviceType = + [NSNumber numberWithUnsignedInt:33UL]; + + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42): Error: %@", err); + } else { + NSLog(@"Constraint error: target has both endpoint and device type (TC-ACL-2.4 step 42): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestConstraintErrorInvalidPrivilegeValueStep32_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:112233ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:6U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Constraint error: Invalid privilege value step 32): Error: %@", err); + } else { + NSLog(@"Constraint error: Invalid privilege value step 32): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfffFfffTcAcl24Step35_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:112233ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:18446744073709551615ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35): Error: %@", err); + } else { + NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_FFFF (TC-ACL-2.4 step 35): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFffd00000000TcAcl24Step36_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:112233ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:18446744060824649728ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36): Error: %@", err); + } else { + NSLog(@"Constraint error: invalid subject 0xFFFF_FFFD_0000_0000 (TC-ACL-2.4 step 36): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestConstraintErrorInvalidSubject0xFFFFFfffFfff0000TcAcl24Step37_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:112233ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).privilege = + [NSNumber numberWithUnsignedChar:3U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [NSNumber numberWithUnsignedLongLong:18446744073709486080ULL]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37): Error: %@", err); + } else { + NSLog(@"Constraint error: invalid subject 0xFFFF_FFFF_FFFF_0000 (TC-ACL-2.4 step 37): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestLevelControlWithOnOffDependency : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestLevelControlWithOnOffDependency() + : TestCommandBridge("TestLevelControlWithOnOffDependency") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestLevelControlWithOnOffDependency() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestLevelControlWithOnOffDependency\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestLevelControlWithOnOffDependency\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Sends a MoveToLevel command to set CurrentLevel to min value\n"); + err = TestSendsAMoveToLevelCommandToSetCurrentLevelToMinValue_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Wait 100 ms\n"); + err = TestWait100Ms_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Reads CurrentLevel attribute from DUT\n"); + err = TestReadsCurrentLevelAttributeFromDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Write OnOffTransitionTime attribute\n"); + err = TestWriteOnOffTransitionTimeAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait 100 ms\n"); + err = TestWait100Ms_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read OnOffTransitionTime attribute\n"); + err = TestReadOnOffTransitionTimeAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Write OnLevel attribute\n"); + err = TestWriteOnLevelAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Wait 100 ms\n"); + err = TestWait100Ms_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Read OnLevel attribute\n"); + err = TestReadOnLevelAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Read MinValue attribute\n"); + err = TestReadMinValueAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Send On Command\n"); + err = TestSendOnCommand_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Check on/off attribute value is true after on command\n"); + err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait OnOffTransitionTime\n"); + err = TestWaitOnOffTransitionTime_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : If OnLevel is defined, check CurrentLevel is OnLevel value\n"); + err = TestIfOnLevelIsDefinedCheckCurrentLevelIsOnLevelValue_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Send Off Command\n"); + err = TestSendOffCommand_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Check on/off attribute value is false after off command\n"); + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Wait OnOffTransitionTime\n"); + err = TestWaitOnOffTransitionTime_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : If OnLevel is defined, check CurrentLevel is min value\n"); + err = TestIfOnLevelIsDefinedCheckCurrentLevelIsMinValue_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Sends a MoveToLevel command to set CurrentLevel to a mid value\n"); + err = TestSendsAMoveToLevelCommandToSetCurrentLevelToAMidValue_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Wait 100 ms\n"); + err = TestWait100Ms_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Reads CurrentLevel attribute from DUT\n"); + err = TestReadsCurrentLevelAttributeFromDut_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Set OnLevel attribute to null\n"); + err = TestSetOnLevelAttributeToNull_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Wait 100 ms\n"); + err = TestWait100Ms_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Read OnLevel attribute\n"); + err = TestReadOnLevelAttribute_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Send On Command\n"); + err = TestSendOnCommand_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Check on/off attribute value is true after on command\n"); + err = TestCheckOnOffAttributeValueIsTrueAfterOnCommand_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Wait OnOffTransitionTime\n"); + err = TestWaitOnOffTransitionTime_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : If OnLevel is not defined, check CurrentLevel is restored\n"); + err = TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Send Off Command\n"); + err = TestSendOffCommand_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Check on/off attribute value is false after off command\n"); + err = TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Wait OnOffTransitionTime\n"); + err = TestWaitOnOffTransitionTime_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : If OnLevel is not defined, check CurrentLevel is restored\n"); + err = TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_32(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 33; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestSendsAMoveToLevelCommandToSetCurrentLevelToMinValue_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:1U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:1U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:1U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Sends a MoveToLevel command to set CurrentLevel to min value: Error: %@", err); + } else { + NSLog(@"Sends a MoveToLevel command to set CurrentLevel to min value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100Ms_2() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadsCurrentLevelAttributeFromDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteOnOffTransitionTimeAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onOffTransitionTimeArgument; + onOffTransitionTimeArgument = + [NSNumber numberWithUnsignedShort:0U]; + [cluster writeAttributeOnOffTransitionTimeWithValue:onOffTransitionTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write OnOffTransitionTime attribute: Error: %@", err); + } else { + NSLog(@"Write OnOffTransitionTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100Ms_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadOnOffTransitionTimeAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffTransitionTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read OnOffTransitionTime attribute: Error: %@", err); + } else { + NSLog(@"Read OnOffTransitionTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOffTransitionTime", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteOnLevelAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onLevelArgument; + onLevelArgument = + [NSNumber numberWithUnsignedChar:254U]; + [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write OnLevel attribute: Error: %@", err); + } else { + NSLog(@"Write OnLevel attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100Ms_8() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadOnLevelAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read OnLevel attribute: Error: %@", err); + } else { + NSLog(@"Read OnLevel attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("OnLevel", actualValue)); + VerifyOrReturn(CheckValue("OnLevel", actualValue, 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadMinValueAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read MinValue attribute: Error: %@", err); + } else { + NSLog(@"Read MinValue attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("MinLevel", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendOnCommand_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send On Command: Error: %@", err); + } else { + NSLog(@"Send On Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is true after on command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitOnOffTransitionTime_13() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestIfOnLevelIsDefinedCheckCurrentLevelIsOnLevelValue_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"If OnLevel is defined, check CurrentLevel is OnLevel value: Error: %@", err); + } else { + NSLog(@"If OnLevel is defined, check CurrentLevel is OnLevel value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 254U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendOffCommand_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Off Command: Error: %@", err); + } else { + NSLog(@"Send Off Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitOnOffTransitionTime_17() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 0UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestIfOnLevelIsDefinedCheckCurrentLevelIsMinValue_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"If OnLevel is defined, check CurrentLevel is min value: Error: %@", err); + } else { + NSLog(@"If OnLevel is defined, check CurrentLevel is min value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendsAMoveToLevelCommandToSetCurrentLevelToAMidValue_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:127U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:1U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:1U]; + [cluster moveToLevelWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Sends a MoveToLevel command to set CurrentLevel to a mid value: Error: %@", err); + } else { + NSLog(@"Sends a MoveToLevel command to set CurrentLevel to a mid value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100Ms_20() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadsCurrentLevelAttributeFromDut_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Reads CurrentLevel attribute from DUT: Error: %@", err); + } else { + NSLog(@"Reads CurrentLevel attribute from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetOnLevelAttributeToNull_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id onLevelArgument; + onLevelArgument = nil; + [cluster writeAttributeOnLevelWithValue:onLevelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set OnLevel attribute to null: Error: %@", err); + } else { + NSLog(@"Set OnLevel attribute to null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait100Ms_23() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestReadOnLevelAttribute_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read OnLevel attribute: Error: %@", err); + } else { + NSLog(@"Read OnLevel attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("OnLevel", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendOnCommand_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send On Command: Error: %@", err); + } else { + NSLog(@"Send On Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsTrueAfterOnCommand_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is true after on command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is true after on command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 1)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitOnOffTransitionTime_27() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 100UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Error: %@", err); + } else { + NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSendOffCommand_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Send Off Command: Error: %@", err); + } else { + NSLog(@"Send Off Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckOnOffAttributeValueIsFalseAfterOffCommand_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOnOffWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check on/off attribute value is false after off command: Error: %@", err); + } else { + NSLog(@"Check on/off attribute value is false after off command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, 0)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitOnOffTransitionTime_31() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 0UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestIfOnLevelIsNotDefinedCheckCurrentLevelIsRestored_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Error: %@", err); + } else { + NSLog(@"If OnLevel is not defined, check CurrentLevel is restored: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 127U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestCommissioningWindow : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestCommissioningWindow() + : TestCommandBridge("TestCommissioningWindow") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("cluster", &mCluster); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("payload", &mPayload); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestCommissioningWindow() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestCommissioningWindow\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestCommissioningWindow\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved for alpha\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Get alpha's fabric index\n"); + err = TestGetAlphasFabricIndex_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Check that commissioning window is not open\n"); + err = TestCheckThatCommissioningWindowIsNotOpen_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Check that there is no AdminFabricIndex\n"); + err = TestCheckThatThereIsNoAdminFabricIndex_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Check that there is no AdminVendorId\n"); + err = TestCheckThatThereIsNoAdminVendorId_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Open Commissioning Window from alpha\n"); + err = TestOpenCommissioningWindowFromAlpha_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Check that commissioning window is open\n"); + err = TestCheckThatCommissioningWindowIsOpen_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Check the AdminFabricIndex\n"); + err = TestCheckTheAdminFabricIndex_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Check the AdminVendorId is not null\n"); + err = TestCheckTheAdminVendorIdIsNotNull_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Close Commissioning Window\n"); + err = TestCloseCommissioningWindow_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Check that commissioning window is again not open\n"); + err = TestCheckThatCommissioningWindowIsAgainNotOpen_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Check that again there is no AdminFabricIndex\n"); + err = TestCheckThatAgainThereIsNoAdminFabricIndex_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Check that again there is no AdminVendorId\n"); + err = TestCheckThatAgainThereIsNoAdminVendorId_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Open Commissioning Window from alpha again\n"); + err = TestOpenCommissioningWindowFromAlphaAgain_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Commission from beta\n"); + err = TestCommissionFromBeta_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Wait for the commissioned device to be retrieved for beta\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Check that commissioning window is not open for the third time\n"); + err = TestCheckThatCommissioningWindowIsNotOpenForTheThirdTime_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Check that there is no AdminFabricIndex for the third time\n"); + err = TestCheckThatThereIsNoAdminFabricIndexForTheThirdTime_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Check that there is no AdminVendorId for the third time\n"); + err = TestCheckThatThereIsNoAdminVendorIdForTheThirdTime_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Get beta's fabric index\n"); + err = TestGetBetasFabricIndex_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Open Commissioning Window from beta\n"); + err = TestOpenCommissioningWindowFromBeta_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Check that commissioning window is open again\n"); + err = TestCheckThatCommissioningWindowIsOpenAgain_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Check the AdminFabricIndex again\n"); + err = TestCheckTheAdminFabricIndexAgain_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Check the AdminVendorId is not null again\n"); + err = TestCheckTheAdminVendorIdIsNotNullAgain_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Remove beta fabric\n"); + err = TestRemoveBetaFabric_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Check that commissioning window is still open\n"); + err = TestCheckThatCommissioningWindowIsStillOpen_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Check the AdminFabricIndex got reset\n"); + err = TestCheckTheAdminFabricIndexGotReset_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Check the AdminVendorId did not get reset\n"); + err = TestCheckTheAdminVendorIdDidNotGetReset_27(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 28; + + chip::Optional mNodeId; + chip::Optional mNodeId2; + chip::Optional mEndpoint; + chip::Optional mCluster; + chip::Optional mDiscriminator; + chip::Optional mPayload; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull alphaIndex; + + CHIP_ERROR TestGetAlphasFabricIndex_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get alpha's fabric index: Error: %@", err); + } else { + NSLog(@"Get alpha's fabric index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + alphaIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatCommissioningWindowIsNotOpen_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that commissioning window is not open: Error: %@", err); + } else { + NSLog(@"Check that commissioning window is not open: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatThereIsNoAdminFabricIndex_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that there is no AdminFabricIndex: Error: %@", err); + } else { + NSLog(@"Check that there is no AdminFabricIndex: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatThereIsNoAdminVendorId_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that there is no AdminVendorId: Error: %@", err); + } else { + NSLog(@"Check that there is no AdminVendorId: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestOpenCommissioningWindowFromAlpha_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open Commissioning Window from alpha: Error: %@", err); + } else { + NSLog(@"Open Commissioning Window from alpha: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatCommissioningWindowIsOpen_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that commissioning window is open: Error: %@", err); + } else { + NSLog(@"Check that commissioning window is open: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckTheAdminFabricIndex_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check the AdminFabricIndex: Error: %@", err); + } else { + NSLog(@"Check the AdminFabricIndex: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (alphaIndex == nil) { + VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, alphaIndex)); + } + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckTheAdminVendorIdIsNotNull_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check the AdminVendorId is not null: Error: %@", err); + } else { + NSLog(@"Check the AdminVendorId is not null: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckValueNonNull("adminVendorId", value)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCloseCommissioningWindow_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster revokeCommissioningWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Close Commissioning Window: Error: %@", err); + } else { + NSLog(@"Close Commissioning Window: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatCommissioningWindowIsAgainNotOpen_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that commissioning window is again not open: Error: %@", err); + } else { + NSLog(@"Check that commissioning window is again not open: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatAgainThereIsNoAdminFabricIndex_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that again there is no AdminFabricIndex: Error: %@", err); + } else { + NSLog(@"Check that again there is no AdminFabricIndex: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatAgainThereIsNoAdminVendorId_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that again there is no AdminVendorId: Error: %@", err); + } else { + NSLog(@"Check that again there is no AdminVendorId: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestOpenCommissioningWindowFromAlphaAgain_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open Commissioning Window from alpha again: Error: %@", err); + } else { + NSLog(@"Open Commissioning Window from alpha again: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCommissionFromBeta_14() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_15() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + return WaitForCommissionee("beta", value); + } + + CHIP_ERROR TestCheckThatCommissioningWindowIsNotOpenForTheThirdTime_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that commissioning window is not open for the third time: Error: %@", err); + } else { + NSLog(@"Check that commissioning window is not open for the third time: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatThereIsNoAdminFabricIndexForTheThirdTime_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that there is no AdminFabricIndex for the third time: Error: %@", err); + } else { + NSLog(@"Check that there is no AdminFabricIndex for the third time: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatThereIsNoAdminVendorIdForTheThirdTime_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that there is no AdminVendorId for the third time: Error: %@", err); + } else { + NSLog(@"Check that there is no AdminVendorId for the third time: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull betaIndex; + + CHIP_ERROR TestGetBetasFabricIndex_19() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get beta's fabric index: Error: %@", err); + } else { + NSLog(@"Get beta's fabric index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + betaIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestOpenCommissioningWindowFromBeta_20() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open Commissioning Window from beta: Error: %@", err); + } else { + NSLog(@"Open Commissioning Window from beta: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatCommissioningWindowIsOpenAgain_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that commissioning window is open again: Error: %@", err); + } else { + NSLog(@"Check that commissioning window is open again: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckTheAdminFabricIndexAgain_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check the AdminFabricIndex again: Error: %@", err); + } else { + NSLog(@"Check the AdminFabricIndex again: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (betaIndex == nil) { + VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, betaIndex)); + } + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable adminVendorId; + + CHIP_ERROR TestCheckTheAdminVendorIdIsNotNullAgain_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check the AdminVendorId is not null again: Error: %@", err); + } else { + NSLog(@"Check the AdminVendorId is not null again: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + } + VerifyOrReturn(CheckValueNonNull("adminVendorId", value)); + { + adminVendorId = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveBetaFabric_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; + params.fabricIndex = + [betaIndex copy]; + [cluster removeFabricWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Remove beta fabric: Error: %@", err); + } else { + NSLog(@"Remove beta fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatCommissioningWindowIsStillOpen_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeWindowStatusWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that commissioning window is still open: Error: %@", err); + } else { + NSLog(@"Check that commissioning window is still open: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckTheAdminFabricIndexGotReset_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check the AdminFabricIndex got reset: Error: %@", err); + } else { + NSLog(@"Check the AdminFabricIndex got reset: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckTheAdminVendorIdDidNotGetReset_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAdminVendorIdWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check the AdminVendorId did not get reset: Error: %@", err); + } else { + NSLog(@"Check the AdminVendorId did not get reset: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (adminVendorId == nil) { + VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("AdminVendorId", actualValue)); + VerifyOrReturn(CheckValue("AdminVendorId", actualValue, adminVendorId)); + } + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestCommissionerNodeId : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestCommissionerNodeId() + : TestCommandBridge("TestCommissionerNodeId") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("cluster", &mCluster); + AddArgument("payload", &mPayload); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestCommissionerNodeId() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestCommissionerNodeId\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestCommissionerNodeId\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved for alpha\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Open Commissioning Window from alpha\n"); + err = TestOpenCommissioningWindowFromAlpha_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Commission from beta\n"); + err = TestCommissionFromBeta_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Wait for the commissioned device to be retrieved for beta\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Open Commissioning Window from alpha\n"); + err = TestOpenCommissioningWindowFromAlpha_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Commission from gamma\n"); + err = TestCommissionFromGamma_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Wait for the commissioned device to be retrieved for gamma\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Read the fabric ID from the alpha fabric\n"); + err = TestReadTheFabricIdFromTheAlphaFabric_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Read the commissioner node ID from the alpha fabric\n"); + err = TestReadTheCommissionerNodeIdFromTheAlphaFabric_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Read the fabric ID from the beta fabric\n"); + err = TestReadTheFabricIdFromTheBetaFabric_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Read the commissioner node ID from the beta fabric\n"); + err = TestReadTheCommissionerNodeIdFromTheBetaFabric_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Read the fabric ID from the gamma fabric\n"); + err = TestReadTheFabricIdFromTheGammaFabric_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Read the commissioner node ID from the gamma fabric\n"); + err = TestReadTheCommissionerNodeIdFromTheGammaFabric_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Read the ACL from alpha and check commissioner node id\n"); + err = TestReadTheAclFromAlphaAndCheckCommissionerNodeId_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Read the ACL from beta and check commissioner node id\n"); + err = TestReadTheAclFromBetaAndCheckCommissionerNodeId_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Read the ACL from gamma and check commissioner node id\n"); + err = TestReadTheAclFromGammaAndCheckCommissionerNodeId_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Write the ACL using the commissioner node id value\n"); + err = TestWriteTheAclUsingTheCommissionerNodeIdValue_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Write the ACL using the commissioner node id value\n"); + err = TestWriteTheAclUsingTheCommissionerNodeIdValue_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Read the ACL from beta and check commissioner node id\n"); + err = TestReadTheAclFromBetaAndCheckCommissionerNodeId_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Read the ACL from gamma and check commissioner node id\n"); + err = TestReadTheAclFromGammaAndCheckCommissionerNodeId_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Remove beta fabric\n"); + err = TestRemoveBetaFabric_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Remove gamma fabric\n"); + err = TestRemoveGammaFabric_21(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 22; + + chip::Optional mNodeId; + chip::Optional mEndpoint; + chip::Optional mCluster; + chip::Optional mPayload; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestOpenCommissioningWindowFromAlpha_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open Commissioning Window from alpha: Error: %@", err); + } else { + NSLog(@"Open Commissioning Window from alpha: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCommissionFromBeta_2() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_3() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("beta", value); + } + + CHIP_ERROR TestOpenCommissioningWindowFromAlpha_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open Commissioning Window from alpha: Error: %@", err); + } else { + NSLog(@"Open Commissioning Window from alpha: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCommissionFromGamma_5() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("gamma", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_6() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("gamma", value); + } + NSNumber * _Nonnull alphaIndex; + + CHIP_ERROR TestReadTheFabricIdFromTheAlphaFabric_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the fabric ID from the alpha fabric: Error: %@", err); + } else { + NSLog(@"Read the fabric ID from the alpha fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + alphaIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull commissionerNodeIdAlpha; + + CHIP_ERROR TestReadTheCommissionerNodeIdFromTheAlphaFabric_8() + { + + chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; + return GetCommissionerNodeId("alpha", value, ^(const chip::GetCommissionerNodeIdResponse & values) { + { + commissionerNodeIdAlpha = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; + } + NextTest(); + }); + } + NSNumber * _Nonnull betaIndex; + + CHIP_ERROR TestReadTheFabricIdFromTheBetaFabric_9() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the fabric ID from the beta fabric: Error: %@", err); + } else { + NSLog(@"Read the fabric ID from the beta fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + betaIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull commissionerNodeIdBeta; + + CHIP_ERROR TestReadTheCommissionerNodeIdFromTheBetaFabric_10() + { + + chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; + return GetCommissionerNodeId("beta", value, ^(const chip::GetCommissionerNodeIdResponse & values) { + { + commissionerNodeIdBeta = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; + } + NextTest(); + }); + } + NSNumber * _Nonnull gammaIndex; + + CHIP_ERROR TestReadTheFabricIdFromTheGammaFabric_11() + { + + MTRBaseDevice * device = GetDevice("gamma"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the fabric ID from the gamma fabric: Error: %@", err); + } else { + NSLog(@"Read the fabric ID from the gamma fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + gammaIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull commissionerNodeIdGamma; + + CHIP_ERROR TestReadTheCommissionerNodeIdFromTheGammaFabric_12() + { + + chip::app::Clusters::CommissionerCommands::Commands::GetCommissionerNodeId::Type value; + return GetCommissionerNodeId("gamma", value, ^(const chip::GetCommissionerNodeIdResponse & values) { + { + commissionerNodeIdGamma = [[NSNumber alloc] initWithUnsignedLongLong:values.nodeId]; + } + NextTest(); + }); + } + + CHIP_ERROR TestReadTheAclFromAlphaAndCheckCommissionerNodeId_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the ACL from alpha and check commissioner node id: Error: %@", err); + } else { + NSLog(@"Read the ACL from alpha and check commissioner node id: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdAlpha)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, alphaIndex)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheAclFromBetaAndCheckCommissionerNodeId_14() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the ACL from beta and check commissioner node id: Error: %@", err); + } else { + NSLog(@"Read the ACL from beta and check commissioner node id: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdBeta)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, betaIndex)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheAclFromGammaAndCheckCommissionerNodeId_15() + { + + MTRBaseDevice * device = GetDevice("gamma"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the ACL from gamma and check commissioner node id: Error: %@", err); + } else { + NSLog(@"Read the ACL from gamma and check commissioner node id: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdGamma)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, gammaIndex)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteTheAclUsingTheCommissionerNodeIdValue_16() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeIdBeta copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [betaIndex copy]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write the ACL using the commissioner node id value: Error: %@", err); + } else { + NSLog(@"Write the ACL using the commissioner node id value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteTheAclUsingTheCommissionerNodeIdValue_17() + { + + MTRBaseDevice * device = GetDevice("gamma"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id aclArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRAccessControlClusterAccessControlEntryStruct alloc] init]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).privilege = + [NSNumber numberWithUnsignedChar:5U]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).authMode = + [NSNumber numberWithUnsignedChar:2U]; + { + NSMutableArray * temp_3 = [[NSMutableArray alloc] init]; + temp_3[0] = + [commissionerNodeIdGamma copy]; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).subjects = temp_3; + } + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).targets = nil; + ((MTRAccessControlClusterAccessControlEntryStruct *) temp_0[0]).fabricIndex = + [gammaIndex copy]; + + aclArgument = temp_0; + } + [cluster writeAttributeACLWithValue:aclArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write the ACL using the commissioner node id value: Error: %@", err); + } else { + NSLog(@"Write the ACL using the commissioner node id value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheAclFromBetaAndCheckCommissionerNodeId_18() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the ACL from beta and check commissioner node id: Error: %@", err); + } else { + NSLog(@"Read the ACL from beta and check commissioner node id: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdBeta)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, betaIndex)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheAclFromGammaAndCheckCommissionerNodeId_19() + { + + MTRBaseDevice * device = GetDevice("gamma"); + __auto_type * cluster = [[MTRBaseClusterAccessControl alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeACLWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the ACL from gamma and check commissioner node id: Error: %@", err); + } else { + NSLog(@"Read the ACL from gamma and check commissioner node id: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ACL", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Privilege", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).privilege, 5U)); + VerifyOrReturn(CheckValue("AuthMode", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).authMode, 2U)); + VerifyOrReturn(CheckValueNonNull("Subjects", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects)); + VerifyOrReturn(CheckValue("Subjects", [((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects count], static_cast(1))); + VerifyOrReturn(CheckValue("", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).subjects[0], commissionerNodeIdGamma)); + VerifyOrReturn(CheckValueNull("Targets", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).targets)); + VerifyOrReturn(CheckValue("FabricIndex", ((MTRAccessControlClusterAccessControlEntryStruct *) actualValue[0]).fabricIndex, gammaIndex)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveBetaFabric_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; + params.fabricIndex = + [betaIndex copy]; + [cluster removeFabricWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Remove beta fabric: Error: %@", err); + } else { + NSLog(@"Remove beta fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveGammaFabric_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; + params.fabricIndex = + [gammaIndex copy]; + [cluster removeFabricWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Remove gamma fabric: Error: %@", err); + } else { + NSLog(@"Remove gamma fabric: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestTimeSynchronization : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestTimeSynchronization() + : TestCommandBridge("TestTimeSynchronization") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestTimeSynchronization() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestTimeSynchronization\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestTimeSynchronization\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read Time Zone\n"); + err = TestReadTimeZone_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Set Time Zone list\n"); + err = TestSetTimeZoneList_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read Time Zone\n"); + err = TestReadTimeZone_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Set Time Zone with missing optional name field\n"); + err = TestSetTimeZoneWithMissingOptionalNameField_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read Time Zone\n"); + err = TestReadTimeZone_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Set Time Zone with very long name\n"); + err = TestSetTimeZoneWithVeryLongName_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Set Time Zone with first item validAt not zero\n"); + err = TestSetTimeZoneWithFirstItemValidAtNotZero_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Set Time Zone with second item validAt zero\n"); + err = TestSetTimeZoneWithSecondItemValidAtZero_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Set Time Zone with more than supported list count\n"); + err = TestSetTimeZoneWithMoreThanSupportedListCount_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Set Time Zone empty\n"); + err = TestSetTimeZoneEmpty_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Read Time Zone\n"); + err = TestReadTimeZone_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Read DSTOffset\n"); + err = TestReadDSTOffset_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Set DSTOffset single item\n"); + err = TestSetDSTOffsetSingleItem_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Set DSTOffset empty\n"); + err = TestSetDSTOffsetEmpty_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Set DSTOffset with more than 1 null value\n"); + err = TestSetDSTOffsetWithMoreThan1NullValue_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Set unsorted DSTOffset entries\n"); + err = TestSetUnsortedDSTOffsetEntries_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Set DSTOffset with multiple entries\n"); + err = TestSetDSTOffsetWithMultipleEntries_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Read DSTOffset\n"); + err = TestReadDSTOffset_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Set DSTOffset with same validStarting and validUntil\n"); + err = TestSetDSTOffsetWithSameValidStartingAndValidUntil_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Set DSTOffset with more than supported list count\n"); + err = TestSetDSTOffsetWithMoreThanSupportedListCount_20(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 21; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadTimeZone_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Time Zone: Error: %@", err); + } else { + NSLog(@"Read Time Zone: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 0L)); + VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetTimeZoneList_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:100L]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CET"; + + params.timeZone = temp_0; + } + [cluster setTimeZoneWithParams:params completion: + ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set Time Zone list: Error: %@", err); + } else { + NSLog(@"Set Time Zone list: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.dstOffsetRequired; + VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTimeZone_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Time Zone: Error: %@", err); + } else { + NSLog(@"Read Time Zone: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 100L)); + VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); + VerifyOrReturn(CheckValueAsString("Name", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).name, @"CET")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetTimeZoneWithMissingOptionalNameField_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:100L]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = + [NSNumber numberWithUnsignedLongLong:0ULL]; + + params.timeZone = temp_0; + } + [cluster setTimeZoneWithParams:params completion: + ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set Time Zone with missing optional name field: Error: %@", err); + } else { + NSLog(@"Set Time Zone with missing optional name field: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.dstOffsetRequired; + VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTimeZone_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Time Zone: Error: %@", err); + } else { + NSLog(@"Read Time Zone: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 100L)); + VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetTimeZoneWithVeryLongName_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:100L]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"MunichOnTheLongRiverOfIsarInNiceSummerWeatherWithAugustinerBeerss"; + + params.timeZone = temp_0; + } + [cluster setTimeZoneWithParams:params completion: + ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set Time Zone with very long name: Error: %@", err); + } else { + NSLog(@"Set Time Zone with very long name: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetTimeZoneWithFirstItemValidAtNotZero_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:100L]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CDT"; + + params.timeZone = temp_0; + } + [cluster setTimeZoneWithParams:params completion: + ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set Time Zone with first item validAt not zero: Error: %@", err); + } else { + NSLog(@"Set Time Zone with first item validAt not zero: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetTimeZoneWithSecondItemValidAtZero_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:100L]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CST"; + + temp_0[1] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).offset = + [NSNumber numberWithInt:200L]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).validAt = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).name = @"CDT"; + + params.timeZone = temp_0; + } + [cluster setTimeZoneWithParams:params completion: + ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set Time Zone with second item validAt zero: Error: %@", err); + } else { + NSLog(@"Set Time Zone with second item validAt zero: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetTimeZoneWithMoreThanSupportedListCount_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:100L]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).validAt = + [NSNumber numberWithUnsignedLongLong:0ULL]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[0]).name = @"CST"; + + temp_0[1] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).offset = + [NSNumber numberWithInt:200L]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).validAt = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[1]).name = @"CDT"; + + temp_0[2] = [[MTRTimeSynchronizationClusterTimeZoneStruct alloc] init]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).offset = + [NSNumber numberWithInt:200L]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).validAt = + [NSNumber numberWithUnsignedLongLong:2ULL]; + ((MTRTimeSynchronizationClusterTimeZoneStruct *) temp_0[2]).name = @"CET"; + + params.timeZone = temp_0; + } + [cluster setTimeZoneWithParams:params completion: + ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set Time Zone with more than supported list count: Error: %@", err); + } else { + NSLog(@"Set Time Zone with more than supported list count: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetTimeZoneEmpty_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetTimeZoneParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + params.timeZone = temp_0; + } + [cluster setTimeZoneWithParams:params completion: + ^(MTRTimeSynchronizationClusterSetTimeZoneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set Time Zone empty: Error: %@", err); + } else { + NSLog(@"Set Time Zone empty: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.dstOffsetRequired; + VerifyOrReturn(CheckValue("DSTOffsetRequired", actualValue, true)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTimeZone_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeTimeZoneWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Time Zone: Error: %@", err); + } else { + NSLog(@"Read Time Zone: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("TimeZone", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).offset, 0L)); + VerifyOrReturn(CheckValue("ValidAt", ((MTRTimeSynchronizationClusterTimeZoneStruct *) actualValue[0]).validAt, 0ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadDSTOffset_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDSTOffsetWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read DSTOffset: Error: %@", err); + } else { + NSLog(@"Read DSTOffset: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("DSTOffset", [actualValue count], static_cast(0))); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetDSTOffsetSingleItem_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:1L]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = + [NSNumber numberWithUnsignedLongLong:2ULL]; + + params.dstOffset = temp_0; + } + [cluster setDSTOffsetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set DSTOffset single item: Error: %@", err); + } else { + NSLog(@"Set DSTOffset single item: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetDSTOffsetEmpty_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + params.dstOffset = temp_0; + } + [cluster setDSTOffsetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set DSTOffset empty: Error: %@", err); + } else { + NSLog(@"Set DSTOffset empty: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetDSTOffsetWithMoreThan1NullValue_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:1L]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = nil; + + temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = + [NSNumber numberWithInt:0L]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = + [NSNumber numberWithUnsignedLongLong:2ULL]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; + + params.dstOffset = temp_0; + } + [cluster setDSTOffsetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set DSTOffset with more than 1 null value: Error: %@", err); + } else { + NSLog(@"Set DSTOffset with more than 1 null value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetUnsortedDSTOffsetEntries_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:1L]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = + [NSNumber numberWithUnsignedLongLong:2ULL]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = + [NSNumber numberWithUnsignedLongLong:3ULL]; + + temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = + [NSNumber numberWithInt:0L]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; + + params.dstOffset = temp_0; + } + [cluster setDSTOffsetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set unsorted DSTOffset entries: Error: %@", err); + } else { + NSLog(@"Set unsorted DSTOffset entries: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetDSTOffsetWithMultipleEntries_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:1L]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = + [NSNumber numberWithUnsignedLongLong:2ULL]; + + temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = + [NSNumber numberWithInt:0L]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = + [NSNumber numberWithUnsignedLongLong:3ULL]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = nil; + + params.dstOffset = temp_0; + } + [cluster setDSTOffsetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set DSTOffset with multiple entries: Error: %@", err); + } else { + NSLog(@"Set DSTOffset with multiple entries: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadDSTOffset_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDSTOffsetWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read DSTOffset: Error: %@", err); + } else { + NSLog(@"Read DSTOffset: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("DSTOffset", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).offset, 1L)); + VerifyOrReturn(CheckValue("ValidStarting", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validStarting, 1ULL)); + VerifyOrReturn(CheckValueNonNull("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validUntil)); + VerifyOrReturn(CheckValue("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[0]).validUntil, 2ULL)); + VerifyOrReturn(CheckValue("Offset", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).offset, 0L)); + VerifyOrReturn(CheckValue("ValidStarting", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).validStarting, 3ULL)); + VerifyOrReturn(CheckValueNull("ValidUntil", ((MTRTimeSynchronizationClusterDSTOffsetStruct *) actualValue[1]).validUntil)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetDSTOffsetWithSameValidStartingAndValidUntil_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:0L]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = + [NSNumber numberWithUnsignedLongLong:1ULL]; + + params.dstOffset = temp_0; + } + [cluster setDSTOffsetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set DSTOffset with same validStarting and validUntil: Error: %@", err); + } else { + NSLog(@"Set DSTOffset with same validStarting and validUntil: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_CONSTRAINT_ERROR)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetDSTOffsetWithMoreThanSupportedListCount_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterTimeSynchronization alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRTimeSynchronizationClusterSetDSTOffsetParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).offset = + [NSNumber numberWithInt:1L]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validStarting = + [NSNumber numberWithUnsignedLongLong:1ULL]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[0]).validUntil = + [NSNumber numberWithUnsignedLongLong:2ULL]; + + temp_0[1] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).offset = + [NSNumber numberWithInt:0L]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validStarting = + [NSNumber numberWithUnsignedLongLong:3ULL]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[1]).validUntil = + [NSNumber numberWithUnsignedLongLong:5ULL]; + + temp_0[2] = [[MTRTimeSynchronizationClusterDSTOffsetStruct alloc] init]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).offset = + [NSNumber numberWithInt:0L]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).validStarting = + [NSNumber numberWithUnsignedLongLong:6ULL]; + ((MTRTimeSynchronizationClusterDSTOffsetStruct *) temp_0[2]).validUntil = nil; + + params.dstOffset = temp_0; + } + [cluster setDSTOffsetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set DSTOffset with more than supported list count: Error: %@", err); + } else { + NSLog(@"Set DSTOffset with more than supported list count: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_RESOURCE_EXHAUSTED)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestOperationalState : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestOperationalState() + : TestCommandBridge("TestOperationalState") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestOperationalState() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestOperationalState\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestOperationalState\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read Phase List\n"); + err = TestReadPhaseList_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read current Phase\n"); + err = TestReadCurrentPhase_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read Countdown Time\n"); + err = TestReadCountdownTime_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read Operational State List\n"); + err = TestReadOperationalStateList_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read current Operational Error\n"); + err = TestReadCurrentOperationalError_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Start Command\n"); + err = TestStartCommand_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Pause Command\n"); + err = TestPauseCommand_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Resume Command\n"); + err = TestResumeCommand_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Stop Command\n"); + err = TestStopCommand_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_14(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 15; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadPhaseList_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePhaseListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Phase List: Error: %@", err); + } else { + NSLog(@"Read Phase List: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("PhaseList", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentPhase_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPhaseWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Phase: Error: %@", err); + } else { + NSLog(@"Read current Phase: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("CurrentPhase", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCountdownTime_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCountdownTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Countdown Time: Error: %@", err); + } else { + NSLog(@"Read Countdown Time: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("CountdownTime", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadOperationalStateList_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Operational State List: Error: %@", err); + } else { + NSLog(@"Read Operational State List: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalError_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalErrorWithCompletion:^(MTROperationalStateClusterErrorStateStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational Error: Error: %@", err); + } else { + NSLog(@"Read current Operational Error: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalState_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational State: Error: %@", err); + } else { + NSLog(@"Read current Operational State: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStartCommand_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster startWithCompletion: + ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Start Command: Error: %@", err); + } else { + NSLog(@"Start Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.commandResponseState; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalState_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational State: Error: %@", err); + } else { + NSLog(@"Read current Operational State: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPauseCommand_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster pauseWithCompletion: + ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Pause Command: Error: %@", err); + } else { + NSLog(@"Pause Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.commandResponseState; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalState_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational State: Error: %@", err); + } else { + NSLog(@"Read current Operational State: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestResumeCommand_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster resumeWithCompletion: + ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Resume Command: Error: %@", err); + } else { + NSLog(@"Resume Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.commandResponseState; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalState_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational State: Error: %@", err); + } else { + NSLog(@"Read current Operational State: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStopCommand_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster stopWithCompletion: + ^(MTROperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Stop Command: Error: %@", err); + } else { + NSLog(@"Stop Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.commandResponseState; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTROperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalState_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational State: Error: %@", err); + } else { + NSLog(@"Read current Operational State: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestRVCOperationalState : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestRVCOperationalState() + : TestCommandBridge("TestRVCOperationalState") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestRVCOperationalState() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestRVCOperationalState\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestRVCOperationalState\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read Phase List\n"); + err = TestReadPhaseList_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read current Phase\n"); + err = TestReadCurrentPhase_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read Countdown Time\n"); + err = TestReadCountdownTime_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read Operational State List\n"); + err = TestReadOperationalStateList_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read current Operational Error\n"); + err = TestReadCurrentOperationalError_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Start Command\n"); + err = TestStartCommand_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Pause Command\n"); + err = TestPauseCommand_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Resume Command\n"); + err = TestResumeCommand_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Stop Command\n"); + err = TestStopCommand_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Read current Operational State\n"); + err = TestReadCurrentOperationalState_14(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 15; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadPhaseList_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePhaseListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Phase List: Error: %@", err); + } else { + NSLog(@"Read Phase List: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("PhaseList", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentPhase_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPhaseWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Phase: Error: %@", err); + } else { + NSLog(@"Read current Phase: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("CurrentPhase", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCountdownTime_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCountdownTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Countdown Time: Error: %@", err); + } else { + NSLog(@"Read Countdown Time: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("CountdownTime", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadOperationalStateList_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Operational State List: Error: %@", err); + } else { + NSLog(@"Read Operational State List: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(7))); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[4]).operationalStateID, 64U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[5]).operationalStateID, 65U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTRRVCOperationalStateClusterOperationalStateStruct *) actualValue[6]).operationalStateID, 66U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalError_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalErrorWithCompletion:^(MTRRVCOperationalStateClusterErrorStateStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational Error: Error: %@", err); + } else { + NSLog(@"Read current Operational Error: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalState_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational State: Error: %@", err); + } else { + NSLog(@"Read current Operational State: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStartCommand_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster startWithCompletion: + ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Start Command: Error: %@", err); + } else { + NSLog(@"Start Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalState_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational State: Error: %@", err); + } else { + NSLog(@"Read current Operational State: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPauseCommand_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster pauseWithCompletion: + ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Pause Command: Error: %@", err); + } else { + NSLog(@"Pause Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.commandResponseState; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalState_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational State: Error: %@", err); + } else { + NSLog(@"Read current Operational State: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestResumeCommand_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster resumeWithCompletion: + ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Resume Command: Error: %@", err); + } else { + NSLog(@"Resume Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.commandResponseState; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTRRVCOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalState_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational State: Error: %@", err); + } else { + NSLog(@"Read current Operational State: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStopCommand_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster stopWithCompletion: + ^(MTRRVCOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Stop Command: Error: %@", err); + } else { + NSLog(@"Stop Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadCurrentOperationalState_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterRVCOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read current Operational State: Error: %@", err); + } else { + NSLog(@"Read current Operational State: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestDishwasherAlarm : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestDishwasherAlarm() + : TestCommandBridge("TestDishwasherAlarm") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestDishwasherAlarm() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestDishwasherAlarm\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestDishwasherAlarm\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read Supported Attribute\n"); + err = TestReadSupportedAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read Mask Attribute\n"); + err = TestReadMaskAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read Latch Attribute\n"); + err = TestReadLatchAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read State Attribute\n"); + err = TestReadStateAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Read feature map Attribute\n"); + err = TestReadFeatureMapAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Modify enabled alarms Command\n"); + err = TestModifyEnabledAlarmsCommand_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Read Mask Attribute\n"); + err = TestReadMaskAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Read Latch Attribute\n"); + err = TestReadLatchAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Read State Attribute\n"); + err = TestReadStateAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Modify enabled alarms Command\n"); + err = TestModifyEnabledAlarmsCommand_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Read Mask Attribute\n"); + err = TestReadMaskAttribute_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Read Latch Attribute\n"); + err = TestReadLatchAttribute_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Read State Attribute\n"); + err = TestReadStateAttribute_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Modify enabled alarms Command\n"); + err = TestModifyEnabledAlarmsCommand_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Read Mask Attribute\n"); + err = TestReadMaskAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Read Latch Attribute\n"); + err = TestReadLatchAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Read State Attribute\n"); + err = TestReadStateAttribute_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Reset Command\n"); + err = TestResetCommand_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Read Mask Attribute\n"); + err = TestReadMaskAttribute_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Read Latch Attribute\n"); + err = TestReadLatchAttribute_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Read State Attribute\n"); + err = TestReadStateAttribute_21(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 22; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadSupportedAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Supported Attribute: Error: %@", err); + } else { + NSLog(@"Read Supported Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Supported", actualValue, 47UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadMaskAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Mask Attribute: Error: %@", err); + } else { + NSLog(@"Read Mask Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Mask", actualValue, 47UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadLatchAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Latch Attribute: Error: %@", err); + } else { + NSLog(@"Read Latch Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadStateAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read State Attribute: Error: %@", err); + } else { + NSLog(@"Read State Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("State", actualValue, 7UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadFeatureMapAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read feature map Attribute: Error: %@", err); + } else { + NSLog(@"Read feature map Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyEnabledAlarmsCommand_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; + params.mask = + [NSNumber numberWithUnsignedInt:41UL]; + [cluster modifyEnabledAlarmsWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify enabled alarms Command: Error: %@", err); + } else { + NSLog(@"Modify enabled alarms Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadMaskAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Mask Attribute: Error: %@", err); + } else { + NSLog(@"Read Mask Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadLatchAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Latch Attribute: Error: %@", err); + } else { + NSLog(@"Read Latch Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadStateAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read State Attribute: Error: %@", err); + } else { + NSLog(@"Read State Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("State", actualValue, 1UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyEnabledAlarmsCommand_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; + params.mask = + [NSNumber numberWithUnsignedInt:105UL]; + [cluster modifyEnabledAlarmsWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify enabled alarms Command: Error: %@", err); + } else { + NSLog(@"Modify enabled alarms Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadMaskAttribute_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Mask Attribute: Error: %@", err); + } else { + NSLog(@"Read Mask Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadLatchAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Latch Attribute: Error: %@", err); + } else { + NSLog(@"Read Latch Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadStateAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read State Attribute: Error: %@", err); + } else { + NSLog(@"Read State Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("State", actualValue, 1UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyEnabledAlarmsCommand_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDishwasherAlarmClusterModifyEnabledAlarmsParams alloc] init]; + params.mask = + [NSNumber numberWithUnsignedInt:59UL]; + [cluster modifyEnabledAlarmsWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify enabled alarms Command: Error: %@", err); + } else { + NSLog(@"Modify enabled alarms Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadMaskAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Mask Attribute: Error: %@", err); + } else { + NSLog(@"Read Mask Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadLatchAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Latch Attribute: Error: %@", err); + } else { + NSLog(@"Read Latch Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadStateAttribute_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read State Attribute: Error: %@", err); + } else { + NSLog(@"Read State Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("State", actualValue, 1UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestResetCommand_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDishwasherAlarmClusterResetParams alloc] init]; + params.alarms = + [NSNumber numberWithUnsignedInt:1UL]; + [cluster resetWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Reset Command: Error: %@", err); + } else { + NSLog(@"Reset Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadMaskAttribute_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaskWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Mask Attribute: Error: %@", err); + } else { + NSLog(@"Read Mask Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Mask", actualValue, 41UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadLatchAttribute_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLatchWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Latch Attribute: Error: %@", err); + } else { + NSLog(@"Read Latch Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Latch", actualValue, 3UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadStateAttribute_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDishwasherAlarm alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read State Attribute: Error: %@", err); + } else { + NSLog(@"Read State Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("State", actualValue, 0UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestMultiAdmin : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestMultiAdmin() + : TestCommandBridge("TestMultiAdmin") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("nodeIdForDuplicateCommissioning", 0, UINT64_MAX, &mNodeIdForDuplicateCommissioning); + AddArgument("nodeId2", 0, UINT64_MAX, &mNodeId2); + AddArgument("nodeId3", 0, UINT64_MAX, &mNodeId3); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("payload", &mPayload); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestMultiAdmin() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestMultiAdmin\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestMultiAdmin\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Stop target device\n"); + err = TestStopTargetDevice_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Start target device with the provided discriminator for basic commissioning advertisement\n"); + err = TestStartTargetDeviceWithTheProvidedDiscriminatorForBasicCommissioningAdvertisement_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Wait for the commissioned device to be retrieved for alpha\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Commission from alpha when the commissioning window is not opened\n"); + err = TestCommissionFromAlphaWhenTheCommissioningWindowIsNotOpened_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Open Commissioning Window from alpha\n"); + err = TestOpenCommissioningWindowFromAlpha_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Commission from alpha again\n"); + err = TestCommissionFromAlphaAgain_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Check that we just have the one fabric and did not add a new one\n"); + err = TestCheckThatWeJustHaveTheOneFabricAndDidNotAddANewOne_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Close Commissioning Window after failed commissioning\n"); + err = TestCloseCommissioningWindowAfterFailedCommissioning_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Open Commissioning Window from alpha again\n"); + err = TestOpenCommissioningWindowFromAlphaAgain_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Commission from beta\n"); + err = TestCommissionFromBeta_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Wait for the commissioned device to be retrieved for beta\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Open Commissioning Window from beta\n"); + err = TestOpenCommissioningWindowFromBeta_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Commission from gamma\n"); + err = TestCommissionFromGamma_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for the commissioned device to be retrieved for gamma\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : read the mandatory attribute: NodeLabel from alpha\n"); + err = TestReadTheMandatoryAttributeNodeLabelFromAlpha_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : write the mandatory attribute NodeLabel from beta\n"); + err = TestWriteTheMandatoryAttributeNodeLabelFromBeta_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : read the mandatory attribute: NodeLabel from gamma\n"); + err = TestReadTheMandatoryAttributeNodeLabelFromGamma_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : write the mandatory attribute NodeLabel back to default\n"); + err = TestWriteTheMandatoryAttributeNodeLabelBackToDefault_17(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 18; + + chip::Optional mNodeId; + chip::Optional mNodeIdForDuplicateCommissioning; + chip::Optional mNodeId2; + chip::Optional mNodeId3; + chip::Optional mEndpoint; + chip::Optional mDiscriminator; + chip::Optional mPayload; + chip::Optional mTimeout; + + CHIP_ERROR TestStopTargetDevice_0() + { + + chip::app::Clusters::SystemCommands::Commands::Stop::Type value; + return Stop("alpha", value); + } + + CHIP_ERROR TestStartTargetDeviceWithTheProvidedDiscriminatorForBasicCommissioningAdvertisement_1() + { + + chip::app::Clusters::SystemCommands::Commands::Start::Type value; + value.discriminator.Emplace(); + value.discriminator.Value() = mDiscriminator.HasValue() ? mDiscriminator.Value() : 3840U; + return Start("alpha", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForAlpha_2() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestCommissionFromAlphaWhenTheCommissioningWindowIsNotOpened_3() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeIdForDuplicateCommissioning.HasValue() ? mNodeIdForDuplicateCommissioning.Value() : 17ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("alpha", value); + } + + CHIP_ERROR TestOpenCommissioningWindowFromAlpha_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open Commissioning Window from alpha: Error: %@", err); + } else { + NSLog(@"Open Commissioning Window from alpha: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCommissionFromAlphaAgain_5() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeIdForDuplicateCommissioning.HasValue() ? mNodeIdForDuplicateCommissioning.Value() : 17ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("alpha", value); + } + + CHIP_ERROR TestCheckThatWeJustHaveTheOneFabricAndDidNotAddANewOne_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = false; + [cluster readAttributeFabricsWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that we just have the one fabric and did not add a new one: Error: %@", err); + } else { + NSLog(@"Check that we just have the one fabric and did not add a new one: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("Fabrics", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("NodeID", ((MTROperationalCredentialsClusterFabricDescriptorStruct *) actualValue[0]).nodeID, mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCloseCommissioningWindowAfterFailedCommissioning_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster revokeCommissioningWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Close Commissioning Window after failed commissioning: Error: %@", err); + } else { + NSLog(@"Close Commissioning Window after failed commissioning: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestOpenCommissioningWindowFromAlphaAgain_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open Commissioning Window from alpha again: Error: %@", err); + } else { + NSLog(@"Open Commissioning Window from alpha again: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCommissionFromBeta_9() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForBeta_10() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId2.HasValue() ? mNodeId2.Value() : 51966ULL; + return WaitForCommissionee("beta", value); + } + + CHIP_ERROR TestOpenCommissioningWindowFromBeta_11() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open Commissioning Window from beta: Error: %@", err); + } else { + NSLog(@"Open Commissioning Window from beta: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCommissionFromGamma_12() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("gamma", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForGamma_13() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId3.HasValue() ? mNodeId3.Value() : 12586990ULL; + return WaitForCommissionee("gamma", value); + } + NSString * _Nonnull readFromAlpha; + + CHIP_ERROR TestReadTheMandatoryAttributeNodeLabelFromAlpha_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"read the mandatory attribute: NodeLabel from alpha: Error: %@", err); + } else { + NSLog(@"read the mandatory attribute: NodeLabel from alpha: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueAsString("NodeLabel", actualValue, @"")); + } + { + readFromAlpha = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteTheMandatoryAttributeNodeLabelFromBeta_15() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nodeLabelArgument; + nodeLabelArgument = @"written from beta"; + [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"write the mandatory attribute NodeLabel from beta: Error: %@", err); + } else { + NSLog(@"write the mandatory attribute NodeLabel from beta: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheMandatoryAttributeNodeLabelFromGamma_16() + { + + MTRBaseDevice * device = GetDevice("gamma"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNodeLabelWithCompletion:^(NSString * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"read the mandatory attribute: NodeLabel from gamma: Error: %@", err); + } else { + NSLog(@"read the mandatory attribute: NodeLabel from gamma: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintNotValue("nodeLabel", value, readFromAlpha)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteTheMandatoryAttributeNodeLabelBackToDefault_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterBasicInformation alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id nodeLabelArgument; + nodeLabelArgument = + [readFromAlpha copy]; + [cluster writeAttributeNodeLabelWithValue:nodeLabelArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"write the mandatory attribute NodeLabel back to default: Error: %@", err); + } else { + NSLog(@"write the mandatory attribute NodeLabel back to default: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DGSW_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DGSW_1_1() + : TestCommandBridge("Test_TC_DGSW_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DGSW_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DGSW_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DGSW_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); + err = TestStep2ThReadsTheClusterRevisionFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); + if (ShouldSkip(" !DGSW.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheFeatureMapFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DGSW.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenDGSWSF00WatermarksEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList\n"); + if (ShouldSkip("DGSW.S.A0000")) { + NextTest(); + return; + } + err = TestStep4bThReadsOptionalAttributeThreadMetricsInAttributeList_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList\n"); + if (ShouldSkip("DGSW.S.A0001")) { + NextTest(); + return; + } + err = TestStep4cThReadsOptionalAttributeCurrentHeapFreeInAttributeList_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList\n"); + if (ShouldSkip("DGSW.S.A0002")) { + NextTest(); + return; + } + err = TestStep4dThReadsOptionalAttributeCurrentHeapUsedInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList\n"); + if (ShouldSkip("( DGSW.S.F00 || DGSW.S.A0003 )")) { + NextTest(); + return; + } + err = TestStep4eThReadsFeatureDependentAttributeCurrentHeapHighWatermarkInAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH reads EventList from DUT\n"); + if (ShouldSkip("DGSW.S.E00 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 5b: TH reads EventList from DUT\n"); + if (ShouldSkip(" !DGSW.S.E00 && PICS_EVENT_LIST_ENABLED ")) { + NextTest(); + return; + } + NextTest(); + return; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 6: TH reads AcceptedCommandList from DUT\n"); + if (ShouldSkip("DGSW.S.F00")) { + NextTest(); + return; + } + err = TestStep6ThReadsAcceptedCommandListFromDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads AcceptedCommandList from DUT\n"); + if (ShouldSkip(" !DGSW.S.F00 ")) { + NextTest(); + return; + } + err = TestStep6ThReadsAcceptedCommandListFromDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 7: TH reads GeneratedCommandList from DUT\n"); + err = TestStep7ThReadsGeneratedCommandListFromDut_14(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 15; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenDGSWSF00WatermarksEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given DGSW.S.F00(Watermarks) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsOptionalAttributeThreadMetricsInAttributeList_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads optional attribute(ThreadMetrics) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsOptionalAttributeCurrentHeapFreeInAttributeList_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads optional attribute(CurrentHeapFree) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsOptionalAttributeCurrentHeapUsedInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads optional attribute(CurrentHeapUsed) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsFeatureDependentAttributeCurrentHeapHighWatermarkInAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads Feature dependent attribute(CurrentHeapHighWatermark) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsAcceptedCommandListFromDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads AcceptedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsGeneratedCommandListFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterSoftwareDiagnostics alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads GeneratedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestSubscribe_OnOff : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestSubscribe_OnOff() + : TestCommandBridge("TestSubscribe_OnOff") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestSubscribe_OnOff() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestSubscribe_OnOff\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestSubscribe_OnOff\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Set OnOff Attribute to false\n"); + err = TestSetOnOffAttributeToFalse_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Report: Subscribe OnOff Attribute\n"); + err = TestReportSubscribeOnOffAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Subscribe OnOff Attribute\n"); + err = TestSubscribeOnOffAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Turn On the light to see attribute change\n"); + err = TestTurnOnTheLightToSeeAttributeChange_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Check for attribute report\n"); + err = TestCheckForAttributeReport_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Turn Off the light to see attribute change\n"); + err = TestTurnOffTheLightToSeeAttributeChange_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Check for attribute report\n"); + err = TestCheckForAttributeReport_7(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 8; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestSetOnOffAttributeToFalse_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set OnOff Attribute to false: Error: %@", err); + } else { + NSLog(@"Set OnOff Attribute to false: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + bool testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled = false; + ResponseHandler _Nullable test_TestSubscribe_OnOff_OnOff_Reported + = nil; + + CHIP_ERROR TestReportSubscribeOnOffAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_OnOff_OnOff_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Report: Subscribe OnOff Attribute: Error: %@", err); + } else { + NSLog(@"Report: Subscribe OnOff Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, false)); + } + + testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled = true; + }; + + NextTest(); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSubscribeOnOffAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + uint16_t minIntervalArgument = 2U; + uint16_t maxIntervalArgument = 5U; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; + params.filterByFabric = true; + params.replaceExistingSubscriptions = true; + [cluster subscribeAttributeOnOffWithParams:params + subscriptionEstablished:^{ + VerifyOrReturn(testSendClusterTestSubscribe_OnOff_2_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); + NextTest(); + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Subscribe OnOff Attribute: Error: %@", err); + } else { + NSLog(@"Subscribe OnOff Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + if (test_TestSubscribe_OnOff_OnOff_Reported + != nil) { + ResponseHandler callback = test_TestSubscribe_OnOff_OnOff_Reported; + test_TestSubscribe_OnOff_OnOff_Reported + = nil; + callback(value, err); + } + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOnTheLightToSeeAttributeChange_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster onWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn On the light to see attribute change: Error: %@", err); + } else { + NSLog(@"Turn On the light to see attribute change: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckForAttributeReport_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_OnOff_OnOff_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check for attribute report: Error: %@", err); + } else { + NSLog(@"Check for attribute report: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, true)); + } + + NextTest(); + }; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTurnOffTheLightToSeeAttributeChange_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster offWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Turn Off the light to see attribute change: Error: %@", err); + } else { + NSLog(@"Turn Off the light to see attribute change: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckForAttributeReport_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOnOff alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_OnOff_OnOff_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check for attribute report: Error: %@", err); + } else { + NSLog(@"Check for attribute report: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OnOff", actualValue, false)); + } + + NextTest(); + }; + + return CHIP_NO_ERROR; + } +}; + +class TestSubscribe_AdministratorCommissioning : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestSubscribe_AdministratorCommissioning() + : TestCommandBridge("TestSubscribe_AdministratorCommissioning") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("ourVendorId", 0, UINT16_MAX, &mOurVendorId); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestSubscribe_AdministratorCommissioning() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestSubscribe_AdministratorCommissioning\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestSubscribe_AdministratorCommissioning\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Get ourfabric index\n"); + err = TestGetOurfabricIndex_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Report: Subscribe WindowStatus Attribute\n"); + err = TestReportSubscribeWindowStatusAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Subscribe WindowStatus Attribute\n"); + err = TestSubscribeWindowStatusAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Open the commissioning window 1\n"); + err = TestOpenTheCommissioningWindow1_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Check for first attribute report for WindowStatus\n"); + err = TestCheckForFirstAttributeReportForWindowStatus_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Close the commissioning window 1\n"); + err = TestCloseTheCommissioningWindow1_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Check for second attribute report for WindowStatus\n"); + err = TestCheckForSecondAttributeReportForWindowStatus_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Report: Subscribe AdminVendorId Attribute\n"); + err = TestReportSubscribeAdminVendorIdAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Subscribe AdminVendorId Attribute\n"); + err = TestSubscribeAdminVendorIdAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Open the commissioning window 2\n"); + err = TestOpenTheCommissioningWindow2_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Check for first attribute report for AdminVendorId\n"); + err = TestCheckForFirstAttributeReportForAdminVendorId_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Close the commissioning window 2\n"); + err = TestCloseTheCommissioningWindow2_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Check for second attribute report for AdminVendorId\n"); + err = TestCheckForSecondAttributeReportForAdminVendorId_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Report: Subscribe AdminFabricIndex Attribute\n"); + err = TestReportSubscribeAdminFabricIndexAttribute_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Subscribe AdminFabricIndex Attribute\n"); + err = TestSubscribeAdminFabricIndexAttribute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Open the commissioning window 3\n"); + err = TestOpenTheCommissioningWindow3_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Check for first attribute report for AdminFabricIndex\n"); + err = TestCheckForFirstAttributeReportForAdminFabricIndex_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Close the commissioning window 2\n"); + err = TestCloseTheCommissioningWindow2_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Check for second attribute report for AdminFabricIndex\n"); + err = TestCheckForSecondAttributeReportForAdminFabricIndex_19(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 20; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mOurVendorId; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull ourFabricIndex; + + CHIP_ERROR TestGetOurfabricIndex_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get ourfabric index: Error: %@", err); + } else { + NSLog(@"Get ourfabric index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + ourFabricIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + bool testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled = false; + ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported + = nil; + + CHIP_ERROR TestReportSubscribeWindowStatusAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Report: Subscribe WindowStatus Attribute: Error: %@", err); + } else { + NSLog(@"Report: Subscribe WindowStatus Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); + } + + testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled = true; + }; + + NextTest(); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSubscribeWindowStatusAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + uint16_t minIntervalArgument = 2U; + uint16_t maxIntervalArgument = 50U; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; + params.filterByFabric = true; + params.replaceExistingSubscriptions = true; + [cluster subscribeAttributeWindowStatusWithParams:params + subscriptionEstablished:^{ + VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_2_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); + NextTest(); + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Subscribe WindowStatus Attribute: Error: %@", err); + } else { + NSLog(@"Subscribe WindowStatus Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + if (test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported + != nil) { + ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported; + test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported + = nil; + callback(value, err); + } + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestOpenTheCommissioningWindow1_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open the commissioning window 1: Error: %@", err); + } else { + NSLog(@"Open the commissioning window 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckForFirstAttributeReportForWindowStatus_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check for first attribute report for WindowStatus: Error: %@", err); + } else { + NSLog(@"Check for first attribute report for WindowStatus: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("WindowStatus", actualValue, 2U)); + } + + NextTest(); + }; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCloseTheCommissioningWindow1_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster revokeCommissioningWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Close the commissioning window 1: Error: %@", err); + } else { + NSLog(@"Close the commissioning window 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckForSecondAttributeReportForWindowStatus_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_AdministratorCommissioning_WindowStatus_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check for second attribute report for WindowStatus: Error: %@", err); + } else { + NSLog(@"Check for second attribute report for WindowStatus: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("WindowStatus", actualValue, 0U)); + } + + NextTest(); + }; + + return CHIP_NO_ERROR; + } + bool testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled = false; + ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported + = nil; + + CHIP_ERROR TestReportSubscribeAdminVendorIdAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Report: Subscribe AdminVendorId Attribute: Error: %@", err); + } else { + NSLog(@"Report: Subscribe AdminVendorId Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); + } + + testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled = true; + }; + + NextTest(); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSubscribeAdminVendorIdAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + uint16_t minIntervalArgument = 2U; + uint16_t maxIntervalArgument = 50U; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; + params.filterByFabric = true; + params.replaceExistingSubscriptions = true; + [cluster subscribeAttributeAdminVendorIdWithParams:params + subscriptionEstablished:^{ + VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_8_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); + NextTest(); + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Subscribe AdminVendorId Attribute: Error: %@", err); + } else { + NSLog(@"Subscribe AdminVendorId Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + if (test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported + != nil) { + ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported; + test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported + = nil; + callback(value, err); + } + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestOpenTheCommissioningWindow2_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open the commissioning window 2: Error: %@", err); + } else { + NSLog(@"Open the commissioning window 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckForFirstAttributeReportForAdminVendorId_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check for first attribute report for AdminVendorId: Error: %@", err); + } else { + NSLog(@"Check for first attribute report for AdminVendorId: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("AdminVendorId", actualValue)); + VerifyOrReturn(CheckValue("AdminVendorId", actualValue, mOurVendorId.HasValue() ? mOurVendorId.Value() : 65521U)); + } + + NextTest(); + }; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCloseTheCommissioningWindow2_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster revokeCommissioningWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Close the commissioning window 2: Error: %@", err); + } else { + NSLog(@"Close the commissioning window 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckForSecondAttributeReportForAdminVendorId_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_AdministratorCommissioning_AdminVendorId_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check for second attribute report for AdminVendorId: Error: %@", err); + } else { + NSLog(@"Check for second attribute report for AdminVendorId: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("AdminVendorId", actualValue)); + } + + NextTest(); + }; + + return CHIP_NO_ERROR; + } + bool testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled = false; + ResponseHandler _Nullable test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported + = nil; + + CHIP_ERROR TestReportSubscribeAdminFabricIndexAttribute_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Report: Subscribe AdminFabricIndex Attribute: Error: %@", err); + } else { + NSLog(@"Report: Subscribe AdminFabricIndex Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); + } + + testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled = true; + }; + + NextTest(); + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSubscribeAdminFabricIndexAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + uint16_t minIntervalArgument = 2U; + uint16_t maxIntervalArgument = 50U; + __auto_type * params = [[MTRSubscribeParams alloc] initWithMinInterval:@(minIntervalArgument) maxInterval:@(maxIntervalArgument)]; + params.filterByFabric = true; + params.replaceExistingSubscriptions = true; + [cluster subscribeAttributeAdminFabricIndexWithParams:params + subscriptionEstablished:^{ + VerifyOrReturn(testSendClusterTestSubscribe_AdministratorCommissioning_14_WaitForReport_Fulfilled, SetCommandExitStatus(CHIP_ERROR_INCORRECT_STATE)); + NextTest(); + } + reportHandler:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Subscribe AdminFabricIndex Attribute: Error: %@", err); + } else { + NSLog(@"Subscribe AdminFabricIndex Attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + if (test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported + != nil) { + ResponseHandler callback = test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported; + test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported + = nil; + callback(value, err); + } + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestOpenTheCommissioningWindow3_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenBasicCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + [cluster openBasicCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open the commissioning window 3: Error: %@", err); + } else { + NSLog(@"Open the commissioning window 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckForFirstAttributeReportForAdminFabricIndex_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check for first attribute report for AdminFabricIndex: Error: %@", err); + } else { + NSLog(@"Check for first attribute report for AdminFabricIndex: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + if (ourFabricIndex == nil) { + VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("AdminFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("AdminFabricIndex", actualValue, ourFabricIndex)); + } + } + + NextTest(); + }; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCloseTheCommissioningWindow2_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster revokeCommissioningWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Close the commissioning window 2: Error: %@", err); + } else { + NSLog(@"Close the commissioning window 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckForSecondAttributeReportForAdminFabricIndex_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + test_TestSubscribe_AdministratorCommissioning_AdminFabricIndex_Reported + = ^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check for second attribute report for AdminFabricIndex: Error: %@", err); + } else { + NSLog(@"Check for second attribute report for AdminFabricIndex: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("AdminFabricIndex", actualValue)); + } + + NextTest(); + }; + + return CHIP_NO_ERROR; + } +}; + +class DL_UsersAndCredentials : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + DL_UsersAndCredentials() + : TestCommandBridge("DL_UsersAndCredentials") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~DL_UsersAndCredentials() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: DL_UsersAndCredentials\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: DL_UsersAndCredentials\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Read available user slot and verify response fields\n"); + err = TestReadAvailableUserSlotAndVerifyResponseFields_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Get number of supported users and verify default value\n"); + err = TestGetNumberOfSupportedUsersAndVerifyDefaultValue_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Read fails for user with index 0\n"); + err = TestReadFailsForUserWithIndex0_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Read fails for user with index greater than Number Of Users Supported\n"); + err = TestReadFailsForUserWithIndexGreaterThanNumberOfUsersSupported_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Create new user with default parameters\n"); + err = TestCreateNewUserWithDefaultParameters_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Read the user back and verify its fields\n"); + err = TestReadTheUserBackAndVerifyItsFields_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Set user at the occupied index fails with appropriate response\n"); + err = TestSetUserAtTheOccupiedIndexFailsWithAppropriateResponse_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Modify userName for existing user\n"); + err = TestModifyUserNameForExistingUser_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Read the modified user back and verify its fields\n"); + err = TestReadTheModifiedUserBackAndVerifyItsFields_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Modify userUniqueId for existing user\n"); + err = TestModifyUserUniqueIdForExistingUser_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Read the modified user back and verify its fields\n"); + err = TestReadTheModifiedUserBackAndVerifyItsFields_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Modify userStatus for existing user\n"); + err = TestModifyUserStatusForExistingUser_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Read the modified user back and verify its fields\n"); + err = TestReadTheModifiedUserBackAndVerifyItsFields_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Modify userType for existing user\n"); + err = TestModifyUserTypeForExistingUser_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Read the modified user back and verify its fields\n"); + err = TestReadTheModifiedUserBackAndVerifyItsFields_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Modify credentialRule for existing user\n"); + err = TestModifyCredentialRuleForExistingUser_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Read the modified user back and verify its fields\n"); + err = TestReadTheModifiedUserBackAndVerifyItsFields_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Modify all fields for existing user\n"); + err = TestModifyAllFieldsForExistingUser_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Read the modified user back and verify its fields\n"); + err = TestReadTheModifiedUserBackAndVerifyItsFields_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Add another user with non-default fields\n"); + err = TestAddAnotherUserWithNonDefaultFields_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Read the new user back and verify its fields\n"); + err = TestReadTheNewUserBackAndVerifyItsFields_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Try to add a user with userStatus 0\n"); + err = TestTryToAddAUserWithUserStatus0_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Make sure the user did not get created\n"); + err = TestMakeSureTheUserDidNotGetCreated_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Try to add a user with userStatus 2\n"); + err = TestTryToAddAUserWithUserStatus2_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Make sure the user did not get created\n"); + err = TestMakeSureTheUserDidNotGetCreated_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Try to add a user with userStatus 3\n"); + err = TestTryToAddAUserWithUserStatus3_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Read the new third user back and verify its fields\n"); + err = TestReadTheNewThirdUserBackAndVerifyItsFields_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Create user in the last slot\n"); + err = TestCreateUserInTheLastSlot_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Read the last user back and verify its fields\n"); + err = TestReadTheLastUserBackAndVerifyItsFields_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : User creation in the 0 slot fails\n"); + err = TestUserCreationInThe0SlotFails_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : User creation in the out-of-bounds slot fails\n"); + err = TestUserCreationInTheOutOfBoundsSlotFails_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Clear first user\n"); + err = TestClearFirstUser_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Read cleared user and verify it is available\n"); + err = TestReadClearedUserAndVerifyItIsAvailable_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Create new user in the cleared slot\n"); + err = TestCreateNewUserInTheClearedSlot_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Read the user in the previously cleared slot and verify its fields\n"); + err = TestReadTheUserInThePreviouslyClearedSlotAndVerifyItsFields_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Clear user with index 0 fails\n"); + err = TestClearUserWithIndex0Fails_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Clear user with out-of-bounds index fails\n"); + err = TestClearUserWithOutOfBoundsIndexFails_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Clear all users\n"); + err = TestClearAllUsers_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Read first cleared user and verify it is available\n"); + err = TestReadFirstClearedUserAndVerifyItIsAvailable_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Read last cleared user and verify it is available\n"); + err = TestReadLastClearedUserAndVerifyItIsAvailable_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Get number of supported PIN credentials and verify default value\n"); + err = TestGetNumberOfSupportedPinCredentialsAndVerifyDefaultValue_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Check that PIN credential does not exist\n"); + err = TestCheckThatPinCredentialDoesNotExist_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Reading PIN credential with index 0 returns no credential\n"); + err = TestReadingPinCredentialWithIndex0ReturnsNoCredential_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Reading PIN credential with out-of-bounds index returns no credential\n"); + err = TestReadingPinCredentialWithOutOfBoundsIndexReturnsNoCredential_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Verify that a user with UserStatus = 0 cannot be added via SetCredential\n"); + err = TestVerifyThatAUserWithUserStatus0CannotBeAddedViaSetCredential_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Verify that a user with UserStatus = 2 cannot be added via SetCredential\n"); + err = TestVerifyThatAUserWithUserStatus2CannotBeAddedViaSetCredential_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Create new PIN credential and user\n"); + err = TestCreateNewPinCredentialAndUser_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Verify created user\n"); + err = TestVerifyCreatedUser_48(); + break; + case 49: + ChipLogProgress(chipTool, " ***** Test Step 49 : Verify created PIN credential\n"); + err = TestVerifyCreatedPinCredential_49(); + break; + case 50: + ChipLogProgress(chipTool, " ***** Test Step 50 : Create new PIN credential and user with index 0 fails\n"); + err = TestCreateNewPinCredentialAndUserWithIndex0Fails_50(); + break; + case 51: + ChipLogProgress(chipTool, " ***** Test Step 51 : Create new PIN credential and user with out-of-bounds index fails\n"); + err = TestCreateNewPinCredentialAndUserWithOutOfBoundsIndexFails_51(); + break; + case 52: + ChipLogProgress(chipTool, " ***** Test Step 52 : Get number of supported RFID credentials and verify default value\n"); + err = TestGetNumberOfSupportedRfidCredentialsAndVerifyDefaultValue_52(); + break; + case 53: + ChipLogProgress(chipTool, " ***** Test Step 53 : Reading RFID credential with index 0 returns no credential\n"); + err = TestReadingRfidCredentialWithIndex0ReturnsNoCredential_53(); + break; + case 54: + ChipLogProgress(chipTool, " ***** Test Step 54 : Reading RFID credential with out-of-bounds index returns no credential\n"); + err = TestReadingRfidCredentialWithOutOfBoundsIndexReturnsNoCredential_54(); + break; + case 55: + ChipLogProgress(chipTool, " ***** Test Step 55 : Check that RFID credential does not exist\n"); + err = TestCheckThatRfidCredentialDoesNotExist_55(); + break; + case 56: + ChipLogProgress(chipTool, " ***** Test Step 56 : Create new RFID credential and add it to existing user with non-null UserStatus should fail\n"); + err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserStatusShouldFail_56(); + break; + case 57: + ChipLogProgress(chipTool, " ***** Test Step 57 : Create new RFID credential and add it to existing user with non-null UserType should fail\n"); + err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeShouldFail_57(); + break; + case 58: + ChipLogProgress(chipTool, " ***** Test Step 58 : Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail\n"); + err = TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeAndUserStatusShouldFail_58(); + break; + case 59: + ChipLogProgress(chipTool, " ***** Test Step 59 : Create new RFID credential and add it to existing user\n"); + err = TestCreateNewRfidCredentialAndAddItToExistingUser_59(); + break; + case 60: + ChipLogProgress(chipTool, " ***** Test Step 60 : Verify modified user\n"); + err = TestVerifyModifiedUser_60(); + break; + case 61: + ChipLogProgress(chipTool, " ***** Test Step 61 : Verify created credential\n"); + err = TestVerifyCreatedCredential_61(); + break; + case 62: + ChipLogProgress(chipTool, " ***** Test Step 62 : Create new RFID credential and user with index 0 fails\n"); + err = TestCreateNewRfidCredentialAndUserWithIndex0Fails_62(); + break; + case 63: + ChipLogProgress(chipTool, " ***** Test Step 63 : Create new RFID credential and user with out-of-bounds index fails\n"); + err = TestCreateNewRfidCredentialAndUserWithOutOfBoundsIndexFails_63(); + break; + case 64: + ChipLogProgress(chipTool, " ***** Test Step 64 : Create new credential and try to add it to 0 user\n"); + err = TestCreateNewCredentialAndTryToAddItTo0User_64(); + break; + case 65: + ChipLogProgress(chipTool, " ***** Test Step 65 : Create new credential and try to add it to out-of-bounds user\n"); + err = TestCreateNewCredentialAndTryToAddItToOutOfBoundsUser_65(); + break; + case 66: + ChipLogProgress(chipTool, " ***** Test Step 66 : Create new PIN with too short data\n"); + err = TestCreateNewPinWithTooShortData_66(); + break; + case 67: + ChipLogProgress(chipTool, " ***** Test Step 67 : Create new PIN with too long data\n"); + err = TestCreateNewPinWithTooLongData_67(); + break; + case 68: + ChipLogProgress(chipTool, " ***** Test Step 68 : Create new RFID with too short data\n"); + err = TestCreateNewRfidWithTooShortData_68(); + break; + case 69: + ChipLogProgress(chipTool, " ***** Test Step 69 : Create new PIN with Programming user type fails\n"); + err = TestCreateNewPinWithProgrammingUserTypeFails_69(); + break; + case 70: + ChipLogProgress(chipTool, " ***** Test Step 70 : Create new RFID with too short data\n"); + err = TestCreateNewRfidWithTooShortData_70(); + break; + case 71: + ChipLogProgress(chipTool, " ***** Test Step 71 : Create new PIN credential with data the would cause duplicate\n"); + err = TestCreateNewPinCredentialWithDataTheWouldCauseDuplicate_71(); + break; + case 72: + ChipLogProgress(chipTool, " ***** Test Step 72 : Create new RFID credential with data the would cause duplicate\n"); + err = TestCreateNewRfidCredentialWithDataTheWouldCauseDuplicate_72(); + break; + case 73: + ChipLogProgress(chipTool, " ***** Test Step 73 : Modify credentialData of existing PIN credential with non-null UserStatus should fail\n"); + err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusShouldFail_73(); + break; + case 74: + ChipLogProgress(chipTool, " ***** Test Step 74 : Modify credentialData of existing PIN credential with non-null UserType should fail\n"); + err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserTypeShouldFail_74(); + break; + case 75: + ChipLogProgress(chipTool, " ***** Test Step 75 : Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail\n"); + err = TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusAndUserTypeShouldFail_75(); + break; + case 76: + ChipLogProgress(chipTool, " ***** Test Step 76 : Modify credentialData of existing PIN credential\n"); + err = TestModifyCredentialDataOfExistingPinCredential_76(); + break; + case 77: + ChipLogProgress(chipTool, " ***** Test Step 77 : Verify that credential was changed by creating new credential with old data\n"); + err = TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithOldData_77(); + break; + case 78: + ChipLogProgress(chipTool, " ***** Test Step 78 : Verify that credential was changed by creating new credential with new data\n"); + err = TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithNewData_78(); + break; + case 79: + ChipLogProgress(chipTool, " ***** Test Step 79 : Create new RFID credential and add it to existing user\n"); + err = TestCreateNewRfidCredentialAndAddItToExistingUser_79(); + break; + case 80: + ChipLogProgress(chipTool, " ***** Test Step 80 : Verify modified user\n"); + err = TestVerifyModifiedUser_80(); + break; + case 81: + ChipLogProgress(chipTool, " ***** Test Step 81 : Create new RFID credential and add it to existing user\n"); + err = TestCreateNewRfidCredentialAndAddItToExistingUser_81(); + break; + case 82: + ChipLogProgress(chipTool, " ***** Test Step 82 : Verify modified user\n"); + err = TestVerifyModifiedUser_82(); + break; + case 83: + ChipLogProgress(chipTool, " ***** Test Step 83 : Clear first PIN credential\n"); + err = TestClearFirstPinCredential_83(); + break; + case 84: + ChipLogProgress(chipTool, " ***** Test Step 84 : Read back the credential and make sure it is deleted\n"); + err = TestReadBackTheCredentialAndMakeSureItIsDeleted_84(); + break; + case 85: + ChipLogProgress(chipTool, " ***** Test Step 85 : Read the user back and make sure PIN credential is deleted\n"); + err = TestReadTheUserBackAndMakeSurePinCredentialIsDeleted_85(); + break; + case 86: + ChipLogProgress(chipTool, " ***** Test Step 86 : Clear the second PIN credential\n"); + err = TestClearTheSecondPinCredential_86(); + break; + case 87: + ChipLogProgress(chipTool, " ***** Test Step 87 : Read back the credential and make sure it is deleted\n"); + err = TestReadBackTheCredentialAndMakeSureItIsDeleted_87(); + break; + case 88: + ChipLogProgress(chipTool, " ***** Test Step 88 : Read the user back and make sure related user is deleted\n"); + err = TestReadTheUserBackAndMakeSureRelatedUserIsDeleted_88(); + break; + case 89: + ChipLogProgress(chipTool, " ***** Test Step 89 : Create new RFID credential with user\n"); + err = TestCreateNewRfidCredentialWithUser_89(); + break; + case 90: + ChipLogProgress(chipTool, " ***** Test Step 90 : Clear all the RFID credentials\n"); + err = TestClearAllTheRfidCredentials_90(); + break; + case 91: + ChipLogProgress(chipTool, " ***** Test Step 91 : Read back the fist RFID credential and make sure it is deleted\n"); + err = TestReadBackTheFistRfidCredentialAndMakeSureItIsDeleted_91(); + break; + case 92: + ChipLogProgress(chipTool, " ***** Test Step 92 : Read back the second RFID credential and make sure it is deleted\n"); + err = TestReadBackTheSecondRfidCredentialAndMakeSureItIsDeleted_92(); + break; + case 93: + ChipLogProgress(chipTool, " ***** Test Step 93 : Read back the third RFID credential and make sure it is deleted\n"); + err = TestReadBackTheThirdRfidCredentialAndMakeSureItIsDeleted_93(); + break; + case 94: + ChipLogProgress(chipTool, " ***** Test Step 94 : Read the user related with first RFID back and make sure it has only PIN credential\n"); + err = TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItHasOnlyPinCredential_94(); + break; + case 95: + ChipLogProgress(chipTool, " ***** Test Step 95 : Read the user related with second RFID back and make sure it is deleted\n"); + err = TestReadTheUserRelatedWithSecondRfidBackAndMakeSureItIsDeleted_95(); + break; + case 96: + ChipLogProgress(chipTool, " ***** Test Step 96 : Create new PIN credential with user\n"); + err = TestCreateNewPinCredentialWithUser_96(); + break; + case 97: + ChipLogProgress(chipTool, " ***** Test Step 97 : Create new RFID credential with user\n"); + err = TestCreateNewRfidCredentialWithUser_97(); + break; + case 98: + ChipLogProgress(chipTool, " ***** Test Step 98 : Create another RFID credential with user\n"); + err = TestCreateAnotherRfidCredentialWithUser_98(); + break; + case 99: + ChipLogProgress(chipTool, " ***** Test Step 99 : Clear all the credentials\n"); + err = TestClearAllTheCredentials_99(); + break; + case 100: + ChipLogProgress(chipTool, " ***** Test Step 100 : Read back the first PIN credential and make sure it is deleted\n"); + err = TestReadBackTheFirstPinCredentialAndMakeSureItIsDeleted_100(); + break; + case 101: + ChipLogProgress(chipTool, " ***** Test Step 101 : Read back the first RFID credential and make sure it is deleted\n"); + err = TestReadBackTheFirstRfidCredentialAndMakeSureItIsDeleted_101(); + break; + case 102: + ChipLogProgress(chipTool, " ***** Test Step 102 : Read back the second PIN credential and make sure it is deleted\n"); + err = TestReadBackTheSecondPinCredentialAndMakeSureItIsDeleted_102(); + break; + case 103: + ChipLogProgress(chipTool, " ***** Test Step 103 : Read the user related with first PIN back and make sure it is deleted\n"); + err = TestReadTheUserRelatedWithFirstPinBackAndMakeSureItIsDeleted_103(); + break; + case 104: + ChipLogProgress(chipTool, " ***** Test Step 104 : Read the user related with first RFID back and make sure it is deleted\n"); + err = TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItIsDeleted_104(); + break; + case 105: + ChipLogProgress(chipTool, " ***** Test Step 105 : Read the user related with second PIN back and make sure it is deleted\n"); + err = TestReadTheUserRelatedWithSecondPinBackAndMakeSureItIsDeleted_105(); + break; + case 106: + ChipLogProgress(chipTool, " ***** Test Step 106 : Read the user related with last RFID back and make sure it is deleted\n"); + err = TestReadTheUserRelatedWithLastRfidBackAndMakeSureItIsDeleted_106(); + break; + case 107: + ChipLogProgress(chipTool, " ***** Test Step 107 : Create new Programming PIN credential with invalid index\n"); + err = TestCreateNewProgrammingPinCredentialWithInvalidIndex_107(); + break; + case 108: + ChipLogProgress(chipTool, " ***** Test Step 108 : Create new Programming PIN credential with valid index\n"); + err = TestCreateNewProgrammingPinCredentialWithValidIndex_108(); + break; + case 109: + ChipLogProgress(chipTool, " ***** Test Step 109 : Verify created user\n"); + err = TestVerifyCreatedUser_109(); + break; + case 110: + ChipLogProgress(chipTool, " ***** Test Step 110 : Verify created programming PIN credential\n"); + err = TestVerifyCreatedProgrammingPinCredential_110(); + break; + case 111: + ChipLogProgress(chipTool, " ***** Test Step 111 : Modify the Programming PIN credential\n"); + err = TestModifyTheProgrammingPinCredential_111(); + break; + case 112: + ChipLogProgress(chipTool, " ***** Test Step 112 : Clearing Programming PIN fails\n"); + err = TestClearingProgrammingPinFails_112(); + break; + case 113: + ChipLogProgress(chipTool, " ***** Test Step 113 : Clearing Programming PIN with invalid index fails\n"); + err = TestClearingProgrammingPinWithInvalidIndexFails_113(); + break; + case 114: + ChipLogProgress(chipTool, " ***** Test Step 114 : Clearing PIN credential with zero index fails\n"); + err = TestClearingPinCredentialWithZeroIndexFails_114(); + break; + case 115: + ChipLogProgress(chipTool, " ***** Test Step 115 : Clearing PIN credential with out-of-bound index fails\n"); + err = TestClearingPinCredentialWithOutOfBoundIndexFails_115(); + break; + case 116: + ChipLogProgress(chipTool, " ***** Test Step 116 : Clearing RFID credential with zero index fails\n"); + err = TestClearingRfidCredentialWithZeroIndexFails_116(); + break; + case 117: + ChipLogProgress(chipTool, " ***** Test Step 117 : Clearing RFID credential with out-of-bound index fails\n"); + err = TestClearingRfidCredentialWithOutOfBoundIndexFails_117(); + break; + case 118: + ChipLogProgress(chipTool, " ***** Test Step 118 : Clear the Programming PIN user\n"); + err = TestClearTheProgrammingPinUser_118(); + break; + case 119: + ChipLogProgress(chipTool, " ***** Test Step 119 : Make sure Programming PIN user is deleted\n"); + err = TestMakeSureProgrammingPinUserIsDeleted_119(); + break; + case 120: + ChipLogProgress(chipTool, " ***** Test Step 120 : Make sure programming PIN credential is deleted\n"); + err = TestMakeSureProgrammingPinCredentialIsDeleted_120(); + break; + case 121: + ChipLogProgress(chipTool, " ***** Test Step 121 : Create new PIN credential and user\n"); + err = TestCreateNewPinCredentialAndUser_121(); + break; + case 122: + ChipLogProgress(chipTool, " ***** Test Step 122 : Create second PIN credential and add it to existing user\n"); + err = TestCreateSecondPinCredentialAndAddItToExistingUser_122(); + break; + case 123: + ChipLogProgress(chipTool, " ***** Test Step 123 : Create third PIN credential and add it to existing user\n"); + err = TestCreateThirdPinCredentialAndAddItToExistingUser_123(); + break; + case 124: + ChipLogProgress(chipTool, " ***** Test Step 124 : Create fourth PIN credential and add it to existing user\n"); + err = TestCreateFourthPinCredentialAndAddItToExistingUser_124(); + break; + case 125: + ChipLogProgress(chipTool, " ***** Test Step 125 : Create fifth PIN credential and add it to existing user\n"); + err = TestCreateFifthPinCredentialAndAddItToExistingUser_125(); + break; + case 126: + ChipLogProgress(chipTool, " ***** Test Step 126 : Try to create sixth PIN credential and make sure it fails\n"); + err = TestTryToCreateSixthPinCredentialAndMakeSureItFails_126(); + break; + case 127: + ChipLogProgress(chipTool, " ***** Test Step 127 : Final clean-up\n"); + err = TestFinalCleanUp_127(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 49: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 50: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 51: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 52: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 53: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 54: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 55: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 56: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 57: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 58: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 59: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 60: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 61: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 62: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 63: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 64: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 65: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 66: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 67: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 68: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 69: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 70: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 71: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 72: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 73: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 74: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 75: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 76: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 77: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 78: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 79: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 80: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 81: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 82: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 83: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 84: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 85: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 86: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 87: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 88: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 89: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 90: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 91: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 92: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 93: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 94: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 95: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 96: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 97: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 98: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 99: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 100: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 101: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 102: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 103: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 104: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 105: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 106: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 107: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 108: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 109: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 110: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 111: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 112: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 113: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 114: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 115: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 116: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 117: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 118: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 119: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 120: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 121: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 122: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 123: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 124: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 125: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 126: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 127: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 128; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestReadAvailableUserSlotAndVerifyResponseFields_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read available user slot and verify response fields: Error: %@", err); + } else { + NSLog(@"Read available user slot and verify response fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; + + CHIP_ERROR TestGetNumberOfSupportedUsersAndVerifyDefaultValue_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get number of supported users and verify default value: Error: %@", err); + } else { + NSLog(@"Get number of supported users and verify default value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NumberOfTotalUsersSupported", actualValue, 10U)); + } + { + NumberOfTotalUsersSupportedValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadFailsForUserWithIndex0_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read fails for user with index 0: Error: %@", err); + } else { + NSLog(@"Read fails for user with index 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadFailsForUserWithIndexGreaterThanNumberOfUsersSupported_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read fails for user with index greater than Number Of Users Supported: Error: %@", err); + } else { + NSLog(@"Read fails for user with index greater than Number Of Users Supported: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewUserWithDefaultParameters_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new user with default parameters: Error: %@", err); + } else { + NSLog(@"Create new user with default parameters: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheUserBackAndVerifyItsFields_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestSetUserAtTheOccupiedIndexFailsWithAppropriateResponse_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Set user at the occupied index fails with appropriate response: Error: %@", err); + } else { + NSLog(@"Set user at the occupied index fails with appropriate response: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyUserNameForExistingUser_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = @"new_user"; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify userName for existing user: Error: %@", err); + } else { + NSLog(@"Modify userName for existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the modified user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the modified user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyUserUniqueIdForExistingUser_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = nil; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:305441741UL]; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify userUniqueId for existing user: Error: %@", err); + } else { + NSLog(@"Modify userUniqueId for existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the modified user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the modified user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyUserStatusForExistingUser_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = + [NSNumber numberWithUnsignedChar:3U]; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify userStatus for existing user: Error: %@", err); + } else { + NSLog(@"Modify userStatus for existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the modified user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the modified user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyUserTypeForExistingUser_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = + [NSNumber numberWithUnsignedChar:6U]; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify userType for existing user: Error: %@", err); + } else { + NSLog(@"Modify userType for existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the modified user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the modified user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 6U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyCredentialRuleForExistingUser_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = + [NSNumber numberWithUnsignedChar:2U]; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify credentialRule for existing user: Error: %@", err); + } else { + NSLog(@"Modify credentialRule for existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the modified user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the modified user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"new_user")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 305441741UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 6U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 2U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyAllFieldsForExistingUser_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = @"test_user"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:466460832UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + params.credentialRule = + [NSNumber numberWithUnsignedChar:1U]; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify all fields for existing user: Error: %@", err); + } else { + NSLog(@"Modify all fields for existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheModifiedUserBackAndVerifyItsFields_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the modified user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the modified user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 466460832UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 1U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestAddAnotherUserWithNonDefaultFields_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + params.userName = @"test_user2"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:12648430UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:1U]; + params.credentialRule = + [NSNumber numberWithUnsignedChar:2U]; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Add another user with non-default fields: Error: %@", err); + } else { + NSLog(@"Add another user with non-default fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheNewUserBackAndVerifyItsFields_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the new user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the new user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user2")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 12648430UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 1U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 2U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToAddAUserWithUserStatus0_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:3U]; + params.userName = @"test_user3"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:47802UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:0U]; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Try to add a user with userStatus 0: Error: %@", err); + } else { + NSLog(@"Try to add a user with userStatus 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureTheUserDidNotGetCreated_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:3U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure the user did not get created: Error: %@", err); + } else { + NSLog(@"Make sure the user did not get created: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToAddAUserWithUserStatus2_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:3U]; + params.userName = @"test_user3"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:47802UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:2U]; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Try to add a user with userStatus 2: Error: %@", err); + } else { + NSLog(@"Try to add a user with userStatus 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureTheUserDidNotGetCreated_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:3U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure the user did not get created: Error: %@", err); + } else { + NSLog(@"Make sure the user did not get created: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToAddAUserWithUserStatus3_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:3U]; + params.userName = @"test_user3"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:47802UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:3U]; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Try to add a user with userStatus 3: Error: %@", err); + } else { + NSLog(@"Try to add a user with userStatus 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheNewThirdUserBackAndVerifyItsFields_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:3U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the new third user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the new third user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"test_user3")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 47802UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 3U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateUserInTheLastSlot_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NumberOfTotalUsersSupportedValue copy]; + params.userName = @"last_user"; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create user in the last slot: Error: %@", err); + } else { + NSLog(@"Create user in the last slot: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheLastUserBackAndVerifyItsFields_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NumberOfTotalUsersSupportedValue copy]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the last user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the last user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, NumberOfTotalUsersSupportedValue)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"last_user")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestUserCreationInThe0SlotFails_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"User creation in the 0 slot fails: Error: %@", err); + } else { + NSLog(@"User creation in the 0 slot fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestUserCreationInTheOutOfBoundsSlotFails_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"User creation in the out-of-bounds slot fails: Error: %@", err); + } else { + NSLog(@"User creation in the out-of-bounds slot fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearFirstUser_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear first user: Error: %@", err); + } else { + NSLog(@"Clear first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadClearedUserAndVerifyItIsAvailable_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read cleared user and verify it is available: Error: %@", err); + } else { + NSLog(@"Read cleared user and verify it is available: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); + VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewUserInTheClearedSlot_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new user in the cleared slot: Error: %@", err); + } else { + NSLog(@"Create new user in the cleared slot: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheUserInThePreviouslyClearedSlotAndVerifyItsFields_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the user in the previously cleared slot and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the user in the previously cleared slot and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); + VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearUserWithIndex0Fails_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear user with index 0 fails: Error: %@", err); + } else { + NSLog(@"Clear user with index 0 fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearUserWithOutOfBoundsIndexFails_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear user with out-of-bounds index fails: Error: %@", err); + } else { + NSLog(@"Clear user with out-of-bounds index fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearAllUsers_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:65534U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear all users: Error: %@", err); + } else { + NSLog(@"Clear all users: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadFirstClearedUserAndVerifyItIsAvailable_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read first cleared user and verify it is available: Error: %@", err); + } else { + NSLog(@"Read first cleared user and verify it is available: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadLastClearedUserAndVerifyItIsAvailable_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NumberOfTotalUsersSupportedValue copy]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read last cleared user and verify it is available: Error: %@", err); + } else { + NSLog(@"Read last cleared user and verify it is available: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, NumberOfTotalUsersSupportedValue)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull NumberOfPINUsersSupportedValue; + + CHIP_ERROR TestGetNumberOfSupportedPinCredentialsAndVerifyDefaultValue_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfPINUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get number of supported PIN credentials and verify default value: Error: %@", err); + } else { + NSLog(@"Get number of supported PIN credentials and verify default value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NumberOfPINUsersSupported", actualValue, 10U)); + } + { + NumberOfPINUsersSupportedValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatPinCredentialDoesNotExist_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that PIN credential does not exist: Error: %@", err); + } else { + NSLog(@"Check that PIN credential does not exist: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadingPinCredentialWithIndex0ReturnsNoCredential_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:0U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Reading PIN credential with index 0 returns no credential: Error: %@", err); + } else { + NSLog(@"Reading PIN credential with index 0 returns no credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadingPinCredentialWithOutOfBoundsIndexReturnsNoCredential_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Reading PIN credential with out-of-bounds index returns no credential: Error: %@", err); + } else { + NSLog(@"Reading PIN credential with out-of-bounds index returns no credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatAUserWithUserStatus0CannotBeAddedViaSetCredential_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"000000" length:6]; + params.userIndex = nil; + params.userStatus = + [NSNumber numberWithUnsignedChar:0U]; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify that a user with UserStatus = 0 cannot be added via SetCredential: Error: %@", err); + } else { + NSLog(@"Verify that a user with UserStatus = 0 cannot be added via SetCredential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatAUserWithUserStatus2CannotBeAddedViaSetCredential_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"000000" length:6]; + params.userIndex = nil; + params.userStatus = + [NSNumber numberWithUnsignedChar:2U]; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify that a user with UserStatus = 2 cannot be added via SetCredential: Error: %@", err); + } else { + NSLog(@"Verify that a user with UserStatus = 2 cannot be added via SetCredential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinCredentialAndUser_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"000000" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN credential and user: Error: %@", err); + } else { + NSLog(@"Create new PIN credential and user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedUser_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created user: Error: %@", err); + } else { + NSLog(@"Verify created user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedPinCredential_49() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created PIN credential: Error: %@", err); + } else { + NSLog(@"Verify created PIN credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinCredentialAndUserWithIndex0Fails_50() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:0U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN credential and user with index 0 fails: Error: %@", err); + } else { + NSLog(@"Create new PIN credential and user with index 0 fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinCredentialAndUserWithOutOfBoundsIndexFails_51() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN credential and user with out-of-bounds index fails: Error: %@", err); + } else { + NSLog(@"Create new PIN credential and user with out-of-bounds index fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull NumberOfRFIDUsersSupportedValue; + + CHIP_ERROR TestGetNumberOfSupportedRfidCredentialsAndVerifyDefaultValue_52() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfRFIDUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get number of supported RFID credentials and verify default value: Error: %@", err); + } else { + NSLog(@"Get number of supported RFID credentials and verify default value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NumberOfRFIDUsersSupported", actualValue, 10U)); + } + { + NumberOfRFIDUsersSupportedValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadingRfidCredentialWithIndex0ReturnsNoCredential_53() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:0U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Reading RFID credential with index 0 returns no credential: Error: %@", err); + } else { + NSLog(@"Reading RFID credential with index 0 returns no credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadingRfidCredentialWithOutOfBoundsIndexReturnsNoCredential_54() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Reading RFID credential with out-of-bounds index returns no credential: Error: %@", err); + } else { + NSLog(@"Reading RFID credential with out-of-bounds index returns no credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCheckThatRfidCredentialDoesNotExist_55() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Check that RFID credential does not exist: Error: %@", err); + } else { + NSLog(@"Check that RFID credential does not exist: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserStatusShouldFail_56() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID credential and add it to existing user with non-null UserStatus should fail: Error: %@", err); + } else { + NSLog(@"Create new RFID credential and add it to existing user with non-null UserStatus should fail: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeShouldFail_57() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID credential and add it to existing user with non-null UserType should fail: Error: %@", err); + } else { + NSLog(@"Create new RFID credential and add it to existing user with non-null UserType should fail: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUserWithNonNullUserTypeAndUserStatusShouldFail_58() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail: Error: %@", err); + } else { + NSLog(@"Create new RFID credential and add it to existing user with non-null UserType and UserStatus should fail: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_59() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); + } else { + NSLog(@"Create new RFID credential and add it to existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyModifiedUser_60() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify modified user: Error: %@", err); + } else { + NSLog(@"Verify modified user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedCredential_61() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created credential: Error: %@", err); + } else { + NSLog(@"Verify created credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidCredentialAndUserWithIndex0Fails_62() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:0U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"new_rfid_data_field" length:19]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID credential and user with index 0 fails: Error: %@", err); + } else { + NSLog(@"Create new RFID credential and user with index 0 fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidCredentialAndUserWithOutOfBoundsIndexFails_63() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"new_rfid_data_field" length:19]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID credential and user with out-of-bounds index fails: Error: %@", err); + } else { + NSLog(@"Create new RFID credential and user with out-of-bounds index fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewCredentialAndTryToAddItTo0User_64() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123465" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new credential and try to add it to 0 user: Error: %@", err); + } else { + NSLog(@"Create new credential and try to add it to 0 user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewCredentialAndTryToAddItToOutOfBoundsUser_65() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123465" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new credential and try to add it to out-of-bounds user: Error: %@", err); + } else { + NSLog(@"Create new credential and try to add it to out-of-bounds user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinWithTooShortData_66() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"12345" length:5]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN with too short data: Error: %@", err); + } else { + NSLog(@"Create new PIN with too short data: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinWithTooLongData_67() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456789" length:9]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN with too long data: Error: %@", err); + } else { + NSLog(@"Create new PIN with too long data: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidWithTooShortData_68() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"rfid_data" length:9]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID with too short data: Error: %@", err); + } else { + NSLog(@"Create new RFID with too short data: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinWithProgrammingUserTypeFails_69() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + params.userStatus = nil; + params.userType = + [NSNumber numberWithUnsignedChar:3U]; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN with Programming user type fails: Error: %@", err); + } else { + NSLog(@"Create new PIN with Programming user type fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidWithTooShortData_70() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"very_long_rfid_data_to_test_boundaries" length:38]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID with too short data: Error: %@", err); + } else { + NSLog(@"Create new RFID with too short data: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinCredentialWithDataTheWouldCauseDuplicate_71() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:3U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"000000" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN credential with data the would cause duplicate: Error: %@", err); + } else { + NSLog(@"Create new PIN credential with data the would cause duplicate: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 2U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidCredentialWithDataTheWouldCauseDuplicate_72() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"rfid_data_123456" length:16]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID credential with data the would cause duplicate: Error: %@", err); + } else { + NSLog(@"Create new RFID credential with data the would cause duplicate: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 2U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusShouldFail_73() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus should fail: Error: %@", err); + } else { + NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus should fail: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserTypeShouldFail_74() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify credentialData of existing PIN credential with non-null UserType should fail: Error: %@", err); + } else { + NSLog(@"Modify credentialData of existing PIN credential with non-null UserType should fail: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyCredentialDataOfExistingPinCredentialWithNonNullUserStatusAndUserTypeShouldFail_75() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail: Error: %@", err); + } else { + NSLog(@"Modify credentialData of existing PIN credential with non-null UserStatus and UserType should fail: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyCredentialDataOfExistingPinCredential_76() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify credentialData of existing PIN credential: Error: %@", err); + } else { + NSLog(@"Modify credentialData of existing PIN credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithOldData_77() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"000000" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify that credential was changed by creating new credential with old data: Error: %@", err); + } else { + NSLog(@"Verify that credential was changed by creating new credential with old data: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatCredentialWasChangedByCreatingNewCredentialWithNewData_78() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:3U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify that credential was changed by creating new credential with new data: Error: %@", err); + } else { + NSLog(@"Verify that credential was changed by creating new credential with new data: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 2U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_79() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"rfid_data_7890" length:14]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); + } else { + NSLog(@"Create new RFID credential and add it to existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyModifiedUser_80() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify modified user: Error: %@", err); + } else { + NSLog(@"Verify modified user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(3))); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 2U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 2U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); + VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidCredentialAndAddItToExistingUser_81() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:3U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"789012" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID credential and add it to existing user: Error: %@", err); + } else { + NSLog(@"Create new RFID credential and add it to existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyModifiedUser_82() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify modified user: Error: %@", err); + } else { + NSLog(@"Verify modified user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 1U)); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 2U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 2U)); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[3]).credentialType, 1U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[3]).credentialIndex, 3U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); + VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearFirstPinCredential_83() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear first PIN credential: Error: %@", err); + } else { + NSLog(@"Clear first PIN credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackTheCredentialAndMakeSureItIsDeleted_84() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back the credential and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read back the credential and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheUserBackAndMakeSurePinCredentialIsDeleted_85() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the user back and make sure PIN credential is deleted: Error: %@", err); + } else { + NSLog(@"Read the user back and make sure PIN credential is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(3))); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 2U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 1U)); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialType, 2U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[1]).credentialIndex, 2U)); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialType, 1U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[2]).credentialIndex, 3U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); + VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearTheSecondPinCredential_86() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear the second PIN credential: Error: %@", err); + } else { + NSLog(@"Clear the second PIN credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackTheCredentialAndMakeSureItIsDeleted_87() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back the credential and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read back the credential and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheUserBackAndMakeSureRelatedUserIsDeleted_88() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the user back and make sure related user is deleted: Error: %@", err); + } else { + NSLog(@"Read the user back and make sure related user is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidCredentialWithUser_89() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:3U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"rfid_data_12345" length:15]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID credential with user: Error: %@", err); + } else { + NSLog(@"Create new RFID credential with user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearAllTheRfidCredentials_90() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:65534U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear all the RFID credentials: Error: %@", err); + } else { + NSLog(@"Clear all the RFID credentials: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackTheFistRfidCredentialAndMakeSureItIsDeleted_91() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back the fist RFID credential and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read back the fist RFID credential and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackTheSecondRfidCredentialAndMakeSureItIsDeleted_92() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back the second RFID credential and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read back the second RFID credential and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackTheThirdRfidCredentialAndMakeSureItIsDeleted_93() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:3U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back the third RFID credential and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read back the third RFID credential and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItHasOnlyPinCredential_94() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the user related with first RFID back and make sure it has only PIN credential: Error: %@", err); + } else { + NSLog(@"Read the user related with first RFID back and make sure it has only PIN credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 1U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 3U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheUserRelatedWithSecondRfidBackAndMakeSureItIsDeleted_95() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the user related with second RFID back and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read the user related with second RFID back and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinCredentialWithUser_96() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN credential with user: Error: %@", err); + } else { + NSLog(@"Create new PIN credential with user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewRfidCredentialWithUser_97() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"rfid_data_1234" length:14]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new RFID credential with user: Error: %@", err); + } else { + NSLog(@"Create new RFID credential with user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateAnotherRfidCredentialWithUser_98() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:6U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"rfid_data_9876" length:14]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create another RFID credential with user: Error: %@", err); + } else { + NSLog(@"Create another RFID credential with user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 4U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 7U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearAllTheCredentials_99() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = nil; + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear all the credentials: Error: %@", err); + } else { + NSLog(@"Clear all the credentials: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackTheFirstPinCredentialAndMakeSureItIsDeleted_100() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back the first PIN credential and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read back the first PIN credential and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackTheFirstRfidCredentialAndMakeSureItIsDeleted_101() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back the first RFID credential and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read back the first RFID credential and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadBackTheSecondPinCredentialAndMakeSureItIsDeleted_102() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:6U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read back the second PIN credential and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read back the second PIN credential and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheUserRelatedWithFirstPinBackAndMakeSureItIsDeleted_103() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the user related with first PIN back and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read the user related with first PIN back and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheUserRelatedWithFirstRfidBackAndMakeSureItIsDeleted_104() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the user related with first RFID back and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read the user related with first RFID back and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheUserRelatedWithSecondPinBackAndMakeSureItIsDeleted_105() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:3U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the user related with second PIN back and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read the user related with second PIN back and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 3U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheUserRelatedWithLastRfidBackAndMakeSureItIsDeleted_106() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:4U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the user related with last RFID back and make sure it is deleted: Error: %@", err); + } else { + NSLog(@"Read the user related with last RFID back and make sure it is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 4U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewProgrammingPinCredentialWithInvalidIndex_107() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new Programming PIN credential with invalid index: Error: %@", err); + } else { + NSLog(@"Create new Programming PIN credential with invalid index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewProgrammingPinCredentialWithValidIndex_108() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:0U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new Programming PIN credential with valid index: Error: %@", err); + } else { + NSLog(@"Create new Programming PIN credential with valid index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedUser_109() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created user: Error: %@", err); + } else { + NSLog(@"Verify created user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("CredentialType", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialType, 0U)); + VerifyOrReturn(CheckValue("CredentialIndex", ((MTRDoorLockClusterCredentialStruct *) actualValue[0]).credentialIndex, 0U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedProgrammingPinCredential_110() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:0U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created programming PIN credential: Error: %@", err); + } else { + NSLog(@"Verify created programming PIN credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestModifyTheProgrammingPinCredential_111() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:0U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"654321" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Modify the Programming PIN credential: Error: %@", err); + } else { + NSLog(@"Modify the Programming PIN credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearingProgrammingPinFails_112() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:0U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clearing Programming PIN fails: Error: %@", err); + } else { + NSLog(@"Clearing Programming PIN fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearingProgrammingPinWithInvalidIndexFails_113() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clearing Programming PIN with invalid index fails: Error: %@", err); + } else { + NSLog(@"Clearing Programming PIN with invalid index fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearingPinCredentialWithZeroIndexFails_114() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:0U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clearing PIN credential with zero index fails: Error: %@", err); + } else { + NSLog(@"Clearing PIN credential with zero index fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearingPinCredentialWithOutOfBoundIndexFails_115() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:[NumberOfPINUsersSupportedValue unsignedShortValue] + 1U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clearing PIN credential with out-of-bound index fails: Error: %@", err); + } else { + NSLog(@"Clearing PIN credential with out-of-bound index fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearingRfidCredentialWithZeroIndexFails_116() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:0U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clearing RFID credential with zero index fails: Error: %@", err); + } else { + NSLog(@"Clearing RFID credential with zero index fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearingRfidCredentialWithOutOfBoundIndexFails_117() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:[NumberOfRFIDUsersSupportedValue unsignedShortValue] + 1U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clearing RFID credential with out-of-bound index fails: Error: %@", err); + } else { + NSLog(@"Clearing RFID credential with out-of-bound index fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearTheProgrammingPinUser_118() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear the Programming PIN user: Error: %@", err); + } else { + NSLog(@"Clear the Programming PIN user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureProgrammingPinUserIsDeleted_119() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure Programming PIN user is deleted: Error: %@", err); + } else { + NSLog(@"Make sure Programming PIN user is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureProgrammingPinCredentialIsDeleted_120() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:0U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure programming PIN credential is deleted: Error: %@", err); + } else { + NSLog(@"Make sure programming PIN credential is deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinCredentialAndUser_121() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"000000" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN credential and user: Error: %@", err); + } else { + NSLog(@"Create new PIN credential and user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateSecondPinCredentialAndAddItToExistingUser_122() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:2U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"000001" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create second PIN credential and add it to existing user: Error: %@", err); + } else { + NSLog(@"Create second PIN credential and add it to existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 3U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateThirdPinCredentialAndAddItToExistingUser_123() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:3U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"000002" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create third PIN credential and add it to existing user: Error: %@", err); + } else { + NSLog(@"Create third PIN credential and add it to existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateFourthPinCredentialAndAddItToExistingUser_124() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:4U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"000003" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create fourth PIN credential and add it to existing user: Error: %@", err); + } else { + NSLog(@"Create fourth PIN credential and add it to existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 5U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateFifthPinCredentialAndAddItToExistingUser_125() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:5U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"000004" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create fifth PIN credential and add it to existing user: Error: %@", err); + } else { + NSLog(@"Create fifth PIN credential and add it to existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 6U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTryToCreateSixthPinCredentialAndMakeSureItFails_126() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:6U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"000005" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Try to create sixth PIN credential and make sure it fails: Error: %@", err); + } else { + NSLog(@"Try to create sixth PIN credential and make sure it fails: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 137U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 7U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestFinalCleanUp_127() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Final clean-up: Error: %@", err); + } else { + NSLog(@"Final clean-up: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class DL_Schedules : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + DL_Schedules() + : TestCommandBridge("DL_Schedules") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~DL_Schedules() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: DL_Schedules\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: DL_Schedules\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Create new PIN credential and schedule user\n"); + err = TestCreateNewPinCredentialAndScheduleUser_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Get number of supported users\n"); + err = TestGetNumberOfSupportedUsers_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Get Max number of Week Day schedules for user and verify default value\n"); + err = TestGetMaxNumberOfWeekDaySchedulesForUserAndVerifyDefaultValue_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Get Max number of Year Day schedules for user and verify default value\n"); + err = TestGetMaxNumberOfYearDaySchedulesForUserAndVerifyDefaultValue_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Get Max number of Holiday schedules and verify default value\n"); + err = TestGetMaxNumberOfHolidaySchedulesAndVerifyDefaultValue_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Create Week Day schedule with 0 index\n"); + err = TestCreateWeekDayScheduleWith0Index_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Create Week Day schedule with out-of-bounds index\n"); + err = TestCreateWeekDayScheduleWithOutOfBoundsIndex_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Create Week Day schedule with 0 user index\n"); + err = TestCreateWeekDayScheduleWith0UserIndex_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Create Week Day schedule with out-of-bounds user index\n"); + err = TestCreateWeekDayScheduleWithOutOfBoundsUserIndex_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Create Week Day schedule for non-existing user\n"); + err = TestCreateWeekDayScheduleForNonExistingUser_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Create Week Day schedule with 0 days mask\n"); + err = TestCreateWeekDayScheduleWith0DaysMask_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Create Week Day schedule for Sunday and Monday\n"); + err = TestCreateWeekDayScheduleForSundayAndMonday_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Create Week Day schedule for Sunday Wednesday and Saturday\n"); + err = TestCreateWeekDayScheduleForSundayWednesdayAndSaturday_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Create Week Day schedule with invalid start hour\n"); + err = TestCreateWeekDayScheduleWithInvalidStartHour_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Create Week Day schedule with invalid start minute\n"); + err = TestCreateWeekDayScheduleWithInvalidStartMinute_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Create Week Day schedule with invalid end hour\n"); + err = TestCreateWeekDayScheduleWithInvalidEndHour_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Create Week Day schedule with invalid end minute\n"); + err = TestCreateWeekDayScheduleWithInvalidEndMinute_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Create Week Day schedule with start hour later that end hour\n"); + err = TestCreateWeekDayScheduleWithStartHourLaterThatEndHour_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Create Week Day schedule with start minute later that end minute when hours are equal\n"); + err = TestCreateWeekDayScheduleWithStartMinuteLaterThatEndMinuteWhenHoursAreEqual_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Make sure that previous operations did not create a schedule\n"); + err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Get Week Day schedule with 0 index\n"); + err = TestGetWeekDayScheduleWith0Index_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Get Week Day schedule with out-of-bounds index\n"); + err = TestGetWeekDayScheduleWithOutOfBoundsIndex_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Get Week Day schedule with 0 user index\n"); + err = TestGetWeekDayScheduleWith0UserIndex_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Get Week Day schedule with out-of-bounds user index\n"); + err = TestGetWeekDayScheduleWithOutOfBoundsUserIndex_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Get Week Day schedule with non-existing user index\n"); + err = TestGetWeekDayScheduleWithNonExistingUserIndex_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Create Year Day schedule with 0 index\n"); + err = TestCreateYearDayScheduleWith0Index_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Create Year Day schedule with out-of-bounds index\n"); + err = TestCreateYearDayScheduleWithOutOfBoundsIndex_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Create Year Day schedule with 0 user index\n"); + err = TestCreateYearDayScheduleWith0UserIndex_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Create Year Day schedule with out-of-bounds user index\n"); + err = TestCreateYearDayScheduleWithOutOfBoundsUserIndex_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Create Year Day schedule for non-existing user\n"); + err = TestCreateYearDayScheduleForNonExistingUser_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Create Year Day schedule with start hour later that end hour\n"); + err = TestCreateYearDayScheduleWithStartHourLaterThatEndHour_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Make sure that previous operations did not create a schedule\n"); + err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Get Year Day schedule with 0 index\n"); + err = TestGetYearDayScheduleWith0Index_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Get Year Day schedule with out-of-bounds index\n"); + err = TestGetYearDayScheduleWithOutOfBoundsIndex_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Get Year Day schedule with 0 user index\n"); + err = TestGetYearDayScheduleWith0UserIndex_35(); + break; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Get Year Day schedule with out-of-bounds user index\n"); + err = TestGetYearDayScheduleWithOutOfBoundsUserIndex_36(); + break; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Get Year Day schedule with non-existing user index\n"); + err = TestGetYearDayScheduleWithNonExistingUserIndex_37(); + break; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Create Holiday schedule with 0 index\n"); + err = TestCreateHolidayScheduleWith0Index_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Create Holiday schedule with out-of-bounds index\n"); + err = TestCreateHolidayScheduleWithOutOfBoundsIndex_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Create Holiday schedule with start hour later that end hour\n"); + err = TestCreateHolidayScheduleWithStartHourLaterThatEndHour_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Create Holiday schedule with invalid operating mode\n"); + err = TestCreateHolidayScheduleWithInvalidOperatingMode_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Make sure that previous operations did not create a schedule\n"); + err = TestMakeSureThatPreviousOperationsDidNotCreateASchedule_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Get Holiday schedule with 0 index\n"); + err = TestGetHolidayScheduleWith0Index_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Get Holiday schedule with out-of-bounds index\n"); + err = TestGetHolidayScheduleWithOutOfBoundsIndex_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Create Holiday schedule with valid parameters\n"); + err = TestCreateHolidayScheduleWithValidParameters_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Verify created schedule\n"); + err = TestVerifyCreatedSchedule_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Create Week Day schedule with valid parameters\n"); + err = TestCreateWeekDayScheduleWithValidParameters_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Verify created schedule\n"); + err = TestVerifyCreatedSchedule_48(); + break; + case 49: + ChipLogProgress(chipTool, " ***** Test Step 49 : Create Year Day schedule with valid parameters\n"); + err = TestCreateYearDayScheduleWithValidParameters_49(); + break; + case 50: + ChipLogProgress(chipTool, " ***** Test Step 50 : Verify created schedule\n"); + err = TestVerifyCreatedSchedule_50(); + break; + case 51: + ChipLogProgress(chipTool, " ***** Test Step 51 : Clear Week Day schedule with 0 index\n"); + err = TestClearWeekDayScheduleWith0Index_51(); + break; + case 52: + ChipLogProgress(chipTool, " ***** Test Step 52 : Clear Week Day schedule with out-of-bounds index\n"); + err = TestClearWeekDayScheduleWithOutOfBoundsIndex_52(); + break; + case 53: + ChipLogProgress(chipTool, " ***** Test Step 53 : Clear Week Day schedule with 0 user index\n"); + err = TestClearWeekDayScheduleWith0UserIndex_53(); + break; + case 54: + ChipLogProgress(chipTool, " ***** Test Step 54 : Clear Week Day schedule with out-of-bounds user index\n"); + err = TestClearWeekDayScheduleWithOutOfBoundsUserIndex_54(); + break; + case 55: + ChipLogProgress(chipTool, " ***** Test Step 55 : Clear Week Day schedule with non-existing user\n"); + err = TestClearWeekDayScheduleWithNonExistingUser_55(); + break; + case 56: + ChipLogProgress(chipTool, " ***** Test Step 56 : Make sure that week day schedule was not deleted\n"); + err = TestMakeSureThatWeekDayScheduleWasNotDeleted_56(); + break; + case 57: + ChipLogProgress(chipTool, " ***** Test Step 57 : Make sure that year day schedule was not deleted\n"); + err = TestMakeSureThatYearDayScheduleWasNotDeleted_57(); + break; + case 58: + ChipLogProgress(chipTool, " ***** Test Step 58 : Make sure that holiday schedule was not deleted\n"); + err = TestMakeSureThatHolidayScheduleWasNotDeleted_58(); + break; + case 59: + ChipLogProgress(chipTool, " ***** Test Step 59 : Clear Year Day schedule with 0 index\n"); + err = TestClearYearDayScheduleWith0Index_59(); + break; + case 60: + ChipLogProgress(chipTool, " ***** Test Step 60 : Clear Year Day schedule with out-of-bounds index\n"); + err = TestClearYearDayScheduleWithOutOfBoundsIndex_60(); + break; + case 61: + ChipLogProgress(chipTool, " ***** Test Step 61 : Clear Year Day schedule with 0 user index\n"); + err = TestClearYearDayScheduleWith0UserIndex_61(); + break; + case 62: + ChipLogProgress(chipTool, " ***** Test Step 62 : Clear Year Day schedule with out-of-bounds user index\n"); + err = TestClearYearDayScheduleWithOutOfBoundsUserIndex_62(); + break; + case 63: + ChipLogProgress(chipTool, " ***** Test Step 63 : Clear Year Day schedule with non-existing user\n"); + err = TestClearYearDayScheduleWithNonExistingUser_63(); + break; + case 64: + ChipLogProgress(chipTool, " ***** Test Step 64 : Make sure that week day schedule was not deleted\n"); + err = TestMakeSureThatWeekDayScheduleWasNotDeleted_64(); + break; + case 65: + ChipLogProgress(chipTool, " ***** Test Step 65 : Make sure that year day schedule was not deleted\n"); + err = TestMakeSureThatYearDayScheduleWasNotDeleted_65(); + break; + case 66: + ChipLogProgress(chipTool, " ***** Test Step 66 : Make sure that holiday schedule was not deleted\n"); + err = TestMakeSureThatHolidayScheduleWasNotDeleted_66(); + break; + case 67: + ChipLogProgress(chipTool, " ***** Test Step 67 : Clear Holiday schedule with 0 index\n"); + err = TestClearHolidayScheduleWith0Index_67(); + break; + case 68: + ChipLogProgress(chipTool, " ***** Test Step 68 : Clear Holiday schedule with out-of-bounds index\n"); + err = TestClearHolidayScheduleWithOutOfBoundsIndex_68(); + break; + case 69: + ChipLogProgress(chipTool, " ***** Test Step 69 : Make sure that week day schedule was not deleted\n"); + err = TestMakeSureThatWeekDayScheduleWasNotDeleted_69(); + break; + case 70: + ChipLogProgress(chipTool, " ***** Test Step 70 : Make sure that year day schedule was not deleted\n"); + err = TestMakeSureThatYearDayScheduleWasNotDeleted_70(); + break; + case 71: + ChipLogProgress(chipTool, " ***** Test Step 71 : Make sure that holiday schedule was not deleted\n"); + err = TestMakeSureThatHolidayScheduleWasNotDeleted_71(); + break; + case 72: + ChipLogProgress(chipTool, " ***** Test Step 72 : Create another Week Day schedule with valid parameters\n"); + err = TestCreateAnotherWeekDayScheduleWithValidParameters_72(); + break; + case 73: + ChipLogProgress(chipTool, " ***** Test Step 73 : Verify created week day schedule\n"); + err = TestVerifyCreatedWeekDaySchedule_73(); + break; + case 74: + ChipLogProgress(chipTool, " ***** Test Step 74 : Create another Year Day schedule with valid parameters\n"); + err = TestCreateAnotherYearDayScheduleWithValidParameters_74(); + break; + case 75: + ChipLogProgress(chipTool, " ***** Test Step 75 : Verify created year day schedule\n"); + err = TestVerifyCreatedYearDaySchedule_75(); + break; + case 76: + ChipLogProgress(chipTool, " ***** Test Step 76 : Create another Holiday schedule with valid parameters\n"); + err = TestCreateAnotherHolidayScheduleWithValidParameters_76(); + break; + case 77: + ChipLogProgress(chipTool, " ***** Test Step 77 : Verify created holiday schedule\n"); + err = TestVerifyCreatedHolidaySchedule_77(); + break; + case 78: + ChipLogProgress(chipTool, " ***** Test Step 78 : Clear a single week day schedule for the first user\n"); + err = TestClearASingleWeekDayScheduleForTheFirstUser_78(); + break; + case 79: + ChipLogProgress(chipTool, " ***** Test Step 79 : Verify cleared week day schedule\n"); + err = TestVerifyClearedWeekDaySchedule_79(); + break; + case 80: + ChipLogProgress(chipTool, " ***** Test Step 80 : Clear all remaining week day schedules for the first user\n"); + err = TestClearAllRemainingWeekDaySchedulesForTheFirstUser_80(); + break; + case 81: + ChipLogProgress(chipTool, " ***** Test Step 81 : Verify cleared week schedule\n"); + err = TestVerifyClearedWeekSchedule_81(); + break; + case 82: + ChipLogProgress(chipTool, " ***** Test Step 82 : Make sure that first year day schedule was not deleted\n"); + err = TestMakeSureThatFirstYearDayScheduleWasNotDeleted_82(); + break; + case 83: + ChipLogProgress(chipTool, " ***** Test Step 83 : Make sure that second year day schedule was not deleted\n"); + err = TestMakeSureThatSecondYearDayScheduleWasNotDeleted_83(); + break; + case 84: + ChipLogProgress(chipTool, " ***** Test Step 84 : Make sure that first holiday schedule was not deleted\n"); + err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_84(); + break; + case 85: + ChipLogProgress(chipTool, " ***** Test Step 85 : Make sure that second holiday schedule was not deleted\n"); + err = TestMakeSureThatSecondHolidayScheduleWasNotDeleted_85(); + break; + case 86: + ChipLogProgress(chipTool, " ***** Test Step 86 : Create another Week Day schedule with valid parameters\n"); + err = TestCreateAnotherWeekDayScheduleWithValidParameters_86(); + break; + case 87: + ChipLogProgress(chipTool, " ***** Test Step 87 : Clear a single year day schedule for the first user\n"); + err = TestClearASingleYearDayScheduleForTheFirstUser_87(); + break; + case 88: + ChipLogProgress(chipTool, " ***** Test Step 88 : Verify cleared year day schedule\n"); + err = TestVerifyClearedYearDaySchedule_88(); + break; + case 89: + ChipLogProgress(chipTool, " ***** Test Step 89 : Clear all remaining year schedules for the first user\n"); + err = TestClearAllRemainingYearSchedulesForTheFirstUser_89(); + break; + case 90: + ChipLogProgress(chipTool, " ***** Test Step 90 : Verify that second year day schedule was cleared\n"); + err = TestVerifyThatSecondYearDayScheduleWasCleared_90(); + break; + case 91: + ChipLogProgress(chipTool, " ***** Test Step 91 : Verify created week day schedule\n"); + err = TestVerifyCreatedWeekDaySchedule_91(); + break; + case 92: + ChipLogProgress(chipTool, " ***** Test Step 92 : Clear all remaining week day schedules for the first user\n"); + err = TestClearAllRemainingWeekDaySchedulesForTheFirstUser_92(); + break; + case 93: + ChipLogProgress(chipTool, " ***** Test Step 93 : Create new user without credential so we can add more schedules to it\n"); + err = TestCreateNewUserWithoutCredentialSoWeCanAddMoreSchedulesToIt_93(); + break; + case 94: + ChipLogProgress(chipTool, " ***** Test Step 94 : Create Week Day schedule with valid parameters for first user\n"); + err = TestCreateWeekDayScheduleWithValidParametersForFirstUser_94(); + break; + case 95: + ChipLogProgress(chipTool, " ***** Test Step 95 : Verify created week day schedule for first user\n"); + err = TestVerifyCreatedWeekDayScheduleForFirstUser_95(); + break; + case 96: + ChipLogProgress(chipTool, " ***** Test Step 96 : Create Year Day schedule for first user\n"); + err = TestCreateYearDayScheduleForFirstUser_96(); + break; + case 97: + ChipLogProgress(chipTool, " ***** Test Step 97 : Verify created year day schedule for first\n"); + err = TestVerifyCreatedYearDayScheduleForFirst_97(); + break; + case 98: + ChipLogProgress(chipTool, " ***** Test Step 98 : Create Week Day schedule with valid parameters for second user\n"); + err = TestCreateWeekDayScheduleWithValidParametersForSecondUser_98(); + break; + case 99: + ChipLogProgress(chipTool, " ***** Test Step 99 : Verify created week day schedule for first user\n"); + err = TestVerifyCreatedWeekDayScheduleForFirstUser_99(); + break; + case 100: + ChipLogProgress(chipTool, " ***** Test Step 100 : Create Year Day schedule for second user\n"); + err = TestCreateYearDayScheduleForSecondUser_100(); + break; + case 101: + ChipLogProgress(chipTool, " ***** Test Step 101 : Verify created year day schedule for first\n"); + err = TestVerifyCreatedYearDayScheduleForFirst_101(); + break; + case 102: + ChipLogProgress(chipTool, " ***** Test Step 102 : Cleanup the user\n"); + err = TestCleanupTheUser_102(); + break; + case 103: + ChipLogProgress(chipTool, " ***** Test Step 103 : Make sure clearing first user also cleared week day schedules\n"); + err = TestMakeSureClearingFirstUserAlsoClearedWeekDaySchedules_103(); + break; + case 104: + ChipLogProgress(chipTool, " ***** Test Step 104 : Make sure clearing first user also cleared year day schedules\n"); + err = TestMakeSureClearingFirstUserAlsoClearedYearDaySchedules_104(); + break; + case 105: + ChipLogProgress(chipTool, " ***** Test Step 105 : Make sure clearing second user also cleared week day schedules\n"); + err = TestMakeSureClearingSecondUserAlsoClearedWeekDaySchedules_105(); + break; + case 106: + ChipLogProgress(chipTool, " ***** Test Step 106 : Make sure clearing second user also cleared year day schedules\n"); + err = TestMakeSureClearingSecondUserAlsoClearedYearDaySchedules_106(); + break; + case 107: + ChipLogProgress(chipTool, " ***** Test Step 107 : Make sure that first holiday schedule was not deleted\n"); + err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_107(); + break; + case 108: + ChipLogProgress(chipTool, " ***** Test Step 108 : Make sure that second holiday schedule was not deleted\n"); + err = TestMakeSureThatSecondHolidayScheduleWasNotDeleted_108(); + break; + case 109: + ChipLogProgress(chipTool, " ***** Test Step 109 : Create another Holiday schedule at the last slot\n"); + err = TestCreateAnotherHolidayScheduleAtTheLastSlot_109(); + break; + case 110: + ChipLogProgress(chipTool, " ***** Test Step 110 : Verify Created Holiday Schedule\n"); + err = TestVerifyCreatedHolidaySchedule_110(); + break; + case 111: + ChipLogProgress(chipTool, " ***** Test Step 111 : Create new PIN credential and schedule user\n"); + err = TestCreateNewPinCredentialAndScheduleUser_111(); + break; + case 112: + ChipLogProgress(chipTool, " ***** Test Step 112 : Create Week Day schedule for first user\n"); + err = TestCreateWeekDayScheduleForFirstUser_112(); + break; + case 113: + ChipLogProgress(chipTool, " ***** Test Step 113 : Create Year Day schedule for first user\n"); + err = TestCreateYearDayScheduleForFirstUser_113(); + break; + case 114: + ChipLogProgress(chipTool, " ***** Test Step 114 : Clear a single holiday schedule\n"); + err = TestClearASingleHolidaySchedule_114(); + break; + case 115: + ChipLogProgress(chipTool, " ***** Test Step 115 : Make sure that first holiday schedule was not deleted\n"); + err = TestMakeSureThatFirstHolidayScheduleWasNotDeleted_115(); + break; + case 116: + ChipLogProgress(chipTool, " ***** Test Step 116 : Make sure that second holiday schedule was deleted\n"); + err = TestMakeSureThatSecondHolidayScheduleWasDeleted_116(); + break; + case 117: + ChipLogProgress(chipTool, " ***** Test Step 117 : Make sure that third holiday schedule was not deleted\n"); + err = TestMakeSureThatThirdHolidayScheduleWasNotDeleted_117(); + break; + case 118: + ChipLogProgress(chipTool, " ***** Test Step 118 : Make sure clearing holiday schedule did not clear week day schedule\n"); + err = TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_118(); + break; + case 119: + ChipLogProgress(chipTool, " ***** Test Step 119 : Make sure clearing holiday schedule did not clear year day schedule\n"); + err = TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_119(); + break; + case 120: + ChipLogProgress(chipTool, " ***** Test Step 120 : Clear all remaining holiday schedules\n"); + err = TestClearAllRemainingHolidaySchedules_120(); + break; + case 121: + ChipLogProgress(chipTool, " ***** Test Step 121 : Make sure that first holiday is still deleted\n"); + err = TestMakeSureThatFirstHolidayIsStillDeleted_121(); + break; + case 122: + ChipLogProgress(chipTool, " ***** Test Step 122 : Make sure that second holiday schedule was deleted\n"); + err = TestMakeSureThatSecondHolidayScheduleWasDeleted_122(); + break; + case 123: + ChipLogProgress(chipTool, " ***** Test Step 123 : Make sure that third holiday schedule was not deleted\n"); + err = TestMakeSureThatThirdHolidayScheduleWasNotDeleted_123(); + break; + case 124: + ChipLogProgress(chipTool, " ***** Test Step 124 : Make sure clearing holiday schedule did not clear week day schedule\n"); + err = TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_124(); + break; + case 125: + ChipLogProgress(chipTool, " ***** Test Step 125 : Make sure clearing holiday schedule did not clear year day schedule\n"); + err = TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_125(); + break; + case 126: + ChipLogProgress(chipTool, " ***** Test Step 126 : Final Cleanup\n"); + err = TestFinalCleanup_126(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 49: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 50: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 51: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 52: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 53: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 54: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 55: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 56: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 57: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 58: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 59: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 60: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 61: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 62: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 63: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + break; + case 64: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 65: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 66: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 67: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 68: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 69: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 70: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 71: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 72: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 73: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 74: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 75: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 76: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 77: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 78: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 79: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 80: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 81: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 82: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 83: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 84: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 85: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 86: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 87: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 88: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 89: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 90: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 91: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 92: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 93: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 94: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 95: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 96: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 97: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 98: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 99: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 100: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 101: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 102: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 103: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 104: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 105: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 106: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 107: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 108: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 109: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 110: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 111: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 112: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 113: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 114: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 115: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 116: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 117: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 118: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 119: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 120: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 121: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 122: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 123: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 124: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 125: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 126: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 127; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestCreateNewPinCredentialAndScheduleUser_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN credential and schedule user: Error: %@", err); + } else { + NSLog(@"Create new PIN credential and schedule user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; + + CHIP_ERROR TestGetNumberOfSupportedUsers_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get number of supported users: Error: %@", err); + } else { + NSLog(@"Get number of supported users: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NumberOfTotalUsersSupported", actualValue, 10U)); + } + { + NumberOfTotalUsersSupportedValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull NumberOfWeekDaySchedulesSupportedPerUserValue; + + CHIP_ERROR TestGetMaxNumberOfWeekDaySchedulesForUserAndVerifyDefaultValue_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Max number of Week Day schedules for user and verify default value: Error: %@", err); + } else { + NSLog(@"Get Max number of Week Day schedules for user and verify default value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NumberOfWeekDaySchedulesSupportedPerUser", actualValue, 10U)); + } + { + NumberOfWeekDaySchedulesSupportedPerUserValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull NumberOfYearDaySchedulesSupportedPerUserValue; + + CHIP_ERROR TestGetMaxNumberOfYearDaySchedulesForUserAndVerifyDefaultValue_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfYearDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Max number of Year Day schedules for user and verify default value: Error: %@", err); + } else { + NSLog(@"Get Max number of Year Day schedules for user and verify default value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NumberOfYearDaySchedulesSupportedPerUser", actualValue, 10U)); + } + { + NumberOfYearDaySchedulesSupportedPerUserValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull NumberOfHolidaySchedulesSupportedValue; + + CHIP_ERROR TestGetMaxNumberOfHolidaySchedulesAndVerifyDefaultValue_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfHolidaySchedulesSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Max number of Holiday schedules and verify default value: Error: %@", err); + } else { + NSLog(@"Get Max number of Holiday schedules and verify default value: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NumberOfHolidaySchedulesSupported", actualValue, 10U)); + } + { + NumberOfHolidaySchedulesSupportedValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWith0Index_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with 0 index: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with 0 index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWithOutOfBoundsIndex_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with out-of-bounds index: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with out-of-bounds index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWith0UserIndex_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with 0 user index: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with 0 user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWithOutOfBoundsUserIndex_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with out-of-bounds user index: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with out-of-bounds user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleForNonExistingUser_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule for non-existing user: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule for non-existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWith0DaysMask_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:0U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with 0 days mask: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with 0 days mask: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleForSundayAndMonday_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:3U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule for Sunday and Monday: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule for Sunday and Monday: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleForSundayWednesdayAndSaturday_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:73U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule for Sunday Wednesday and Saturday: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule for Sunday Wednesday and Saturday: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWithInvalidStartHour_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:24U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with invalid start hour: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with invalid start hour: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWithInvalidStartMinute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:60U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with invalid start minute: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with invalid start minute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWithInvalidEndHour_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:24U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with invalid end hour: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with invalid end hour: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWithInvalidEndMinute_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:60U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with invalid end minute: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with invalid end minute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWithStartHourLaterThatEndHour_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:19U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with start hour later that end hour: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with start hour later that end hour: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWithStartMinuteLaterThatEndMinuteWhenHoursAreEqual_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:50U]; + params.endHour = + [NSNumber numberWithUnsignedChar:15U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:49U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with start minute later that end minute when hours are equal: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with start minute later that end minute when hours are equal: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); + } else { + NSLog(@"Make sure that previous operations did not create a schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetWeekDayScheduleWith0Index_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Week Day schedule with 0 index: Error: %@", err); + } else { + NSLog(@"Get Week Day schedule with 0 index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetWeekDayScheduleWithOutOfBoundsIndex_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Week Day schedule with out-of-bounds index: Error: %@", err); + } else { + NSLog(@"Get Week Day schedule with out-of-bounds index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, [NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetWeekDayScheduleWith0UserIndex_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Week Day schedule with 0 user index: Error: %@", err); + } else { + NSLog(@"Get Week Day schedule with 0 user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 0U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetWeekDayScheduleWithOutOfBoundsUserIndex_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Week Day schedule with out-of-bounds user index: Error: %@", err); + } else { + NSLog(@"Get Week Day schedule with out-of-bounds user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, [NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetWeekDayScheduleWithNonExistingUserIndex_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Week Day schedule with non-existing user index: Error: %@", err); + } else { + NSLog(@"Get Week Day schedule with non-existing user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateYearDayScheduleWith0Index_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Year Day schedule with 0 index: Error: %@", err); + } else { + NSLog(@"Create Year Day schedule with 0 index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateYearDayScheduleWithOutOfBoundsIndex_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Year Day schedule with out-of-bounds index: Error: %@", err); + } else { + NSLog(@"Create Year Day schedule with out-of-bounds index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateYearDayScheduleWith0UserIndex_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Year Day schedule with 0 user index: Error: %@", err); + } else { + NSLog(@"Create Year Day schedule with 0 user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateYearDayScheduleWithOutOfBoundsUserIndex_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Year Day schedule with out-of-bounds user index: Error: %@", err); + } else { + NSLog(@"Create Year Day schedule with out-of-bounds user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateYearDayScheduleForNonExistingUser_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Year Day schedule for non-existing user: Error: %@", err); + } else { + NSLog(@"Create Year Day schedule for non-existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateYearDayScheduleWithStartHourLaterThatEndHour_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345688UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Year Day schedule with start hour later that end hour: Error: %@", err); + } else { + NSLog(@"Create Year Day schedule with start hour later that end hour: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); + } else { + NSLog(@"Make sure that previous operations did not create a schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetYearDayScheduleWith0Index_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Year Day schedule with 0 index: Error: %@", err); + } else { + NSLog(@"Get Year Day schedule with 0 index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetYearDayScheduleWithOutOfBoundsIndex_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Year Day schedule with out-of-bounds index: Error: %@", err); + } else { + NSLog(@"Get Year Day schedule with out-of-bounds index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, [NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetYearDayScheduleWith0UserIndex_35() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Year Day schedule with 0 user index: Error: %@", err); + } else { + NSLog(@"Get Year Day schedule with 0 user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 0U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetYearDayScheduleWithOutOfBoundsUserIndex_36() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Year Day schedule with out-of-bounds user index: Error: %@", err); + } else { + NSLog(@"Get Year Day schedule with out-of-bounds user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, [NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetYearDayScheduleWithNonExistingUserIndex_37() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Year Day schedule with non-existing user index: Error: %@", err); + } else { + NSLog(@"Get Year Day schedule with non-existing user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateHolidayScheduleWith0Index_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + params.operatingMode = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Holiday schedule with 0 index: Error: %@", err); + } else { + NSLog(@"Create Holiday schedule with 0 index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateHolidayScheduleWithOutOfBoundsIndex_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:[NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + params.operatingMode = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Holiday schedule with out-of-bounds index: Error: %@", err); + } else { + NSLog(@"Create Holiday schedule with out-of-bounds index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateHolidayScheduleWithStartHourLaterThatEndHour_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345688UL]; + params.operatingMode = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Holiday schedule with start hour later that end hour: Error: %@", err); + } else { + NSLog(@"Create Holiday schedule with start hour later that end hour: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateHolidayScheduleWithInvalidOperatingMode_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + params.operatingMode = + [NSNumber numberWithUnsignedChar:5U]; + [cluster setHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Holiday schedule with invalid operating mode: Error: %@", err); + } else { + NSLog(@"Create Holiday schedule with invalid operating mode: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatPreviousOperationsDidNotCreateASchedule_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that previous operations did not create a schedule: Error: %@", err); + } else { + NSLog(@"Make sure that previous operations did not create a schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetHolidayScheduleWith0Index_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:0U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Holiday schedule with 0 index: Error: %@", err); + } else { + NSLog(@"Get Holiday schedule with 0 index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 0U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetHolidayScheduleWithOutOfBoundsIndex_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:[NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Holiday schedule with out-of-bounds index: Error: %@", err); + } else { + NSLog(@"Get Holiday schedule with out-of-bounds index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, [NumberOfHolidaySchedulesSupportedValue unsignedCharValue] + 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateHolidayScheduleWithValidParameters_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + params.operatingMode = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Holiday schedule with valid parameters: Error: %@", err); + } else { + NSLog(@"Create Holiday schedule with valid parameters: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedSchedule_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created schedule: Error: %@", err); + } else { + NSLog(@"Verify created schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWithValidParameters_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:16U]; + params.endHour = + [NSNumber numberWithUnsignedChar:18U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with valid parameters: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with valid parameters: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedSchedule_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created schedule: Error: %@", err); + } else { + NSLog(@"Verify created schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); + } + + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); + } + + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); + } + + { + id actualValue = values.endHour; + VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); + } + + { + id actualValue = values.endMinute; + VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateYearDayScheduleWithValidParameters_49() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:12345UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:12345689UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Year Day schedule with valid parameters: Error: %@", err); + } else { + NSLog(@"Create Year Day schedule with valid parameters: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedSchedule_50() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created schedule: Error: %@", err); + } else { + NSLog(@"Verify created schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearWeekDayScheduleWith0Index_51() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Week Day schedule with 0 index: Error: %@", err); + } else { + NSLog(@"Clear Week Day schedule with 0 index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearWeekDayScheduleWithOutOfBoundsIndex_52() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:[NumberOfWeekDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Week Day schedule with out-of-bounds index: Error: %@", err); + } else { + NSLog(@"Clear Week Day schedule with out-of-bounds index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearWeekDayScheduleWith0UserIndex_53() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + [cluster clearWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Week Day schedule with 0 user index: Error: %@", err); + } else { + NSLog(@"Clear Week Day schedule with 0 user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearWeekDayScheduleWithOutOfBoundsUserIndex_54() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; + [cluster clearWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Week Day schedule with out-of-bounds user index: Error: %@", err); + } else { + NSLog(@"Clear Week Day schedule with out-of-bounds user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearWeekDayScheduleWithNonExistingUser_55() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster clearWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Week Day schedule with non-existing user: Error: %@", err); + } else { + NSLog(@"Clear Week Day schedule with non-existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_56() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that week day schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); + } + + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); + } + + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); + } + + { + id actualValue = values.endHour; + VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); + } + + { + id actualValue = values.endMinute; + VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_57() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that year day schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_58() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that holiday schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearYearDayScheduleWith0Index_59() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Year Day schedule with 0 index: Error: %@", err); + } else { + NSLog(@"Clear Year Day schedule with 0 index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearYearDayScheduleWithOutOfBoundsIndex_60() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Year Day schedule with out-of-bounds index: Error: %@", err); + } else { + NSLog(@"Clear Year Day schedule with out-of-bounds index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearYearDayScheduleWith0UserIndex_61() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + [cluster clearYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Year Day schedule with 0 user index: Error: %@", err); + } else { + NSLog(@"Clear Year Day schedule with 0 user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearYearDayScheduleWithOutOfBoundsUserIndex_62() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:[NumberOfTotalUsersSupportedValue unsignedShortValue] + 1U]; + [cluster clearYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Year Day schedule with out-of-bounds user index: Error: %@", err); + } else { + NSLog(@"Clear Year Day schedule with out-of-bounds user index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearYearDayScheduleWithNonExistingUser_63() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster clearYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Year Day schedule with non-existing user: Error: %@", err); + } else { + NSLog(@"Clear Year Day schedule with non-existing user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_64() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that week day schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); + } + + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); + } + + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); + } + + { + id actualValue = values.endHour; + VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); + } + + { + id actualValue = values.endMinute; + VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_65() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that year day schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_66() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that holiday schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearHolidayScheduleWith0Index_67() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:0U]; + [cluster clearHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Holiday schedule with 0 index: Error: %@", err); + } else { + NSLog(@"Clear Holiday schedule with 0 index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearHolidayScheduleWithOutOfBoundsIndex_68() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:[NumberOfYearDaySchedulesSupportedPerUserValue unsignedCharValue] + 1U]; + [cluster clearHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear Holiday schedule with out-of-bounds index: Error: %@", err); + } else { + NSLog(@"Clear Holiday schedule with out-of-bounds index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatWeekDayScheduleWasNotDeleted_69() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that week day schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that week day schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); + } + + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); + } + + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 16U)); + } + + { + id actualValue = values.endHour; + VerifyOrReturn(CheckValue("EndHour", actualValue, 18U)); + } + + { + id actualValue = values.endMinute; + VerifyOrReturn(CheckValue("EndMinute", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatYearDayScheduleWasNotDeleted_70() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that year day schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that year day schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatHolidayScheduleWasNotDeleted_71() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that holiday schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that holiday schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateAnotherWeekDayScheduleWithValidParameters_72() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:2U]; + params.startHour = + [NSNumber numberWithUnsignedChar:0U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:0U]; + params.endHour = + [NSNumber numberWithUnsignedChar:23U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:59U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create another Week Day schedule with valid parameters: Error: %@", err); + } else { + NSLog(@"Create another Week Day schedule with valid parameters: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedWeekDaySchedule_73() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created week day schedule: Error: %@", err); + } else { + NSLog(@"Verify created week day schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 2U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); + } + + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); + } + + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); + } + + { + id actualValue = values.endHour; + VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); + } + + { + id actualValue = values.endMinute; + VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateAnotherYearDayScheduleWithValidParameters_74() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:9000UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:888888888UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create another Year Day schedule with valid parameters: Error: %@", err); + } else { + NSLog(@"Create another Year Day schedule with valid parameters: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedYearDaySchedule_75() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created year day schedule: Error: %@", err); + } else { + NSLog(@"Verify created year day schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateAnotherHolidayScheduleWithValidParameters_76() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:2U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:123456UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:1234567UL]; + params.operatingMode = + [NSNumber numberWithUnsignedChar:1U]; + [cluster setHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create another Holiday schedule with valid parameters: Error: %@", err); + } else { + NSLog(@"Create another Holiday schedule with valid parameters: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedHolidaySchedule_77() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:2U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created holiday schedule: Error: %@", err); + } else { + NSLog(@"Verify created holiday schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearASingleWeekDayScheduleForTheFirstUser_78() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear a single week day schedule for the first user: Error: %@", err); + } else { + NSLog(@"Clear a single week day schedule for the first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyClearedWeekDaySchedule_79() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify cleared week day schedule: Error: %@", err); + } else { + NSLog(@"Verify cleared week day schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearAllRemainingWeekDaySchedulesForTheFirstUser_80() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:254U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear all remaining week day schedules for the first user: Error: %@", err); + } else { + NSLog(@"Clear all remaining week day schedules for the first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyClearedWeekSchedule_81() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify cleared week schedule: Error: %@", err); + } else { + NSLog(@"Verify cleared week schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 2U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatFirstYearDayScheduleWasNotDeleted_82() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that first year day schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that first year day schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatSecondYearDayScheduleWasNotDeleted_83() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that second year day schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that second year day schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_84() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that first holiday schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasNotDeleted_85() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:2U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that second holiday schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that second holiday schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateAnotherWeekDayScheduleWithValidParameters_86() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:2U]; + params.startHour = + [NSNumber numberWithUnsignedChar:0U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:0U]; + params.endHour = + [NSNumber numberWithUnsignedChar:23U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:59U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create another Week Day schedule with valid parameters: Error: %@", err); + } else { + NSLog(@"Create another Week Day schedule with valid parameters: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearASingleYearDayScheduleForTheFirstUser_87() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear a single year day schedule for the first user: Error: %@", err); + } else { + NSLog(@"Clear a single year day schedule for the first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyClearedYearDaySchedule_88() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify cleared year day schedule: Error: %@", err); + } else { + NSLog(@"Verify cleared year day schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearAllRemainingYearSchedulesForTheFirstUser_89() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:254U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear all remaining year schedules for the first user: Error: %@", err); + } else { + NSLog(@"Clear all remaining year schedules for the first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyThatSecondYearDayScheduleWasCleared_90() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify that second year day schedule was cleared: Error: %@", err); + } else { + NSLog(@"Verify that second year day schedule was cleared: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 2U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedWeekDaySchedule_91() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created week day schedule: Error: %@", err); + } else { + NSLog(@"Verify created week day schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); + } + + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); + } + + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); + } + + { + id actualValue = values.endHour; + VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); + } + + { + id actualValue = values.endMinute; + VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearAllRemainingWeekDaySchedulesForTheFirstUser_92() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:254U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear all remaining week day schedules for the first user: Error: %@", err); + } else { + NSLog(@"Clear all remaining week day schedules for the first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewUserWithoutCredentialSoWeCanAddMoreSchedulesToIt_93() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new user without credential so we can add more schedules to it: Error: %@", err); + } else { + NSLog(@"Create new user without credential so we can add more schedules to it: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWithValidParametersForFirstUser_94() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:0U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:0U]; + params.endHour = + [NSNumber numberWithUnsignedChar:23U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:59U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with valid parameters for first user: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with valid parameters for first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedWeekDayScheduleForFirstUser_95() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created week day schedule for first user: Error: %@", err); + } else { + NSLog(@"Verify created week day schedule for first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); + } + + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); + } + + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); + } + + { + id actualValue = values.endHour; + VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); + } + + { + id actualValue = values.endMinute; + VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateYearDayScheduleForFirstUser_96() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:4U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:9000UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:888888888UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Year Day schedule for first user: Error: %@", err); + } else { + NSLog(@"Create Year Day schedule for first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedYearDayScheduleForFirst_97() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:4U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created year day schedule for first: Error: %@", err); + } else { + NSLog(@"Verify created year day schedule for first: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 4U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleWithValidParametersForSecondUser_98() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:4U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:64U]; + params.startHour = + [NSNumber numberWithUnsignedChar:23U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:0U]; + params.endHour = + [NSNumber numberWithUnsignedChar:23U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:59U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule with valid parameters for second user: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule with valid parameters for second user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedWeekDayScheduleForFirstUser_99() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:4U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created week day schedule for first user: Error: %@", err); + } else { + NSLog(@"Verify created week day schedule for first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 4U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 64U)); + } + + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 23U)); + } + + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); + } + + { + id actualValue = values.endHour; + VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); + } + + { + id actualValue = values.endMinute; + VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateYearDayScheduleForSecondUser_100() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:55555UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:7777777UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Year Day schedule for second user: Error: %@", err); + } else { + NSLog(@"Create Year Day schedule for second user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedYearDayScheduleForFirst_101() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created year day schedule for first: Error: %@", err); + } else { + NSLog(@"Verify created year day schedule for first: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 55555UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 7777777UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCleanupTheUser_102() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:65534U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Cleanup the user: Error: %@", err); + } else { + NSLog(@"Cleanup the user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureClearingFirstUserAlsoClearedWeekDaySchedules_103() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure clearing first user also cleared week day schedules: Error: %@", err); + } else { + NSLog(@"Make sure clearing first user also cleared week day schedules: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureClearingFirstUserAlsoClearedYearDaySchedules_104() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:4U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure clearing first user also cleared year day schedules: Error: %@", err); + } else { + NSLog(@"Make sure clearing first user also cleared year day schedules: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 4U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureClearingSecondUserAlsoClearedWeekDaySchedules_105() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:4U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure clearing second user also cleared week day schedules: Error: %@", err); + } else { + NSLog(@"Make sure clearing second user also cleared week day schedules: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 4U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureClearingSecondUserAlsoClearedYearDaySchedules_106() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure clearing second user also cleared year day schedules: Error: %@", err); + } else { + NSLog(@"Make sure clearing second user also cleared year day schedules: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_107() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that first holiday schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasNotDeleted_108() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:2U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that second holiday schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that second holiday schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 123456UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1234567UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateAnotherHolidayScheduleAtTheLastSlot_109() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NumberOfHolidaySchedulesSupportedValue copy]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:1UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:100UL]; + params.operatingMode = + [NSNumber numberWithUnsignedChar:4U]; + [cluster setHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create another Holiday schedule at the last slot: Error: %@", err); + } else { + NSLog(@"Create another Holiday schedule at the last slot: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedHolidaySchedule_110() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NumberOfHolidaySchedulesSupportedValue copy]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify Created Holiday Schedule: Error: %@", err); + } else { + NSLog(@"Verify Created Holiday Schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 100UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinCredentialAndScheduleUser_111() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = nil; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN credential and schedule user: Error: %@", err); + } else { + NSLog(@"Create new PIN credential and schedule user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateWeekDayScheduleForFirstUser_112() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:1U]; + params.startHour = + [NSNumber numberWithUnsignedChar:0U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:0U]; + params.endHour = + [NSNumber numberWithUnsignedChar:23U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:59U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Week Day schedule for first user: Error: %@", err); + } else { + NSLog(@"Create Week Day schedule for first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateYearDayScheduleForFirstUser_113() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:9000UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:888888888UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create Year Day schedule for first user: Error: %@", err); + } else { + NSLog(@"Create Year Day schedule for first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearASingleHolidaySchedule_114() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:2U]; + [cluster clearHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear a single holiday schedule: Error: %@", err); + } else { + NSLog(@"Clear a single holiday schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatFirstHolidayScheduleWasNotDeleted_115() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that first holiday schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that first holiday schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 12345UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 12345689UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasDeleted_116() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:2U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that second holiday schedule was deleted: Error: %@", err); + } else { + NSLog(@"Make sure that second holiday schedule was deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatThirdHolidayScheduleWasNotDeleted_117() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NumberOfHolidaySchedulesSupportedValue copy]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that third holiday schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that third holiday schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 100UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 4U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_118() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Error: %@", err); + } else { + NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); + } + + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); + } + + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); + } + + { + id actualValue = values.endHour; + VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); + } + + { + id actualValue = values.endMinute; + VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_119() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Error: %@", err); + } else { + NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearAllRemainingHolidaySchedules_120() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:254U]; + [cluster clearHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear all remaining holiday schedules: Error: %@", err); + } else { + NSLog(@"Clear all remaining holiday schedules: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatFirstHolidayIsStillDeleted_121() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that first holiday is still deleted: Error: %@", err); + } else { + NSLog(@"Make sure that first holiday is still deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatSecondHolidayScheduleWasDeleted_122() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:2U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that second holiday schedule was deleted: Error: %@", err); + } else { + NSLog(@"Make sure that second holiday schedule was deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureThatThirdHolidayScheduleWasNotDeleted_123() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NumberOfHolidaySchedulesSupportedValue copy]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure that third holiday schedule was not deleted: Error: %@", err); + } else { + NSLog(@"Make sure that third holiday schedule was not deleted: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, NumberOfHolidaySchedulesSupportedValue)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearWeekDaySchedule_124() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Error: %@", err); + } else { + NSLog(@"Make sure clearing holiday schedule did not clear week day schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 1U)); + } + + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 0U)); + } + + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 0U)); + } + + { + id actualValue = values.endHour; + VerifyOrReturn(CheckValue("EndHour", actualValue, 23U)); + } + + { + id actualValue = values.endMinute; + VerifyOrReturn(CheckValue("EndMinute", actualValue, 59U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestMakeSureClearingHolidayScheduleDidNotClearYearDaySchedule_125() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Error: %@", err); + } else { + NSLog(@"Make sure clearing holiday schedule did not clear year day schedule: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 9000UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 888888888UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestFinalCleanup_126() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:65534U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Final Cleanup: Error: %@", err); + } else { + NSLog(@"Final Cleanup: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DRLK_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DRLK_1_1() + : TestCommandBridge("Test_TC_DRLK_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DRLK_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision from DUT\n"); + err = TestStep2ThReadsTheClusterRevisionFromDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads the FeatureMap from DUT\n"); + if (ShouldSkip(" !DRLK.S.F00 && !DRLK.S.F01 && !DRLK.S.F02 && !DRLK.S.F04 && !DRLK.S.F05 && !DRLK.S.F06 && !DRLK.S.F07 && !DRLK.S.F08 && !DRLK.S.F0a && !DRLK.S.F0b && !DRLK.S.F0c ")) { + NextTest(); + return; + } + err = TestStep3aThReadsTheFeatureMapFromDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DRLK.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenDrlksf00pinEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DRLK.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenDrlksf01ridEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DRLK.S.F02")) { + NextTest(); + return; + } + err = TestStep3dGivenDrlksf02fgpEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DRLK.S.F04")) { + NextTest(); + return; + } + err = TestStep3eGivenDrlksf04wdschEnsureFeaturemapHasTheCorrectBitSet_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DRLK.S.F05")) { + NextTest(); + return; + } + err = TestStep3fGivenDrlksf05dpsEnsureFeaturemapHasTheCorrectBitSet_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DRLK.S.F06")) { + NextTest(); + return; + } + err = TestStep3gGivenDrlksf06faceEnsureFeaturemapHasTheCorrectBitSet_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DRLK.S.F07")) { + NextTest(); + return; + } + err = TestStep3hGivenDrlksf07cotaEnsureFeaturemapHasTheCorrectBitSet_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DRLK.S.F08")) { + NextTest(); + return; + } + err = TestStep3iGivenDrlksf08usrEnsureFeaturemapHasTheCorrectBitSet_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DRLK.S.F0a")) { + NextTest(); + return; + } + err = TestStep3jGivenDRLKSF0aYDSCHEnsureFeaturemapHasTheCorrectBitSet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DRLK.S.F0b")) { + NextTest(); + return; + } + err = TestStep3kGivenDRLKSF0bHDSCHEnsureFeaturemapHasTheCorrectBitSet_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("DRLK.S.F0c")) { + NextTest(); + return; + } + err = TestStep3lGivenDRLKSF0cUBOLTEnsureFeaturemapHasTheCorrectBitSet_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4a: TH reads AttributeList from DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsAttributeListFromDut_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList\n"); + if (ShouldSkip("DRLK.S.F05")) { + NextTest(); + return; + } + err = TestStep4bThReadsFeatureDependentDRLKSF05AttributesInAttributeList_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList\n"); + if (ShouldSkip("DRLK.S.F08")) { + NextTest(); + return; + } + err = TestStep4cThReadsFeatureDependentDRLKSF08AttributesInAttributeList_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList\n"); + if (ShouldSkip("DRLK.S.F00")) { + NextTest(); + return; + } + err = TestStep4dThReadsFeatureDependentDRLKSF00AttributesInAttributeList_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList\n"); + if (ShouldSkip("DRLK.S.F01")) { + NextTest(); + return; + } + err = TestStep4eThReadsFeatureDependentDRLKSF01AttributesInAttributeList_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList\n"); + if (ShouldSkip("DRLK.S.F04")) { + NextTest(); + return; + } + err = TestStep4fThReadsFeatureDependentDRLKSF04AttributeInAttributeList_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList\n"); + if (ShouldSkip("DRLK.S.F0a")) { + NextTest(); + return; + } + err = TestStep4gThReadsFeatureDependentDRLKSF0aAttributeInAttributeList_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList\n"); + if (ShouldSkip("DRLK.S.F0b")) { + NextTest(); + return; + } + err = TestStep4hThReadsFeatureDependentDRLKSF0bAttributeInAttributeList_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList\n"); + if (ShouldSkip("DRLK.S.F00 || DRLK.S.F01")) { + NextTest(); + return; + } + err = TestStep4iThReadsFeatureDependentDRLKSF00OrDrlksf01AttributesInAttributeList_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList\n"); + if (ShouldSkip("DRLK.S.F07 || DRLK.S.F00")) { + NextTest(); + return; + } + err = TestStep4jThReadsFeatureDependentDRLKSF07OrDrlksf00AttributeInAttributeList_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 4k: TH reads optional attribute(Language) in AttributeList\n"); + if (ShouldSkip("DRLK.S.A0021")) { + NextTest(); + return; + } + err = TestStep4kThReadsOptionalAttributeLanguageInAttributeList_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 4l: TH reads optional attribute(LEDSettings) in AttributeList\n"); + if (ShouldSkip("DRLK.S.A0022")) { + NextTest(); + return; + } + err = TestStep4lThReadsOptionalAttributeLEDSettingsInAttributeList_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList\n"); + if (ShouldSkip("DRLK.S.A0023")) { + NextTest(); + return; + } + err = TestStep4mThReadsOptionalAttributeAutoRelockTimeInAttributeList_27(); + break; + case 28: + ChipLogProgress(chipTool, " ***** Test Step 28 : Step 4n: TH reads optional attribute(SoundVolume) in AttributeList\n"); + if (ShouldSkip("DRLK.S.A0024")) { + NextTest(); + return; + } + err = TestStep4nThReadsOptionalAttributeSoundVolumeInAttributeList_28(); + break; + case 29: + ChipLogProgress(chipTool, " ***** Test Step 29 : Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList\n"); + if (ShouldSkip("DRLK.S.A0027")) { + NextTest(); + return; + } + err = TestStep4oThReadsOptionalAttributeDefaultConfigurationRegisterInAttributeList_29(); + break; + case 30: + ChipLogProgress(chipTool, " ***** Test Step 30 : Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList\n"); + if (ShouldSkip("DRLK.S.A0028")) { + NextTest(); + return; + } + err = TestStep4pThReadsOptionalAttributeEnableLocalProgrammingInAttributeList_30(); + break; + case 31: + ChipLogProgress(chipTool, " ***** Test Step 31 : Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList\n"); + if (ShouldSkip("DRLK.S.A0029")) { + NextTest(); + return; + } + err = TestStep4qThReadsOptionalAttributeEnableOneTouchLockingInAttributeList_31(); + break; + case 32: + ChipLogProgress(chipTool, " ***** Test Step 32 : Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList\n"); + if (ShouldSkip("DRLK.S.A002a")) { + NextTest(); + return; + } + err = TestStep4rThReadsOptionalAttributeEnableInsideStatusLEDInAttributeList_32(); + break; + case 33: + ChipLogProgress(chipTool, " ***** Test Step 33 : Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList\n"); + if (ShouldSkip("DRLK.S.A002b")) { + NextTest(); + return; + } + err = TestStep4sThReadsOptionalAttributeEnablePrivacyModeButtonInAttributeList_33(); + break; + case 34: + ChipLogProgress(chipTool, " ***** Test Step 34 : Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList\n"); + if (ShouldSkip("DRLK.S.A002c")) { + NextTest(); + return; + } + err = TestStep4tThReadsOptionalAttributeLocalProgrammingFeaturesInAttributeList_34(); + break; + case 35: + ChipLogProgress(chipTool, " ***** Test Step 35 : Step 5a: TH reads EventList from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 36: + ChipLogProgress(chipTool, " ***** Test Step 36 : Step 5b: TH reads optional event(Door position sensor) in EventList\n"); + if (ShouldSkip("DRLK.S.F05 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 37: + ChipLogProgress(chipTool, " ***** Test Step 37 : Step 5c: TH reads optional event(User commands and database) in EventList\n"); + if (ShouldSkip("DRLK.S.F08 && PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 38: + ChipLogProgress(chipTool, " ***** Test Step 38 : Step 6a: TH reads AcceptedCommandList from DUT\n"); + err = TestStep6aThReadsAcceptedCommandListFromDut_38(); + break; + case 39: + ChipLogProgress(chipTool, " ***** Test Step 39 : Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList\n"); + if (ShouldSkip("DRLK.S.F04")) { + NextTest(); + return; + } + err = TestStep6bThReadsFeatureDependentCommandsDRLKSF04InAcceptedCommandList_39(); + break; + case 40: + ChipLogProgress(chipTool, " ***** Test Step 40 : Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList\n"); + if (ShouldSkip("DRLK.S.F0a")) { + NextTest(); + return; + } + err = TestStep6cThReadsFeatureDependentCommandsDRLKSF0aInAcceptedCommandList_40(); + break; + case 41: + ChipLogProgress(chipTool, " ***** Test Step 41 : Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList\n"); + if (ShouldSkip("DRLK.S.F0b")) { + NextTest(); + return; + } + err = TestStep6dThReadsFeatureDependentCommandsDRLKSF0bInAcceptedCommandList_41(); + break; + case 42: + ChipLogProgress(chipTool, " ***** Test Step 42 : Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList\n"); + if (ShouldSkip("DRLK.S.F0c")) { + NextTest(); + return; + } + err = TestStep6eThReadsFeatureDependentCommandsDRLKSF0cInAcceptedCommandList_42(); + break; + case 43: + ChipLogProgress(chipTool, " ***** Test Step 43 : Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList\n"); + if (ShouldSkip("DRLK.S.F08")) { + NextTest(); + return; + } + err = TestStep6fThReadsFeatureDependentCommandsDRLKSF08InAcceptedCommandList_43(); + break; + case 44: + ChipLogProgress(chipTool, " ***** Test Step 44 : Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList\n"); + if (ShouldSkip("DRLK.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep6gThReadsOptionalCommandsDRLKSC03RspInAcceptedCommandList_44(); + break; + case 45: + ChipLogProgress(chipTool, " ***** Test Step 45 : Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList\n"); + if (ShouldSkip("DRLK.S.F04")) { + NextTest(); + return; + } + err = TestStep7aThReadsFeatureDependentCommandDRLKSF04InGeneratedCommandList_45(); + break; + case 46: + ChipLogProgress(chipTool, " ***** Test Step 46 : Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList\n"); + if (ShouldSkip("DRLK.S.F0a")) { + NextTest(); + return; + } + err = TestStep7bThReadsFeatureDependentCommandDRLKSF0aInGeneratedCommandList_46(); + break; + case 47: + ChipLogProgress(chipTool, " ***** Test Step 47 : Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList\n"); + if (ShouldSkip("DRLK.S.F0b")) { + NextTest(); + return; + } + err = TestStep7cThReadsFeatureDependentCommandDRLKSF0bInGeneratedCommandList_47(); + break; + case 48: + ChipLogProgress(chipTool, " ***** Test Step 48 : Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList\n"); + if (ShouldSkip("DRLK.S.F08")) { + NextTest(); + return; + } + err = TestStep7dThReadsFeatureDependentCommandDRLKSF08InGeneratedCommandList_48(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 28: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 29: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 30: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 31: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 32: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 33: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 34: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 35: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 36: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 37: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 38: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 39: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 40: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 41: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 42: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 43: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 44: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 45: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 46: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 47: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 48: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 49; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionFromDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 7U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsTheFeatureMapFromDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads the FeatureMap from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenDrlksf00pinEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given DRLK.S.F00(PIN) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenDrlksf01ridEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given DRLK.S.F01(RID) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenDrlksf02fgpEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given DRLK.S.F02(FGP) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3eGivenDrlksf04wdschEnsureFeaturemapHasTheCorrectBitSet_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3e: Given DRLK.S.F04(WDSCH) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3fGivenDrlksf05dpsEnsureFeaturemapHasTheCorrectBitSet_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3f: Given DRLK.S.F05(DPS) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3gGivenDrlksf06faceEnsureFeaturemapHasTheCorrectBitSet_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3g: Given DRLK.S.F06(FACE) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3hGivenDrlksf07cotaEnsureFeaturemapHasTheCorrectBitSet_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3h: Given DRLK.S.F07(COTA) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3iGivenDrlksf08usrEnsureFeaturemapHasTheCorrectBitSet_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3i: Given DRLK.S.F08(USR) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3jGivenDRLKSF0aYDSCHEnsureFeaturemapHasTheCorrectBitSet_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3j: Given DRLK.S.F0a(YDSCH) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3kGivenDRLKSF0bHDSCHEnsureFeaturemapHasTheCorrectBitSet_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3k: Given DRLK.S.F0b(HDSCH) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3lGivenDRLKSF0cUBOLTEnsureFeaturemapHasTheCorrectBitSet_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3l: Given DRLK.S.F0c(UBOLT) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsAttributeListFromDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads AttributeList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 37UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 38UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFeatureDependentDRLKSF05AttributesInAttributeList_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads Feature dependent(DRLK.S.F05) attributes in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsFeatureDependentDRLKSF08AttributesInAttributeList_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads Feature dependent(DRLK.S.F08) attributes in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 17UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 27UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 28UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsFeatureDependentDRLKSF00AttributesInAttributeList_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads Feature dependent(DRLK.S.F00) attributes in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 18UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 23UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 24UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsFeatureDependentDRLKSF01AttributesInAttributeList_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads Feature dependent(DRLK.S.F01) attributes in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 19UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 25UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 26UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThReadsFeatureDependentDRLKSF04AttributeInAttributeList_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4f: TH reads Feature dependent(DRLK.S.F04) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 20UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4gThReadsFeatureDependentDRLKSF0aAttributeInAttributeList_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4g: TH reads Feature dependent(DRLK.S.F0a) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 21UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4hThReadsFeatureDependentDRLKSF0bAttributeInAttributeList_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4h: TH reads Feature dependent(DRLK.S.F0b) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 22UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4iThReadsFeatureDependentDRLKSF00OrDrlksf01AttributesInAttributeList_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4i: TH reads Feature dependent(DRLK.S.F00 or DRLK.S.F01) attributes in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 48UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 49UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4jThReadsFeatureDependentDRLKSF07OrDrlksf00AttributeInAttributeList_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4j: TH reads Feature dependent(DRLK.S.F07 or DRLK.S.F00) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 51UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4kThReadsOptionalAttributeLanguageInAttributeList_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4k: TH reads optional attribute(Language) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4k: TH reads optional attribute(Language) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 33UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4lThReadsOptionalAttributeLEDSettingsInAttributeList_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4l: TH reads optional attribute(LEDSettings) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4l: TH reads optional attribute(LEDSettings) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 34UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4mThReadsOptionalAttributeAutoRelockTimeInAttributeList_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4m: TH reads optional attribute(AutoRelockTime) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 35UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4nThReadsOptionalAttributeSoundVolumeInAttributeList_28() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4n: TH reads optional attribute(SoundVolume) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4n: TH reads optional attribute(SoundVolume) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 36UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4oThReadsOptionalAttributeDefaultConfigurationRegisterInAttributeList_29() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4o: TH reads optional attribute(DefaultConfigurationRegister) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 39UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4pThReadsOptionalAttributeEnableLocalProgrammingInAttributeList_30() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4p: TH reads optional attribute(EnableLocalProgramming) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 40UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4qThReadsOptionalAttributeEnableOneTouchLockingInAttributeList_31() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4q: TH reads optional attribute(EnableOneTouchLocking) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 41UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4rThReadsOptionalAttributeEnableInsideStatusLEDInAttributeList_32() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4r: TH reads optional attribute(EnableInsideStatusLED) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 42UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4sThReadsOptionalAttributeEnablePrivacyModeButtonInAttributeList_33() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4s: TH reads optional attribute(EnablePrivacyModeButton) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 43UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4tThReadsOptionalAttributeLocalProgrammingFeaturesInAttributeList_34() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4t: TH reads optional attribute(LocalProgrammingFeatures) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 44UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsAcceptedCommandListFromDut_38() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads AcceptedCommandList from DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsFeatureDependentCommandsDRLKSF04InAcceptedCommandList_39() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads Feature dependent commands(DRLK.S.F04) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 11UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 12UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 13UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cThReadsFeatureDependentCommandsDRLKSF0aInAcceptedCommandList_40() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6c: TH reads Feature dependent commands(DRLK.S.F0a) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 14UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 15UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 16UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6dThReadsFeatureDependentCommandsDRLKSF0bInAcceptedCommandList_41() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6d: TH reads Feature dependent commands(DRLK.S.F0b) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 17UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 18UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 19UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6eThReadsFeatureDependentCommandsDRLKSF0cInAcceptedCommandList_42() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6e: TH reads Feature dependent commands(DRLK.S.F0c) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 39UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6fThReadsFeatureDependentCommandsDRLKSF08InAcceptedCommandList_43() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6f: TH reads Feature dependent commands(DRLK.S.F08) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 26UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 27UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 29UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 34UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 36UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 38UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6gThReadsOptionalCommandsDRLKSC03RspInAcceptedCommandList_44() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6g: TH reads optional commands(DRLK.S.C03.Rsp) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7aThReadsFeatureDependentCommandDRLKSF04InGeneratedCommandList_45() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7a: TH reads Feature dependent command(DRLK.S.F04) in GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 12UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7bThReadsFeatureDependentCommandDRLKSF0aInGeneratedCommandList_46() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7b: TH reads Feature dependent command(DRLK.S.F0a) in GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 15UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7cThReadsFeatureDependentCommandDRLKSF0bInGeneratedCommandList_47() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7c: TH reads Feature dependent command(DRLK.S.F0b) in GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 18UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7dThReadsFeatureDependentCommandDRLKSF08InGeneratedCommandList_48() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7d: TH reads Feature dependent command(DRLK.S.F08) in GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 28UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 35UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 37UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DRLK_2_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DRLK_2_4() + : TestCommandBridge("Test_TC_DRLK_2_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DRLK_2_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Create new user\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { + NextTest(); + return; + } + err = TestCreateNewUser_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read the user back and verify its fields\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { + NextTest(); + return; + } + err = TestReadTheUserBackAndVerifyItsFields_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Create new PIN credential and lock/unlock user\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { + NextTest(); + return; + } + err = TestCreateNewPinCredentialAndLockUnlockUser_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Verify created PIN credential\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { + NextTest(); + return; + } + err = TestVerifyCreatedPinCredential_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); + if (ShouldSkip("DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); + if (ShouldSkip("DRLK.S.M.AutoRelockTimeAttributeWritable && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY && !DRLK.S.M.AutoRelockTimeAttributeWritable")) { + NextTest(); + return; + } + err = TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && !DRLK.S.M.AutoRelockTimeAttributeWritable")) { + NextTest(); + return; + } + err = TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds\n"); + if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds\n"); + if (ShouldSkip(" DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP ")) { + NextTest(); + return; + } + err = TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds\n"); + if (ShouldSkip(" (!DRLK.S.F08 || !DRLK.S.F00) && DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP ")) { + NextTest(); + return; + } + err = TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Wait for AutoRelockTime Expires\n"); + if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestWaitForAutoRelockTimeExpires_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Wait for AutoRelockTime Expires\n"); + if (ShouldSkip("DRLK.S.C03.Rsp && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestWaitForAutoRelockTimeExpires_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 2c: TH reads LockState attribute\n"); + if (ShouldSkip("DRLK.S.A0000 && DRLK.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep2cThReadsLockStateAttribute_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Cleanup the created user\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { + NextTest(); + return; + } + err = TestCleanupTheCreatedUser_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Clean the created credential\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00 && DRLK.S.C26.Rsp")) { + NextTest(); + return; + } + err = TestCleanTheCreatedCredential_16(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 17; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestCreateNewUser_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = @"xxx"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:6452UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + params.credentialRule = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new user: Error: %@", err); + } else { + NSLog(@"Create new user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadTheUserBackAndVerifyItsFields_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read the user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Read the user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCreateNewPinCredentialAndLockUnlockUser_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = + [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Create new PIN credential and lock/unlock user: Error: %@", err); + } else { + NSLog(@"Create new PIN credential and lock/unlock user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestVerifyCreatedPinCredential_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Verify created PIN credential: Error: %@", err); + } else { + NSLog(@"Verify created PIN credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1aThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id autoRelockTimeArgument; + autoRelockTimeArgument = + [NSNumber numberWithUnsignedInt:10UL]; + [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Error: %@", err); + } else { + NSLog(@"Step 1a: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id autoRelockTimeArgument; + autoRelockTimeArgument = + [NSNumber numberWithUnsignedInt:60UL]; + [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Error: %@", err); + } else { + NSLog(@"Step 1b: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1cThWritesAutoRelockTimeAttributeValueAs10SecondsOnTheDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id autoRelockTimeArgument; + autoRelockTimeArgument = + [NSNumber numberWithUnsignedInt:10UL]; + [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Error: %@", err); + } else { + NSLog(@"Step 1c: TH writes AutoRelockTime attribute value as 10 seconds on the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1dThWritesAutoRelockTimeAttributeValueAs60SecondsOnTheDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id autoRelockTimeArgument; + autoRelockTimeArgument = + [NSNumber numberWithUnsignedInt:60UL]; + [cluster writeAttributeAutoRelockTimeWithValue:autoRelockTimeArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Error: %@", err); + } else { + NSLog(@"Step 1d: TH writes AutoRelockTime attribute value as 60 seconds on the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_UNSUPPORTED_WRITE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsTheUnlockWithTimeoutArgumentValueAs10Seconds_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; + params.timeout = + [NSNumber numberWithUnsignedShort:10U]; + params.pinCode = + [[NSData alloc] initWithBytes:"123456" length:6]; + [cluster unlockWithTimeoutWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends the Unlock with Timeout argument value as 10 seconds: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; + params.timeout = + [NSNumber numberWithUnsignedShort:60U]; + params.pinCode = + [[NSData alloc] initWithBytes:"123456" length:6]; + [cluster unlockWithTimeoutWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThSendsTheUnlockWithTimeoutArgumentValueAs60Seconds_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterUnlockWithTimeoutParams alloc] init]; + params.timeout = + [NSNumber numberWithUnsignedShort:60U]; + [cluster unlockWithTimeoutWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends the Unlock with Timeout argument value as 60 seconds: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitForAutoRelockTimeExpires_12() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 11000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestWaitForAutoRelockTimeExpires_13() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 70000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestStep2cThReadsLockStateAttribute_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLockStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH reads LockState attribute: Error: %@", err); + } else { + NSLog(@"Step 2c: TH reads LockState attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("LockState", actualValue)); + VerifyOrReturn(CheckValue("LockState", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCleanupTheCreatedUser_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Cleanup the created user: Error: %@", err); + } else { + NSLog(@"Cleanup the created user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCleanTheCreatedCredential_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clean the created credential: Error: %@", err); + } else { + NSLog(@"Clean the created credential: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DRLK_2_5 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DRLK_2_5() + : TestCommandBridge("Test_TC_DRLK_2_5") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DRLK_2_5() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_5\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_5\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); + err = TestPreconditionCreateNewUser_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); + err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.A0014")) { + NextTest(); + return; + } + err = TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { + NextTest(); + return; + } + err = TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH send Set Week Day Schedule Command\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThSendSetWeekDayScheduleCommand_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH send Get Week Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { + NextTest(); + return; + } + err = TestStep4ThSendGetWeekDayScheduleCommandToDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Week Day Schedule Command\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0b.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThSendSetWeekDayScheduleCommand_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH send Get Week Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { + NextTest(); + return; + } + err = TestStep6ThSendGetWeekDayScheduleCommandToDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7: TH sends Get Week Day Schedule Command to DUT for non-existent User\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { + NextTest(); + return; + } + err = TestStep7ThSendsGetWeekDayScheduleCommandToDutForNonExistentUser_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 8: TH sends Clear Week Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0d.Rsp")) { + NextTest(); + return; + } + err = TestStep8ThSendsClearWeekDayScheduleCommandToDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 9: TH sends Get Week Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F04 && DRLK.S.C0c.Rsp && DRLK.S.C0c.Tx")) { + NextTest(); + return; + } + err = TestStep9ThSendsGetWeekDayScheduleCommandToDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Cleanup the created user\n"); + err = TestCleanupTheCreatedUser_12(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 13; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionCreateNewUser_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = @"xxx"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:6452UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + params.credentialRule = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: Create new user: Error: %@", err); + } else { + NSLog(@"Precondition: Create new user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Precondition: Read the user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull NumberOfWeekDaySchedulesSupportedPerUserValue; + + CHIP_ERROR TestStep1ThReadsNumberOfWeekDaySchedulesSupportedPerUserAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfWeekDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads NumberOfWeekDay SchedulesSupportedPerUser attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfWeekDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); + { + NumberOfWeekDaySchedulesSupportedPerUserValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; + + CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); + { + NumberOfTotalUsersSupportedValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThSendSetWeekDayScheduleCommand_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:2U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:45U]; + params.endHour = + [NSNumber numberWithUnsignedChar:16U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:55U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH send Set Week Day Schedule Command: Error: %@", err); + } else { + NSLog(@"Step 3: TH send Set Week Day Schedule Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThSendGetWeekDayScheduleCommandToDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH send Get Week Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH send Get Week Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.daysMask; + VerifyOrReturn(CheckValue("DaysMask", actualValue, 2U)); + } + + { + id actualValue = values.startHour; + VerifyOrReturn(CheckValue("StartHour", actualValue, 15U)); + } + + { + id actualValue = values.startMinute; + VerifyOrReturn(CheckValue("StartMinute", actualValue, 45U)); + } + + VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, true)); + if (values.endHour != nil) { + + VerifyOrReturn(CheckConstraintMinValue("endHour", [values.endHour unsignedCharValue], 16U)); + } + + VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, true)); + if (values.endMinute != nil) { + + VerifyOrReturn(CheckConstraintMinValue("endMinute", [values.endMinute unsignedCharValue], 55U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThSendSetWeekDayScheduleCommand_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.daysMask = + [NSNumber numberWithUnsignedChar:7U]; + params.startHour = + [NSNumber numberWithUnsignedChar:15U]; + params.startMinute = + [NSNumber numberWithUnsignedChar:45U]; + params.endHour = + [NSNumber numberWithUnsignedChar:16U]; + params.endMinute = + [NSNumber numberWithUnsignedChar:55U]; + [cluster setWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH send Set Week Day Schedule Command: Error: %@", err); + } else { + NSLog(@"Step 5: TH send Set Week Day Schedule Command: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThSendGetWeekDayScheduleCommandToDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH send Get Week Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH send Get Week Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); + if (values.daysMask != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); + if (values.startHour != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); + if (values.startMinute != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); + if (values.endHour != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); + if (values.endMinute != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThSendsGetWeekDayScheduleCommandToDutForNonExistentUser_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH sends Get Week Day Schedule Command to DUT for non-existent User: Error: %@", err); + } else { + NSLog(@"Step 7: TH sends Get Week Day Schedule Command to DUT for non-existent User: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); + if (values.daysMask != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); + if (values.startHour != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); + if (values.startMinute != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); + if (values.endHour != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); + if (values.endMinute != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThSendsClearWeekDayScheduleCommandToDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearWeekDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH sends Clear Week Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 8: TH sends Clear Week Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThSendsGetWeekDayScheduleCommandToDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetWeekDayScheduleParams alloc] init]; + params.weekDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getWeekDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetWeekDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH sends Get Week Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 9: TH sends Get Week Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.weekDayIndex; + VerifyOrReturn(CheckValue("WeekDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + VerifyOrReturn(CheckConstraintHasValue("daysMask", values.daysMask, false)); + if (values.daysMask != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("startHour", values.startHour, false)); + if (values.startHour != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("startMinute", values.startMinute, false)); + if (values.startMinute != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("endHour", values.endHour, false)); + if (values.endHour != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("endMinute", values.endMinute, false)); + if (values.endMinute != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCleanupTheCreatedUser_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Cleanup the created user: Error: %@", err); + } else { + NSLog(@"Cleanup the created user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DRLK_2_6 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DRLK_2_6() + : TestCommandBridge("Test_TC_DRLK_2_6") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DRLK_2_6() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_6\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_6\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for commissionee\n"); + err = TestWaitForCommissionee_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.A0016")) { + NextTest(); + return; + } + err = TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C11.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20SecondsCLocalEndTimeAs30SecondsDOperatingModeAs0_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { + NextTest(); + return; + } + err = TestStep3aThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value)\n"); + if (ShouldSkip("DRLK.S.C11.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20CLocalEndTimeAs30DOperatingModeAs5InvalidValue_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { + NextTest(); + return; + } + err = TestStep5ThSendsGetHolidayScheduleCommandToDutWithInvalidHolidayIndexAs15_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available)\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { + NextTest(); + return; + } + err = TestStep6ThSendsGetHolidayScheduleCommandToDutWithTheHolidayIndexAs10ValueIsInTheTheRangeOfStep1ButHolidayScheduleEntryNotAvailable_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C13.Rsp")) { + NextTest(); + return; + } + err = TestStep7ThSendClearHolidayScheduleCommandToDutWithHolidayIndexAs1_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1\n"); + if (ShouldSkip("DRLK.S.F0b && DRLK.S.C12.Rsp && DRLK.S.C12.Tx")) { + NextTest(); + return; + } + err = TestStep8ThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Cleanup the created user\n"); + err = TestCleanupTheCreatedUser_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForCommissionee_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull NumberOfHolidaySchedulesSupportedValue; + + CHIP_ERROR TestStep1ThReadsNumberOfHolidaySchedulesSupportedAndSavesForFutureUse_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfHolidaySchedulesSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads NumberOfHoliday SchedulesSupported and saves for future use.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfHolidaySchedulesSupported", [value unsignedCharValue], 255U)); + { + NumberOfHolidaySchedulesSupportedValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20SecondsCLocalEndTimeAs30SecondsDOperatingModeAs0_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:20UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:30UL]; + params.operatingMode = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 Seconds c)LocalEndTime as 30 Seconds d)OperatingMode as 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 20UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 30UL)); + } + + if (values.localEndTime != nil) { + + VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 21UL)); + } + + { + id actualValue = values.operatingMode; + VerifyOrReturn(CheckValue("OperatingMode", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThSendsSetHolidayScheduleCommandToDutWithTheFollowingValuesAHolidayIndexAs1BLocalStartTimeAs20CLocalEndTimeAs30DOperatingModeAs5InvalidValue_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:20UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:30UL]; + params.operatingMode = + [NSNumber numberWithUnsignedChar:5U]; + [cluster setHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value): Error: %@", err); + } else { + NSLog(@"Step 4: TH sends Set Holiday Schedule Command to DUT with the following values: a)HolidayIndex as 1 b)LocalStartTime as 20 c)LocalEndTime as 30 d)OperatingMode as 5(Invalid value): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThSendsGetHolidayScheduleCommandToDutWithInvalidHolidayIndexAs15_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:15U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15: Error: %@", err); + } else { + NSLog(@"Step 5: TH sends Get Holiday Schedule Command to DUT with Invalid HolidayIndex as 15: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 15U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThSendsGetHolidayScheduleCommandToDutWithTheHolidayIndexAs10ValueIsInTheTheRangeOfStep1ButHolidayScheduleEntryNotAvailable_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:10U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available): Error: %@", err); + } else { + NSLog(@"Step 6: TH sends Get Holiday Schedule Command to DUT with the HolidayIndex as 10 (value is in the the range of step 1 but Holiday Schedule entry not available): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 10U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThSendClearHolidayScheduleCommandToDutWithHolidayIndexAs1_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster clearHolidayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); + } else { + NSLog(@"Step 7: TH send Clear Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThSendsGetHolidayScheduleCommandToDutWithHolidayIndexAs1_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetHolidayScheduleParams alloc] init]; + params.holidayIndex = + [NSNumber numberWithUnsignedChar:1U]; + [cluster getHolidayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetHolidayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Error: %@", err); + } else { + NSLog(@"Step 8: TH sends Get Holiday Schedule Command to DUT with HolidayIndex as 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.holidayIndex; + VerifyOrReturn(CheckValue("HolidayIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCleanupTheCreatedUser_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Cleanup the created user: Error: %@", err); + } else { + NSLog(@"Cleanup the created user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DRLK_2_7 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DRLK_2_7() + : TestCommandBridge("Test_TC_DRLK_2_7") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DRLK_2_7() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_7\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_7\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user\n"); + err = TestPreconditionCreateNewUser_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); + err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.A0015")) { + NextTest(); + return; + } + err = TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2: TH reads NumberOfTotalUsers Supported attribute\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { + NextTest(); + return; + } + err = TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3: TH sends Set Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0e.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThSendsSetYearDayScheduleCommandToDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { + NextTest(); + return; + } + err = TestStep4a4bThSendsGetYearDayScheduleCommandToDut_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5: TH send Set Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.C0e.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThSendSetYearDayScheduleCommandToDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6: TH sends Get Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { + NextTest(); + return; + } + err = TestStep6ThSendsGetYearDayScheduleCommandToDut_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 7a: Create a user with userIndex as 5\n"); + err = TestStep7aCreateAUserWithUserIndexAs5_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 7b: TH sends Get Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { + NextTest(); + return; + } + err = TestStep7bThSendsGetYearDayScheduleCommandToDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 8: TH sends Clear Year Day Schedule to DUT\n"); + if (ShouldSkip("DRLK.S.C10.Rsp")) { + NextTest(); + return; + } + err = TestStep8ThSendsClearYearDayScheduleToDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 9: TH sends Get Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx && DRLK.S.C10.Rsp")) { + NextTest(); + return; + } + err = TestStep9ThSendsGetYearDayScheduleCommandToDut_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 10: TH sends Set Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.C0e.Rsp")) { + NextTest(); + return; + } + err = TestStep10ThSendsSetYearDayScheduleCommandToDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 11: TH sends Get Year Day Schedule Command to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { + NextTest(); + return; + } + err = TestStep11ThSendsGetYearDayScheduleCommandToDut_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 12: TH sends Get Year Day Schedule Command to DUT for non-existent User\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C0f.Rsp && DRLK.S.C0f.Tx")) { + NextTest(); + return; + } + err = TestStep12ThSendsGetYearDayScheduleCommandToDutForNonExistentUser_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 13: TH sends Clear Year Day Schedule to DUT\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { + NextTest(); + return; + } + err = TestStep13ThSendsClearYearDayScheduleToDut_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Clear a year day schedule for the first user\n"); + if (ShouldSkip("DRLK.S.F0a && DRLK.S.C10.Rsp")) { + NextTest(); + return; + } + err = TestClearAYearDayScheduleForTheFirstUser_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Cleanup the created user with UserIndex 1\n"); + err = TestCleanupTheCreatedUserWithUserIndex1_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Cleanup the created user with UserIndex 5\n"); + err = TestCleanupTheCreatedUserWithUserIndex5_19(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 20; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionCreateNewUser_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = @"xxx"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:6452UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + params.credentialRule = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: Create new user: Error: %@", err); + } else { + NSLog(@"Precondition: Create new user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Precondition: Read the user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull NumberOfYearDaySchedulesSupportedPerUserValue; + + CHIP_ERROR TestStep1ThReadsNumberOfYearDaySchedulesSupportedPerUserAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfYearDaySchedulesSupportedPerUserWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads NumberOfYearDay SchedulesSupportedPerUser attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfYearDaySchedulesSupportedPerUser", [value unsignedCharValue], 255U)); + { + NumberOfYearDaySchedulesSupportedPerUserValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nonnull NumberOfTotalUsersSupportedValue; + + CHIP_ERROR TestStep2ThReadsNumberOfTotalUsersSupportedAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads NumberOfTotalUsers Supported attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); + { + NumberOfTotalUsersSupportedValue = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThSendsSetYearDayScheduleCommandToDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:960UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:1980UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH sends Set Year Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH sends Set Year Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4a4bThSendsGetYearDayScheduleCommandToDut_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 4a & 4b: TH sends Get Year Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 960UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 1980UL)); + } + + if (values.localEndTime != nil) { + + VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 961UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThSendSetYearDayScheduleCommandToDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:15U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:1020UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:2040UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH send Set Year Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 5: TH send Set Year Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThSendsGetYearDayScheduleCommandToDut_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:15U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH sends Get Year Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 6: TH sends Get Year Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 15U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 133U)); + } + + VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); + if (values.localStartTime != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); + if (values.localEndTime != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7aCreateAUserWithUserIndexAs5_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:5U]; + params.userName = @"xxx"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:6452UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + params.credentialRule = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7a: Create a user with userIndex as 5: Error: %@", err); + } else { + NSLog(@"Step 7a: Create a user with userIndex as 5: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7bThSendsGetYearDayScheduleCommandToDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NumberOfYearDaySchedulesSupportedPerUserValue copy]; + params.userIndex = + [NSNumber numberWithUnsignedShort:5U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7b: TH sends Get Year Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 7b: TH sends Get Year Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, NumberOfYearDaySchedulesSupportedPerUserValue)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 5U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); + if (values.localStartTime != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); + if (values.localEndTime != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThSendsClearYearDayScheduleToDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH sends Clear Year Day Schedule to DUT: Error: %@", err); + } else { + NSLog(@"Step 8: TH sends Clear Year Day Schedule to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThSendsGetYearDayScheduleCommandToDut_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH sends Get Year Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 9: TH sends Get Year Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); + if (values.localStartTime != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); + if (values.localEndTime != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThSendsSetYearDayScheduleCommandToDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.localStartTime = + [NSNumber numberWithUnsignedInt:1080UL]; + params.localEndTime = + [NSNumber numberWithUnsignedInt:2100UL]; + [cluster setYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH sends Set Year Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 10: TH sends Set Year Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThSendsGetYearDayScheduleCommandToDut_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH sends Get Year Day Schedule Command to DUT: Error: %@", err); + } else { + NSLog(@"Step 11: TH sends Get Year Day Schedule Command to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.localStartTime; + VerifyOrReturn(CheckValue("LocalStartTime", actualValue, 1080UL)); + } + + { + id actualValue = values.localEndTime; + VerifyOrReturn(CheckValue("LocalEndTime", actualValue, 2100UL)); + } + + if (values.localEndTime != nil) { + + VerifyOrReturn(CheckConstraintMinValue("localEndTime", [values.localEndTime unsignedIntValue], 1081UL)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThSendsGetYearDayScheduleCommandToDutForNonExistentUser_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getYearDayScheduleWithParams:params completion: + ^(MTRDoorLockClusterGetYearDayScheduleResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH sends Get Year Day Schedule Command to DUT for non-existent User: Error: %@", err); + } else { + NSLog(@"Step 12: TH sends Get Year Day Schedule Command to DUT for non-existent User: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.yearDayIndex; + VerifyOrReturn(CheckValue("YearDayIndex", actualValue, 1U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + VerifyOrReturn(CheckConstraintHasValue("localStartTime", values.localStartTime, false)); + if (values.localStartTime != nil) { + } + + VerifyOrReturn(CheckConstraintHasValue("localEndTime", values.localEndTime, false)); + if (values.localEndTime != nil) { + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13ThSendsClearYearDayScheduleToDut_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:0U]; + [cluster clearYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH sends Clear Year Day Schedule to DUT: Error: %@", err); + } else { + NSLog(@"Step 13: TH sends Clear Year Day Schedule to DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestClearAYearDayScheduleForTheFirstUser_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearYearDayScheduleParams alloc] init]; + params.yearDayIndex = + [NSNumber numberWithUnsignedChar:1U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearYearDayScheduleWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Clear a year day schedule for the first user: Error: %@", err); + } else { + NSLog(@"Clear a year day schedule for the first user: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex1_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Cleanup the created user with UserIndex 1: Error: %@", err); + } else { + NSLog(@"Cleanup the created user with UserIndex 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestCleanupTheCreatedUserWithUserIndex5_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:5U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Cleanup the created user with UserIndex 5: Error: %@", err); + } else { + NSLog(@"Cleanup the created user with UserIndex 5: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DRLK_2_8 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DRLK_2_8() + : TestCommandBridge("Test_TC_DRLK_2_8") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DRLK_2_8() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_8\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_8\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { + NextTest(); + return; + } + err = TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { + NextTest(); + return; + } + err = TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3: TH sends Get User Command to DUT with UserIndex as 1\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { + NextTest(); + return; + } + err = TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { + NextTest(); + return; + } + err = TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { + NextTest(); + return; + } + err = TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { + NextTest(); + return; + } + err = TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6b: TH sends Get User Command to DUT with UserIndex as 2\n"); + if (ShouldSkip("DRLK.S.C1a.Rsp && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { + NextTest(); + return; + } + err = TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1a.Rsp")) { + NextTest(); + return; + } + err = TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 8: TH sends Get User Command to DUT with the UserIndex as 2\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { + NextTest(); + return; + } + err = TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 9: TH sends Clear User Command to DUT with the UserIndex as 1\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { + NextTest(); + return; + } + err = TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 10: TH sends Get User Command to DUT with the UserIndex as 1\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { + NextTest(); + return; + } + err = TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1d.Rsp")) { + NextTest(); + return; + } + err = TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.C1b.Rsp && DRLK.S.C1c.Tx")) { + NextTest(); + return; + } + err = TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_INVALID_COMMAND)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), EMBER_ZCL_STATUS_FAILURE)); + VerifyOrReturn(CheckValue("clusterStatus present", status.mClusterStatus.HasValue(), true)); + VerifyOrReturn(CheckValue("clusterStatus value", status.mClusterStatus.Value(), 3)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 14; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull Current_NumberOfTotalUsersSupported; + + CHIP_ERROR TestStep1ThReadsNumberOfTotalUsersSupportedAttributeAndSavesForFutureUse_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.: Error: %@", err); + } else { + NSLog(@"Step 1: TH reads NumberOfTotalUsers Supported attribute and saves for future use.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65534U)); + { + Current_NumberOfTotalUsersSupported = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs0CredentialRuleAs0_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = @"xxx"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:6452UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + params.credentialRule = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0: Error: %@", err); + } else { + NSLog(@"Step 2: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 0 CredentialRule as 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThSendsGetUserCommandToDutWithUserIndexAs1_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH sends Get User Command to DUT with UserIndex as 1: Error: %@", err); + } else { + NSLog(@"Step 3: TH sends Get User Command to DUT with UserIndex as 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsXxxUserUniqueIDAs6452UserStatusAs1UserTypeAs10InvalidValueCredentialRuleAs3_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + params.userName = @"xxx"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:6452UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:10U]; + params.credentialRule = + [NSNumber numberWithUnsignedChar:3U]; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3: Error: %@", err); + } else { + NSLog(@"Step 4: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as xxx UserUniqueID as 6452 UserStatus as 1 UserType as 10 (Invalid value) CredentialRule as 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_INVALID_COMMAND)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs1SameAsStep2UserNameAsXxxUserUniqueIDAs8965UserStatusAs1UserTypeAs0CredentialRuleAs0_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = @"xxx"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:8965UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + params.credentialRule = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0: Error: %@", err); + } else { + NSLog(@"Step 5: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 1 (Same as step 2) UserName as xxx UserUniqueID as 8965 UserStatus as 1 UserType as 0 CredentialRule as 0: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? ([err.domain isEqualToString:MTRInteractionErrorDomain] ? err.code : EMBER_ZCL_STATUS_FAILURE) : 0, EMBER_ZCL_STATUS_FAILURE)); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs0UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Error: %@", err); + } else { + NSLog(@"Step 6a: TH sends Set User Command to DUT with the following values: OperationType as 0 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThSendsGetUserCommandToDutWithUserIndexAs2_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH sends Get User Command to DUT with UserIndex as 2: Error: %@", err); + } else { + NSLog(@"Step 6b: TH sends Get User Command to DUT with UserIndex as 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThSendsSetUserCommandToDutWithTheFollowingValuesOperationTypeAs2UserIndexAs2UserNameAsNullUserUniqueIDAsNullUserStatusAsNullUserTypeAsNullCredentialRuleAsNull_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:2U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + params.userName = nil; + params.userUniqueID = nil; + params.userStatus = nil; + params.userType = nil; + params.credentialRule = nil; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Error: %@", err); + } else { + NSLog(@"Step 7: TH sends Set User Command to DUT with the following values: OperationType as 2 UserIndex as 2 UserName as NULL UserUniqueID as NULL UserStatus as NULL UserType as NULL CredentialRule as NULL: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThSendsGetUserCommandToDutWithTheUserIndexAs2_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH sends Get User Command to DUT with the UserIndex as 2: Error: %@", err); + } else { + NSLog(@"Step 8: TH sends Get User Command to DUT with the UserIndex as 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThSendsClearUserCommandToDutWithTheUserIndexAs1_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH sends Clear User Command to DUT with the UserIndex as 1: Error: %@", err); + } else { + NSLog(@"Step 9: TH sends Clear User Command to DUT with the UserIndex as 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep10ThSendsGetUserCommandToDutWithTheUserIndexAs1_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 10: TH sends Get User Command to DUT with the UserIndex as 1: Error: %@", err); + } else { + NSLog(@"Step 10: TH sends Get User Command to DUT with the UserIndex as 1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNonNull("NextUserIndex", actualValue)); + VerifyOrReturn(CheckValue("NextUserIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTestCleanupThSendsClearUserCommandToDutWithTheUserIndexAs2_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster clearUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2: Error: %@", err); + } else { + NSLog(@"Test cleanup: TH sends Clear User Command to DUT with the UserIndex as 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTestCleanupThSendsGetUserCommandToDutWithTheUserIndexAs2_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:2U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2: Error: %@", err); + } else { + NSLog(@"Test cleanup: TH sends Get User Command to DUT with the UserIndex as 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 2U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNull("UserName", actualValue)); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNull("UserUniqueID", actualValue)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNull("UserStatus", actualValue)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNull("UserType", actualValue)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNull("CredentialRule", actualValue)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNull("Credentials", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_DRLK_2_11 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_DRLK_2_11() + : TestCommandBridge("Test_TC_DRLK_2_11") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("PINCredentialData", &mPINCredentialData); + AddArgument("RFIDCredentialData", &mRFIDCredentialData); + AddArgument("FingerVeinCredentialData", &mFingerVeinCredentialData); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_DRLK_2_11() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_DRLK_2_11\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_DRLK_2_11\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Precondition: Create new user with default parameters\n"); + err = TestPreconditionCreateNewUserWithDefaultParameters_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Precondition: Read the user back and verify its fields\n"); + err = TestPreconditionReadTheUserBackAndVerifyItsFields_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.A0011")) { + NextTest(); + return; + } + err = TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 1b: TH reads MinPINCodeLength and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { + NextTest(); + return; + } + err = TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 1c: TH reads MaxPINCodeLength and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F00")) { + NextTest(); + return; + } + err = TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 1d: TH reads MinRFIDCodeLength and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A001a")) { + NextTest(); + return; + } + err = TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 1e: TH reads MaxRFIDCodeLength and saves for future use.\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.A0019")) { + NextTest(); + return; + } + err = TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 2a: TH sends Set Credential Command to DUT with type PIN\n"); + if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { + NextTest(); + return; + } + err = TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 2b: TH sends Set Credential Command to DUT with type RFID\n"); + if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { + NextTest(); + return; + } + err = TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 2c: TH sends Set Credential Command to DUT with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C22.Rsp && DRLK.S.C23.Tx")) { + NextTest(); + return; + } + err = TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 3a: TH sends Get Credential Status Command with type PIN\n"); + if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { + NextTest(); + return; + } + err = TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 3b: TH sends Get Credential Status Command with type RFID\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { + NextTest(); + return; + } + err = TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 3c: TH sends Get Credential Status Command with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { + NextTest(); + return; + } + err = TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4a: TH sends Clear Credential Command to DUT with type PIN\n"); + if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { + NextTest(); + return; + } + err = TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 4b: TH sends Get Credential Status Command with type RFID\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F01 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { + NextTest(); + return; + } + err = TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 4c: TH sends Get Credential Status Command with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { + NextTest(); + return; + } + err = TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 4d: TH sends Clear Credential Command to DUT with type RFID\n"); + if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { + NextTest(); + return; + } + err = TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 4e: TH sends Get Credential Status Command with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F08 && DRLK.S.F02 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { + NextTest(); + return; + } + err = TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 4f: TH sends Clear Credential Command to DUT with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C26.Rsp")) { + NextTest(); + return; + } + err = TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 5a: TH sends Get Credential Status Command to DUT with type PIN\n"); + if (ShouldSkip("DRLK.S.F00 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { + NextTest(); + return; + } + err = TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 5b: TH sends Get Credential Status Command to DUT with type RFID\n"); + if (ShouldSkip("DRLK.S.F01 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { + NextTest(); + return; + } + err = TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein\n"); + if (ShouldSkip("DRLK.S.F02 && DRLK.S.F08 && DRLK.S.C24.Rsp && DRLK.S.C25.Tx")) { + NextTest(); + return; + } + err = TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 23; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mPINCredentialData; + chip::Optional mRFIDCredentialData; + chip::Optional mFingerVeinCredentialData; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestPreconditionCreateNewUserWithDefaultParameters_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetUserParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userName = @"xxx"; + params.userUniqueID = + [NSNumber numberWithUnsignedInt:6452UL]; + params.userStatus = + [NSNumber numberWithUnsignedChar:1U]; + params.userType = + [NSNumber numberWithUnsignedChar:0U]; + params.credentialRule = + [NSNumber numberWithUnsignedChar:0U]; + [cluster setUserWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: Create new user with default parameters: Error: %@", err); + } else { + NSLog(@"Precondition: Create new user with default parameters: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreconditionReadTheUserBackAndVerifyItsFields_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetUserParams alloc] init]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + [cluster getUserWithParams:params completion: + ^(MTRDoorLockClusterGetUserResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Precondition: Read the user back and verify its fields: Error: %@", err); + } else { + NSLog(@"Precondition: Read the user back and verify its fields: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.userName; + VerifyOrReturn(CheckValueNonNull("UserName", actualValue)); + VerifyOrReturn(CheckValueAsString("UserName", actualValue, @"xxx")); + } + + { + id actualValue = values.userUniqueID; + VerifyOrReturn(CheckValueNonNull("UserUniqueID", actualValue)); + VerifyOrReturn(CheckValue("UserUniqueID", actualValue, 6452UL)); + } + + { + id actualValue = values.userStatus; + VerifyOrReturn(CheckValueNonNull("UserStatus", actualValue)); + VerifyOrReturn(CheckValue("UserStatus", actualValue, 1U)); + } + + { + id actualValue = values.userType; + VerifyOrReturn(CheckValueNonNull("UserType", actualValue)); + VerifyOrReturn(CheckValue("UserType", actualValue, 0U)); + } + + { + id actualValue = values.credentialRule; + VerifyOrReturn(CheckValueNonNull("CredentialRule", actualValue)); + VerifyOrReturn(CheckValue("CredentialRule", actualValue, 0U)); + } + + { + id actualValue = values.credentials; + VerifyOrReturn(CheckValueNonNull("Credentials", actualValue)); + VerifyOrReturn(CheckValue("Credentials", [actualValue count], static_cast(0))); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextUserIndex; + VerifyOrReturn(CheckValueNull("NextUserIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1aThReadsNumberOfTotalUsersSupportedAndSavesForFutureUse_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNumberOfTotalUsersSupportedWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.: Error: %@", err); + } else { + NSLog(@"Step 1a: TH reads NumberOfTotalUsersSupported and saves for future use.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("numberOfTotalUsersSupported", [value unsignedShortValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("numberOfTotalUsersSupported", [value unsignedShortValue], 65535U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1bThReadsMinPINCodeLengthAndSavesForFutureUse_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1b: TH reads MinPINCodeLength and saves for future use.: Error: %@", err); + } else { + NSLog(@"Step 1b: TH reads MinPINCodeLength and saves for future use.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("minPINCodeLength", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("minPINCodeLength", [value unsignedCharValue], 255U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1cThReadsMaxPINCodeLengthAndSavesForFutureUse_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxPINCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1c: TH reads MaxPINCodeLength and saves for future use.: Error: %@", err); + } else { + NSLog(@"Step 1c: TH reads MaxPINCodeLength and saves for future use.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("maxPINCodeLength", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("maxPINCodeLength", [value unsignedCharValue], 255U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1dThReadsMinRFIDCodeLengthAndSavesForFutureUse_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMinRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1d: TH reads MinRFIDCodeLength and saves for future use.: Error: %@", err); + } else { + NSLog(@"Step 1d: TH reads MinRFIDCodeLength and saves for future use.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("minRFIDCodeLength", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("minRFIDCodeLength", [value unsignedCharValue], 255U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep1eThReadsMaxRFIDCodeLengthAndSavesForFutureUse_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeMaxRFIDCodeLengthWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 1e: TH reads MaxRFIDCodeLength and saves for future use.: Error: %@", err); + } else { + NSLog(@"Step 1e: TH reads MaxRFIDCodeLength and saves for future use.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintMinValue("maxRFIDCodeLength", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("maxRFIDCodeLength", [value unsignedCharValue], 255U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsSetCredentialCommandToDutWithTypePin_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = mPINCredentialData.HasValue() ? [NSData dataWithBytes:mPINCredentialData.Value().data() length:mPINCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456" length:6]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends Set Credential Command to DUT with type PIN: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends Set Credential Command to DUT with type PIN: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThSendsSetCredentialCommandToDutWithTypeRfid_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = mRFIDCredentialData.HasValue() ? [NSData dataWithBytes:mRFIDCredentialData.Value().data() length:mRFIDCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456789A" length:10]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends Set Credential Command to DUT with type RFID: Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends Set Credential Command to DUT with type RFID: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2cThSendsSetCredentialCommandToDutWithTypeFingerVein_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterSetCredentialParams alloc] init]; + params.operationType = + [NSNumber numberWithUnsignedChar:0U]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:4U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + params.credentialData = mFingerVeinCredentialData.HasValue() ? [NSData dataWithBytes:mFingerVeinCredentialData.Value().data() length:mFingerVeinCredentialData.Value().size()] : [[NSData alloc] initWithBytes:"123456789A" length:10]; + params.userIndex = + [NSNumber numberWithUnsignedShort:1U]; + params.userStatus = nil; + params.userType = nil; + [cluster setCredentialWithParams:params completion: + ^(MTRDoorLockClusterSetCredentialResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2c: TH sends Set Credential Command to DUT with type FingerVein: Error: %@", err); + } else { + NSLog(@"Step 2c: TH sends Set Credential Command to DUT with type FingerVein: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNonNull("NextCredentialIndex", actualValue)); + VerifyOrReturn(CheckValue("NextCredentialIndex", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThSendsGetCredentialStatusCommandWithTypePin_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH sends Get Credential Status Command with type PIN: Error: %@", err); + } else { + NSLog(@"Step 3a: TH sends Get Credential Status Command with type PIN: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } + + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThSendsGetCredentialStatusCommandWithTypeRfid_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH sends Get Credential Status Command with type RFID: Error: %@", err); + } else { + NSLog(@"Step 3b: TH sends Get Credential Status Command with type RFID: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } + + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThSendsGetCredentialStatusCommandWithTypeFingerVein_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:4U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); + } else { + NSLog(@"Step 3c: TH sends Get Credential Status Command with type FingerVein: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } + + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThSendsClearCredentialCommandToDutWithTypePin_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH sends Clear Credential Command to DUT with type PIN: Error: %@", err); + } else { + NSLog(@"Step 4a: TH sends Clear Credential Command to DUT with type PIN: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThSendsGetCredentialStatusCommandWithTypeRfid_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH sends Get Credential Status Command with type RFID: Error: %@", err); + } else { + NSLog(@"Step 4b: TH sends Get Credential Status Command with type RFID: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } + + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThSendsGetCredentialStatusCommandWithTypeFingerVein_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:4U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); + } else { + NSLog(@"Step 4c: TH sends Get Credential Status Command with type FingerVein: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } + + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThSendsClearCredentialCommandToDutWithTypeRfid_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH sends Clear Credential Command to DUT with type RFID: Error: %@", err); + } else { + NSLog(@"Step 4d: TH sends Clear Credential Command to DUT with type RFID: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThSendsGetCredentialStatusCommandWithTypeFingerVein_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:4U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH sends Get Credential Status Command with type FingerVein: Error: %@", err); + } else { + NSLog(@"Step 4e: TH sends Get Credential Status Command with type FingerVein: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, true)); + } + + VerifyOrReturn(CheckConstraintType("credentialExists", "boolean", "boolean")); + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNonNull("UserIndex", actualValue)); + VerifyOrReturn(CheckValue("UserIndex", actualValue, 1U)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNonNull("CreatorFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("CreatorFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNonNull("LastModifiedFabricIndex", actualValue)); + VerifyOrReturn(CheckValue("LastModifiedFabricIndex", actualValue, 1U)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4fThSendsClearCredentialCommandToDutWithTypeFingerVein_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterClearCredentialParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:4U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster clearCredentialWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4f: TH sends Clear Credential Command to DUT with type FingerVein: Error: %@", err); + } else { + NSLog(@"Step 4f: TH sends Clear Credential Command to DUT with type FingerVein: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThSendsGetCredentialStatusCommandToDutWithTypePin_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:1U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH sends Get Credential Status Command to DUT with type PIN: Error: %@", err); + } else { + NSLog(@"Step 5a: TH sends Get Credential Status Command to DUT with type PIN: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5bThSendsGetCredentialStatusCommandToDutWithTypeRfid_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:2U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH sends Get Credential Status Command to DUT with type RFID: Error: %@", err); + } else { + NSLog(@"Step 5b: TH sends Get Credential Status Command to DUT with type RFID: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5cThSendsGetCredentialStatusCommandToDutWithTypeFingerVein_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterDoorLock alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRDoorLockClusterGetCredentialStatusParams alloc] init]; + params.credential = [[MTRDoorLockClusterCredentialStruct alloc] init]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialType = + [NSNumber numberWithUnsignedChar:4U]; + ((MTRDoorLockClusterCredentialStruct *) params.credential).credentialIndex = + [NSNumber numberWithUnsignedShort:1U]; + + [cluster getCredentialStatusWithParams:params completion: + ^(MTRDoorLockClusterGetCredentialStatusResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein: Error: %@", err); + } else { + NSLog(@"Step 5c: TH sends Get Credential Status Command to DUT with type FingerVein: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.credentialExists; + VerifyOrReturn(CheckValue("CredentialExists", actualValue, false)); + } + + { + id actualValue = values.userIndex; + VerifyOrReturn(CheckValueNull("UserIndex", actualValue)); + } + + { + id actualValue = values.creatorFabricIndex; + VerifyOrReturn(CheckValueNull("CreatorFabricIndex", actualValue)); + } + + { + id actualValue = values.lastModifiedFabricIndex; + VerifyOrReturn(CheckValueNull("LastModifiedFabricIndex", actualValue)); + } + + { + id actualValue = values.nextCredentialIndex; + VerifyOrReturn(CheckValueNull("NextCredentialIndex", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestGroupsCluster : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestGroupsCluster() + : TestCommandBridge("TestGroupsCluster") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestGroupsCluster() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestGroupsCluster\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestGroupsCluster\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : View Group 0 (invalid)\n"); + err = TestViewGroup0Invalid_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : View First Group (not found)\n"); + err = TestViewFirstGroupNotFound_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Add First Group (no keys)\n"); + err = TestAddFirstGroupNoKeys_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Add KeySet\n"); + err = TestAddKeySet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Write Group Keys\n"); + err = TestWriteGroupKeys_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Add First Group (name too long)\n"); + err = TestAddFirstGroupNameTooLong_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Add First Group (new)\n"); + err = TestAddFirstGroupNew_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : View First Group (new)\n"); + err = TestViewFirstGroupNew_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : View Second Group (not found)\n"); + err = TestViewSecondGroupNotFound_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Get Group Membership 1 (all)\n"); + err = TestGetGroupMembership1All_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Add Second Group (new)\n"); + err = TestAddSecondGroupNew_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : View Second Group (new)\n"); + err = TestViewSecondGroupNew_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : View Group 3 (not found)\n"); + err = TestViewGroup3NotFound_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : View First Group (existing)\n"); + err = TestViewFirstGroupExisting_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : View Second Group (existing)\n"); + err = TestViewSecondGroupExisting_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Get Group Membership 2\n"); + err = TestGetGroupMembership2_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Remove Group 0 (invalid)\n"); + err = TestRemoveGroup0Invalid_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Remove Group 4 (not found)\n"); + err = TestRemoveGroup4NotFound_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Remove Second Group (existing)\n"); + err = TestRemoveSecondGroupExisting_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : View First Group (not removed)\n"); + err = TestViewFirstGroupNotRemoved_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : View Second Group (removed)\n"); + err = TestViewSecondGroupRemoved_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Get Group Membership 3\n"); + err = TestGetGroupMembership3_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Remove All\n"); + err = TestRemoveAll_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : View First Group (removed)\n"); + err = TestViewFirstGroupRemoved_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : View Second Group (still removed)\n"); + err = TestViewSecondGroupStillRemoved_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : View Group 3 (removed)\n"); + err = TestViewGroup3Removed_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Get Group Membership 4\n"); + err = TestGetGroupMembership4_27(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 28; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestViewGroup0Invalid_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:0U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View Group 0 (invalid): Error: %@", err); + } else { + NSLog(@"View Group 0 (invalid): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 135U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewFirstGroupNotFound_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:257U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View First Group (not found): Error: %@", err); + } else { + NSLog(@"View First Group (not found): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestAddFirstGroupNoKeys_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:257U]; + params.groupName = @"Group #1"; + [cluster addGroupWithParams:params completion: + ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Add First Group (no keys): Error: %@", err); + } else { + NSLog(@"Add First Group (no keys): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 126U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestAddKeySet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1110000ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:1110001ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1110002ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Add KeySet: Error: %@", err); + } else { + NSLog(@"Add KeySet: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWriteGroupKeys_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id groupKeyMapArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = + [NSNumber numberWithUnsignedShort:257U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = + [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + temp_0[1] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupId = + [NSNumber numberWithUnsignedShort:258U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).groupKeySetID = + [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[1]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + groupKeyMapArgument = temp_0; + } + [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Write Group Keys: Error: %@", err); + } else { + NSLog(@"Write Group Keys: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestAddFirstGroupNameTooLong_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:257U]; + params.groupName = @"12345678901234567"; + [cluster addGroupWithParams:params completion: + ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Add First Group (name too long): Error: %@", err); + } else { + NSLog(@"Add First Group (name too long): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 135U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestAddFirstGroupNew_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:257U]; + params.groupName = @"Group #101234567"; + [cluster addGroupWithParams:params completion: + ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Add First Group (new): Error: %@", err); + } else { + NSLog(@"Add First Group (new): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewFirstGroupNew_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:257U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View First Group (new): Error: %@", err); + } else { + NSLog(@"View First Group (new): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); + } + + { + id actualValue = values.groupName; + VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewSecondGroupNotFound_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:258U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View Second Group (not found): Error: %@", err); + } else { + NSLog(@"View Second Group (not found): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetGroupMembership1All_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + params.groupList = temp_0; + } + [cluster getGroupMembershipWithParams:params completion: + ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Group Membership 1 (all): Error: %@", err); + } else { + NSLog(@"Get Group Membership 1 (all): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.capacity; + VerifyOrReturn(CheckValueNull("Capacity", actualValue)); + } + + { + id actualValue = values.groupList; + VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 257U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestAddSecondGroupNew_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:258U]; + params.groupName = @"Group #2"; + [cluster addGroupWithParams:params completion: + ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Add Second Group (new): Error: %@", err); + } else { + NSLog(@"Add Second Group (new): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewSecondGroupNew_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:258U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View Second Group (new): Error: %@", err); + } else { + NSLog(@"View Second Group (new): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); + } + + { + id actualValue = values.groupName; + VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #2")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewGroup3NotFound_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:32767U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View Group 3 (not found): Error: %@", err); + } else { + NSLog(@"View Group 3 (not found): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 32767U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewFirstGroupExisting_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:257U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View First Group (existing): Error: %@", err); + } else { + NSLog(@"View First Group (existing): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); + } + + { + id actualValue = values.groupName; + VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewSecondGroupExisting_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:258U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View Second Group (existing): Error: %@", err); + } else { + NSLog(@"View Second Group (existing): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); + } + + { + id actualValue = values.groupName; + VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #2")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetGroupMembership2_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [NSNumber numberWithUnsignedShort:258U]; + temp_0[1] = + [NSNumber numberWithUnsignedShort:259U]; + temp_0[2] = + [NSNumber numberWithUnsignedShort:32767U]; + params.groupList = temp_0; + } + [cluster getGroupMembershipWithParams:params completion: + ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Group Membership 2: Error: %@", err); + } else { + NSLog(@"Get Group Membership 2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.capacity; + VerifyOrReturn(CheckValueNull("Capacity", actualValue)); + } + + { + id actualValue = values.groupList; + VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 258U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveGroup0Invalid_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:0U]; + [cluster removeGroupWithParams:params completion: + ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Remove Group 0 (invalid): Error: %@", err); + } else { + NSLog(@"Remove Group 0 (invalid): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 135U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveGroup4NotFound_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:260U]; + [cluster removeGroupWithParams:params completion: + ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Remove Group 4 (not found): Error: %@", err); + } else { + NSLog(@"Remove Group 4 (not found): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 260U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveSecondGroupExisting_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterRemoveGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:258U]; + [cluster removeGroupWithParams:params completion: + ^(MTRGroupsClusterRemoveGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Remove Second Group (existing): Error: %@", err); + } else { + NSLog(@"Remove Second Group (existing): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewFirstGroupNotRemoved_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:257U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View First Group (not removed): Error: %@", err); + } else { + NSLog(@"View First Group (not removed): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); + } + + { + id actualValue = values.groupName; + VerifyOrReturn(CheckValueAsString("GroupName", actualValue, @"Group #101234567")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewSecondGroupRemoved_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:258U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View Second Group (removed): Error: %@", err); + } else { + NSLog(@"View Second Group (removed): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetGroupMembership3_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [NSNumber numberWithUnsignedShort:1U]; + temp_0[1] = + [NSNumber numberWithUnsignedShort:257U]; + temp_0[2] = + [NSNumber numberWithUnsignedShort:258U]; + temp_0[3] = + [NSNumber numberWithUnsignedShort:3U]; + params.groupList = temp_0; + } + [cluster getGroupMembershipWithParams:params completion: + ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Group Membership 3: Error: %@", err); + } else { + NSLog(@"Get Group Membership 3: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.capacity; + VerifyOrReturn(CheckValueNull("Capacity", actualValue)); + } + + { + id actualValue = values.groupList; + VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(1))); + VerifyOrReturn(CheckValue("", actualValue[0], 257U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestRemoveAll_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster removeAllGroupsWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Remove All: Error: %@", err); + } else { + NSLog(@"Remove All: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewFirstGroupRemoved_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:257U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View First Group (removed): Error: %@", err); + } else { + NSLog(@"View First Group (removed): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 257U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewSecondGroupStillRemoved_25() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:258U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View Second Group (still removed): Error: %@", err); + } else { + NSLog(@"View Second Group (still removed): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 258U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestViewGroup3Removed_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterViewGroupParams alloc] init]; + params.groupID = + [NSNumber numberWithUnsignedShort:32767U]; + [cluster viewGroupWithParams:params completion: + ^(MTRGroupsClusterViewGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"View Group 3 (removed): Error: %@", err); + } else { + NSLog(@"View Group 3 (removed): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 139U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, 32767U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestGetGroupMembership4_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterGetGroupMembershipParams alloc] init]; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = + [NSNumber numberWithUnsignedShort:1U]; + temp_0[1] = + [NSNumber numberWithUnsignedShort:257U]; + temp_0[2] = + [NSNumber numberWithUnsignedShort:258U]; + temp_0[3] = + [NSNumber numberWithUnsignedShort:3U]; + temp_0[4] = + [NSNumber numberWithUnsignedShort:32767U]; + params.groupList = temp_0; + } + [cluster getGroupMembershipWithParams:params completion: + ^(MTRGroupsClusterGetGroupMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Get Group Membership 4: Error: %@", err); + } else { + NSLog(@"Get Group Membership 4: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.capacity; + VerifyOrReturn(CheckValueNull("Capacity", actualValue)); + } + + { + id actualValue = values.groupList; + VerifyOrReturn(CheckValue("GroupList", [actualValue count], static_cast(0))); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_G_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_G_1_1() + : TestCommandBridge("Test_TC_G_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_G_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_G_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_G_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip(" !G.S.F00 ")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given G.S.F00 ensure featuremap has the correct bit set\n"); + if (ShouldSkip("G.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenGsf00EnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 9; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 4U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenGsf00EnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given G.S.F00 ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given G.S.F00 ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestScenesFabricRemoval : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestScenesFabricRemoval() + : TestCommandBridge("TestScenesFabricRemoval") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("payload", &mPayload); + AddArgument("discriminator", 0, UINT16_MAX, &mDiscriminator); + AddArgument("waitAfterCommissioning", 0, UINT16_MAX, &mWaitAfterCommissioning); + AddArgument("PakeVerifier", &mPakeVerifier); + AddArgument("G1", 0, UINT16_MAX, &mG1); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestScenesFabricRemoval() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestScenesFabricRemoval\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestScenesFabricRemoval\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Commission DUT to TH1\n"); + err = TestCommissionDutToTh1_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : TH1 reads the fabric index\n"); + err = TestTh1ReadsTheFabricIndex_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Open Commissioning Window from alpha\n"); + err = TestOpenCommissioningWindowFromAlpha_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Waiting after opening commissioning window\n"); + err = TestWaitingAfterOpeningCommissioningWindow_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Commission from TH2\n"); + err = TestCommissionFromTh2_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Wait for the commissioned device to be retrieved for TH2\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : TH2 reads the fabric index\n"); + err = TestTh2ReadsTheFabricIndex_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : TH1 sends a RemoveAllGroups command to DUT.\n"); + err = TestTh1SendsARemoveAllGroupsCommandToDut_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : TH 1 Add Group KeySet.\n"); + err = TestTh1AddGroupKeySet_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : TH1 Map KeySets to GroupId.\n"); + err = TestTh1MapKeySetsToGroupId_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : TH1 sends a AddGroup command to DUT for G1.\n"); + err = TestTh1SendsAAddGroupCommandToDutForG1_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Preparation step : TH2 Add Group KeySet.\n"); + err = TestPreparationStepTh2AddGroupKeySet_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Preparation step TH2 Map KeySets to GroupId.\n"); + err = TestPreparationStepTh2MapKeySetsToGroupId_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : TH2 sends a AddGroup command to DUT for G1.\n"); + err = TestTh2SendsAAddGroupCommandToDutForG1_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : TH1 confirms its Scene table is empty and gets its capacity\n"); + err = TestTh1ConfirmsItsSceneTableIsEmptyAndGetsItsCapacity_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : TH2 confirms its Scene table is empty and has the same capacity as TH1\n"); + err = TestTh2ConfirmsItsSceneTableIsEmptyAndHasTheSameCapacityAsTh1_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : TH1 sends an AddScene command to DUT for Scene 1 G1\n"); + err = TestTh1SendsAnAddSceneCommandToDutForScene1G1_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : TH1 sends an AddScene command to DUT for Scene 2 G1\n"); + err = TestTh1SendsAnAddSceneCommandToDutForScene2G1_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : TH2 sends an AddScene command to DUT for Scene 1 G1\n"); + err = TestTh2SendsAnAddSceneCommandToDutForScene1G1_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : TH2 sends an AddScene command to DUT for Scene 2 G1\n"); + err = TestTh2SendsAnAddSceneCommandToDutForScene2G1_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : TH1 confirms its G1 holds 2 scenes\n"); + err = TestTh1ConfirmsItsG1Holds2Scenes_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : TH2 confirms its G1 holds 2 scenes\n"); + err = TestTh2ConfirmsItsG1Holds2Scenes_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : TH1 sends RemoveFabric command for TH2\n"); + err = TestTh1SendsRemoveFabricCommandForTh2_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : TH1 confirms its G1 still holds 2 scenes\n"); + err = TestTh1ConfirmsItsG1StillHolds2Scenes_23(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 24; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mPayload; + chip::Optional mDiscriminator; + chip::Optional mWaitAfterCommissioning; + chip::Optional mPakeVerifier; + chip::Optional mG1; + chip::Optional mTimeout; + + CHIP_ERROR TestCommissionDutToTh1_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + NSNumber * _Nonnull th1FabricIndex; + + CHIP_ERROR TestTh1ReadsTheFabricIndex_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH1 reads the fabric index: Error: %@", err); + } else { + NSLog(@"TH1 reads the fabric index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + th1FabricIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestOpenCommissioningWindowFromAlpha_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterAdministratorCommissioning alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRAdministratorCommissioningClusterOpenCommissioningWindowParams alloc] init]; + params.commissioningTimeout = + [NSNumber numberWithUnsignedShort:180U]; + params.pakePasscodeVerifier = mPakeVerifier.HasValue() ? [NSData dataWithBytes:mPakeVerifier.Value().data() length:mPakeVerifier.Value().size()] : [[NSData alloc] initWithBytes:"\xb9\x61\x70\xaa\xe8\x03\x34\x68\x84\x72\x4f\xe9\xa3\xb2\x87\xc3\x03\x30\xc2\xa6\x60\x37\x5d\x17\xbb\x20\x5a\x8c\xf1\xae\xcb\x35\x04\x57\xf8\xab\x79\xee\x25\x3a\xb6\xa8\xe4\x6b\xb0\x9e\x54\x3a\xe4\x22\x73\x6d\xe5\x01\xe3\xdb\x37\xd4\x41\xfe\x34\x49\x20\xd0\x95\x48\xe4\xc1\x82\x40\x63\x0c\x4f\xf4\x91\x3c\x53\x51\x38\x39\xb7\xc0\x7f\xcc\x06\x27\xa1\xb8\x57\x3a\x14\x9f\xcd\x1f\xa4\x66\xcf" length:97]; + params.discriminator = mDiscriminator.HasValue() ? [NSNumber numberWithUnsignedShort:mDiscriminator.Value()] : [NSNumber numberWithUnsignedShort:3840U]; + params.iterations = + [NSNumber numberWithUnsignedInt:1000UL]; + params.salt = + [[NSData alloc] initWithBytes:"SPAKE2P Key Salt" length:16]; + [cluster openCommissioningWindowWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Open Commissioning Window from alpha: Error: %@", err); + } else { + NSLog(@"Open Commissioning Window from alpha: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWaitingAfterOpeningCommissioningWindow_3() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = mWaitAfterCommissioning.HasValue() ? mWaitAfterCommissioning.Value() : 5000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestCommissionFromTh2_4() + { + + chip::app::Clusters::CommissionerCommands::Commands::PairWithCode::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + value.payload = mPayload.HasValue() ? mPayload.Value() : chip::Span("MT:-24J0AFN00KA0648G00", 22); + return PairWithCode("beta", value); + } + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrievedForTh2_5() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("beta", value); + } + NSNumber * _Nonnull th2FabricIndex; + + CHIP_ERROR TestTh2ReadsTheFabricIndex_6() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentFabricIndexWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH2 reads the fabric index: Error: %@", err); + } else { + NSLog(@"TH2 reads the fabric index: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + th2FabricIndex = value; + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh1SendsARemoveAllGroupsCommandToDut_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster removeAllGroupsWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH1 sends a RemoveAllGroups command to DUT.: Error: %@", err); + } else { + NSLog(@"TH1 sends a RemoveAllGroups command to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh1AddGroupKeySet_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1110000ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:1110001ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1110002ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH 1 Add Group KeySet.: Error: %@", err); + } else { + NSLog(@"TH 1 Add Group KeySet.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh1MapKeySetsToGroupId_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id groupKeyMapArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = + [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + groupKeyMapArgument = temp_0; + } + [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH1 Map KeySets to GroupId.: Error: %@", err); + } else { + NSLog(@"TH1 Map KeySets to GroupId.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh1SendsAAddGroupCommandToDutForG1_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.groupName = @"Group1"; + [cluster addGroupWithParams:params completion: + ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH1 sends a AddGroup command to DUT for G1.: Error: %@", err); + } else { + NSLog(@"TH1 sends a AddGroup command to DUT for G1.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreparationStepTh2AddGroupKeySet_11() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:418U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1120000ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:1120001ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1120002ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Preparation step : TH2 Add Group KeySet.: Error: %@", err); + } else { + NSLog(@"Preparation step : TH2 Add Group KeySet.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestPreparationStepTh2MapKeySetsToGroupId_12() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id groupKeyMapArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = + [NSNumber numberWithUnsignedShort:418U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:0U]; + + groupKeyMapArgument = temp_0; + } + [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Preparation step TH2 Map KeySets to GroupId.: Error: %@", err); + } else { + NSLog(@"Preparation step TH2 Map KeySets to GroupId.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh2SendsAAddGroupCommandToDutForG1_13() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.groupName = @"Group1"; + [cluster addGroupWithParams:params completion: + ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH2 sends a AddGroup command to DUT for G1.: Error: %@", err); + } else { + NSLog(@"TH2 sends a AddGroup command to DUT for G1.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + NSNumber * _Nullable fabricCapacity; + + CHIP_ERROR TestTh1ConfirmsItsSceneTableIsEmptyAndGetsItsCapacity_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + [cluster getSceneMembershipWithParams:params completion: + ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH1 confirms its Scene table is empty and gets its capacity: Error: %@", err); + } else { + NSLog(@"TH1 confirms its Scene table is empty and gets its capacity: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + fabricCapacity = values.capacity; + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh2ConfirmsItsSceneTableIsEmptyAndHasTheSameCapacityAsTh1_15() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + [cluster getSceneMembershipWithParams:params completion: + ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH2 confirms its Scene table is empty and has the same capacity as TH1: Error: %@", err); + } else { + NSLog(@"TH2 confirms its Scene table is empty and has the same capacity as TH1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.capacity; + if (fabricCapacity == nil) { + VerifyOrReturn(CheckValueNull("Capacity", actualValue)); + } else { + VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); + VerifyOrReturn(CheckValue("Capacity", actualValue, fabricCapacity)); + } + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh1SendsAnAddSceneCommandToDutForScene1G1_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:1U]; + params.sceneName = @"Scene1"; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + params.extensionFieldSets = temp_0; + } + [cluster addSceneWithParams:params completion: + ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH1 sends an AddScene command to DUT for Scene 1 G1: Error: %@", err); + } else { + NSLog(@"TH1 sends an AddScene command to DUT for Scene 1 G1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + { + id actualValue = values.sceneID; + VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh1SendsAnAddSceneCommandToDutForScene2G1_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:2U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.sceneName = @"Scene2"; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + params.extensionFieldSets = temp_0; + } + [cluster addSceneWithParams:params completion: + ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH1 sends an AddScene command to DUT for Scene 2 G1: Error: %@", err); + } else { + NSLog(@"TH1 sends an AddScene command to DUT for Scene 2 G1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + { + id actualValue = values.sceneID; + VerifyOrReturn(CheckValue("SceneID", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh2SendsAnAddSceneCommandToDutForScene1G1_18() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:1U]; + params.sceneName = @"Scene1"; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + params.extensionFieldSets = temp_0; + } + [cluster addSceneWithParams:params completion: + ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH2 sends an AddScene command to DUT for Scene 1 G1: Error: %@", err); + } else { + NSLog(@"TH2 sends an AddScene command to DUT for Scene 1 G1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + { + id actualValue = values.sceneID; + VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh2SendsAnAddSceneCommandToDutForScene2G1_19() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:2U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.sceneName = @"Scene2"; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + params.extensionFieldSets = temp_0; + } + [cluster addSceneWithParams:params completion: + ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH2 sends an AddScene command to DUT for Scene 2 G1: Error: %@", err); + } else { + NSLog(@"TH2 sends an AddScene command to DUT for Scene 2 G1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + { + id actualValue = values.sceneID; + VerifyOrReturn(CheckValue("SceneID", actualValue, 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh1ConfirmsItsG1Holds2Scenes_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + [cluster getSceneMembershipWithParams:params completion: + ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH1 confirms its G1 holds 2 scenes: Error: %@", err); + } else { + NSLog(@"TH1 confirms its G1 holds 2 scenes: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.capacity; + VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); + VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + { + id actualValue = values.sceneList; + VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("", actualValue[0], 1U)); + VerifyOrReturn(CheckValue("", actualValue[1], 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh2ConfirmsItsG1Holds2Scenes_21() + { + + MTRBaseDevice * device = GetDevice("beta"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + [cluster getSceneMembershipWithParams:params completion: + ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH2 confirms its G1 holds 2 scenes: Error: %@", err); + } else { + NSLog(@"TH2 confirms its G1 holds 2 scenes: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.capacity; + VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); + VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + { + id actualValue = values.sceneList; + VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("", actualValue[0], 1U)); + VerifyOrReturn(CheckValue("", actualValue[1], 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh1SendsRemoveFabricCommandForTh2_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOperationalCredentials alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTROperationalCredentialsClusterRemoveFabricParams alloc] init]; + params.fabricIndex = + [th2FabricIndex copy]; + [cluster removeFabricWithParams:params completion: + ^(MTROperationalCredentialsClusterNOCResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH1 sends RemoveFabric command for TH2: Error: %@", err); + } else { + NSLog(@"TH1 sends RemoveFabric command for TH2: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestTh1ConfirmsItsG1StillHolds2Scenes_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterGetSceneMembershipParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + [cluster getSceneMembershipWithParams:params completion: + ^(MTRScenesManagementClusterGetSceneMembershipResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH1 confirms its G1 still holds 2 scenes: Error: %@", err); + } else { + NSLog(@"TH1 confirms its G1 still holds 2 scenes: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.capacity; + VerifyOrReturn(CheckValueNonNull("Capacity", actualValue)); + VerifyOrReturn(CheckValue("Capacity", actualValue, [fabricCapacity unsignedCharValue] - 2U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + { + id actualValue = values.sceneList; + VerifyOrReturn(CheckValue("SceneList", [actualValue count], static_cast(2))); + VerifyOrReturn(CheckValue("", actualValue[0], 1U)); + VerifyOrReturn(CheckValue("", actualValue[1], 2U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_S_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_S_1_1() + : TestCommandBridge("Test_TC_S_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_S_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test)\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532)\n"); + if (ShouldSkip("(!S.S.F00)")) { + NextTest(); + return; + } + err = TestStep3aThReadsFeatureMapNameSupportBitGlobalAttribute65532_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532)\n"); + if (ShouldSkip("S.S.F00")) { + NextTest(); + return; + } + err = TestStep3aThReadsFeatureMapNameSupportBitGlobalAttribute65532_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532)\n"); + if (ShouldSkip("(!S.S.F01)")) { + NextTest(); + return; + } + err = TestStep3bThReadsFeatureMapExplicitBitGlobalAttribute65532_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532)\n"); + if (ShouldSkip("S.S.F01")) { + NextTest(); + return; + } + err = TestStep3bThReadsFeatureMapExplicitBitGlobalAttribute65532_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532)\n"); + if (ShouldSkip("(!S.S.F02)")) { + NextTest(); + return; + } + err = TestStep3cThReadsFeatureMapTableSizeBitGlobalAttribute65532_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532)\n"); + if (ShouldSkip("S.S.F02")) { + NextTest(); + return; + } + err = TestStep3cThReadsFeatureMapTableSizeBitGlobalAttribute65532_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532)\n"); + if (ShouldSkip("(!S.S.F03)")) { + NextTest(); + return; + } + err = TestStep3dThReadsFeatureMapFabricSceneBitGlobalAttribute65532_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532)\n"); + if (ShouldSkip("S.S.F03")) { + NextTest(); + return; + } + err = TestStep3dThReadsFeatureMapFabricSceneBitGlobalAttribute65532_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4: TH reads from the DUT the AttributeList attribute\n"); + if (ShouldSkip("S.S")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4b: TH reads optional attributes(SceneCount, CurrentScene, CurrentGroup, SceneValid) in AttributeList (global attribute 65531)\n"); + if (ShouldSkip("(!S.S.F03)")) { + NextTest(); + return; + } + err = TestStep4bThReadsOptionalAttributesSceneCountCurrentSceneCurrentGroupSceneValidInAttributeListGlobalAttribute65531_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 4c: TH reads optinnal attribute(LastConfiguredBy) in AttributeList (global attribute 65531)\n"); + if (ShouldSkip("S.S.A0005")) { + NextTest(); + return; + } + err = TestStep4cThReadsOptinnalAttributeLastConfiguredByInAttributeListGlobalAttribute65531_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 4d: TH reads optionnal attribute(SceneTableSize) in AttributeList (global attribute 65531)\n"); + if (ShouldSkip("S.S.F02")) { + NextTest(); + return; + } + err = TestStep4dThReadsOptionnalAttributeSceneTableSizeInAttributeListGlobalAttribute65531_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 4e: TH reads optional attribute(FabricSceneInfo) in AttributeList (global attribute 65531)\n"); + if (ShouldSkip("S.S.F03")) { + NextTest(); + return; + } + err = TestStep4eThReadsOptionalAttributeFabricSceneInfoInAttributeListGlobalAttribute65531_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 5: TH reads from the DUT the EventList attribute\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : Step 6a:TH reads from the DUT the AcceptedCommandList attribute\n"); + if (ShouldSkip("S.S")) { + NextTest(); + return; + } + err = TestStep6aTHReadsFromTheDutTheAcceptedCommandListAttribute_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : Step 6b: TH reads optional command(EnhancedAddSceneResponse) AcceptedCommandList (global attribute 65529)\n"); + if (ShouldSkip("S.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep6bThReadsOptionalCommandEnhancedAddSceneResponseAcceptedCommandListGlobalAttribute65529_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6c: TH reads optional command(EnhancedViewSceneResponse) AcceptedCommandList (global attribute 65529)\n"); + if (ShouldSkip("S.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep6cThReadsOptionalCommandEnhancedViewSceneResponseAcceptedCommandListGlobalAttribute65529_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6d: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529)\n"); + if (ShouldSkip("S.S.C42.Rsp")) { + NextTest(); + return; + } + err = TestStep6dThReadsOptionalCommandCopySceneResponseAcceptedCommandListGlobalAttribute65529_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 7a: TH reads from the DUT the GeneratedCommandList attribute\n"); + err = TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Step 7b: TH reads optional command(EnhancedAddSceneResponse) in GeneratedCommandList (global attribute 65528)\n"); + if (ShouldSkip("S.S.C40.Rsp")) { + NextTest(); + return; + } + err = TestStep7bThReadsOptionalCommandEnhancedAddSceneResponseInGeneratedCommandListGlobalAttribute65528_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : Step 7c: TH reads optional command(EnhancedViewSceneResponse) in GeneratedCommandList (global attribute 65528)\n"); + if (ShouldSkip("S.S.C41.Rsp")) { + NextTest(); + return; + } + err = TestStep7cThReadsOptionalCommandEnhancedViewSceneResponseInGeneratedCommandListGlobalAttribute65528_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : Step 7d: TH reads optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528)\n"); + if (ShouldSkip("S.S.C42.Rsp")) { + NextTest(); + return; + } + err = TestStep7dThReadsOptionalCommandCopySceneResponseInGeneratedCommandListGlobalAttribute65528_23(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 24; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 5U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFeatureMapNameSupportBitGlobalAttribute65532_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532): Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFeatureMapNameSupportBitGlobalAttribute65532_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532): Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads FeatureMap NameSupport bit (global attribute 65532): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsFeatureMapExplicitBitGlobalAttribute65532_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532): Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bThReadsFeatureMapExplicitBitGlobalAttribute65532_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532): Error: %@", err); + } else { + NSLog(@"Step 3b: TH reads FeatureMap Explicit bit (global attribute 65532): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsFeatureMapTableSizeBitGlobalAttribute65532_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532): Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cThReadsFeatureMapTableSizeBitGlobalAttribute65532_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532): Error: %@", err); + } else { + NSLog(@"Step 3c: TH reads FeatureMap TableSize bit (global attribute 65532): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThReadsFeatureMapFabricSceneBitGlobalAttribute65532_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532): Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dThReadsFeatureMapFabricSceneBitGlobalAttribute65532_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532): Error: %@", err); + } else { + NSLog(@"Step 3d: TH reads FeatureMap FabricScene bit (global attribute 65532): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsOptionalAttributesSceneCountCurrentSceneCurrentGroupSceneValidInAttributeListGlobalAttribute65531_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads optional attributes(SceneCount, CurrentScene, CurrentGroup, SceneValid) in AttributeList (global attribute 65531): Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads optional attributes(SceneCount, CurrentScene, CurrentGroup, SceneValid) in AttributeList (global attribute 65531): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsOptinnalAttributeLastConfiguredByInAttributeListGlobalAttribute65531_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads optinnal attribute(LastConfiguredBy) in AttributeList (global attribute 65531): Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads optinnal attribute(LastConfiguredBy) in AttributeList (global attribute 65531): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsOptionnalAttributeSceneTableSizeInAttributeListGlobalAttribute65531_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads optionnal attribute(SceneTableSize) in AttributeList (global attribute 65531): Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads optionnal attribute(SceneTableSize) in AttributeList (global attribute 65531): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsOptionalAttributeFabricSceneInfoInAttributeListGlobalAttribute65531_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads optional attribute(FabricSceneInfo) in AttributeList (global attribute 65531): Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads optional attribute(FabricSceneInfo) in AttributeList (global attribute 65531): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 7UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aTHReadsFromTheDutTheAcceptedCommandListAttribute_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a:TH reads from the DUT the AcceptedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 6a:TH reads from the DUT the AcceptedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsOptionalCommandEnhancedAddSceneResponseAcceptedCommandListGlobalAttribute65529_17() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads optional command(EnhancedAddSceneResponse) AcceptedCommandList (global attribute 65529): Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads optional command(EnhancedAddSceneResponse) AcceptedCommandList (global attribute 65529): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 64UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cThReadsOptionalCommandEnhancedViewSceneResponseAcceptedCommandListGlobalAttribute65529_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: TH reads optional command(EnhancedViewSceneResponse) AcceptedCommandList (global attribute 65529): Error: %@", err); + } else { + NSLog(@"Step 6c: TH reads optional command(EnhancedViewSceneResponse) AcceptedCommandList (global attribute 65529): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 65UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6dThReadsOptionalCommandCopySceneResponseAcceptedCommandListGlobalAttribute65529_19() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529): Error: %@", err); + } else { + NSLog(@"Step 6d: TH reads optional command(CopySceneResponse) AcceptedCommandList (global attribute 65529): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 66UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7aThReadsFromTheDutTheGeneratedCommandListAttribute_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Error: %@", err); + } else { + NSLog(@"Step 7a: TH reads from the DUT the GeneratedCommandList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 6UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7bThReadsOptionalCommandEnhancedAddSceneResponseInGeneratedCommandListGlobalAttribute65528_21() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7b: TH reads optional command(EnhancedAddSceneResponse) in GeneratedCommandList (global attribute 65528): Error: %@", err); + } else { + NSLog(@"Step 7b: TH reads optional command(EnhancedAddSceneResponse) in GeneratedCommandList (global attribute 65528): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 64UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7cThReadsOptionalCommandEnhancedViewSceneResponseInGeneratedCommandListGlobalAttribute65528_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7c: TH reads optional command(EnhancedViewSceneResponse) in GeneratedCommandList (global attribute 65528): Error: %@", err); + } else { + NSLog(@"Step 7c: TH reads optional command(EnhancedViewSceneResponse) in GeneratedCommandList (global attribute 65528): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 65UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7dThReadsOptionalCommandCopySceneResponseInGeneratedCommandListGlobalAttribute65528_23() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7d: TH reads optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528): Error: %@", err); + } else { + NSLog(@"Step 7d: TH reads optional command(CopySceneResponse) in GeneratedCommandList (global attribute 65528): Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 66UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_S_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_S_2_1() + : TestCommandBridge("Test_TC_S_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_S_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the SceneCount attribute\n"); + if (ShouldSkip("S.S.A0000 && (!S.S.F03)")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheSceneCountAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the CurrentScene attribute\n"); + if (ShouldSkip("S.S.A0001 && (!S.S.F03)")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheCurrentSceneAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the CurrentGroup attribute\n"); + if (ShouldSkip("S.S.A0002 && (!S.S.F03)")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheCurrentGroupAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the SceneValid attribute\n"); + if (ShouldSkip("S.S.A0003 && (!S.S.F03)")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutTheSceneValidAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the NameSupport attribute\n"); + if (ShouldSkip("S.S.A0004 && S.S.F00")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheNameSupportAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 6: TH reads from the DUT the NameSupport attribute\n"); + if (ShouldSkip("S.S.A0004 && (!S.S.F00)")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheNameSupportAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 7: TH reads from the DUT the LastConfiguredBy attribute\n"); + if (ShouldSkip("S.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheLastConfiguredByAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 8: TH reads from the DUT the SceneTableSize attribute\n"); + if (ShouldSkip("S.S.A0006")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutTheSceneTableSizeAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 9: TH reads from the DUT the FabricSceneInfo attribute\n"); + if (ShouldSkip("S.S.A0007")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheFabricSceneInfoAttribute_9(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 10; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheSceneCountAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSceneCountWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the SceneCount attribute: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the SceneCount attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("sceneCount", "int8u", "int8u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheCurrentSceneAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentSceneWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the CurrentScene attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the CurrentScene attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentScene", "int8u", "int8u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheCurrentGroupAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentGroupWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the CurrentGroup attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the CurrentGroup attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("currentGroup", "group_id", "group_id")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheSceneValidAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSceneValidWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the SceneValid attribute: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the SceneValid attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("sceneValid", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheNameSupportAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNameSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the NameSupport attribute: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the NameSupport attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NameSupport", actualValue, 128U)); + } + + VerifyOrReturn(CheckConstraintType("nameSupport", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheNameSupportAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeNameSupportWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the NameSupport attribute: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the NameSupport attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("NameSupport", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintType("nameSupport", "bitmap8", "bitmap8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheLastConfiguredByAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLastConfiguredByWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the LastConfiguredBy attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the LastConfiguredBy attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("lastConfiguredBy", "node_id", "node_id")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutTheSceneTableSizeAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeSceneTableSizeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the SceneTableSize attribute: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the SceneTableSize attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("sceneTableSize", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheFabricSceneInfoAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRReadParams alloc] init]; + params.filterByFabric = true; + [cluster readAttributeFabricSceneInfoWithParams:params completion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the FabricSceneInfo attribute: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the FabricSceneInfo attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("fabricSceneInfo", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_S_2_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_S_2_4() + : TestCommandBridge("Test_TC_S_2_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("G1", 0, UINT16_MAX, &mG1); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_S_2_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_S_2_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_S_2_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002\n"); + err = TestStep0aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutUsingAKeyThatIsPreInstalledOnTheThGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a12GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime022200005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime122200017EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime22220002_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1\n"); + err = TestStep0bThBindsGroupId0x0001WithGroupKeySetID0x01a1InTheGroupKeyMapAttributeListOnGroupKeyManagementClusterByWritingTheGroupKeyMapAttributeWithOneEntryAsFollowsListItem11FabricIndex12GroupId0x00013GroupKeySetId0x01a1_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 0c: TH sends a RemoveAllGroups command to DUT.\n"); + if (ShouldSkip("G.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep0cThSendsARemoveAllGroupsCommandToDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.\n"); + if (ShouldSkip("G.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep2aThSendsAAddGroupCommandToDutWithTheGroupIDFieldSetToG1_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.\n"); + if (ShouldSkip("S.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep2bThSendsARemoveAllScenesCommandToDutWithTheGroupIDFieldSetToG1_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x0014 (20s) and no extension field sets.\n"); + if (ShouldSkip("S.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep3ThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x001420sAndNoExtensionFieldSets_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.\n"); + if (ShouldSkip("S.S.C04.Rsp")) { + NextTest(); + return; + } + err = TestStep4bThSendsAStoreSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Wait 1s for level to change\n"); + err = TestWait1sForLevelToChange_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter1sWhichIsDifferentFromAc1_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.\n"); + if (ShouldSkip("S.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep5bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldOmitted_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Wait 20s\n"); + err = TestWait20s_15(); + break; + case 16: + ChipLogProgress(chipTool, " ***** Test Step 16 : TH confirm the DUT reached AC1 (on level control cluster) after 20s\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestThConfirmTheDutReachedAc1OnLevelControlClusterAfter20s_16(); + break; + case 17: + ChipLogProgress(chipTool, " ***** Test Step 17 : DUT transitions to AC1 over 20s.\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestDutTransitionsToAc1Over20s_17(); + break; + case 18: + ChipLogProgress(chipTool, " ***** Test Step 18 : Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_18(); + break; + case 19: + ChipLogProgress(chipTool, " ***** Test Step 19 : Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP && PICS_SC_RECALL_SCENE_TRANSITION_TIME")) { + NextTest(); + return; + } + err = TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_19(); + break; + case 20: + ChipLogProgress(chipTool, " ***** Test Step 20 : Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 0x0032 (5s).\n"); + if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME")) { + NextTest(); + return; + } + err = TestStep6bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetTo0x00325s_20(); + break; + case 21: + ChipLogProgress(chipTool, " ***** Test Step 21 : Wait 5s\n"); + if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME")) { + NextTest(); + return; + } + err = TestWait5s_21(); + break; + case 22: + ChipLogProgress(chipTool, " ***** Test Step 22 : TH confirm the DUT reached AC2 (on level control cluster) after 5s\n"); + if (ShouldSkip("S.S.C05.Rsp && PICS_SC_RECALL_SCENE_TRANSITION_TIME && PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter5s_22(); + break; + case 23: + ChipLogProgress(chipTool, " ***** Test Step 23 : DUT transitions to AC1 over 5.\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestDutTransitionsToAc1Over5_23(); + break; + case 24: + ChipLogProgress(chipTool, " ***** Test Step 24 : Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); + if (ShouldSkip("PICS_SDK_CI_ONLY")) { + NextTest(); + return; + } + err = TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_24(); + break; + case 25: + ChipLogProgress(chipTool, " ***** Test Step 25 : Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.\n"); + if (ShouldSkip("PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_25(); + break; + case 26: + ChipLogProgress(chipTool, " ***** Test Step 26 : Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).\n"); + if (ShouldSkip("S.S.C05.Rsp")) { + NextTest(); + return; + } + err = TestStep7bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetToNullNoTransitionTimeOverride_26(); + break; + case 27: + ChipLogProgress(chipTool, " ***** Test Step 27 : Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1\n"); + err = TestStep8ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a1_27(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 16: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 17: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 18: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 19: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 20: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 21: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 22: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 23: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 24: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 25: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 26: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 27: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 28; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mG1; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep0aThSendsKeySetWriteCommandInTheGroupKeyManagementClusterToDutUsingAKeyThatIsPreInstalledOnTheThGroupKeySetFieldsAreAsFollows1GroupKeySetID0x01a12GroupKeySecurityPolicyTrustFirst03EpochKey0D0d1d2d3d4d5d6d7d8d9dadbdcdddedf4EpochStartTime022200005EpochKey1D1d1d2d3d4d5d6d7d8d9dadbdcdddedf6EpochStartTime122200017EpochKey2D2d1d2d3d4d5d6d7d8d9dadbdcdddedf8EpochStartTime22220002_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetWriteParams alloc] init]; + params.groupKeySet = [[MTRGroupKeyManagementClusterGroupKeySetStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySetID = + [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).groupKeySecurityPolicy = + [NSNumber numberWithUnsignedChar:0U]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey0 = + [[NSData alloc] initWithBytes:"\240\241\242\243\244\245\246\247\250\251\252\253\254\255\256\257" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime0 = + [NSNumber numberWithUnsignedLongLong:1110000ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey1 = + [[NSData alloc] initWithBytes:"\260\261\262\263\264\265\266\267\270\271\272\273\274\275\276\277" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime1 = + [NSNumber numberWithUnsignedLongLong:1110001ULL]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochKey2 = + [[NSData alloc] initWithBytes:"\300\301\302\303\304\305\306\307\310\311\312\313\314\315\316\317" length:16]; + ((MTRGroupKeyManagementClusterGroupKeySetStruct *) params.groupKeySet).epochStartTime2 = + [NSNumber numberWithUnsignedLongLong:1110002ULL]; + + [cluster keySetWriteWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002: Error: %@", err); + } else { + NSLog(@"Step 0a: TH sends KeySetWrite command in the GroupKeyManagement cluster to DUT using a key that is pre-installed on the TH. GroupKeySet fields are as follows: 1)GroupKeySetID: 0x01a1 2)GroupKeySecurityPolicy: TrustFirst (0) 3)EpochKey0: d0d1d2d3d4d5d6d7d8d9dadbdcdddedf 4)EpochStartTime0: 2220000 5)EpochKey1: d1d1d2d3d4d5d6d7d8d9dadbdcdddedf 6)EpochStartTime1: 2220001 7)EpochKey2: d2d1d2d3d4d5d6d7d8d9dadbdcdddedf 8)EpochStartTime2: 2220002: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0bThBindsGroupId0x0001WithGroupKeySetID0x01a1InTheGroupKeyMapAttributeListOnGroupKeyManagementClusterByWritingTheGroupKeyMapAttributeWithOneEntryAsFollowsListItem11FabricIndex12GroupId0x00013GroupKeySetId0x01a1_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + id groupKeyMapArgument; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + temp_0[0] = [[MTRGroupKeyManagementClusterGroupKeyMapStruct alloc] init]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupId = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).groupKeySetID = + [NSNumber numberWithUnsignedShort:417U]; + ((MTRGroupKeyManagementClusterGroupKeyMapStruct *) temp_0[0]).fabricIndex = + [NSNumber numberWithUnsignedChar:1U]; + + groupKeyMapArgument = temp_0; + } + [cluster writeAttributeGroupKeyMapWithValue:groupKeyMapArgument completion:^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1: Error: %@", err); + } else { + NSLog(@"Step 0b: TH binds GroupId 0x0001 with GroupKeySetID 0x01a1 in the GroupKeyMap attribute list on GroupKeyManagement cluster by writing the GroupKeyMap attribute with one entry as follows: List item 1: 1)FabricIndex: 1 2)GroupId: 0x0001 3)GroupKeySetId: 0x01a1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep0cThSendsARemoveAllGroupsCommandToDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster removeAllGroupsWithCompletion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 0c: TH sends a RemoveAllGroups command to DUT.: Error: %@", err); + } else { + NSLog(@"Step 0c: TH sends a RemoveAllGroups command to DUT.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2aThSendsAAddGroupCommandToDutWithTheGroupIDFieldSetToG1_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroups alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupsClusterAddGroupParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.groupName = @"Group1"; + [cluster addGroupWithParams:params completion: + ^(MTRGroupsClusterAddGroupResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.: Error: %@", err); + } else { + NSLog(@"Step 2a: TH sends a AddGroup command to DUT with the GroupID field set to G1.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep2bThSendsARemoveAllScenesCommandToDutWithTheGroupIDFieldSetToG1_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterRemoveAllScenesParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + [cluster removeAllScenesWithParams:params completion: + ^(MTRScenesManagementClusterRemoveAllScenesResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.: Error: %@", err); + } else { + NSLog(@"Step 2b: TH sends a RemoveAllScenes command to DUT with the GroupID field set to G1.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThSendsAAddSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01TheTransitionTimeFieldSetTo0x001420sAndNoExtensionFieldSets_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterAddSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:20U]; + params.sceneName = @"Scene1"; + { + NSMutableArray * temp_0 = [[NSMutableArray alloc] init]; + params.extensionFieldSets = temp_0; + } + [cluster addSceneWithParams:params completion: + ^(MTRScenesManagementClusterAddSceneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x0014 (20s) and no extension field sets.: Error: %@", err); + } else { + NSLog(@"Step 3: TH sends a AddScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01, the TransitionTime field set to 0x0014 (20s) and no extension field sets.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + { + id actualValue = values.sceneID; + VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:100U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithOnOffWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH configures AC1 on DUT for all implemented application clusters supporting scenes.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThConfiguresAc1OnDutForAllImplementedApplicationClustersSupportingScenes_8() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please configure AC1 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep4bThSendsAStoreSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterStoreSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + [cluster storeSceneWithParams:params completion: + ^(MTRScenesManagementClusterStoreSceneResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.: Error: %@", err); + } else { + NSLog(@"Step 4b: TH sends a StoreScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.status; + VerifyOrReturn(CheckValue("Status", actualValue, 0U)); + } + + { + id actualValue = values.groupID; + VerifyOrReturn(CheckValue("GroupID", actualValue, mG1.HasValue() ? mG1.Value() : 1U)); + } + + { + id actualValue = values.sceneID; + VerifyOrReturn(CheckValue("SceneID", actualValue, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:200U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithOnOffWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); + } else { + NSLog(@"Step 5a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait1sForLevelToChange_11() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 1000UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter1sWhichIsDifferentFromAc1_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1: Error: %@", err); + } else { + NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 1s, which is different from AC1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 200U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_13() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep5bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1AndTheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldOmitted_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + [cluster recallSceneWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.: Error: %@", err); + } else { + NSLog(@"Step 5b: TH sends a RecallScene command to DUT with the GroupID field set to G1 and the SceneID field set to 0x01 and the TransitionTime field omitted.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait20s_15() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 20500UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestThConfirmTheDutReachedAc1OnLevelControlClusterAfter20s_16() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH confirm the DUT reached AC1 (on level control cluster) after 20s: Error: %@", err); + } else { + NSLog(@"TH confirm the DUT reached AC1 (on level control cluster) after 20s: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestDutTransitionsToAc1Over20s_17() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please confirm that transition to AC1 was made over 20sgarbage: not in length on purpose", 55); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_18() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:200U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithOnOffWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); + } else { + NSLog(@"Step 6a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_19() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep6bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetTo0x00325s_20() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:50U]; + [cluster recallSceneWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 0x0032 (5s).: Error: %@", err); + } else { + NSLog(@"Step 6b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to 0x0032 (5s).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestWait5s_21() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForMs::Type value; + value.ms = 5500UL; + return WaitForMs("alpha", value); + } + + CHIP_ERROR TestThConfirmTheDutReachedAc2OnLevelControlClusterAfter5s_22() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentLevelWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 5s: Error: %@", err); + } else { + NSLog(@"TH confirm the DUT reached AC2 (on level control cluster) after 5s: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNonNull("CurrentLevel", actualValue)); + VerifyOrReturn(CheckValue("CurrentLevel", actualValue, 100U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestDutTransitionsToAc1Over5_23() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please confirm that transition to AC1 was made over 5sgarbage: not in length on purpose", 54); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_24() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterLevelControl alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRLevelControlClusterMoveToLevelWithOnOffParams alloc] init]; + params.level = + [NSNumber numberWithUnsignedChar:200U]; + params.transitionTime = + [NSNumber numberWithUnsignedShort:0U]; + params.optionsMask = + [NSNumber numberWithUnsignedChar:0U]; + params.optionsOverride = + [NSNumber numberWithUnsignedChar:0U]; + [cluster moveToLevelWithOnOffWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Error: %@", err); + } else { + NSLog(@"Step 7a: TH configures AC2 on DUT for all implemented application clusters supporting scenes.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7aThConfiguresAc2OnDutForAllImplementedApplicationClustersSupportingScenes_25() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please configure AC2 on DUT and enter 'y' after the configuration is completegarbage: not in length on purpose", 77); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep7bThSendsARecallSceneCommandToDutWithTheGroupIDFieldSetToG1TheSceneIDFieldSetTo0x01AndTheTransitionTimeFieldSetToNullNoTransitionTimeOverride_26() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterScenesManagement alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRScenesManagementClusterRecallSceneParams alloc] init]; + params.groupID = mG1.HasValue() ? [NSNumber numberWithUnsignedShort:mG1.Value()] : [NSNumber numberWithUnsignedShort:1U]; + params.sceneID = + [NSNumber numberWithUnsignedChar:1U]; + params.transitionTime = nil; + [cluster recallSceneWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).: Error: %@", err); + } else { + NSLog(@"Step 7b: TH sends a RecallScene command to DUT with the GroupID field set to G1, the SceneID field set to 0x01 and the TransitionTime field set to null (no transition time override).: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThRemovesTheGroupKeySetThatWasAddedBySendingAKeySetRemoveCommandToTheGroupKeyManagementClusterWithTheGroupKeySetIDFieldSetTo0x01a1_27() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterGroupKeyManagement alloc] initWithDevice:device endpointID:@(0) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + __auto_type * params = [[MTRGroupKeyManagementClusterKeySetRemoveParams alloc] init]; + params.groupKeySetID = + [NSNumber numberWithUnsignedShort:417U]; + [cluster keySetRemoveWithParams:params completion: + ^(NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1: Error: %@", err); + } else { + NSLog(@"Step 8: TH removes the Group key set that was added by sending a KeySetRemove command to the GroupKeyManagement cluster with the GroupKeySetID field set to 0x01a1: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestActivatedCarbonFilterMonitoring : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestActivatedCarbonFilterMonitoring() + : TestCommandBridge("TestActivatedCarbonFilterMonitoring") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestActivatedCarbonFilterMonitoring() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestActivatedCarbonFilterMonitoring\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestActivatedCarbonFilterMonitoring\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Validate the feature map\n"); + err = TestValidateTheFeatureMap_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read Replacement Product List\n"); + err = TestReadReplacementProductList_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestValidateTheFeatureMap_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Validate the feature map: Error: %@", err); + } else { + NSLog(@"Validate the feature map: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadReplacementProductList_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Replacement Product List: Error: %@", err); + } else { + NSLog(@"Read Replacement Product List: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ReplacementProductList", [actualValue count], static_cast(5))); + VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierType, 0U)); + VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierValue, @"111112222233")); + VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierType, 1U)); + VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierValue, @"gtin8xxx")); + VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierType, 2U)); + VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierValue, @"4444455555666")); + VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierType, 3U)); + VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierValue, @"gtin14xxxxxxxx")); + VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierType, 4U)); + VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRActivatedCarbonFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierValue, @"oem20xxxxxxxxxxxxxxx")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class TestHepaFilterMonitoring : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + TestHepaFilterMonitoring() + : TestCommandBridge("TestHepaFilterMonitoring") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~TestHepaFilterMonitoring() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: TestHepaFilterMonitoring\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: TestHepaFilterMonitoring\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Wait for the commissioned device to be retrieved\n"); + err = TestWaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Validate the feature map\n"); + err = TestValidateTheFeatureMap_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Read Replacement Product List\n"); + err = TestReadReplacementProductList_2(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 3; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestWaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestValidateTheFeatureMap_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Validate the feature map: Error: %@", err); + } else { + NSLog(@"Validate the feature map: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestReadReplacementProductList_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Read Replacement Product List: Error: %@", err); + } else { + NSLog(@"Read Replacement Product List: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ReplacementProductList", [actualValue count], static_cast(5))); + VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierType, 0U)); + VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[0]).productIdentifierValue, @"111112222233")); + VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierType, 1U)); + VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[1]).productIdentifierValue, @"gtin8xxx")); + VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierType, 2U)); + VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[2]).productIdentifierValue, @"4444455555666")); + VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierType, 3U)); + VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[3]).productIdentifierValue, @"gtin14xxxxxxxx")); + VerifyOrReturn(CheckValue("ProductIdentifierType", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierType, 4U)); + VerifyOrReturn(CheckValueAsString("ProductIdentifierValue", ((MTRHEPAFilterMonitoringClusterReplacementProductStruct *) actualValue[4]).productIdentifierValue, @"oem20xxxxxxxxxxxxxxx")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ACFREMON_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ACFREMON_1_1() + : TestCommandBridge("Test_TC_ACFREMON_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ACFREMON_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACFREMON_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACFREMON_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip("!ACFREMON.S.F00 && !ACFREMON.S.F01 && !ACFREMON.S.F02")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("ACFREMON.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenACFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("ACFREMON.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenACFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given ACFREMON.S.F01(ReplacementProductList) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("ACFREMON.S.F02")) { + NextTest(); + return; + } + err = TestStep3dGivenACFREMONSF01ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4a: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsFromTheDutTheAttributeListAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList\n"); + if (ShouldSkip("ACFREMON.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheFeatureDependentACFREMONSF00AttributeInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList\n"); + if (ShouldSkip("ACFREMON.S.A0003")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorAcfremonsa0003InAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList\n"); + if (ShouldSkip("ACFREMON.S.A0004")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheOptionalAttributeLastChangedTimeAcfremonsa0004InAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList\n"); + if (ShouldSkip("ACFREMON.S.F02")) { + NextTest(); + return; + } + err = TestStep4eThReadsTheOptionalAttributeReplacementProductListAcfremonsf02InAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads EventList attribute from DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6a: TH reads from the DUT the AcceptedCommandList attribute.\n"); + if (ShouldSkip("!ACFREMON.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList\n"); + if (ShouldSkip("ACFREMON.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6bThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 16; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenACFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given ACFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenACFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given ACFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenACFREMONSF01ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given ACFREMON.S.F01(ReplacementProductList) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given ACFREMON.S.F01(ReplacementProductList) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsFromTheDutTheAttributeListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheFeatureDependentACFREMONSF00AttributeInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the feature dependent(ACFREMON.S.F00) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorAcfremonsa0003InAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (ACFREMON.S.A0003) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheOptionalAttributeLastChangedTimeAcfremonsa0004InAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (ACFREMON.S.A0004) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsTheOptionalAttributeReplacementProductListAcfremonsf02InAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (ACFREMON.S.F02) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aThReadsFromTheDutTheAcceptedCommandListAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6a: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6b: TH reads the optional command (ResetCondition) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_ACFREMON_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_ACFREMON_2_1() + : TestCommandBridge("Test_TC_ACFREMON_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_ACFREMON_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_ACFREMON_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_ACFREMON_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the Condition attribute.\n"); + if (ShouldSkip("ACFREMON.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheConditionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the DegradationDirection attribute..\n"); + if (ShouldSkip("ACFREMON.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the ChangeIndication attribute.\n"); + if (ShouldSkip("ACFREMON.S.A0002")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the InPlaceIndicator attribute\n"); + if (ShouldSkip("ACFREMON.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the LastChangedTime attribute\n"); + if (ShouldSkip("ACFREMON.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the ReplacementProductList attribute\n"); + if (ShouldSkip("ACFREMON.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 7; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheConditionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConditionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("condition", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("condition", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("condition", [value unsignedCharValue], 100U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDegradationDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("degradationDirection", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("degradationDirection", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("degradationDirection", [value unsignedCharValue], 1U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeChangeIndicationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("changeIndication", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("changeIndication", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("changeIndication", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInPlaceIndicatorWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("inPlaceIndicator", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLastChangedTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("lastChangedTime", "epoch_s", "epoch_s")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterActivatedCarbonFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("replacementProductList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_HEPAFREMON_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_HEPAFREMON_1_1() + : TestCommandBridge("Test_TC_HEPAFREMON_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_HEPAFREMON_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_HEPAFREMON_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_HEPAFREMON_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the ClusterRevision attribute.\n"); + err = TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3a: TH reads from the DUT the FeatureMap attribute.\n"); + if (ShouldSkip("!HEPAFREMON.S.F00 && !HEPAFREMON.S.F01 && !HEPAFREMON.S.F02")) { + NextTest(); + return; + } + err = TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("HEPAFREMON.S.F00")) { + NextTest(); + return; + } + err = TestStep3bGivenHEPAFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("HEPAFREMON.S.F01")) { + NextTest(); + return; + } + err = TestStep3cGivenHEPAFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set\n"); + if (ShouldSkip("HEPAFREMON.S.F02")) { + NextTest(); + return; + } + err = TestStep3dGivenHEPAFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 4: TH reads from the DUT the AttributeList attribute.\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheAttributeListAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList\n"); + if (ShouldSkip("HEPAFREMON.S.F00")) { + NextTest(); + return; + } + err = TestStep4bThReadsTheFeatureDependentHEPAFREMONSF00AttributeInAttributeList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList\n"); + if (ShouldSkip("HEPAFREMON.S.A0003")) { + NextTest(); + return; + } + err = TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorHepafremonsa0003InAttributeList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList\n"); + if (ShouldSkip("HEPAFREMON.S.A0004")) { + NextTest(); + return; + } + err = TestStep4dThReadsTheOptionalAttributeLastChangedTimeHepafremonsa0004InAttributeList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList\n"); + if (ShouldSkip("HEPAFREMON.S.F02")) { + NextTest(); + return; + } + err = TestStep4eThReadsTheOptionalAttributeReplacementProductListHepafremonsf02InAttributeList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 5: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 6: TH reads from the DUT the AcceptedCommandList attribute.\n"); + if (ShouldSkip("!HEPAFREMON.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList\n"); + if (ShouldSkip("HEPAFREMON.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6ThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 7: TH reads from the DUT the GeneratedCommandList attribute.\n"); + err = TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 16; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheClusterRevisionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the ClusterRevision attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3aThReadsFromTheDutTheFeatureMapAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Error: %@", err); + } else { + NSLog(@"Step 3a: TH reads from the DUT the FeatureMap attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3bGivenHEPAFREMONSF00ConditionEnsureFeaturemapHasTheCorrectBitSet_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3b: Given HEPAFREMON.S.F00(Condition) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3cGivenHEPAFREMONSF01WarningEnsureFeaturemapHasTheCorrectBitSet_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3c: Given HEPAFREMON.S.F01(Warning) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3dGivenHEPAFREMONSF02ReplacementProductListEnsureFeaturemapHasTheCorrectBitSet_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Error: %@", err); + } else { + NSLog(@"Step 3d: Given HEPAFREMON.S.F02(ReplacementProductList) ensure featuremap has the correct bit set: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheAttributeListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the AttributeList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsTheFeatureDependentHEPAFREMONSF00AttributeInAttributeList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads the feature dependent(HEPAFREMON.S.F00) attribute in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4cThReadsTheOptionalAttributeInPlaceIndicatorHepafremonsa0003InAttributeList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4c: TH reads the optional attribute InPlaceIndicator (HEPAFREMON.S.A0003) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4dThReadsTheOptionalAttributeLastChangedTimeHepafremonsa0004InAttributeList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4d: TH reads the optional attribute LastChangedTime (HEPAFREMON.S.A0004) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4eThReadsTheOptionalAttributeReplacementProductListHepafremonsf02InAttributeList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList: Error: %@", err); + } else { + NSLog(@"Step 4e: TH reads the optional attribute ReplacementProductList (HEPAFREMON.S.F02) in AttributeList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheAcceptedCommandListAttribute_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the AcceptedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("AcceptedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsTheOptionalCommandResetConditionInAcceptedCommandList_14() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads the optional command (ResetCondition) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheGeneratedCommandListAttribute_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the GeneratedCommandList attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_HEPAFREMON_2_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_HEPAFREMON_2_1() + : TestCommandBridge("Test_TC_HEPAFREMON_2_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_HEPAFREMON_2_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_HEPAFREMON_2_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_HEPAFREMON_2_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH (can be skipped if done in a preceding test).\n"); + err = TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads from the DUT the Condition attribute.\n"); + if (ShouldSkip("HEPAFREMON.S.A0000")) { + NextTest(); + return; + } + err = TestStep2ThReadsFromTheDutTheConditionAttribute_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the DegradationDirection attribute..\n"); + if (ShouldSkip("HEPAFREMON.S.A0001")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the ChangeIndication attribute.\n"); + if (ShouldSkip("HEPAFREMON.S.A0002")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the InPlaceIndicator attribute\n"); + if (ShouldSkip("HEPAFREMON.S.A0003")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the LastChangedTime attribute\n"); + if (ShouldSkip("HEPAFREMON.S.A0004")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the ReplacementProductList attribute\n"); + if (ShouldSkip("HEPAFREMON.S.A0005")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 7; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToThCanBeSkippedIfDoneInAPrecedingTest_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsFromTheDutTheConditionAttribute_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeConditionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads from the DUT the Condition attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("condition", "percent", "percent")); + VerifyOrReturn(CheckConstraintMinValue("condition", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("condition", [value unsignedCharValue], 100U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheDegradationDirectionAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeDegradationDirectionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the DegradationDirection attribute..: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("degradationDirection", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("degradationDirection", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("degradationDirection", [value unsignedCharValue], 1U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThReadsFromTheDutTheChangeIndicationAttribute_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeChangeIndicationWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the ChangeIndication attribute.: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("changeIndication", "enum8", "enum8")); + VerifyOrReturn(CheckConstraintMinValue("changeIndication", [value unsignedCharValue], 0U)); + VerifyOrReturn(CheckConstraintMaxValue("changeIndication", [value unsignedCharValue], 2U)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheInPlaceIndicatorAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeInPlaceIndicatorWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the InPlaceIndicator attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("inPlaceIndicator", "boolean", "boolean")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheLastChangedTimeAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeLastChangedTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the LastChangedTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + if (value != nil) { + + VerifyOrReturn(CheckConstraintType("lastChangedTime", "epoch_s", "epoch_s")); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheReplacementProductListAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterHEPAFilterMonitoring alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeReplacementProductListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the ReplacementProductList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("replacementProductList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +#endif // CONFIG_ENABLE_YAML_TESTS + +void registerCommandsTests(Commands & commands) +{ + const char * clusterName = "Tests"; + + commands_list clusterCommands = { +#if CONFIG_ENABLE_YAML_TESTS + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), + make_unique(), +#endif // CONFIG_ENABLE_YAML_TESTS + }; + + commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for running YAML tests."); +} From 28cab2cc77d29784633f1b1c0213a8e2c20344a7 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Fri, 19 Jan 2024 16:09:28 -0300 Subject: [PATCH 31/89] Fix opstate pics --- src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml index 0278ff085b201c..79b99541718714 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -33,7 +33,7 @@ tests: "Step 1: Commission DUT to TH (can be skipped if done in a preceding test)" verification: | - OVENOPSTATE.S.C01 && OVENOPSTATE.S.C02 + disabled: true - label: From d67d9e593b86612e108cd8072f3f78af542ade78 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Fri, 19 Jan 2024 17:12:43 -0300 Subject: [PATCH 32/89] Updated commands --- .../zap-generated/test/Commands.h | 816 ++++++++++++++++++ 1 file changed, 816 insertions(+) diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 5a7ad491e1a228..637cc1ae5b84f2 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -183,6 +183,9 @@ class TestList : public Command { printf("Test_TC_OO_2_2\n"); printf("Test_TC_OO_2_4\n"); printf("Test_TC_OPSTATE_1_1\n"); + printf("Test_TC_OVENOPSTATE_1_1\n"); + printf("Test_TC_OVENOPSTATE_2_2\n"); + printf("Test_TC_OVENOPSTATE_2_4\n"); printf("Test_TC_PS_1_1\n"); printf("Test_TC_PS_2_1\n"); printf("Test_TC_PRS_1_1\n"); @@ -89094,6 +89097,816 @@ class Test_TC_OPSTATE_1_1 : public TestCommandBridge { } }; +class Test_TC_OVENOPSTATE_1_1 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OVENOPSTATE_1_1() + : TestCommandBridge("Test_TC_OVENOPSTATE_1_1") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OVENOPSTATE_1_1() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_1_1\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_1_1\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Wait for the commissioned device to be retrieved\n"); + err = TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: TH reads the ClusterRevision attribute from the DUT\n"); + err = TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads the FeatureMap attribute from the DUT\n"); + err = TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 4a: TH reads the AttributeList attribute from the DUT\n"); + if (ShouldSkip("!PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + err = TestStep4aThReadsTheAttributeListAttributeFromTheDut_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT\n"); + if (ShouldSkip("OVENOPSTATE.S.A0002")) { + NextTest(); + return; + } + err = TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 5a: TH reads from the DUT the EventList attribute.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED")) { + NextTest(); + return; + } + NextTest(); + return; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 5b: TH reads from the DUT the optional event(OperationCompletion) in EventList.\n"); + if (ShouldSkip("PICS_EVENT_LIST_ENABLED && OVENOPSTATE.S.E01")) { + NextTest(); + return; + } + NextTest(); + return; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 6a: Read the optional command(Start) in AcceptedCommandList\n"); + if (ShouldSkip("OVENOPSTATE.S.C02.Rsp")) { + NextTest(); + return; + } + err = TestStep6aReadTheOptionalCommandStartInAcceptedCommandList_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 6b: Read the optional command(Stop) in AcceptedCommandList\n"); + if (ShouldSkip("OVENOPSTATE.S.C01.Rsp")) { + NextTest(); + return; + } + err = TestStep6bReadTheOptionalCommandStopInAcceptedCommandList_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 6c: Read the optional command(Pause) in AcceptedCommandList\n"); + if (ShouldSkip("OVENOPSTATE.S.C00.Rsp")) { + NextTest(); + return; + } + err = TestStep6cReadTheOptionalCommandPauseInAcceptedCommandList_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 6d: Read the optional command(Resume) in AcceptedCommandList\n"); + if (ShouldSkip("OVENOPSTATE.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep6dReadTheOptionalCommandResumeInAcceptedCommandList_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 7: Read the global attribute: GeneratedCommandList\n"); + if (ShouldSkip("!OVENOPSTATE.S.C00.Rsp && !OVENOPSTATE.S.C01.Rsp && !OVENOPSTATE.S.C02.Rsp && !OVENOPSTATE.S.C03.Rsp")) { + NextTest(); + return; + } + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 7: Read the global attribute: GeneratedCommandList\n"); + if (ShouldSkip("(OVENOPSTATE.S.C00.Rsp || OVENOPSTATE.S.C01.Rsp || OVENOPSTATE.S.C02.Rsp || OVENOPSTATE.S.C03.Rsp)")) { + NextTest(); + return; + } + err = TestStep7ReadTheGlobalAttributeGeneratedCommandList_13(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 14; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1WaitForTheCommissionedDeviceToBeRetrieved_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ThReadsTheClusterRevisionAttributeFromTheDut_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeClusterRevisionWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 2: TH reads the ClusterRevision attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ClusterRevision", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("clusterRevision", "int16u", "int16u")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep3ThReadsTheFeatureMapAttributeFromTheDut_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeFeatureMapWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads the FeatureMap attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("FeatureMap", actualValue, 0UL)); + } + + VerifyOrReturn(CheckConstraintType("featureMap", "bitmap32", "bitmap32")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65530UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4aThReadsTheAttributeListAttributeFromTheDut_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4a: TH reads the AttributeList attribute from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 3UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 4UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 5UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65528UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65529UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65531UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65532UL)); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 65533UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4bThReadsFromTheDutTheOptionalAttributeCountdownTimeInTheAttributeListFromTheDut_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAttributeListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Error: %@", err); + } else { + NSLog(@"Step 4b: TH reads from the DUT the optional attribute(CountdownTime) in the AttributeList from the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("attributeList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("attributeList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6aReadTheOptionalCommandStartInAcceptedCommandList_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6a: Read the optional command(Start) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6a: Read the optional command(Start) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 2UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6bReadTheOptionalCommandStopInAcceptedCommandList_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6b: Read the optional command(Stop) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6b: Read the optional command(Stop) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 1UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6cReadTheOptionalCommandPauseInAcceptedCommandList_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6c: Read the optional command(Pause) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6c: Read the optional command(Pause) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6dReadTheOptionalCommandResumeInAcceptedCommandList_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeAcceptedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6d: Read the optional command(Resume) in AcceptedCommandList: Error: %@", err); + } else { + NSLog(@"Step 6d: Read the optional command(Resume) in AcceptedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("acceptedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 0UL)); + VerifyOrReturn(CheckConstraintContains("acceptedCommandList", value, 3UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("GeneratedCommandList", [actualValue count], static_cast(0))); + } + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ReadTheGlobalAttributeGeneratedCommandList_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeGeneratedCommandListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Error: %@", err); + } else { + NSLog(@"Step 7: Read the global attribute: GeneratedCommandList: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + VerifyOrReturn(CheckConstraintType("generatedCommandList", "list", "list")); + VerifyOrReturn(CheckConstraintContains("generatedCommandList", value, 4UL)); + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OVENOPSTATE_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OVENOPSTATE_2_2() + : TestCommandBridge("Test_TC_OVENOPSTATE_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OVENOPSTATE_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 3: TH reads from the DUT the OperationalStateList attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0003")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_0(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 1; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_0() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the OperationalStateList attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the OperationalStateList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); + } + + VerifyOrReturn(CheckConstraintType("operationalStateList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + +class Test_TC_OVENOPSTATE_2_4 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OVENOPSTATE_2_4() + : TestCommandBridge("Test_TC_OVENOPSTATE_2_4") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OVENOPSTATE_2_4() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_2_4\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_2_4\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Set up a subscription to the OperationalError event\n"); + if (ShouldSkip("OVENOPSTATE.S.E00")) { + NextTest(); + return; + } + err = TestStep2SetUpASubscriptionToTheOperationalErrorEvent_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: At the DUT take the vendor defined action to generate an OperationalError event\n"); + if (ShouldSkip("OVENOPSTATE.S.E00 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep3AtTheDutTakeTheVendorDefinedActionToGenerateAnOperationalErrorEvent_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the OperationalState attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0004 && PICS_SKIP_SAMPLE_APP")) { + NextTest(); + return; + } + err = TestStep4ThReadsFromTheDutTheOperationalStateAttribute_3(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 4; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2SetUpASubscriptionToTheOperationalErrorEvent_1() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + if (err != nil) { + NSLog(@"Step 2: Set up a subscription to the OperationalError event: Error: %@", err); + } else { + NSLog(@"Step 2: Set up a subscription to the OperationalError event: Success"); + } + }]; + + return CHIP_NO_ERROR; +} + +CHIP_ERROR +TestStep3AtTheDutTakeTheVendorDefinedActionToGenerateAnOperationalErrorEvent_2() +{ + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); +} + +CHIP_ERROR TestStep4ThReadsFromTheDutTheOperationalStateAttribute_3() +{ + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH reads from the DUT the OperationalState attribute: Error: %@", err); + } else { + NSLog(@"Step 4: TH reads from the DUT the OperationalState attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 3U)); + } + + VerifyOrReturn(CheckConstraintType("operationalState", "enum8", "enum8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; +} +} +; + class Test_TC_PS_1_1 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced @@ -193529,6 +194342,9 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), + make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), From 611843a99da86327a4cd5c318392b6a3ad1d4192 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Fri, 19 Jan 2024 18:33:13 -0300 Subject: [PATCH 33/89] Fix white space --- src/app/tests/suites/certification/PICS.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tests/suites/certification/PICS.yaml b/src/app/tests/suites/certification/PICS.yaml index 1731882be1d9e9..bfe0ca5d415b1e 100644 --- a/src/app/tests/suites/certification/PICS.yaml +++ b/src/app/tests/suites/certification/PICS.yaml @@ -8826,7 +8826,7 @@ PICS: "Does the device implement the Operational State cluster as a client?" id: OVENOPSTATE.C - # ManuallyControlled + #ManuallyControlled - label: "Does the DUT support testing the Stopped(0x00) operational state" id: OVENOPSTATE.S.M.ST_STOPPED From 939c969ed98f1293551bca94ad5689482a128954 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sat, 20 Jan 2024 15:16:37 -0300 Subject: [PATCH 34/89] fix for PR --- .../templates/tests/ciTests.json | 3 +- .../Test_TC_OVENOPSTATE_2_2.yaml | 24 +- .../Test_TC_OVENOPSTATE_2_5.yaml | 353 ++++++++++++++++++ src/app/tests/suites/ciTests.json | 3 +- src/app/tests/suites/manualTests.json | 3 +- 5 files changed, 371 insertions(+), 15 deletions(-) create mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml diff --git a/examples/darwin-framework-tool/templates/tests/ciTests.json b/examples/darwin-framework-tool/templates/tests/ciTests.json index a9c54d4bb43193..be975805ff771c 100644 --- a/examples/darwin-framework-tool/templates/tests/ciTests.json +++ b/examples/darwin-framework-tool/templates/tests/ciTests.json @@ -71,6 +71,7 @@ "TestScenesMultiFabric", "TestScenesFabricSceneInfo", "#30759: Darwin chip-tool does not support ICD registration during commissioning", - "TestIcdManagementCluster" + "TestIcdManagementCluster", + "Test_TC_OVENOPSTATE_2_4" ] } diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml index 79b99541718714..912b4e7a993a6e 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -62,7 +62,7 @@ tests: - label: "Step 4: TH sends Start command to the DUT" PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx verification: | - ./chip-tool operationalstate start 1 1 + ./chip-tool ovencavityoperationalstate start 1 1 Via the TH (chip-tool), verify: - the response is an instance of OperationalCommandResponse @@ -84,7 +84,7 @@ tests: - label: "Step 5: TH reads from the DUT the OperationalState attribute" PICS: OVENOPSTATE.S.A0004 verification: | - ./chip-tool operationalstate read operational-state 1 1 + ./chip-tool ovencavityoperationalstate read operational-state 1 1 Via the TH (chip-tool), verify: - the response has an OperationalStateID field that is set to 0x01 (Running) @@ -102,7 +102,7 @@ tests: - label: "Step 6: TH reads from the DUT the OperationalError attribute" PICS: OVENOPSTATE.S.A0005 verification: | - ./chip-tool operationalstate read operational-error 1 1 + ./chip-tool ovencavityoperationalstate read operational-error 1 1 Via the TH (chip-tool), verify: - the response contains the ErrorStateId set to NoError(0x00) @@ -119,7 +119,7 @@ tests: - label: "Step 7: TH reads from the DUT the CountdownTime attribute" PICS: OVENOPSTATE.S.A0002 verification: | - ./chip-tool operationalstate read countdown-time 1 1 + ./chip-tool ovencavityoperationalstate read countdown-time 1 1 Via the TH (chip-tool), verify: - that CountdownTime attribute contains either null our a uint32 value @@ -138,7 +138,7 @@ tests: - label: "Step 8: TH reads from the DUT the PhaseList attribute" PICS: OVENOPSTATE.S.A0000 verification: | - ./chip-tool operationalstate read phase-list 1 1 + ./chip-tool ovencavityoperationalstate read phase-list 1 1 Via the TH (chip-tool), verify: - that PhaseList attribute value contains either null or a list of strings. @@ -158,7 +158,7 @@ tests: - label: "Step 9: TH reads from the DUT the CurrentPhase attribute" PICS: OVENOPSTATE.S.A0001 verification: | - ./chip-tool operationalstate read current-phase 1 1 + ./chip-tool ovencavityoperationalstate read current-phase 1 1 Via the TH (chip-tool), verify: - that the CurrentPhase attribute value contains contains a uint8 value @@ -184,7 +184,7 @@ tests: - label: "Step 11: TH reads from the DUT the CountdownTime attribute" PICS: OVENOPSTATE.S.A0002 verification: | - ./chip-tool operationalstate read countdown-time 1 1 + ./chip-tool ovencavityoperationalstate read countdown-time 1 1 Via the TH (chip-tool), verify: @@ -203,7 +203,7 @@ tests: - label: "Step 12: TH sends Start command to the DUT" PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx verification: | - ./chip-tool operationalstate start 1 1 + ./chip-tool ovencavityoperationalstate start 1 1 Via the TH (chip-tool), verify: - the response is an instance of OperationalCommandResponse @@ -228,7 +228,7 @@ tests: - label: "Step 13: TH sends Stop command to the DUT" PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx verification: | - ./chip-tool operationalstate stop 1 1 + ./chip-tool ovencavityoperationalstate stop 1 1 Via the TH (chip-tool), verify: - the response is an instance of OperationalCommandResponse @@ -252,7 +252,7 @@ tests: - label: "Step 14: TH reads from the DUT the OperationalState attribute" PICS: OVENOPSTATE.S.A0004 verification: | - ./chip-tool operationalstate read operational-state 1 1 + ./chip-tool ovencavityoperationalstate read operational-state 1 1 Via the TH (chip-tool), verify: - the response has an OperationalStateID field that is set to 0x00 (Stopped) @@ -270,7 +270,7 @@ tests: - label: "Step 15: TH sends Stop command to the DUT" PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx verification: | - ./chip-tool operationalstate stop 1 1 + ./chip-tool ovencavityoperationalstate stop 1 1 Via the TH (chip-tool), verify: - the response is an instance of OperationalCommandResponse @@ -301,7 +301,7 @@ tests: OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx verification: | - ./chip-tool operationalstate start 1 1 + ./chip-tool ovencavityoperationalstate start 1 1 Via the TH (chip-tool), verify: - the response is an instance of OperationalCommandResponse diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml new file mode 100644 index 00000000000000..7bec5e573a89f7 --- /dev/null +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml @@ -0,0 +1,353 @@ +# Copyright (c) 2023 Project CHIP Authors +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default + +name: 204.2.5. [TC-OVENOPSTATE-2.5] Optional Events with DUT as Server + +PICS: + - OVENOPSTATE.S + +config: + nodeId: 0x12344321 + cluster: "Basic Information" + endpoint: 0 + +tests: + - label: "Note" + verification: | + This test case can be continuted only when countdown-time read in step 5 is not null + disabled: true + + - label: "Step 1: Commission DUT to TH" + verification: | + + disabled: true + + - label: "Step 2: Set up a subscription to the OperationCompletion event" + PICS: OVENOPSTATE.S.E01 + verification: | + ./chip-tool interactive start + + ovencavityoperationalstate read-event operation-completion 1 1 + + [1702376916.193452][4893:4896] CHIP:DMG: ReportDataMessage = + [1702376916.193461][4893:4896] CHIP:DMG: { + [1702376916.193469][4893:4896] CHIP:DMG: SubscriptionId = 0x85d7a607, + [1702376916.193497][4893:4896] CHIP:DMG: InteractionModelRevision = 11 + [1702376916.193504][4893:4896] CHIP:DMG: } + disabled: true + + - label: "Step 3: TH reads from the DUT the OperationalState attribute" + PICS: OVENOPSTATE.S.A0004 + verification: | + ./chip-tool ovencavityoperationalstate read operational-state 1 1 + + Via the TH (chip-tool), verify: + - the response includes an ID (enum8) amd a label (string) + - the provided ID is found in the set provided in step 4 + - the provided ID is in the allowed range + + [1689673213.434610][16591:16593] CHIP:DMG: } + [1689673213.434686][16591:16593] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 + [1689673213.434721][16591:16593] CHIP:TOO: OperationalState: { + [1689673213.434728][16591:16593] CHIP:TOO: OperationalStateID: 0 + [1689673213.434735][16591:16593] CHIP:TOO: } + disabled: true + + - label: + "Step 4: Manually put the DUT into a state wherein it can receive a + Start Command" + verification: | + + disabled: true + + - label: "Step 5: TH reads from the DUT the CountdownTime attribute" + PICS: OVENOPSTATE.S.A0002 + verification: | + ./chip-tool ovencavityoperationalstate read countdown-time 1 1 + + Via the TH (chip-tool), verify: + - that CountdownTime attribute contains either null our a uint32 value + - if non-null, verify that the value is in the range 1 to 259200 + - store the value in 'initialcountdown-time' + + [1690457637.895405][18808:18810] CHIP:DMG: } + [1690457637.895474][18808:18810] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 4112784416 + [1690457637.895503][18808:18810] CHIP:TOO: CountdownTime: null + disabled: true + + - label: "Step 6: TH sends Start command to the DUT" + PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool ovencavityoperationalstate start 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674637.555734][17326:17328] CHIP:DMG: + [1689674637.555742][17326:17328] CHIP:DMG: InteractionModelRevision = 1 + [1689674637.555751][17326:17328] CHIP:DMG: }, + [1689674637.555784][17326:17328] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674637.555805][17326:17328] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674637.555853][17326:17328] CHIP:TOO: OperationalCommandResponse: { + [1689674637.555862][17326:17328] CHIP:TOO: commandResponseState: { + [1689674637.555872][17326:17328] CHIP:TOO: ErrorStateID: 0 + [1689674637.555883][17326:17328] CHIP:TOO: } + disabled: true + + - label: "Step 7: TH waits for {PIXIT.WAITTIME}" + verification: | + + disabled: true + + - label: "Step 8: TH reads from the DUT the OperationalState attribute" + PICS: OVENOPSTATE.S.A0004 + verification: | + ./chip-tool ovencavityoperationalstate read operational-state 1 1 + + Via the TH (chip-tool), verify: + - the response has an OperationalStateID field that is set to 0x01 (Running) + + [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 + [1689674196.878727][17249:17251] CHIP:DMG: } + [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 + [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { + [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 + [1689674196.878847][17249:17251] CHIP:TOO: } + disabled: true + + - label: "Step 9: TH waits for initial-countdown-time" + verification: | + As the initial-countdown-time in null this test cannot be executed further in case of RPI platform. + Note: The below log are for instructional purpose. In real scenarios, the actual log may vary depending on the feature implementation in the Reference App. + disabled: true + + - label: "Step 10: TH sends Stop command to the DUT" + PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool ovencavityoperationalstate stop 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674653.322963][17330:17332] CHIP:DMG: }, + [1689674653.322994][17330:17332] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674653.323014][17330:17332] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674653.323058][17330:17332] CHIP:TOO: OperationalCommandResponse: { + [1689674653.323066][17330:17332] CHIP:TOO: commandResponseState: { + [1689674653.323076][17330:17332] CHIP:TOO: ErrorStateID: 0 + [1689674653.323085][17330:17332] CHIP:TOO: } + [1689674653.323094][17330:17332] CHIP:TOO: } + disabled: true + + - label: + "Step 11: erify TH receives an OperationCompletion event from the DUT + with the following fields populated as follows: 1)CompletionErrorCode + set to NoError(0x00) 2)TotalOperationalTime is approximately + initial-countdown-time or null 3)PausedTime is zero" + PICS: OVENOPSTATE.S.E01 + verification: | + ovencavityoperationalstate read-event operation-completion 1 1 + + [1657193007.841358][5422:5427] CHIP:TOO: Endpoint: 0 Endpoint: 1 Cluster: 0x0000_0060 Event 0x0000_0001 + [1657193007.841387][5422:5427] CHIP:TOO: Event number: 1 + [1657193007.841409][5422:5427] CHIP:TOO: Priority: INFO + [1657193007.841431][5422:5427] CHIP:TOO: Timestamp: 132146 + [1657193007.841531][5422:5427] CHIP:TOO: OperationCompletion: { + [1657193007.841570][5422:5427] CHIP:TOO: CompletionErrorCode: 0x00 + TotalOperationalTime: null + PausedTime: 0 + [1657193007.841594][5422:5427] CHIP:TOO: } + disabled: true + + - label: "Step 12: TH reads from the DUT the OperationalState attribute" + PICS: OVENOPSTATE.S.A0004 + verification: | + ./chip-tool ovencavityoperationalstate read operational-state 1 1 + + Via the TH (chip-tool), verify: + - the response has an OperationalStateID field that is set to 0x00 (Stopped) + + [1689674675.459656][17333:17335] CHIP:DMG: } + [1689674675.459738][17333:17335] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 + [1689674675.459772][17333:17335] CHIP:TOO: OperationalState: { + [1689674675.459790][17333:17335] CHIP:TOO: OperationalStateID: 0 + [1689674675.459799][17333:17335] CHIP:TOO: } + disabled: true + + - label: "Step 13: Restart DUT and repeat step 5" + verification: | + + disabled: true + + - label: "Step 14: TH sends Start command to the DUT" + PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool ovencavityoperationalstate start 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674637.555734][17326:17328] CHIP:DMG: + [1689674637.555742][17326:17328] CHIP:DMG: InteractionModelRevision = 1 + [1689674637.555751][17326:17328] CHIP:DMG: }, + [1689674637.555784][17326:17328] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674637.555805][17326:17328] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674637.555853][17326:17328] CHIP:TOO: OperationalCommandResponse: { + [1689674637.555862][17326:17328] CHIP:TOO: commandResponseState: { + [1689674637.555872][17326:17328] CHIP:TOO: ErrorStateID: 0 + [1689674637.555883][17326:17328] CHIP:TOO: } + [1689674637.555891][17326:17328] CHIP:TOO: } + disabled: true + + - label: "Step 15: TH waits for {PIXIT.WAITTIME}" + verification: | + + disabled: true + + - label: "Step 16: TH reads from the DUT the OperationalState attribute" + PICS: OVENOPSTATE.S.A0004 + verification: | + ./chip-tool ovencavityoperationalstate read operational-state 1 1 + + Via the TH (chip-tool), verify: + - the response has an OperationalStateID field that is set to 0x01 (Running) + + [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 + [1689674196.878727][17249:17251] CHIP:DMG: } + [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 + [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { + [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 + [1689674196.878847][17249:17251] CHIP:TOO: } + disabled: true + + - label: "Step 17: TH sends Pause command to the DUT" + PICS: OVENOPSTATE.S.C00.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool ovencavityoperationalstate pause 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1690457565.893634][18795:18797] CHIP:DMG: }, + [1690457565.893663][18795:18797] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1690457565.893681][18795:18797] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1690457565.893714][18795:18797] CHIP:TOO: OperationalCommandResponse: { + [1690457565.893729][18795:18797] CHIP:TOO: commandResponseState: { + [1690457565.893736][18795:18797] CHIP:TOO: ErrorStateID: 0 + [1690457565.893744][18795:18797] CHIP:TOO: } + [1690457565.893750][18795:18797] CHIP:TOO: } + disabled: true + + - label: "Step 18: TH reads from the DUT the OperationalState attribute" + PICS: OVENOPSTATE.S.A0004 + verification: | + ./chip-tool ovencavityoperationalstate read operational-state 1 1 + + Via the TH (chip-tool), verify: + - the response has an OperationalStateID field that is set to 0x02 (Paused) + + [1690457601.103082][18800:18802] CHIP:DMG: InteractionModelRevision = 1 + [1690457601.103090][18800:18802] CHIP:DMG: } + [1690457601.103210][18800:18802] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 4112784416 + [1690457601.103259][18800:18802] CHIP:TOO: OperationalState: 2 + disabled: true + + - label: "Step 19: TH waits for half of initial-countdown-time" + verification: | + + disabled: true + + - label: "Step 20: TH sends Resume command to the DUT" + PICS: OVENOPSTATE.S.C03.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool ovencavityoperationalstate resume 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x03 (CommandInvalidInState) + + [1690457852.049135][18877:18879] CHIP:DMG: }, + [1690457852.049164][18877:18879] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1690457852.049183][18877:18879] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1690457852.049217][18877:18879] CHIP:TOO: OperationalCommandResponse: { + [1690457852.049224][18877:18879] CHIP:TOO: commandResponseState: { + [1690457852.049238][18877:18879] CHIP:TOO: ErrorStateID: 3 + [1690457852.049246][18877:18879] CHIP:TOO: } + [1690457852.049252][18877:18879] CHIP:TOO: } + disabled: true + + - label: "Step 21: TH reads from the DUT the OperationalState attribute" + PICS: OVENOPSTATE.S.A0004 + verification: | + ./chip-tool ovencavityoperationalstate read operational-state 1 1 + + Via the TH (chip-tool), verify: + - the response has an OperationalStateID field that is set to 0x01 (Running) + + [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 + [1689674196.878727][17249:17251] CHIP:DMG: } + [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 + [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { + [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 + [1689674196.878847][17249:17251] CHIP:TOO: } + disabled: true + + - label: "Step 22: TH waits for initial-countdown-time" + verification: | + TH waits for initial-countdown-time + disabled: true + + - label: "Step 23: TH sends Stop command to the DUT" + PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx + verification: | + ./chip-tool ovencavityoperationalstate stop 1 1 + + Via the TH (chip-tool), verify: + - the response is an instance of OperationalCommandResponse + - The ErrorStateID field is set to 0x00 (NoError) + + [1689674653.322963][17330:17332] CHIP:DMG: }, + [1689674653.322994][17330:17332] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 + [1689674653.323014][17330:17332] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 + [1689674653.323058][17330:17332] CHIP:TOO: OperationalCommandResponse: { + [1689674653.323066][17330:17332] CHIP:TOO: commandResponseState: { + [1689674653.323076][17330:17332] CHIP:TOO: ErrorStateID: 0 + [1689674653.323085][17330:17332] CHIP:TOO: } + [1689674653.323094][17330:17332] CHIP:TOO: } + disabled: true + + - label: + "Step 24: Verify TH receives an OperationCompletion event with the + following fields populated as follows: 1. CompletionErrorCode set to + NoError(0x00) 2. TotalOperationalTime is approximately 1.5 times the + initial-countdown-time or null 3. PausedTime is 0.5 times the + initial-countdown-time" + PICS: OVENOPSTATE.S.E01 + verification: | + ovencavityoperationalstate read-event operation-completion 1 1 + + [1657193007.841358][5422:5427] CHIP:TOO: Endpoint: 0 Endpoint: 1 Cluster: 0x0000_0060 Event 0x0000_0001 + [1657193007.841387][5422:5427] CHIP:TOO: Event number: 1 + [1657193007.841409][5422:5427] CHIP:TOO: Priority: INFO + [1657193007.841431][5422:5427] CHIP:TOO: Timestamp: 155146 + [1657193007.841531][5422:5427] CHIP:TOO: OperationCompletion: { + [1657193007.841570][5422:5427] CHIP:TOO: CompletionErrorCode: 0x00 + TotalOperationalTime: null + } + disabled: true diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 9f7489db30c0e8..bb35ec7058c934 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -175,7 +175,8 @@ "OvenCavityOperationalState": [ "Test_TC_OVENOPSTATE_1_1", "Test_TC_OVENOPSTATE_2_2", - "Test_TC_OVENOPSTATE_2_4" + "Test_TC_OVENOPSTATE_2_4", + "Test_TC_OVENOPSTATE_2_5" ], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], "PressureMeasurement": [ diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index b1fc8e98eacc5a..31fe31124eec81 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -279,7 +279,8 @@ "OperationalState": ["Test_TC_OPSTATE_2_2", "Test_TC_OPSTATE_2_5"], "OvenCavityOperationalState": [ "Test_TC_OVENOPSTATE_2_2", - "Test_TC_OVENOPSTATE_2_4" + "Test_TC_OVENOPSTATE_2_4", + "Test_TC_OVENOPSTATE_2_5" ], "RelativeHumidityMeasurement": ["Test_TC_RH_2_2"], "SmokeCOAlarm": [], From 886f93151c223b75d084bba8d31433833e7eda06 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sat, 20 Jan 2024 15:27:44 -0300 Subject: [PATCH 35/89] Update commands --- .../zap-generated/test/Commands.h | 124 ++---------------- 1 file changed, 10 insertions(+), 114 deletions(-) diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index b7f991447427f6..5d8a7988aca387 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -185,7 +185,7 @@ class TestList : public Command { printf("Test_TC_OPSTATE_1_1\n"); printf("Test_TC_OVENOPSTATE_1_1\n"); printf("Test_TC_OVENOPSTATE_2_2\n"); - printf("Test_TC_OVENOPSTATE_2_4\n"); + printf("Test_TC_OVENOPSTATE_2_5\n"); printf("Test_TC_PS_1_1\n"); printf("Test_TC_PS_2_1\n"); printf("Test_TC_PRS_1_1\n"); @@ -90461,11 +90461,11 @@ class Test_TC_OVENOPSTATE_2_2 : public TestCommandBridge { } }; -class Test_TC_OVENOPSTATE_2_4 : public TestCommandBridge { +class Test_TC_OVENOPSTATE_2_5 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OVENOPSTATE_2_4() - : TestCommandBridge("Test_TC_OVENOPSTATE_2_4") + Test_TC_OVENOPSTATE_2_5() + : TestCommandBridge("Test_TC_OVENOPSTATE_2_5") , mTestIndex(0) { AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); @@ -90475,7 +90475,7 @@ class Test_TC_OVENOPSTATE_2_4 : public TestCommandBridge { } // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - ~Test_TC_OVENOPSTATE_2_4() + ~Test_TC_OVENOPSTATE_2_5() { } @@ -90485,11 +90485,11 @@ class Test_TC_OVENOPSTATE_2_4 : public TestCommandBridge { CHIP_ERROR err = CHIP_NO_ERROR; if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_2_4\n"); + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_2_5\n"); } if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_2_4\n"); + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_2_5\n"); SetCommandExitStatus(CHIP_NO_ERROR); return; } @@ -90501,34 +90501,6 @@ class Test_TC_OVENOPSTATE_2_4 : public TestCommandBridge { // but before our function call returns, we won't end up with an // incorrect mTestIndex value observed when we get the response. switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Set up a subscription to the OperationalError event\n"); - if (ShouldSkip("OVENOPSTATE.S.E00")) { - NextTest(); - return; - } - err = TestStep2SetUpASubscriptionToTheOperationalErrorEvent_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: At the DUT take the vendor defined action to generate an OperationalError event\n"); - if (ShouldSkip("OVENOPSTATE.S.E00 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep3AtTheDutTakeTheVendorDefinedActionToGenerateAnOperationalErrorEvent_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH reads from the DUT the OperationalState attribute\n"); - if (ShouldSkip("OVENOPSTATE.S.A0004 && PICS_SKIP_SAMPLE_APP")) { - NextTest(); - return; - } - err = TestStep4ThReadsFromTheDutTheOperationalStateAttribute_3(); - break; } if (CHIP_NO_ERROR != err) { @@ -90540,17 +90512,6 @@ class Test_TC_OVENOPSTATE_2_4 : public TestCommandBridge { void OnStatusUpdate(const chip::app::StatusIB & status) override { switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; } // Go on to the next test. @@ -90561,78 +90522,13 @@ class Test_TC_OVENOPSTATE_2_4 : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; + const uint16_t mTestCount = 0; chip::Optional mNodeId; chip::Optional mCluster; chip::Optional mEndpoint; chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2SetUpASubscriptionToTheOperationalErrorEvent_1() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - if (err != nil) { - NSLog(@"Step 2: Set up a subscription to the OperationalError event: Error: %@", err); - } else { - NSLog(@"Step 2: Set up a subscription to the OperationalError event: Success"); - } - }]; - - return CHIP_NO_ERROR; -} - -CHIP_ERROR -TestStep3AtTheDutTakeTheVendorDefinedActionToGenerateAnOperationalErrorEvent_2() -{ - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Enter 'y' after successgarbage: not in length on purpose", 23); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); -} - -CHIP_ERROR TestStep4ThReadsFromTheDutTheOperationalStateAttribute_3() -{ - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 4: TH reads from the DUT the OperationalState attribute: Error: %@", err); - } else { - NSLog(@"Step 4: TH reads from the DUT the OperationalState attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalState", actualValue, 3U)); - } - - VerifyOrReturn(CheckConstraintType("operationalState", "enum8", "enum8")); - NextTest(); - }]; - - return CHIP_NO_ERROR; -} -} -; +}; class Test_TC_PS_1_1 : public TestCommandBridge { public: @@ -194006,7 +193902,7 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), - make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), From 24d9dca01c515a55dbb81dab3c4bb5bf274c7ae7 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 22 Jan 2024 07:57:45 -0300 Subject: [PATCH 36/89] fixes PR --- .../all-clusters-common/all-clusters-app.zap | 9 +++++ .../Test_TC_OVENOPSTATE_2_4.yaml | 34 ++++++------------- .../tests/suites/certification/ci-pics-values | 4 +-- 3 files changed, 22 insertions(+), 25 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 167a75e838fc42..666138eebaec8a 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -8593,6 +8593,15 @@ "maxInterval": 65534, "reportableChange": 0 } + ], + "events": [ + { + "name": "OperationalError", + "code": 0, + "mfgCode": null, + "side": "server", + "included": 1 + } ] }, { diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml index 4820fba4eab995..a97c67d2d65fbb 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml @@ -52,29 +52,17 @@ tests: NOTE : There's a PIXIT value controlling the ability to execute that ({PIXIT_ERROREVENTGEN}), which as the test case notes, requires vendor specific actions to generated the error at the DUT. This is dependent on the vendor app supporting this. The SDK as it stands won't provide the error, this may be testable by some of the vendors depending on their implementations. - [1692859386.707176][6658:6660] CHIP:EM: Rxd Ack; Removing MessageCounter:212756536 from Retrans Table on exchange 36888i - [1692859386.707295][6658:6660] CHIP:DMG: ReportDataMessage = - [1692859386.707360][6658:6660] CHIP:DMG: { - [1692859386.707416][6658:6660] CHIP:DMG: SubscriptionId = 0x97bb846c, - [1692859386.707477][6658:6660] CHIP:DMG: InteractionModelRevision = 10 - [1692859386.707533][6658:6660] CHIP:DMG: } - [1692859386.707621][6658:6660] CHIP:DMG: MoveToState ReadClient[0xffff80011a90]: Moving to [AwaitingSu] - [1692859386.707815][6658:6660] CHIP:EM: <<< [E:36888i S:54523 M:212756537 (Ack:12760634)] (S) Msg TX to 1:0000000000000001 [853D] --- Type 0001:01 (IM:StatusResponse) - [1692859386.707901][6658:6660] CHIP:IN: (S) Sending msg 212756537 on secure session with LSID: 54523 - [1692859386.708167][6658:6660] CHIP:DL: HandlePlatformSpecificBLEEvent 32793 - [1692859386.708237][6658:6660] CHIP:DL: HandlePlatformSpecificBLEEvent 32793 - [1692859386.749217][6658:6660] CHIP:EM: >>> [E:36888i S:54523 M:12760635 (Ack:212756537)] (S) Msg RX from 1:0000000000000001 [853D] --- Type 0001:04 (IM:SubscribeResponse) - [1692859386.749285][6658:6660] CHIP:EM: Found matching exchange: 36888i, Delegate: 0xffff80011aa0 - [1692859386.749350][6658:6660] CHIP:EM: Rxd Ack; Removing MessageCounter:212756537 from Retrans Table on exchange 36888i - [1692859386.749417][6658:6660] CHIP:DMG: SubscribeResponse is received - [1692859386.749489][6658:6660] CHIP:DMG: SubscribeResponseMessage = - [1692859386.749538][6658:6660] CHIP:DMG: { - [1692859386.749584][6658:6660] CHIP:DMG: SubscriptionId = 0x97bb846c, - [1692859386.749637][6658:6660] CHIP:DMG: MaxInterval = 0x6, - [1692859386.749687][6658:6660] CHIP:DMG: InteractionModelRevision = 10 - [1692859386.749734][6658:6660] CHIP:DMG: } - [1692859386.749787][6658:6660] CHIP:DMG: Subscription established with SubscriptionID = 0x97bb846c MinInterval = 5s MaxInterval = 6s Peer = 01:0000000000000001 - [1692859386.749843][6658:6660] CHIP:DMG: MoveToState ReadClient[0xffff80011a90]: Moving to [Subscripti] + [1705871792686] [7030:7008415] [TOO] Endpoint: 1 Cluster: 0x0000_0048 Event 0x0000_0000 + [1705871792686] [7030:7008415] [TOO] Event number: 65541 + [1705871792686] [7030:7008415] [TOO] Priority: Critical + [1705871792686] [7030:7008415] [TOO] Timestamp: 1705871789411 + [1705871792686] [7030:7008415] [TOO] OperationalError: { + [1705871792686] [7030:7008415] [TOO] ErrorState: { + [1705871792686] [7030:7008415] [TOO] ErrorStateID: 3 + [1705871792686] [7030:7008415] [TOO] } + [1705871792686] [7030:7008415] [TOO] } + [1705871792686] [7030:7008415] [DMG] Refresh LivenessCheckTime for 14224 milliseconds with SubscriptionId = 0x6bdd9a34 Peer = 01:0000000000000001 + cluster: "LogCommands" command: "UserPrompt" arguments: diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 66a9da41ccf31b..811e07258fdeec 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -1836,7 +1836,7 @@ OPSTATE.S.C04.Tx=1 # Server Events OPSTATE.S.E00=1 -OPSTATE.S.E01=1 +OPSTATE.S.E01=0 # Oven Operational State @@ -2776,7 +2776,7 @@ DEM.S.A0005=0 DEM.S.A0006=0 DEM.S.A0007=0 -# Features +# Features DEM.S.F00=0 DEM.S.F01=0 DEM.S.F02=0 From ffe1fa105d230fd3b7ca16060166628b565ac0fe Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 22 Jan 2024 08:18:43 -0300 Subject: [PATCH 37/89] fix --- .../all-clusters-app/all-clusters-common/all-clusters-app.matter | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index c2924b07468b28..ae608ba7bc5810 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -7685,6 +7685,7 @@ endpoint 1 { } server cluster OvenCavityOperationalState { + emits event OperationalError; callback attribute phaseList; callback attribute currentPhase; callback attribute operationalStateList; From c14598aeb5ed79be8ce2c1ab9a83529816c2a741 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 22 Jan 2024 10:52:53 -0300 Subject: [PATCH 38/89] fix test cases --- .../Test_TC_OVENOPSTATE_2_2.yaml | 52 ++++++++------- .../tests/suites/certification/ci-pics-values | 4 +- .../zap-generated/test/Commands.h | 65 +++++++++++++++++-- 3 files changed, 92 insertions(+), 29 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml index 912b4e7a993a6e..4a40bf0f09e760 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -29,19 +29,24 @@ tests: This is a simulated example log for instructional purposes only. In real scenarios, the actual log may vary depending on the feature implementation in Reference App. disabled: true - - label: - "Step 1: Commission DUT to TH (can be skipped if done in a preceding - test)" - verification: | - - disabled: true - - - label: - "Step 2: Manually put the DUT into a state wherein it can receive a - Start Command" - verification: | - Manually put the DUT into a state wherein it can receive a Start Command - disabled: true + - label: "Step 1: Commission DUT to TH" + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId + + - label: "Step 2: Manually put the DUT into a state wherein it can receive a Start Command" + cluster: "LogCommands" + command: "UserPrompt" + PICS: PICS_USER_PROMPT + arguments: + values: + - name: "message" + value: "Please enter 'y' for success" + - name: "expectedValue" + value: "y" - label: "Step 3: TH reads from the DUT the OperationalStateList attribute" PICS: OVENOPSTATE.S.A0003 @@ -288,18 +293,19 @@ tests: [1689674689.588810][17337:17339] CHIP:IN: (S) Sending msg 16881995 on secure session with LSID: 35027 disabled: true - - label: - "Step 16: Manually put the DUT into a state wherein it cannot receive - a Start Command" - PICS: OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME - verification: | - Manually put the DUT into a state wherein it cannot receive a Start Command - disabled: true + - label: "Step 16: Manually put the DUT into a state wherein it cannot receive a Start Command" + cluster: "LogCommands" + command: "UserPrompt" + PICS: PICS_USER_PROMPT && OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME + arguments: + values: + - name: "message" + value: "Please enter 'y' for success" + - name: "expectedValue" + value: "y" - label: "Step 17: TH sends Start command to the DUT" - PICS: - OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp - && OVENOPSTATE.S.C04.Tx + PICS: OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx verification: | ./chip-tool ovencavityoperationalstate start 1 1 diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 811e07258fdeec..a4f002713877f2 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -1836,7 +1836,7 @@ OPSTATE.S.C04.Tx=1 # Server Events OPSTATE.S.E00=1 -OPSTATE.S.E01=0 +OPSTATE.S.E01=1 # Oven Operational State @@ -1869,7 +1869,7 @@ OVENOPSTATE.S.C04.Tx=0 # Server Events OVENOPSTATE.S.E00=1 -OVENOPSTATE.S.E01=1 +OVENOPSTATE.S.E01=0 # Thermostat # Server diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 5d8a7988aca387..4aa42922fd92d9 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -90390,12 +90390,32 @@ class Test_TC_OVENOPSTATE_2_2 : public TestCommandBridge { // incorrect mTestIndex value observed when we get the response. switch (mTestIndex++) { case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 3: TH reads from the DUT the OperationalStateList attribute\n"); + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Manually put the DUT into a state wherein it can receive a Start Command\n"); + if (ShouldSkip("PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep2ManuallyPutTheDutIntoAStateWhereinItCanReceiveAStartCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the OperationalStateList attribute\n"); if (ShouldSkip("OVENOPSTATE.S.A0003")) { NextTest(); return; } - err = TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_0(); + err = TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 16: Manually put the DUT into a state wherein it cannot receive a Start Command\n"); + if (ShouldSkip("PICS_USER_PROMPT && OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME")) { + NextTest(); + return; + } + err = TestStep16ManuallyPutTheDutIntoAStateWhereinItCannotReceiveAStartCommand_3(); break; } @@ -90411,6 +90431,15 @@ class Test_TC_OVENOPSTATE_2_2 : public TestCommandBridge { case 0: VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; } // Go on to the next test. @@ -90421,14 +90450,32 @@ class Test_TC_OVENOPSTATE_2_2 : public TestCommandBridge { private: std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 1; + const uint16_t mTestCount = 4; chip::Optional mNodeId; chip::Optional mCluster; chip::Optional mEndpoint; chip::Optional mTimeout; - CHIP_ERROR TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_0() + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ManuallyPutTheDutIntoAStateWhereinItCanReceiveAStartCommand_1() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_2() { MTRBaseDevice * device = GetDevice("alpha"); @@ -90459,6 +90506,16 @@ class Test_TC_OVENOPSTATE_2_2 : public TestCommandBridge { return CHIP_NO_ERROR; } + + CHIP_ERROR TestStep16ManuallyPutTheDutIntoAStateWhereinItCannotReceiveAStartCommand_3() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } }; class Test_TC_OVENOPSTATE_2_5 : public TestCommandBridge { From 8ed41607d436a15c57cd4030cefdf80904782576 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Mon, 22 Jan 2024 13:53:23 +0000 Subject: [PATCH 39/89] Restyled by prettier-yaml --- .../certification/Test_TC_OVENOPSTATE_2_2.yaml | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml index 4a40bf0f09e760..237840ff8349f2 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -37,7 +37,9 @@ tests: - name: "nodeId" value: nodeId - - label: "Step 2: Manually put the DUT into a state wherein it can receive a Start Command" + - label: + "Step 2: Manually put the DUT into a state wherein it can receive a + Start Command" cluster: "LogCommands" command: "UserPrompt" PICS: PICS_USER_PROMPT @@ -293,7 +295,9 @@ tests: [1689674689.588810][17337:17339] CHIP:IN: (S) Sending msg 16881995 on secure session with LSID: 35027 disabled: true - - label: "Step 16: Manually put the DUT into a state wherein it cannot receive a Start Command" + - label: + "Step 16: Manually put the DUT into a state wherein it cannot receive + a Start Command" cluster: "LogCommands" command: "UserPrompt" PICS: PICS_USER_PROMPT && OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME @@ -305,7 +309,9 @@ tests: value: "y" - label: "Step 17: TH sends Start command to the DUT" - PICS: OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx + PICS: + OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp + && OVENOPSTATE.S.C04.Tx verification: | ./chip-tool ovencavityoperationalstate start 1 1 From 33198324ef5e5d3441b04882a83e4d559e64b95c Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 22 Jan 2024 12:40:47 -0300 Subject: [PATCH 40/89] fixed place for test case --- examples/darwin-framework-tool/templates/tests/ciTests.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/darwin-framework-tool/templates/tests/ciTests.json b/examples/darwin-framework-tool/templates/tests/ciTests.json index be975805ff771c..4f852dddae8000 100644 --- a/examples/darwin-framework-tool/templates/tests/ciTests.json +++ b/examples/darwin-framework-tool/templates/tests/ciTests.json @@ -45,6 +45,7 @@ "Test_TC_SMOKECO_2_5", "Test_TC_DGGEN_2_1", "Test_TC_OPSTATE_2_4", + "Test_TC_OVENOPSTATE_2_4", "Disabled due to undefined properties", "Test_TC_SMOKECO_2_6", "Disabled because the power source configuration cluster is now deprecated and not present in all-clusters", @@ -71,7 +72,6 @@ "TestScenesMultiFabric", "TestScenesFabricSceneInfo", "#30759: Darwin chip-tool does not support ICD registration during commissioning", - "TestIcdManagementCluster", - "Test_TC_OVENOPSTATE_2_4" + "TestIcdManagementCluster" ] } From 643b4b794ada7b6ab2fac7010469704c72f0c4ba Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 22 Jan 2024 13:35:37 -0300 Subject: [PATCH 41/89] fixed test json --- src/app/tests/suites/ciTests.json | 4 +--- src/app/tests/suites/manualTests.json | 1 - 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 9e487af388a384..0c9cba382e18d8 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -180,9 +180,7 @@ "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], "OvenCavityOperationalState": [ "Test_TC_OVENOPSTATE_1_1", - "Test_TC_OVENOPSTATE_2_2", - "Test_TC_OVENOPSTATE_2_4", - "Test_TC_OVENOPSTATE_2_5" + "Test_TC_OVENOPSTATE_2_4" ], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], "PressureMeasurement": [ diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index 1ac6c2789452d6..c7d883aa46065e 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -279,7 +279,6 @@ "OperationalState": ["Test_TC_OPSTATE_2_2", "Test_TC_OPSTATE_2_5"], "OvenCavityOperationalState": [ "Test_TC_OVENOPSTATE_2_2", - "Test_TC_OVENOPSTATE_2_4", "Test_TC_OVENOPSTATE_2_5" ], "RelativeHumidityMeasurement": ["Test_TC_RH_2_2"], From b94a8d277208489a44ac724ff7150c9bf8fe5504 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 22 Jan 2024 14:50:20 -0300 Subject: [PATCH 42/89] zap regen --- .../zap-generated/test/Commands.h | 242 ------------------ 1 file changed, 242 deletions(-) diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index f4c2411a4a68dd..4b813181982c3d 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -185,8 +185,6 @@ class TestList : public Command { printf("Test_TC_OO_2_4\n"); printf("Test_TC_OPSTATE_1_1\n"); printf("Test_TC_OVENOPSTATE_1_1\n"); - printf("Test_TC_OVENOPSTATE_2_2\n"); - printf("Test_TC_OVENOPSTATE_2_5\n"); printf("Test_TC_PS_1_1\n"); printf("Test_TC_PS_2_1\n"); printf("Test_TC_PRS_1_1\n"); @@ -90774,244 +90772,6 @@ class Test_TC_OVENOPSTATE_1_1 : public TestCommandBridge { } }; -class Test_TC_OVENOPSTATE_2_2 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OVENOPSTATE_2_2() - : TestCommandBridge("Test_TC_OVENOPSTATE_2_2") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OVENOPSTATE_2_2() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_2_2\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_2_2\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - case 0: - ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); - err = TestStep1CommissionDutToTh_0(); - break; - case 1: - ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Manually put the DUT into a state wherein it can receive a Start Command\n"); - if (ShouldSkip("PICS_USER_PROMPT")) { - NextTest(); - return; - } - err = TestStep2ManuallyPutTheDutIntoAStateWhereinItCanReceiveAStartCommand_1(); - break; - case 2: - ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the OperationalStateList attribute\n"); - if (ShouldSkip("OVENOPSTATE.S.A0003")) { - NextTest(); - return; - } - err = TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_2(); - break; - case 3: - ChipLogProgress(chipTool, " ***** Test Step 3 : Step 16: Manually put the DUT into a state wherein it cannot receive a Start Command\n"); - if (ShouldSkip("PICS_USER_PROMPT && OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME")) { - NextTest(); - return; - } - err = TestStep16ManuallyPutTheDutIntoAStateWhereinItCannotReceiveAStartCommand_3(); - break; - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - case 0: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 1: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 2: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - case 3: - VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); - break; - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 4; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; - - CHIP_ERROR TestStep1CommissionDutToTh_0() - { - - chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; - value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; - return WaitForCommissionee("alpha", value); - } - - CHIP_ERROR TestStep2ManuallyPutTheDutIntoAStateWhereinItCanReceiveAStartCommand_1() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } - - CHIP_ERROR TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_2() - { - - MTRBaseDevice * device = GetDevice("alpha"); - __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; - VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); - - [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { - if (err != nil) { - NSLog(@"Step 3: TH reads from the DUT the OperationalStateList attribute: Error: %@", err); - } else { - NSLog(@"Step 3: TH reads from the DUT the OperationalStateList attribute: Success"); - } - - VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); - - { - id actualValue = value; - VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(4))); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); - VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); - } - - VerifyOrReturn(CheckConstraintType("operationalStateList", "list", "list")); - NextTest(); - }]; - - return CHIP_NO_ERROR; - } - - CHIP_ERROR TestStep16ManuallyPutTheDutIntoAStateWhereinItCannotReceiveAStartCommand_3() - { - - chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; - value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); - value.expectedValue.Emplace(); - value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); - return UserPrompt("alpha", value); - } -}; - -class Test_TC_OVENOPSTATE_2_5 : public TestCommandBridge { -public: - // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced - Test_TC_OVENOPSTATE_2_5() - : TestCommandBridge("Test_TC_OVENOPSTATE_2_5") - , mTestIndex(0) - { - AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); - AddArgument("cluster", &mCluster); - AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); - AddArgument("timeout", 0, UINT16_MAX, &mTimeout); - } - // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) - - ~Test_TC_OVENOPSTATE_2_5() - { - } - - /////////// TestCommand Interface ///////// - void NextTest() override - { - CHIP_ERROR err = CHIP_NO_ERROR; - - if (0 == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_2_5\n"); - } - - if (mTestCount == mTestIndex) { - ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_2_5\n"); - SetCommandExitStatus(CHIP_NO_ERROR); - return; - } - - Wait(); - - // Ensure we increment mTestIndex before we start running the relevant - // command. That way if we lose the timeslice after we send the message - // but before our function call returns, we won't end up with an - // incorrect mTestIndex value observed when we get the response. - switch (mTestIndex++) { - } - - if (CHIP_NO_ERROR != err) { - ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); - SetCommandExitStatus(err); - } - } - - void OnStatusUpdate(const chip::app::StatusIB & status) override - { - switch (mTestIndex - 1) { - } - - // Go on to the next test. - ContinueOnChipMainThread(CHIP_NO_ERROR); - } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } - -private: - std::atomic_uint16_t mTestIndex; - const uint16_t mTestCount = 0; - - chip::Optional mNodeId; - chip::Optional mCluster; - chip::Optional mEndpoint; - chip::Optional mTimeout; -}; - class Test_TC_PS_1_1 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced @@ -194384,8 +194144,6 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), - make_unique(), - make_unique(), make_unique(), make_unique(), make_unique(), From 483ff17fe0065fab13209a7585115ea0997735c8 Mon Sep 17 00:00:00 2001 From: Prakash Ravi Date: Thu, 1 Feb 2024 08:16:45 -0500 Subject: [PATCH 43/89] added Ovenopstate2_2 and 2_5 yaml and python files. Also some associated changed files --- .../Test_TC_OVENOPSTATE_2_2.yaml | 278 ++------ .../Test_TC_OVENOPSTATE_2_5.yaml | 238 ++----- .../tests/suites/certification/ci-pics-values | 14 +- src/app/tests/suites/ciTests.json | 1 + src/python_testing/TC_OVENOPSTATE_2_2.py | 208 ++++++ src/python_testing/TC_OVENOPSTATE_2_5.py | 238 +++++++ .../zap-generated/test/Commands.h | 634 ++++++++++++++++++ 7 files changed, 1225 insertions(+), 386 deletions(-) create mode 100644 src/python_testing/TC_OVENOPSTATE_2_2.py create mode 100644 src/python_testing/TC_OVENOPSTATE_2_5.py diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml index 237840ff8349f2..a0235aaa2e4cb1 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml @@ -24,10 +24,10 @@ config: endpoint: 1 tests: - - label: "Note" - verification: | - This is a simulated example log for instructional purposes only. In real scenarios, the actual log may vary depending on the feature implementation in Reference App. - disabled: true + #- label: "Note" + # verification: | + # This is a simulated example log for instructional purposes only. In real scenarios, the actual log may vary depending on the feature implementation in Reference App. + # disabled: true - label: "Step 1: Commission DUT to TH" cluster: "DelayCommands" @@ -68,117 +68,48 @@ tests: - label: "Step 4: TH sends Start command to the DUT" PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool ovencavityoperationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674139.018639][17233:17235] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674139.018658][17233:17235] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674139.018704][17233:17235] CHIP:TOO: OperationalCommandResponse: { - [1689674139.018712][17233:17235] CHIP:TOO: commandResponseState: { - [1689674139.018719][17233:17235] CHIP:TOO: ErrorStateID: 0 - [1689674139.018726][17233:17235] CHIP:TOO: } - [1689674139.018732][17233:17235] CHIP:TOO: } - [1689674139.018755][17233:17235] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674139.018818][17233:17235] CHIP:EM: <<< [E:26021i S:33879 M:235550100 (Ack:58905970)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674139.018837][17233:17235] CHIP:IN: (S) Sending msg 235550100 on secure session with LSID: 33879 - [1689674139.018885][17233:17235] CHIP:EM: Flushed pending ack for MessageCounter:58905970 on exchange 26021i - disabled: true + command: "Start" + response: + values: + - name: "CommandResponseState" + value: {ErrorStateID: 0} - label: "Step 5: TH reads from the DUT the OperationalState attribute" PICS: OVENOPSTATE.S.A0004 - verification: | - ./chip-tool ovencavityoperationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x01 (Running) - - [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 - [1689674196.878727][17249:17251] CHIP:DMG: } - [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { - [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 - [1689674196.878847][17249:17251] CHIP:TOO: } - [1689674196.878914][17249:17251] CHIP:EM: <<< [E:56939i S:28614 M:63040141 (Ack:57012545)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674196.878928][17249:17251] CHIP:IN: (S) Sending msg 63040141 on secure session with LSID: 28614 - disabled: true - + command: "readAttribute" + attribute: "OperationalState" + response: + value: 1 + constraints: + type: enum8 + - label: "Step 6: TH reads from the DUT the OperationalError attribute" PICS: OVENOPSTATE.S.A0005 - verification: | - ./chip-tool ovencavityoperationalstate read operational-error 1 1 - - Via the TH (chip-tool), verify: - - the response contains the ErrorStateId set to NoError(0x00) - - [1689674342.832448][17274:17276] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0005 DataVersion: 2102885775 - [1689674342.832482][17274:17276] CHIP:TOO: OperationalError: { - [1689674342.832500][17274:17276] CHIP:TOO: ErrorStateID: 0 - [1689674342.832509][17274:17276] CHIP:TOO: } - [1689674342.832570][17274:17276] CHIP:EM: <<< [E:37158i S:10451 M:72875113 (Ack:195983315)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674342.832585][17274:17276] CHIP:IN: (S) Sending msg 72875113 on secure session with LSID: 10451 - [1689674342.832614][17274:17276] CHIP:EM: Flushed pending ack for MessageCounter:195983315 on exchange 37158i - disabled: true + command: "readAttribute" + attribute: "OperationalError" + response: + value: {ErrorStateID: 0} - label: "Step 7: TH reads from the DUT the CountdownTime attribute" PICS: OVENOPSTATE.S.A0002 - verification: | - ./chip-tool ovencavityoperationalstate read countdown-time 1 1 - - Via the TH (chip-tool), verify: - - that CountdownTime attribute contains either null our a uint32 value - - if non-null, verify that the value is in the range 1 to 259200 - - store the value in 'initialcountdown-time' - - [1689674384.271623][17278:17280] CHIP:DMG: InteractionModelRevision = 1 - [1689674384.271625][17278:17280] CHIP:DMG: } - [1689674384.271649][17278:17280] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 2102885775 - [1689674384.271662][17278:17280] CHIP:TOO: CountdownTime: null - [1689674384.271683][17278:17280] CHIP:EM: <<< [E:24665i S:47371 M:757241 (Ack:152992659)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674384.271687][17278:17280] CHIP:IN: (S) Sending msg 757241 on secure session with LSID: 47371 - [1689674384.271696][17278:17280] CHIP:EM: Flushed pending ack for MessageCounter:152992659 on exchange 24665i - disabled: true + command: "readAttribute" + attribute: "CountdownTime" + response: + value: null - label: "Step 8: TH reads from the DUT the PhaseList attribute" PICS: OVENOPSTATE.S.A0000 - verification: | - ./chip-tool ovencavityoperationalstate read phase-list 1 1 - - Via the TH (chip-tool), verify: - - that PhaseList attribute value contains either null or a list of strings. - - If not null, receord the number of entries in the list as 'phase-list-size'; execute step 7. - If null, go to step 8. - - [1689674447.761859][17290:17292] CHIP:DMG: InteractionModelRevision = 1 - [1689674447.761865][17290:17292] CHIP:DMG: } - [1689674447.761938][17290:17292] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0000 DataVersion: 2102885775 - [1689674447.761972][17290:17292] CHIP:TOO: PhaseList: null - [1689674447.762041][17290:17292] CHIP:EM: <<< [E:58737i S:13847 M:251354926 (Ack:137738036)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674447.762055][17290:17292] CHIP:IN: (S) Sending msg 251354926 on secure session with LSID: 13847 - [1689674447.762109][17290:17292] CHIP:EM: Flushed pending ack for MessageCounter:137738036 on exchange 58737i - disabled: true + command: "readAttribute" + attribute: "PhaseList" + response: + value: null - label: "Step 9: TH reads from the DUT the CurrentPhase attribute" PICS: OVENOPSTATE.S.A0001 - verification: | - ./chip-tool ovencavityoperationalstate read current-phase 1 1 - - Via the TH (chip-tool), verify: - - that the CurrentPhase attribute value contains contains a uint8 value - - that the value is between 0 and 'phase-list-size - 1'. - - [1689674497.950563][17299:17301] CHIP:DMG: } - [1689674497.950635][17299:17301] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0001 DataVersion: 2102885775 - [1689674497.950664][17299:17301] CHIP:TOO: CurrentPhase: null - [1689674497.950737][17299:17301] CHIP:EM: <<< [E:64019i S:52010 M:245677798 (Ack:138696372)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674497.950752][17299:17301] CHIP:IN: (S) Sending msg 245677798 on secure session with LSID: 52010 - [1689674497.950798][17299:17301] CHIP:EM: Flushed pending ack for MessageCounter:138696372 on exchange 64019i - [1689674497.950899][17299:17299] CHIP:CTL: Shutting down the commissioner - disabled: true + command: "readAttribute" + attribute: "CurrentPhase" + response: + value: null - label: "Step 10: TH waits for a vendor defined wait time, this being a period @@ -190,110 +121,43 @@ tests: - label: "Step 11: TH reads from the DUT the CountdownTime attribute" PICS: OVENOPSTATE.S.A0002 - verification: | - ./chip-tool ovencavityoperationalstate read countdown-time 1 1 - - - Via the TH (chip-tool), verify: - - that CountdownTime attribute contains either null our a uint32 value - - if non-null, verify that the value is in the range 1 to 259200 - - that the value is approximately 'initialcountdown-time minus the vendor defined wait time' - - - [1689674623.673661][17320:17322] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 2102885775 - [1689674623.673697][17320:17322] CHIP:TOO: CountdownTime: null - [1689674623.673755][17320:17322] CHIP:EM: <<< [E:42152i S:37580 M:19654175 (Ack:176515710)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674623.673768][17320:17322] CHIP:IN: (S) Sending msg 19654175 on secure session with LSID: 37580 - [1689674623.673795][17320:17322] CHIP:EM: Flushed pending ack for MessageCounter:176515710 on exchange 42152i - disabled: true + command: "readAttribute" + attribute: "CountdownTime" + response: + value: null - label: "Step 12: TH sends Start command to the DUT" PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool ovencavityoperationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674637.555734][17326:17328] CHIP:DMG: - [1689674637.555742][17326:17328] CHIP:DMG: InteractionModelRevision = 1 - [1689674637.555751][17326:17328] CHIP:DMG: }, - [1689674637.555784][17326:17328] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674637.555805][17326:17328] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674637.555853][17326:17328] CHIP:TOO: OperationalCommandResponse: { - [1689674637.555862][17326:17328] CHIP:TOO: commandResponseState: { - [1689674637.555872][17326:17328] CHIP:TOO: ErrorStateID: 0 - [1689674637.555883][17326:17328] CHIP:TOO: } - [1689674637.555891][17326:17328] CHIP:TOO: } - [1689674637.555913][17326:17328] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674637.555956][17326:17328] CHIP:EM: <<< [E:28742i S:49023 M:139320570 (Ack:91983883)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674637.555971][17326:17328] CHIP:IN: (S) Sending msg 139320570 on secure session with LSID: 49023 - [1689674637.556001][17326:17328] CHIP:EM: Flushed pending ack for MessageCounter:91983883 on exchange 28742i - disabled: true + command: "Start" + response: + values: + - name: "CommandResponseState" + value: { ErrorStateID: 0 } - label: "Step 13: TH sends Stop command to the DUT" PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool ovencavityoperationalstate stop 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674653.322963][17330:17332] CHIP:DMG: }, - [1689674653.322994][17330:17332] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674653.323014][17330:17332] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674653.323058][17330:17332] CHIP:TOO: OperationalCommandResponse: { - [1689674653.323066][17330:17332] CHIP:TOO: commandResponseState: { - [1689674653.323076][17330:17332] CHIP:TOO: ErrorStateID: 0 - [1689674653.323085][17330:17332] CHIP:TOO: } - [1689674653.323094][17330:17332] CHIP:TOO: } - [1689674653.323113][17330:17332] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674653.323154][17330:17332] CHIP:EM: <<< [E:62878i S:64455 M:173921517 (Ack:216732582)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674653.323168][17330:17332] CHIP:IN: (S) Sending msg 173921517 on secure session with LSID: 64455 - [1689674653.323195][17330:17332] CHIP:EM: Flushed pending ack for MessageCounter:216732582 on exchange 62878i - [1689674653.323284][17330:17330] CHIP:CTL: Shutting down the commissioner - disabled: true + command: "Stop" + response: + values: + - name: "CommandResponseState" + value: { ErrorStateID: 0 } - label: "Step 14: TH reads from the DUT the OperationalState attribute" PICS: OVENOPSTATE.S.A0004 - verification: | - ./chip-tool ovencavityoperationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x00 (Stopped) - - [1689674675.459656][17333:17335] CHIP:DMG: } - [1689674675.459738][17333:17335] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674675.459772][17333:17335] CHIP:TOO: OperationalState: { - [1689674675.459790][17333:17335] CHIP:TOO: OperationalStateID: 0 - [1689674675.459799][17333:17335] CHIP:TOO: } - [1689674675.459869][17333:17335] CHIP:EM: <<< [E:17771i S:16165 M:1572532 (Ack:102448631)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674675.459886][17333:17335] CHIP:IN: (S) Sending msg 1572532 on secure session with LSID: 16165 - [1689674675.459930][17333:17335] CHIP:EM: Flushed pending ack for MessageCounter:102448631 on exchange 17771i - disabled: true + command: "readAttribute" + attribute: "OperationalState" + response: + value: 0 + constraints: + type: enum8 - label: "Step 15: TH sends Stop command to the DUT" PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool ovencavityoperationalstate stop 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674689.588712][17337:17339] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674689.588722][17337:17339] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674689.588745][17337:17339] CHIP:TOO: OperationalCommandResponse: { - [1689674689.588749][17337:17339] CHIP:TOO: commandResponseState: { - [1689674689.588757][17337:17339] CHIP:TOO: ErrorStateID: 0 - [1689674689.588762][17337:17339] CHIP:TOO: } - [1689674689.588765][17337:17339] CHIP:TOO: } - [1689674689.588775][17337:17339] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674689.588802][17337:17339] CHIP:EM: <<< [E:63921i S:35027 M:16881995 (Ack:220265764)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674689.588810][17337:17339] CHIP:IN: (S) Sending msg 16881995 on secure session with LSID: 35027 - disabled: true + command: "Stop" + response: + values: + - name: "CommandResponseState" + value: { ErrorStateID: 0 } - label: "Step 16: Manually put the DUT into a state wherein it cannot receive @@ -310,25 +174,9 @@ tests: - label: "Step 17: TH sends Start command to the DUT" PICS: - OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp - && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool ovencavityoperationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x01 (UnableToStartOrResume) - - [1689674700.385183][17340:17342] CHIP:DMG: }, - [1689674700.385214][17340:17342] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674700.385233][17340:17342] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674700.385266][17340:17342] CHIP:TOO: OperationalCommandResponse: { - [1689674700.385274][17340:17342] CHIP:TOO: commandResponseState: { - [1689674700.385281][17340:17342] CHIP:TOO: ErrorStateID: 1 - [1689674700.385289][17340:17342] CHIP:TOO: } - [1689674700.385295][17340:17342] CHIP:TOO: } - [1689674700.385311][17340:17342] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674700.385361][17340:17342] CHIP:EM: <<< [E:55029i S:46795 M:80501191 (Ack:176711722)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674700.385375][17340:17342] CHIP:IN: (S) Sending msg 80501191 on secure session with LSID: 46795 - [1689674700.385419][17340:17342] CHIP:EM: Flushed pending ack for MessageCounter:176711722 on exchange 55029i - disabled: true + OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx + command: "Start" + response: + values: + - name: "CommandResponseState" + value: { ErrorStateID: 1 } \ No newline at end of file diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml index 7bec5e573a89f7..5dee16ac47111a 100644 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml +++ b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml @@ -20,7 +20,7 @@ PICS: config: nodeId: 0x12344321 - cluster: "Basic Information" + cluster: "Oven Cavity Operational State" endpoint: 0 tests: @@ -30,9 +30,12 @@ tests: disabled: true - label: "Step 1: Commission DUT to TH" - verification: | - - disabled: true + cluster: "DelayCommands" + command: "WaitForCommissionee" + arguments: + values: + - name: "nodeId" + value: nodeId - label: "Step 2: Set up a subscription to the OperationCompletion event" PICS: OVENOPSTATE.S.E01 @@ -50,20 +53,12 @@ tests: - label: "Step 3: TH reads from the DUT the OperationalState attribute" PICS: OVENOPSTATE.S.A0004 - verification: | - ./chip-tool ovencavityoperationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response includes an ID (enum8) amd a label (string) - - the provided ID is found in the set provided in step 4 - - the provided ID is in the allowed range - - [1689673213.434610][16591:16593] CHIP:DMG: } - [1689673213.434686][16591:16593] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689673213.434721][16591:16593] CHIP:TOO: OperationalState: { - [1689673213.434728][16591:16593] CHIP:TOO: OperationalStateID: 0 - [1689673213.434735][16591:16593] CHIP:TOO: } - disabled: true + command: "readAttribute" + attribute: "OperationalState" + response: + value: 0 + constraints: + type: enum8 - label: "Step 4: Manually put the DUT into a state wherein it can receive a @@ -89,23 +84,11 @@ tests: - label: "Step 6: TH sends Start command to the DUT" PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool ovencavityoperationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674637.555734][17326:17328] CHIP:DMG: - [1689674637.555742][17326:17328] CHIP:DMG: InteractionModelRevision = 1 - [1689674637.555751][17326:17328] CHIP:DMG: }, - [1689674637.555784][17326:17328] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674637.555805][17326:17328] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674637.555853][17326:17328] CHIP:TOO: OperationalCommandResponse: { - [1689674637.555862][17326:17328] CHIP:TOO: commandResponseState: { - [1689674637.555872][17326:17328] CHIP:TOO: ErrorStateID: 0 - [1689674637.555883][17326:17328] CHIP:TOO: } - disabled: true + command: "Start" + response: + values: + - name: "CommandResponseState" + value: { ErrorStateID: 0 } - label: "Step 7: TH waits for {PIXIT.WAITTIME}" verification: | @@ -114,19 +97,12 @@ tests: - label: "Step 8: TH reads from the DUT the OperationalState attribute" PICS: OVENOPSTATE.S.A0004 - verification: | - ./chip-tool ovencavityoperationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x01 (Running) - - [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 - [1689674196.878727][17249:17251] CHIP:DMG: } - [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { - [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 - [1689674196.878847][17249:17251] CHIP:TOO: } - disabled: true + command: "readAttribute" + attribute: "OperationalState" + response: + value: 1 + constraints: + type: enum8 - label: "Step 9: TH waits for initial-countdown-time" verification: | @@ -136,22 +112,11 @@ tests: - label: "Step 10: TH sends Stop command to the DUT" PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool ovencavityoperationalstate stop 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674653.322963][17330:17332] CHIP:DMG: }, - [1689674653.322994][17330:17332] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674653.323014][17330:17332] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674653.323058][17330:17332] CHIP:TOO: OperationalCommandResponse: { - [1689674653.323066][17330:17332] CHIP:TOO: commandResponseState: { - [1689674653.323076][17330:17332] CHIP:TOO: ErrorStateID: 0 - [1689674653.323085][17330:17332] CHIP:TOO: } - [1689674653.323094][17330:17332] CHIP:TOO: } - disabled: true + command: "Stop" + response: + values: + - name: "CommandResponseState" + value: { ErrorStateID: 0 } - label: "Step 11: erify TH receives an OperationCompletion event from the DUT @@ -175,18 +140,12 @@ tests: - label: "Step 12: TH reads from the DUT the OperationalState attribute" PICS: OVENOPSTATE.S.A0004 - verification: | - ./chip-tool ovencavityoperationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x00 (Stopped) - - [1689674675.459656][17333:17335] CHIP:DMG: } - [1689674675.459738][17333:17335] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674675.459772][17333:17335] CHIP:TOO: OperationalState: { - [1689674675.459790][17333:17335] CHIP:TOO: OperationalStateID: 0 - [1689674675.459799][17333:17335] CHIP:TOO: } - disabled: true + command: "readAttribute" + attribute: "OperationalState" + response: + value: 0 + constraints: + type: enum8 - label: "Step 13: Restart DUT and repeat step 5" verification: | @@ -195,24 +154,11 @@ tests: - label: "Step 14: TH sends Start command to the DUT" PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool ovencavityoperationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674637.555734][17326:17328] CHIP:DMG: - [1689674637.555742][17326:17328] CHIP:DMG: InteractionModelRevision = 1 - [1689674637.555751][17326:17328] CHIP:DMG: }, - [1689674637.555784][17326:17328] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674637.555805][17326:17328] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674637.555853][17326:17328] CHIP:TOO: OperationalCommandResponse: { - [1689674637.555862][17326:17328] CHIP:TOO: commandResponseState: { - [1689674637.555872][17326:17328] CHIP:TOO: ErrorStateID: 0 - [1689674637.555883][17326:17328] CHIP:TOO: } - [1689674637.555891][17326:17328] CHIP:TOO: } - disabled: true + command: "Start" + response: + values: + - name: "CommandResponseState" + value: { ErrorStateID: 0 } - label: "Step 15: TH waits for {PIXIT.WAITTIME}" verification: | @@ -221,52 +167,29 @@ tests: - label: "Step 16: TH reads from the DUT the OperationalState attribute" PICS: OVENOPSTATE.S.A0004 - verification: | - ./chip-tool ovencavityoperationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x01 (Running) - - [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 - [1689674196.878727][17249:17251] CHIP:DMG: } - [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { - [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 - [1689674196.878847][17249:17251] CHIP:TOO: } - disabled: true - + command: "readAttribute" + attribute: "OperationalState" + response: + value: 1 + constraints: + type: enum8 + - label: "Step 17: TH sends Pause command to the DUT" PICS: OVENOPSTATE.S.C00.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool ovencavityoperationalstate pause 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1690457565.893634][18795:18797] CHIP:DMG: }, - [1690457565.893663][18795:18797] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1690457565.893681][18795:18797] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1690457565.893714][18795:18797] CHIP:TOO: OperationalCommandResponse: { - [1690457565.893729][18795:18797] CHIP:TOO: commandResponseState: { - [1690457565.893736][18795:18797] CHIP:TOO: ErrorStateID: 0 - [1690457565.893744][18795:18797] CHIP:TOO: } - [1690457565.893750][18795:18797] CHIP:TOO: } - disabled: true + command: "Pause" + response: + values: + - name: "CommandResponseState" + value: { ErrorStateID: 0 } - label: "Step 18: TH reads from the DUT the OperationalState attribute" PICS: OVENOPSTATE.S.A0004 - verification: | - ./chip-tool ovencavityoperationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x02 (Paused) - - [1690457601.103082][18800:18802] CHIP:DMG: InteractionModelRevision = 1 - [1690457601.103090][18800:18802] CHIP:DMG: } - [1690457601.103210][18800:18802] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 4112784416 - [1690457601.103259][18800:18802] CHIP:TOO: OperationalState: 2 - disabled: true + command: "readAttribute" + attribute: "OperationalState" + response: + value: 2 + constraints: + type: enum8 - label: "Step 19: TH waits for half of initial-countdown-time" verification: | @@ -275,38 +198,20 @@ tests: - label: "Step 20: TH sends Resume command to the DUT" PICS: OVENOPSTATE.S.C03.Rsp && OVENOPSTATE.S.C04.Tx - verification: | - ./chip-tool ovencavityoperationalstate resume 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x03 (CommandInvalidInState) - - [1690457852.049135][18877:18879] CHIP:DMG: }, - [1690457852.049164][18877:18879] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1690457852.049183][18877:18879] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1690457852.049217][18877:18879] CHIP:TOO: OperationalCommandResponse: { - [1690457852.049224][18877:18879] CHIP:TOO: commandResponseState: { - [1690457852.049238][18877:18879] CHIP:TOO: ErrorStateID: 3 - [1690457852.049246][18877:18879] CHIP:TOO: } - [1690457852.049252][18877:18879] CHIP:TOO: } - disabled: true + command: "Resume" + response: + values: + - name: "CommandResponseState" + value: { ErrorStateID: 3} - label: "Step 21: TH reads from the DUT the OperationalState attribute" PICS: OVENOPSTATE.S.A0004 - verification: | - ./chip-tool ovencavityoperationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x01 (Running) - - [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 - [1689674196.878727][17249:17251] CHIP:DMG: } - [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { - [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 - [1689674196.878847][17249:17251] CHIP:TOO: } - disabled: true + command: "readAttribute" + attribute: "OperationalState" + response: + value: 1 + constraints: + type: enum8 - label: "Step 22: TH waits for initial-countdown-time" verification: | @@ -315,6 +220,11 @@ tests: - label: "Step 23: TH sends Stop command to the DUT" PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx + command: "Stop" + response: + values: + - name: "CommandResponseState" + value: { ErrorStateID: 0 } verification: | ./chip-tool ovencavityoperationalstate stop 1 1 diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index d7bed1bb2ee603..f083ed27b45627 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -1877,19 +1877,19 @@ OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE=1 # Server Attributes OVENOPSTATE.S.A0000=1 OVENOPSTATE.S.A0001=1 -OVENOPSTATE.S.A0002=0 +OVENOPSTATE.S.A0002=1 OVENOPSTATE.S.A0003=1 OVENOPSTATE.S.A0004=1 OVENOPSTATE.S.A0005=1 -OVENOPSTATE.S.C00.Rsp=0 -OVENOPSTATE.S.C01.Rsp=0 -OVENOPSTATE.S.C02.Rsp=0 -OVENOPSTATE.S.C03.Rsp=0 -OVENOPSTATE.S.C04.Tx=0 +OVENOPSTATE.S.C00.Rsp=1 +OVENOPSTATE.S.C01.Rsp=1 +OVENOPSTATE.S.C02.Rsp=1 +OVENOPSTATE.S.C03.Rsp=1 +OVENOPSTATE.S.C04.Tx=1 # Server Events OVENOPSTATE.S.E00=1 -OVENOPSTATE.S.E01=0 +OVENOPSTATE.S.E01=1 # Thermostat # Server diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 0c9cba382e18d8..31ae60e07bae0a 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -180,6 +180,7 @@ "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], "OvenCavityOperationalState": [ "Test_TC_OVENOPSTATE_1_1", + "Test_TC_OVENOPSTATE_2_2", "Test_TC_OVENOPSTATE_2_4" ], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], diff --git a/src/python_testing/TC_OVENOPSTATE_2_2.py b/src/python_testing/TC_OVENOPSTATE_2_2.py new file mode 100644 index 00000000000000..aeed4f949ba1ac --- /dev/null +++ b/src/python_testing/TC_OVENOPSTATE_2_2.py @@ -0,0 +1,208 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging +import time + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches +from mobly import asserts + +# This test requires several additional command line arguments +# run with +# --int-arg PIXIT_ENDPOINT: + + +class TC_OVENOPSTATE_2_2(MatterBaseTest): + + async def read_mod_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.OvenCavityOperationalState + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + async def send_start_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Start: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Start(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), + "Unexpected return type for Start") + return ret + + async def send_pause_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Pause: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Pause(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), + "Unexpected return type for Pause") + return ret + + async def send_resume_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Resume: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Resume(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), + "Unexpected return type for Resume") + return ret + + async def send_stop_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Stop: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Stop(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), + "Unexpected return type for Stop") + return ret + + async def read_and_validate_opstate(self, step, expected_state): + self.print_step(step, "Read OperationalState attribute") + operational_state = await self.read_mod_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, expected_state, + "OperationalState(%s) should equal %s" % (operational_state, expected_state)) + + async def read_and_validate_operror(self, step, expected_error): + self.print_step(step, "Read OperationalError attribute") + operational_error = await self.read_mod_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalError) + logging.info("OperationalError: %s" % (operational_error)) + asserts.assert_equal(operational_error.errorStateID, expected_error, + "errorStateID(%s) should equal %s" % (operational_error.errorStateID, expected_error)) + + @async_test_body + async def test_TC_OVENOPSTATE_2_2(self): + + asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, + "PIXIT_ENDPOINT must be included on the command line in " + "the --int-arg flag as PIXIT_ENDPOINT:") + + self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] + + attributes = Clusters.OvenCavityOperationalState.Attributes + + + self.print_step(1, "Commissioning, already done") + + self.print_step(2, "Manually put the DUT into a state wherein it can receive a Start Command") + input("Press Enter when done.\n") + + if self.check_pics("OVENOPSTATE.S.A0003"): + self.print_step(3, "Read OperationalStateList attribute") + OperationalState_List = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.OperationalStateList) + + if OperationalState_List == NullValue: + logging.info("OperationalStateList is null") + else: + logging.info("OperationalStateList: %s" % (OperationalState_List)) + temp=[0,1,2,3] + for i, state in enumerate(OperationalState_List): + asserts.assert_equal(state.operationalStateID,temp[i],"operationalStateID(%s) should equal %s" %(state.operationalStateID,temp[i])) + + if self.check_pics("OVENOPSTATE.S.C02.Rsp" and "OVENOPSTATE.S.C04.Tx"): + self.print_step(4, "Send Start command") + ret = await self.send_start_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + if self.check_pics("OVENOPSTATE.S.A0004"): + self.print_step(5, "Read operationalState Attribute") + operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, + "OperationalState ID should be Running(0x01)") + + if self.check_pics("OVENOPSTATE.S.A0005"): + self.print_step(6, "Read operationalError Attribute") + operational_error=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalError) + logging.info("OperationalState: %s" % (operational_error)) + asserts.assert_equal(operational_error, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kNoError, + "OperationalState ID should be NoError(0x00)") + + if self.check_pics("OVENOPSTATE.S.A0002"): + self.print_step(7, "Read CountdownTime attribute") + initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.CountdownTime) + logging.info("CountdownTime: %s" % (initial_countdown_time)) + if initial_countdown_time is not NullValue: + in_range = (1 <= initial_countdown_time <= 259200) + asserts.assert_true(initial_countdown_time is NullValue or in_range, + "invalid CountdownTime(%s). Must be in between 1 and 259200, or null " % initial_countdown_time) + + if self.check_pics("OVENOPSTATE.S.A0000"): + self.print_step(8, "Read PhaseList attribute") + phase_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.PhaseList) + + if phase_list == NullValue: + logging.info("PhaseList is null") + else: + logging.info("PhaseList: %s" % (phase_list)) + phase_list_len=len(phase_list) + + if self.check_pics("OVENOPSTATE.S.A0001" and phase_list_len): + self.print_step(9, "Read CurrentPhase attribute") + current_phase = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentPhase) + logging.info("CurrentPhase: %s" % (current_phase)) + asserts.assert_true(0 <= current_phase and current_phase < phase_list_len, + "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) + + if self.check_pics("OVENOPSTATE.S.A0002"): + self.print_step(10, "TH waits for a vendor defined wait time, this being a period of time less than the expected duration of the operation that has been started") + init_time=time.time() + input("Press enter when done. \n") + end_time=time.time()-init_time + + + if self.check_pics("OVENOPSTATE.S.A0002"): + self.print_step(11, "Read countdowntime Attribute") + countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.CountdownTime) + logging.info("CountdownTime: %s" % (countdown_time)) + asserts.assert_true(countdown_time is not NullValue or countdown_time>end_time or countdown_time>initial_countdown_time, + "invalid CountdownTime(%s). Must be in between end_time value and less than initial_countdown_time, or null " % countdown_time) + + if self.check_pics("OVENOPSTATE.S.C02.Rsp" and "OVENOPSTATE.S.C04.Tx"): + self.print_step(12, "Send Start command") + ret = await self.send_start_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + if self.check_pics("OVENOPSTATE.S.C01.Rsp" and "OVENOPSTATE.S.C04.Tx"): + self.print_step(13, "Send Stop command") + ret = await self.send_stop_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + if self.check_pics("OVENOPSTATE.S.A0004"): + self.print_step(14, "Read operationalState Attribute") + operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kStopped, + "OperationalState ID should be Stopped(0x00)") + + if self.check_pics("OVENOPSTATE.S.C01.Rsp" and "OVENOPSTATE.S.C04.Tx"): + self.print_step(15, "Send Stop command") + ret = await self.send_stop_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + if self.check_pics("OVENOPSTATE.M.ERR_UNABLE_TO_START_OR_RESUME"): + self.print_step(16, "Manually put the DUT into a state wherein it cannot receive a Start Command") + input("Press Enter when done.\n") + + if self.check_pics("OVENOPSTATE.M.ERR_UNABLE_TO_START_OR_RESUME" and "OVENOPSTATE.S.C02.Rsp" and "OVENOPSTATE.S.C04.Tx"): + self.print_step(17, "Send Start command") + ret = await self.send_start_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kError, + "errorStateID(%s) should be set to UnableToStartOrResume(0x01)" % ret.commandResponseState.errorStateID) + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_OVENOPSTATE_2_5.py b/src/python_testing/TC_OVENOPSTATE_2_5.py new file mode 100644 index 00000000000000..a54d1da320a3ec --- /dev/null +++ b/src/python_testing/TC_OVENOPSTATE_2_5.py @@ -0,0 +1,238 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging +import time + +import chip.clusters as Clusters +from chip.clusters.Types import NullValue +from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches +from mobly import asserts + +# This test requires several additional command line arguments +# run with +# --int-arg PIXIT_ENDPOINT: + +class TC_OVENOPSTATE_2_5(MatterBaseTest): + + async def read_mod_attribute_expect_success(self, endpoint, attribute): + cluster = Clusters.Objects.OvenCavityOperationalState + return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + async def send_start_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Start: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Start(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), + "Unexpected return type for Start") + return ret + + async def send_pause_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Pause: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Pause(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), + "Unexpected return type for Pause") + return ret + + async def send_resume_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Resume: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Resume(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), + "Unexpected return type for Resume") + return ret + + async def send_stop_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Stop: + ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Stop(), endpoint=self.endpoint) + asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), + "Unexpected return type for Stop") + return ret + + async def read_and_validate_opstate(self, step, expected_state): + self.print_step(step, "Read OperationalState attribute") + operational_state = await self.read_mod_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, expected_state, + "OperationalState(%s) should equal %s" % (operational_state, expected_state)) + + async def read_and_validate_operror(self, step, expected_error): + self.print_step(step, "Read OperationalError attribute") + operational_error = await self.read_mod_attribute_expect_success( + endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalError) + logging.info("OperationalError: %s" % (operational_error)) + asserts.assert_equal(operational_error.errorStateID, expected_error, + "errorStateID(%s) should equal %s" % (operational_error.errorStateID, expected_error)) + + @async_test_body + async def test_TC_OVENOPSTATE_2_5(self): + + asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, + "PIXIT_ENDPOINT must be included on the command line in " + "the --int-arg flag as PIXIT_ENDPOINT:") + + self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] + + attributes = Clusters.OvenCavityOperationalState.Attributes + + + self.print_step(1, "Commissioning, already done") + + # step 2 set subscription to the OperationCompletion event + + if self.check_pics("OVENOPSTATE.A0004"): + self.print_step(3, "Read operationalState Attribute") + operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kNoError, + "OperationalState ID should be NoError(0x00)") + + self.print_step(4, "Manually put the DUT into a state wherein it can receive a Start Command") + input("press enter when done, \n") + + if self.check_pics("OVENOPSTATE.S.A0002"): + self.print_step(5, "Read CountdownTime attribute") + initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.CountdownTime) + logging.info("CountdownTime: %s" % (initial_countdown_time)) + if initial_countdown_time is not NullValue: + in_range = (1 > initial_countdown_time <= 3600) + in_range1=(initial_countdown_time > "PIXIT.COUNTDOWN.THRESHOLD") + + asserts.assert_true(initial_countdown_time is NullValue or in_range or in_range1, + "invalid CountdownTime(%s). Must be in between 1 and 1 hour, or null " % initial_countdown_time) + + if self.check_pics("OVENOPSTATE.S.C02.Rsp" and "OVENOPSTATE.S.C04.Tx"): + self.print_step(6, "Send Start command") + ret = await self.send_start_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + self.print_step(7, "TH Waits for PIXIT.WAITTIME") + time.sleep("PIXIT.WAITTIME") + + if self.check_pics("OVENOPSTATE.S.A0004"): + self.print_step(8, "Read operationalState Attribute") + operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, + "OperationalState ID should be Running(0x01)") + + self.print_step(9, "TH Waits for initial_countdown_time ") + time.sleep(initial_countdown_time) + + if self.check_pics("OVENOPSTATE.S.C01.Rsp" and "OVENOPSTATE.S.C04.Tx"): + self.print_step(10, "Send Stop command") + ret = await self.send_stop_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + self.print_step(11, "Operationalcompletion") + + + if self.check_pics("OVENOPSTATE.S.A0004"): + self.print_step(12, "Read operationalState Attribute") + operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kStopped, + "OperationalState ID should be Stopped (0x00)") + + self.print_step(13, "Manually RESTART THE DUT") + input("press enter when done, \n") + if self.check_pics("OVENOPSTATE.S.A0002"): + self.print_step(13, "Read CountdownTime attribute") + initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.CountdownTime) + logging.info("CountdownTime: %s" % (initial_countdown_time)) + if initial_countdown_time is not NullValue: + in_range = (1 > initial_countdown_time <= 3600) + in_range1=(initial_countdown_time > "PIXIT.COUNTDOWN.THRESHOLD") + + if self.check_pics("OVENOPSTATE.S.C02.Rsp" and "OVENOPSTATE.S.C04.Tx"): + self.print_step(14, "Send Start command") + ret = await self.send_start_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + self.print_step(15, "TH Waits for PIXIT.WAITTIME") + time.sleep("PIXIT.WAITTIME") + + if self.check_pics("OVENOPSTATE.S.A0004"): + self.print_step(16, "Read operationalState Attribute") + operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, + "OperationalState ID should be Running (0x01)") + + if self.check_pics("OVENOPSTATE.S.C00.Rsp" and "OVENOPSTATE.S.C04.Tx"): + self.print_step(17, "Send Pause command") + ret = await self.send_pause_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + if self.check_pics("OVENOPSTATE.S.A0004"): + self.print_step(18, "Read operationalState Attribute") + operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kPaused, + "OperationalState ID should be paused (0x02)") + + self.print_step(19, "TH Waits for half of initial_countdown_time ") + time.sleep(initial_countdown_time//2) + + if self.check_pics("OVENOPSTATE.S.C03.Rsp" and "OVENOPSTATE.S.C04.Tx"): + self.print_step(20, "Send Resume command") + ret = await self.send_resume_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + if self.check_pics("OVENOPSTATE.S.A0004"): + self.print_step(21, "Read operationalState Attribute") + operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + attribute=attributes.OperationalState) + logging.info("OperationalState: %s" % (operational_state)) + asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, + "OperationalState ID should be Running(0x01)") + + self.print_step(22, "TH Waits for initial_countdown_time") + time.sleep(initial_countdown_time) + + if self.check_pics("OVENOPSTATE.S.C01.Rsp" and "OVENOPSTATE.S.C04.Tx"): + self.print_step(23, "Send Stop command") + ret = await self.send_stop_cmd() + asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + self.print_step(24, "Operationalcompletion") + +if __name__ == "__main__": + default_matter_test_main() + + + + + + + + + + + + + + + diff --git a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h index 4b813181982c3d..b74ac374617ef8 100644 --- a/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h +++ b/zzz_generated/darwin-framework-tool/zap-generated/test/Commands.h @@ -185,6 +185,7 @@ class TestList : public Command { printf("Test_TC_OO_2_4\n"); printf("Test_TC_OPSTATE_1_1\n"); printf("Test_TC_OVENOPSTATE_1_1\n"); + printf("Test_TC_OVENOPSTATE_2_2\n"); printf("Test_TC_PS_1_1\n"); printf("Test_TC_PS_2_1\n"); printf("Test_TC_PRS_1_1\n"); @@ -90772,6 +90773,638 @@ class Test_TC_OVENOPSTATE_1_1 : public TestCommandBridge { } }; +class Test_TC_OVENOPSTATE_2_2 : public TestCommandBridge { +public: + // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced + Test_TC_OVENOPSTATE_2_2() + : TestCommandBridge("Test_TC_OVENOPSTATE_2_2") + , mTestIndex(0) + { + AddArgument("nodeId", 0, UINT64_MAX, &mNodeId); + AddArgument("cluster", &mCluster); + AddArgument("endpoint", 0, UINT16_MAX, &mEndpoint); + AddArgument("timeout", 0, UINT16_MAX, &mTimeout); + } + // NOLINTEND(clang-analyzer-nullability.NullPassedToNonnull) + + ~Test_TC_OVENOPSTATE_2_2() + { + } + + /////////// TestCommand Interface ///////// + void NextTest() override + { + CHIP_ERROR err = CHIP_NO_ERROR; + + if (0 == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Start: Test_TC_OVENOPSTATE_2_2\n"); + } + + if (mTestCount == mTestIndex) { + ChipLogProgress(chipTool, " **** Test Complete: Test_TC_OVENOPSTATE_2_2\n"); + SetCommandExitStatus(CHIP_NO_ERROR); + return; + } + + Wait(); + + // Ensure we increment mTestIndex before we start running the relevant + // command. That way if we lose the timeslice after we send the message + // but before our function call returns, we won't end up with an + // incorrect mTestIndex value observed when we get the response. + switch (mTestIndex++) { + case 0: + ChipLogProgress(chipTool, " ***** Test Step 0 : Step 1: Commission DUT to TH\n"); + err = TestStep1CommissionDutToTh_0(); + break; + case 1: + ChipLogProgress(chipTool, " ***** Test Step 1 : Step 2: Manually put the DUT into a state wherein it can receive a Start Command\n"); + if (ShouldSkip("PICS_USER_PROMPT")) { + NextTest(); + return; + } + err = TestStep2ManuallyPutTheDutIntoAStateWhereinItCanReceiveAStartCommand_1(); + break; + case 2: + ChipLogProgress(chipTool, " ***** Test Step 2 : Step 3: TH reads from the DUT the OperationalStateList attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0003")) { + NextTest(); + return; + } + err = TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_2(); + break; + case 3: + ChipLogProgress(chipTool, " ***** Test Step 3 : Step 4: TH sends Start command to the DUT\n"); + if (ShouldSkip("OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx")) { + NextTest(); + return; + } + err = TestStep4ThSendsStartCommandToTheDut_3(); + break; + case 4: + ChipLogProgress(chipTool, " ***** Test Step 4 : Step 5: TH reads from the DUT the OperationalState attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0004")) { + NextTest(); + return; + } + err = TestStep5ThReadsFromTheDutTheOperationalStateAttribute_4(); + break; + case 5: + ChipLogProgress(chipTool, " ***** Test Step 5 : Step 6: TH reads from the DUT the OperationalError attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0005")) { + NextTest(); + return; + } + err = TestStep6ThReadsFromTheDutTheOperationalErrorAttribute_5(); + break; + case 6: + ChipLogProgress(chipTool, " ***** Test Step 6 : Step 7: TH reads from the DUT the CountdownTime attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0002")) { + NextTest(); + return; + } + err = TestStep7ThReadsFromTheDutTheCountdownTimeAttribute_6(); + break; + case 7: + ChipLogProgress(chipTool, " ***** Test Step 7 : Step 8: TH reads from the DUT the PhaseList attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0000")) { + NextTest(); + return; + } + err = TestStep8ThReadsFromTheDutThePhaseListAttribute_7(); + break; + case 8: + ChipLogProgress(chipTool, " ***** Test Step 8 : Step 9: TH reads from the DUT the CurrentPhase attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0001")) { + NextTest(); + return; + } + err = TestStep9ThReadsFromTheDutTheCurrentPhaseAttribute_8(); + break; + case 9: + ChipLogProgress(chipTool, " ***** Test Step 9 : Step 11: TH reads from the DUT the CountdownTime attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0002")) { + NextTest(); + return; + } + err = TestStep11ThReadsFromTheDutTheCountdownTimeAttribute_9(); + break; + case 10: + ChipLogProgress(chipTool, " ***** Test Step 10 : Step 12: TH sends Start command to the DUT\n"); + if (ShouldSkip("OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx")) { + NextTest(); + return; + } + err = TestStep12ThSendsStartCommandToTheDut_10(); + break; + case 11: + ChipLogProgress(chipTool, " ***** Test Step 11 : Step 13: TH sends Stop command to the DUT\n"); + if (ShouldSkip("OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx")) { + NextTest(); + return; + } + err = TestStep13ThSendsStopCommandToTheDut_11(); + break; + case 12: + ChipLogProgress(chipTool, " ***** Test Step 12 : Step 14: TH reads from the DUT the OperationalState attribute\n"); + if (ShouldSkip("OVENOPSTATE.S.A0004")) { + NextTest(); + return; + } + err = TestStep14ThReadsFromTheDutTheOperationalStateAttribute_12(); + break; + case 13: + ChipLogProgress(chipTool, " ***** Test Step 13 : Step 15: TH sends Stop command to the DUT\n"); + if (ShouldSkip("OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx")) { + NextTest(); + return; + } + err = TestStep15ThSendsStopCommandToTheDut_13(); + break; + case 14: + ChipLogProgress(chipTool, " ***** Test Step 14 : Step 16: Manually put the DUT into a state wherein it cannot receive a Start Command\n"); + if (ShouldSkip("PICS_USER_PROMPT && OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME")) { + NextTest(); + return; + } + err = TestStep16ManuallyPutTheDutIntoAStateWhereinItCannotReceiveAStartCommand_14(); + break; + case 15: + ChipLogProgress(chipTool, " ***** Test Step 15 : Step 17: TH sends Start command to the DUT\n"); + if (ShouldSkip("OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx")) { + NextTest(); + return; + } + err = TestStep17ThSendsStartCommandToTheDut_15(); + break; + } + + if (CHIP_NO_ERROR != err) { + ChipLogError(chipTool, " ***** Test Failure: %s\n", chip::ErrorStr(err)); + SetCommandExitStatus(err); + } + } + + void OnStatusUpdate(const chip::app::StatusIB & status) override + { + switch (mTestIndex - 1) { + case 0: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 1: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 2: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 3: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 4: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 5: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 6: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 7: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 8: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 9: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 10: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 11: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 12: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 13: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 14: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + case 15: + VerifyOrReturn(CheckValue("status", chip::to_underlying(status.mStatus), 0)); + break; + } + + // Go on to the next test. + ContinueOnChipMainThread(CHIP_NO_ERROR); + } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(mTimeout.ValueOr(kTimeoutInSeconds)); } + +private: + std::atomic_uint16_t mTestIndex; + const uint16_t mTestCount = 16; + + chip::Optional mNodeId; + chip::Optional mCluster; + chip::Optional mEndpoint; + chip::Optional mTimeout; + + CHIP_ERROR TestStep1CommissionDutToTh_0() + { + + chip::app::Clusters::DelayCommands::Commands::WaitForCommissionee::Type value; + value.nodeId = mNodeId.HasValue() ? mNodeId.Value() : 305414945ULL; + return WaitForCommissionee("alpha", value); + } + + CHIP_ERROR TestStep2ManuallyPutTheDutIntoAStateWhereinItCanReceiveAStartCommand_1() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep3ThReadsFromTheDutTheOperationalStateListAttribute_2() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 3: TH reads from the DUT the OperationalStateList attribute: Error: %@", err); + } else { + NSLog(@"Step 3: TH reads from the DUT the OperationalStateList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalStateList", [actualValue count], static_cast(4))); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[0]).operationalStateID, 0U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[1]).operationalStateID, 1U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[2]).operationalStateID, 2U)); + VerifyOrReturn(CheckValue("OperationalStateID", ((MTROvenCavityOperationalStateClusterOperationalStateStruct *) actualValue[3]).operationalStateID, 3U)); + } + + VerifyOrReturn(CheckConstraintType("operationalStateList", "list", "list")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep4ThSendsStartCommandToTheDut_3() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster startWithCompletion: + ^(MTROvenCavityOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 4: TH sends Start command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 4: TH sends Start command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.commandResponseState; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTROvenCavityOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep5ThReadsFromTheDutTheOperationalStateAttribute_4() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 5: TH reads from the DUT the OperationalState attribute: Error: %@", err); + } else { + NSLog(@"Step 5: TH reads from the DUT the OperationalState attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 1U)); + } + + VerifyOrReturn(CheckConstraintType("operationalState", "enum8", "enum8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep6ThReadsFromTheDutTheOperationalErrorAttribute_5() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalErrorWithCompletion:^(MTROvenCavityOperationalStateClusterErrorStateStruct * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 6: TH reads from the DUT the OperationalError attribute: Error: %@", err); + } else { + NSLog(@"Step 6: TH reads from the DUT the OperationalError attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTROvenCavityOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep7ThReadsFromTheDutTheCountdownTimeAttribute_6() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCountdownTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 7: TH reads from the DUT the CountdownTime attribute: Error: %@", err); + } else { + NSLog(@"Step 7: TH reads from the DUT the CountdownTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("CountdownTime", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep8ThReadsFromTheDutThePhaseListAttribute_7() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributePhaseListWithCompletion:^(NSArray * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 8: TH reads from the DUT the PhaseList attribute: Error: %@", err); + } else { + NSLog(@"Step 8: TH reads from the DUT the PhaseList attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("PhaseList", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep9ThReadsFromTheDutTheCurrentPhaseAttribute_8() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCurrentPhaseWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 9: TH reads from the DUT the CurrentPhase attribute: Error: %@", err); + } else { + NSLog(@"Step 9: TH reads from the DUT the CurrentPhase attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("CurrentPhase", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep11ThReadsFromTheDutTheCountdownTimeAttribute_9() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeCountdownTimeWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 11: TH reads from the DUT the CountdownTime attribute: Error: %@", err); + } else { + NSLog(@"Step 11: TH reads from the DUT the CountdownTime attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValueNull("CountdownTime", actualValue)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep12ThSendsStartCommandToTheDut_10() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster startWithCompletion: + ^(MTROvenCavityOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 12: TH sends Start command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 12: TH sends Start command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.commandResponseState; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTROvenCavityOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep13ThSendsStopCommandToTheDut_11() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster stopWithCompletion: + ^(MTROvenCavityOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 13: TH sends Stop command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 13: TH sends Stop command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.commandResponseState; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTROvenCavityOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep14ThReadsFromTheDutTheOperationalStateAttribute_12() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster readAttributeOperationalStateWithCompletion:^(NSNumber * _Nullable value, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 14: TH reads from the DUT the OperationalState attribute: Error: %@", err); + } else { + NSLog(@"Step 14: TH reads from the DUT the OperationalState attribute: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = value; + VerifyOrReturn(CheckValue("OperationalState", actualValue, 0U)); + } + + VerifyOrReturn(CheckConstraintType("operationalState", "enum8", "enum8")); + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep15ThSendsStopCommandToTheDut_13() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster stopWithCompletion: + ^(MTROvenCavityOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 15: TH sends Stop command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 15: TH sends Stop command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.commandResponseState; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTROvenCavityOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 0U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } + + CHIP_ERROR TestStep16ManuallyPutTheDutIntoAStateWhereinItCannotReceiveAStartCommand_14() + { + + chip::app::Clusters::LogCommands::Commands::UserPrompt::Type value; + value.message = chip::Span("Please enter 'y' for successgarbage: not in length on purpose", 28); + value.expectedValue.Emplace(); + value.expectedValue.Value() = chip::Span("ygarbage: not in length on purpose", 1); + return UserPrompt("alpha", value); + } + + CHIP_ERROR TestStep17ThSendsStartCommandToTheDut_15() + { + + MTRBaseDevice * device = GetDevice("alpha"); + __auto_type * cluster = [[MTRBaseClusterOvenCavityOperationalState alloc] initWithDevice:device endpointID:@(1) queue:mCallbackQueue]; + VerifyOrReturnError(cluster != nil, CHIP_ERROR_INCORRECT_STATE); + + [cluster startWithCompletion: + ^(MTROvenCavityOperationalStateClusterOperationalCommandResponseParams * _Nullable values, NSError * _Nullable err) { + if (err != nil) { + NSLog(@"Step 17: TH sends Start command to the DUT: Error: %@", err); + } else { + NSLog(@"Step 17: TH sends Start command to the DUT: Success"); + } + + VerifyOrReturn(CheckValue("status", err ? err.code : 0, 0)); + + { + id actualValue = values.commandResponseState; + VerifyOrReturn(CheckValue("ErrorStateID", ((MTROvenCavityOperationalStateClusterErrorStateStruct *) actualValue).errorStateID, 1U)); + } + + NextTest(); + }]; + + return CHIP_NO_ERROR; + } +}; + class Test_TC_PS_1_1 : public TestCommandBridge { public: // NOLINTBEGIN(clang-analyzer-nullability.NullPassedToNonnull): Test constructor nullability not enforced @@ -194144,6 +194777,7 @@ void registerCommandsTests(Commands & commands) make_unique(), make_unique(), make_unique(), + make_unique(), make_unique(), make_unique(), make_unique(), From d3b27e73a99d60552d1b4b7e3f691c53a0f57f4e Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Tue, 6 Feb 2024 18:43:40 -0300 Subject: [PATCH 44/89] Removed YAML test --- .../Test_TC_OVENOPSTATE_1_1.yaml | 155 ------------------ src/app/tests/suites/ciTests.json | 6 - src/app/tests/suites/manualTests.json | 5 - 3 files changed, 166 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml deleted file mode 100644 index fd70f795b6f085..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_1_1.yaml +++ /dev/null @@ -1,155 +0,0 @@ -# Copyright (c) 2023 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: 3.1.1. [TC-OVENOPSTATE-1.1] Global attributes with server as DUT -PICS: - - OVENOPSTATE.S - -config: - nodeId: 0x12344321 - cluster: "Oven Cavity Operational State" - endpoint: 1 - -tests: - - label: "Step 1: Wait for the commissioned device to be retrieved" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Step 2: TH reads the ClusterRevision attribute from the DUT" - command: "readAttribute" - attribute: "ClusterRevision" - response: - value: 1 - constraints: - type: int16u - - - label: "Step 3: TH reads the FeatureMap attribute from the DUT" - command: "readAttribute" - attribute: "FeatureMap" - response: - value: 0 - constraints: - type: bitmap32 - - - label: "Step 4a: TH reads the AttributeList attribute from the DUT" - PICS: PICS_EVENT_LIST_ENABLED - command: "readAttribute" - attribute: "AttributeList" - response: - constraints: - type: list - contains: - [0, 1, 3, 4, 5, 65528, 65529, 65530, 65531, 65532, 65533] - - - label: "Step 4a: TH reads the AttributeList attribute from the DUT" - PICS: "!PICS_EVENT_LIST_ENABLED" - command: "readAttribute" - attribute: "AttributeList" - response: - constraints: - type: list - contains: [0, 1, 3, 4, 5, 65528, 65529, 65531, 65532, 65533] - - - label: - "Step 4b: TH reads from the DUT the optional attribute(CountdownTime) - in the AttributeList from the DUT" - PICS: OVENOPSTATE.S.A0002 - command: "readAttribute" - attribute: "AttributeList" - response: - constraints: - type: list - contains: [2] - - - label: "Step 5a: TH reads from the DUT the EventList attribute." - PICS: PICS_EVENT_LIST_ENABLED - command: "readAttribute" - attribute: "EventList" - response: - constraints: - type: list - contains: [0x00] - - - label: - "Step 5b: TH reads from the DUT the optional - event(OperationCompletion) in EventList." - PICS: PICS_EVENT_LIST_ENABLED && OVENOPSTATE.S.E01 - command: "readAttribute" - attribute: "EventList" - response: - constraints: - type: list - contains: [0x01] - - - label: "Step 6a: Read the optional command(Start) in AcceptedCommandList" - PICS: OVENOPSTATE.S.C02.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [1, 2] - - - label: "Step 6b: Read the optional command(Stop) in AcceptedCommandList" - PICS: OVENOPSTATE.S.C01.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [1] - - - label: "Step 6c: Read the optional command(Pause) in AcceptedCommandList" - PICS: OVENOPSTATE.S.C00.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [0, 3] - - - label: "Step 6d: Read the optional command(Resume) in AcceptedCommandList" - PICS: OVENOPSTATE.S.C03.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [0, 3] - - - label: "Step 7: Read the global attribute: GeneratedCommandList" - PICS: - "!OVENOPSTATE.S.C00.Rsp && !OVENOPSTATE.S.C01.Rsp && - !OVENOPSTATE.S.C02.Rsp && !OVENOPSTATE.S.C03.Rsp" - command: "readAttribute" - attribute: "GeneratedCommandList" - response: - value: [] - constraints: - type: list - - - label: "Step 7: Read the global attribute: GeneratedCommandList" - PICS: - (OVENOPSTATE.S.C00.Rsp || OVENOPSTATE.S.C01.Rsp || - OVENOPSTATE.S.C02.Rsp || OVENOPSTATE.S.C03.Rsp) - command: "readAttribute" - attribute: "GeneratedCommandList" - response: - constraints: - type: list - contains: [4] diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 31ae60e07bae0a..9594ea623d1717 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -178,11 +178,6 @@ "Test_TC_OO_2_4" ], "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], - "OvenCavityOperationalState": [ - "Test_TC_OVENOPSTATE_1_1", - "Test_TC_OVENOPSTATE_2_2", - "Test_TC_OVENOPSTATE_2_4" - ], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], "PressureMeasurement": [ "Test_TC_PRS_1_1", @@ -421,7 +416,6 @@ "OccupancySensing", "OnOff", "OperationalState", - "OvenCavityOperationalState", "PowerSource", "PressureMeasurement", "PumpConfigurationControl", diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index c7d883aa46065e..0263fc258b8db0 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -277,10 +277,6 @@ "LaundryWasherMode": ["Test_TC_LWM_1_2"], "OnOff": ["Test_TC_OO_2_3"], "OperationalState": ["Test_TC_OPSTATE_2_2", "Test_TC_OPSTATE_2_5"], - "OvenCavityOperationalState": [ - "Test_TC_OVENOPSTATE_2_2", - "Test_TC_OVENOPSTATE_2_5" - ], "RelativeHumidityMeasurement": ["Test_TC_RH_2_2"], "SmokeCOAlarm": [], "RefrigeratorAlarm": ["Test_TC_REFALM_2_2", "Test_TC_REFALM_2_3"], @@ -359,7 +355,6 @@ "OnOff", "OvenMode", "OperationalState", - "OvenCavityOperationalState", "OvenMode", "RelativeHumidityMeasurement", "SmokeCOAlarm", From a246444f0b4203703c7eb0d7d25c882fe1c8c0c1 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Tue, 6 Feb 2024 18:44:04 -0300 Subject: [PATCH 45/89] added python tests --- .github/workflows/tests.yaml | 1 + src/python_testing/TC_OVENOPSTATE_1_1.py | 124 +++++++++++++ src/python_testing/TC_OpstateCommon.py | 217 +++++++++++++++++++++++ 3 files changed, 342 insertions(+) create mode 100644 src/python_testing/TC_OVENOPSTATE_1_1.py create mode 100644 src/python_testing/TC_OpstateCommon.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 61db68f0233509..49bcd154fdd045 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -508,6 +508,7 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestConformanceSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestSpecParsingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/TestTimeSyncTrustedTimeSourceRunner.py' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_1_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - name: Uploading core files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} diff --git a/src/python_testing/TC_OVENOPSTATE_1_1.py b/src/python_testing/TC_OVENOPSTATE_1_1.py new file mode 100644 index 00000000000000..fe0158e0e8f110 --- /dev/null +++ b/src/python_testing/TC_OVENOPSTATE_1_1.py @@ -0,0 +1,124 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +import chip.clusters as Clusters +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from mobly import asserts +from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo, TestPlanConfig + + +class TC_OVENOPSTATE_1_1(MatterBaseTest): + def __init__(self, *args): + super().__init__(*args) + + test_info = TestInfo( + "OVENOPSTATE", + Clusters.OvenCavityOperationalState + ) + + test_plan_config = TestPlanConfig( + 1, + 0 + ) + + self.TC_BASE = TC_OVENOPSTATE_BASE( + self, + test_info, + test_plan_config) + self.endpoint = 0 + + + def steps_TC_OVENOPSTATE_1_1(self) -> list[TestStep]: + return self.TC_BASE.steps_TC_OPSTATE_BASE_1_1() + + def pics_TC_OVENOPSTATE_1_1(self) -> list[str]: + return ["OVENOPSTATE.S"] + + @async_test_body + async def test_TC_OVENOPSTATE_1_1(self): + self.endpoint = self.matter_test_config.endpoint + + + tc_result = await self.TC_BASE.test_TC_OPSTATE_BASE_1_1(self.endpoint) + + + + # # Verify that each ModeOptionsStruct entry has a unique Mode field value + # for m in supported_modes: + # if m.mode in self.supported_modes_dut: + # asserts.fail("SupportedModes must have unique mode values!") + # else: + # self.supported_modes_dut.append(m.mode) + + # # Verify that each ModeOptionsStruct entry has a unique Label field value + # labels = [] + # for m in supported_modes: + # if m.label in labels: + # asserts.fail("SupportedModes must have unique mode label values!") + # else: + # labels.append(m.label) + + # # Verify that each ModeOptionsStruct entry's ModeTags field has: + # for m in supported_modes: + # # * at least one entry + # if len(m.modeTags) == 0: + # asserts.fail("SupportedModes must have at least one mode tag!") + + # at_least_one_common_or_clean_tag = False + # for t in m.modeTags: + # # * the values of the Value fields that are not larger than 16 bits + # if t.value > 0xFFFF or t.value < 0: + # asserts.fail("Mode tag values must not be larger than 16 bits!") + + # # * for each Value field: {isCommonOrDerivedOrMfgTagsVal} + # is_mfg = (0x8000 <= t.value <= 0xBFFF) + # if (t.value not in self.commonTags and + # t.value not in self.cleanTags and + # not is_mfg): + # asserts.fail("Mode tag value is not a common tag, clean tag or vendor tag!") + + # # * for at least one Value field: {isCommonOrDerivedTagsVal} + # if not is_mfg: + # at_least_one_common_or_clean_tag = True + + # if not at_least_one_common_or_clean_tag: + # asserts.fail("At least one mode tag must be a common tag or clean tag!") + + # # Verify that at least one ModeOptionsStruct entry includes either the + # # Vacuum(0x4001) mode tag or the Mop(0x4002)mode tag in the ModeTags field + # vacuum_mop_tags = [Clusters.RvcCleanMode.Enums.ModeTag.kVacuum, Clusters.RvcCleanMode.Enums.ModeTag.kMop] + # has_vacuum_or_mop_mode_tag = False + # for m in supported_modes: + # has_vacuum_or_mop_mode_tag = any(t.value in vacuum_mop_tags for t in m.modeTags) + # if has_vacuum_or_mop_mode_tag: + # break + + # asserts.assert_true(has_vacuum_or_mop_mode_tag, + # "At least one ModeOptionsStruct entry must include either the Vacuum or Mop mode tag") + + + # self.print_step(3, "Read CurrentMode attribute") + # current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) + + # logging.info("CurrentMode: %s" % (current_mode)) + # asserts.assert_true(current_mode in self.supported_modes_dut, "CurrentMode is not a supported mode!") + + +if __name__ == "__main__": + default_matter_test_main() diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py new file mode 100644 index 00000000000000..20cd773a8a37df --- /dev/null +++ b/src/python_testing/TC_OpstateCommon.py @@ -0,0 +1,217 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +import logging + +import chip.clusters as Clusters +from mobly import asserts +from dataclasses import dataclass +from matter_testing_support import TestStep + +@dataclass +class TestInfo: + pics_name: str + cluster: Clusters + +@dataclass +class TestPlanConfig: + cluster_revision: int + feature_map: int + + +class TC_OVENOPSTATE_BASE(): + def __init__(self, implementer=None, test_info=None, test_plan_config=None): + asserts.assert_true(implementer != None, + "You shall define the instance of Operational State Test Case implementer") + + asserts.assert_true(test_info != None, + "You shall define the test info!") + + asserts.assert_true(test_plan_config != None, + "You shall define the test plan config!") + + self.implementer = implementer + self.test_info = test_info + self.test_plan_config = test_plan_config + + def steps_TC_OPSTATE_BASE_1_1(self) -> list[TestStep]: + steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "TH reads from the DUT the ClusterRevision attribute"), + TestStep(3, "TH reads from the DUT the FeatureMap attribute"), + TestStep(4, "TH reads from the DUT the AttributeList attribute"), + TestStep(5, "TH reads from the DUT the EventList attribute"), + TestStep(6, "TH reads from the DUT the AcceptedCommandList attribute"), + TestStep(7, "TH reads from the DUT the GeneratedCommandList attribute") + ] + return steps + + + async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1): + cluster = self.test_info.cluster + attribute = cluster.Attributes + events = cluster.Events + commands = cluster.Commands + + # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) + self.implementer.step(1) + + # STEP 2: TH reads from the DUT the ClusterRevision attribute + self.implementer.step(2) + + attr_value = await self.implementer.read_single_attribute_check_success( + endpoint=endpoint, + cluster=cluster, + attribute=attribute.ClusterRevision) + logging.info("Cluster Revision: %s" % (attr_value)) + + asserts.assert_equal(attr_value, self.test_plan_config.cluster_revision, + "Cluster Revision not according to the Test Plan. Expected %d, received %d!" % + (self.test_plan_config.cluster_revision, attr_value)) + + # STEP 3: TH reads from the DUT the FeatureMap attribute + self.implementer.step(3) + attr_value = await self.implementer.read_single_attribute_check_success( + endpoint=endpoint, + cluster=cluster, + attribute=attribute.FeatureMap) + logging.info("Feature Map: %s" % (attr_value)) + + # Check for feature map value + asserts.assert_equal(attr_value, self.test_plan_config.feature_map, + "Feature Map not according to the Test Plan. Expected %d, received %d!" % + (self.test_plan_config.feature_map, attr_value)) + + # STEP 4: TH reads from the DUT the AttributeList attribute + self.implementer.step(4) + attr_value = await self.implementer.read_single_attribute_check_success( + endpoint=endpoint, + cluster=cluster, + attribute=attribute.AttributeList) + + expected_value = [ + attribute.PhaseList.attribute_id, + attribute.CurrentPhase.attribute_id, + attribute.OperationalStateList.attribute_id, + attribute.OperationalState.attribute_id, + attribute.OperationalError.attribute_id, + attribute.GeneratedCommandList.attribute_id, + attribute.AcceptedCommandList.attribute_id, + attribute.AttributeList.attribute_id, + attribute.FeatureMap.attribute_id, + attribute.ClusterRevision.attribute_id + ] + + if self.implementer.check_pics(("%s.S.A0002" % self.test_info.pics_name)): + expected_value.append(attribute.CountdownTime.attribute_id) + + attr_value.sort() + expected_value.sort() + + logging.info("Current value: [%s]" % ','.join(map(str, attr_value))) + logging.info("Expected value: [%s]" % ','.join(map(str, expected_value))) + + for item in expected_value: + if item not in attr_value: + asserts.fail("""Attribute (%s), not found! The list SHALL include all the entries: [%s]!""" % + (item, ','.join(map(str, expected_value)))) + + # STEP 5: TH reads from the DUT the EventList attribute + self.implementer.step(5) + if self.implementer.pics_guard(self.implementer.check_pics("PICS_EVENT_LIST_ENABLED")): + attr_value = await self.implementer.read_single_attribute_check_success( + endpoint=endpoint, + cluster=cluster, + attribute=attribute.EventList) + + expected_value = [ + events.OperationalError.event_id, + ] + + if self.implementer.check_pics(("%s.S.E01" % self.test_info.pics_name)): + expected_value.append(events.OperationCompletion.event_id) + + attr_value.sort() + expected_value.sort() + + logging.info("Current value: [%s]" % ','.join(map(str, attr_value))) + logging.info("Expected value: [%s]" % ','.join(map(str, expected_value))) + + for item in expected_value: + if item not in attr_value: + asserts.fail("""Event (%s), not found! The list SHALL include all the entries: [%s]!""" % + (item, ','.join(map(str, expected_value)))) + + # STEP 6: TH reads from the DUT the AcceptedCommandList attribute + self.implementer.step(6) + attr_value = await self.implementer.read_single_attribute_check_success( + endpoint=endpoint, + cluster=cluster, + attribute=attribute.AcceptedCommandList) + + expected_value = [] + + if self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_name)) or \ + self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_name)): + expected_value.append(commands.Pause.command_id) + + if self.implementer.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_name)) or \ + self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_name)): + expected_value.append(commands.Stop.command_id) + + if self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_name)): + expected_value.append(commands.Start.command_id) + + if self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_name)) or \ + self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_name)): + expected_value.append(commands.Resume.command_id) + + attr_value.sort() + expected_value.sort() + + logging.info("Current value: [%s]" % ','.join(map(str, attr_value))) + logging.info("Expected value: [%s]" % ','.join(map(str, expected_value))) + + for item in expected_value: + if item not in attr_value: + asserts.fail("""Command (%s), not found! The list SHALL include all the entries: [%s]!""" % + (item, ','.join(map(str, expected_value)))) + + # STEP 7: TH reads from the DUT the AcceptedCommandList attribute + self.implementer.step(7) + attr_value = await self.implementer.read_single_attribute_check_success( + endpoint=endpoint, + cluster=cluster, + attribute=attribute.GeneratedCommandList) + + expected_value = [] + + if self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_name)) or \ + self.implementer.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_name)) or \ + self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_name)) or \ + self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_name)): + expected_value.append(commands.OperationalCommandResponse.command_id) + + attr_value.sort() + expected_value.sort() + + logging.info("Current value: [%s]" % ','.join(map(str, attr_value))) + logging.info("Expected value: [%s]" % ','.join(map(str, expected_value))) + + for item in expected_value: + if item not in attr_value: + asserts.fail("""Command (%s), not found! The list SHALL include all the entries: [%s]!""" % + (item, ','.join(map(str, expected_value)))) \ No newline at end of file From 938dadfe19acb49b5f9fc167b172f3525bf721b0 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Tue, 6 Feb 2024 18:49:12 -0300 Subject: [PATCH 46/89] Updated zap all cluster app --- .../all-clusters-app.matter | 8 ++ .../all-clusters-common/all-clusters-app.zap | 77 +++++++++++++++++-- 2 files changed, 79 insertions(+), 6 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 4998c1fed6380e..8ef7221ac99219 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -7814,8 +7814,10 @@ endpoint 1 { server cluster OvenCavityOperationalState { emits event OperationalError; + emits event OperationCompletion; callback attribute phaseList; callback attribute currentPhase; + callback attribute countdownTime; callback attribute operationalStateList; callback attribute operationalState; callback attribute operationalError; @@ -7825,6 +7827,12 @@ endpoint 1 { callback attribute attributeList; ram attribute featureMap default = 0; ram attribute clusterRevision default = 1; + + handle command Pause; + handle command Stop; + handle command Start; + handle command Resume; + handle command OperationalCommandResponse; } server cluster OvenMode { diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 54c34004030843..c976bdd3027a01 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -17,6 +17,12 @@ } ], "package": [ + { + "pathRelativity": "relativeToZap", + "path": "../../../src/app/zap-templates/app-templates.json", + "type": "gen-templates-json", + "version": "chip-v1" + }, { "pathRelativity": "relativeToZap", "path": "../../../src/app/zap-templates/zcl/zcl-with-test-extensions.json", @@ -24,12 +30,6 @@ "category": "matter", "version": 1, "description": "Matter SDK ZCL data with some extensions" - }, - { - "pathRelativity": "relativeToZap", - "path": "../../../src/app/zap-templates/app-templates.json", - "type": "gen-templates-json", - "version": "chip-v1" } ], "endpointTypes": [ @@ -8211,6 +8211,48 @@ "side": "server", "enabled": 1, "apiMaturity": "provisional", + "commands": [ + { + "name": "Pause", + "code": 0, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Stop", + "code": 1, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Start", + "code": 2, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "Resume", + "code": 3, + "mfgCode": null, + "source": "client", + "isIncoming": 1, + "isEnabled": 1 + }, + { + "name": "OperationalCommandResponse", + "code": 4, + "mfgCode": null, + "source": "server", + "isIncoming": 0, + "isEnabled": 1 + } + ], "attributes": [ { "name": "PhaseList", @@ -8244,6 +8286,22 @@ "maxInterval": 65534, "reportableChange": 0 }, + { + "name": "CountdownTime", + "code": 2, + "mfgCode": null, + "side": "server", + "type": "elapsed_s", + "included": 1, + "storageOption": "External", + "singleton": 0, + "bounded": 0, + "defaultValue": "", + "reportable": 1, + "minInterval": 1, + "maxInterval": 65534, + "reportableChange": 0 + }, { "name": "OperationalStateList", "code": 3, @@ -8396,6 +8454,13 @@ "mfgCode": null, "side": "server", "included": 1 + }, + { + "name": "OperationCompletion", + "code": 1, + "mfgCode": null, + "side": "server", + "included": 1 } ] }, From 06dbc6c50c618f02cc196542535e3338c2726b07 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Wed, 7 Feb 2024 08:10:48 -0300 Subject: [PATCH 47/89] improvements opstte 1_1 --- src/python_testing/TC_OVENOPSTATE_1_1.py | 78 +++--------------------- 1 file changed, 7 insertions(+), 71 deletions(-) diff --git a/src/python_testing/TC_OVENOPSTATE_1_1.py b/src/python_testing/TC_OVENOPSTATE_1_1.py index fe0158e0e8f110..22d18de7230866 100644 --- a/src/python_testing/TC_OVENOPSTATE_1_1.py +++ b/src/python_testing/TC_OVENOPSTATE_1_1.py @@ -28,19 +28,19 @@ def __init__(self, *args): super().__init__(*args) test_info = TestInfo( - "OVENOPSTATE", - Clusters.OvenCavityOperationalState + pics_name="OVENOPSTATE", + cluster=Clusters.OvenCavityOperationalState ) test_plan_config = TestPlanConfig( - 1, - 0 + cluster_revision=1, + feature_map=0 ) self.TC_BASE = TC_OVENOPSTATE_BASE( - self, - test_info, - test_plan_config) + implementer=self, + test_info=test_info, + test_plan_config=test_plan_config) self.endpoint = 0 @@ -53,72 +53,8 @@ def pics_TC_OVENOPSTATE_1_1(self) -> list[str]: @async_test_body async def test_TC_OVENOPSTATE_1_1(self): self.endpoint = self.matter_test_config.endpoint - - tc_result = await self.TC_BASE.test_TC_OPSTATE_BASE_1_1(self.endpoint) - - # # Verify that each ModeOptionsStruct entry has a unique Mode field value - # for m in supported_modes: - # if m.mode in self.supported_modes_dut: - # asserts.fail("SupportedModes must have unique mode values!") - # else: - # self.supported_modes_dut.append(m.mode) - - # # Verify that each ModeOptionsStruct entry has a unique Label field value - # labels = [] - # for m in supported_modes: - # if m.label in labels: - # asserts.fail("SupportedModes must have unique mode label values!") - # else: - # labels.append(m.label) - - # # Verify that each ModeOptionsStruct entry's ModeTags field has: - # for m in supported_modes: - # # * at least one entry - # if len(m.modeTags) == 0: - # asserts.fail("SupportedModes must have at least one mode tag!") - - # at_least_one_common_or_clean_tag = False - # for t in m.modeTags: - # # * the values of the Value fields that are not larger than 16 bits - # if t.value > 0xFFFF or t.value < 0: - # asserts.fail("Mode tag values must not be larger than 16 bits!") - - # # * for each Value field: {isCommonOrDerivedOrMfgTagsVal} - # is_mfg = (0x8000 <= t.value <= 0xBFFF) - # if (t.value not in self.commonTags and - # t.value not in self.cleanTags and - # not is_mfg): - # asserts.fail("Mode tag value is not a common tag, clean tag or vendor tag!") - - # # * for at least one Value field: {isCommonOrDerivedTagsVal} - # if not is_mfg: - # at_least_one_common_or_clean_tag = True - - # if not at_least_one_common_or_clean_tag: - # asserts.fail("At least one mode tag must be a common tag or clean tag!") - - # # Verify that at least one ModeOptionsStruct entry includes either the - # # Vacuum(0x4001) mode tag or the Mop(0x4002)mode tag in the ModeTags field - # vacuum_mop_tags = [Clusters.RvcCleanMode.Enums.ModeTag.kVacuum, Clusters.RvcCleanMode.Enums.ModeTag.kMop] - # has_vacuum_or_mop_mode_tag = False - # for m in supported_modes: - # has_vacuum_or_mop_mode_tag = any(t.value in vacuum_mop_tags for t in m.modeTags) - # if has_vacuum_or_mop_mode_tag: - # break - - # asserts.assert_true(has_vacuum_or_mop_mode_tag, - # "At least one ModeOptionsStruct entry must include either the Vacuum or Mop mode tag") - - - # self.print_step(3, "Read CurrentMode attribute") - # current_mode = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentMode) - - # logging.info("CurrentMode: %s" % (current_mode)) - # asserts.assert_true(current_mode in self.supported_modes_dut, "CurrentMode is not a supported mode!") - - if __name__ == "__main__": default_matter_test_main() From f9f5577e6ba4cbea93b597b0ded42bf6e1a7ef77 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Wed, 7 Feb 2024 08:47:17 -0300 Subject: [PATCH 48/89] improvement base code --- src/python_testing/TC_OpstateCommon.py | 127 +++++++++---------------- 1 file changed, 47 insertions(+), 80 deletions(-) diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index 20cd773a8a37df..af389484b5ca07 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -48,6 +48,35 @@ def __init__(self, implementer=None, test_info=None, test_plan_config=None): self.test_info = test_info self.test_plan_config = test_plan_config + async def read_and_expect_value(self, endpoint, attribute, expected_value): + logging.info("\t##### Read %s" % attribute) + attr_value = await self.implementer.read_single_attribute_check_success( + endpoint=endpoint, + cluster=self.test_info.cluster, + attribute=attribute) + logging.info("\t## %s: %s" % (attribute, attr_value)) + + asserts.assert_equal(attr_value, expected_value, + "Current value not according expected. Expected %d, received %d!" % + (expected_value, attr_value)) + + async def read_and_expect_array_contains(self, endpoint, attribute, expected_contains): + logging.info("\t##### Read %s" % attribute) + attr_value = await self.implementer.read_single_attribute_check_success( + endpoint=endpoint, + cluster=self.test_info.cluster, + attribute=attribute) + attr_value.sort() + expected_contains.sort() + + logging.info("\t## Current value: [%s]" % ','.join(map(str, attr_value))) + logging.info("\t## Expected value: [%s]" % ','.join(map(str, expected_contains))) + + for item in expected_contains: + if item not in attr_value: + asserts.fail("""Entry (%s), not found! The returned value SHALL include all the entries: [%s]!""" % + (item, ','.join(map(str, expected_contains)))) + def steps_TC_OPSTATE_BASE_1_1(self) -> list[TestStep]: steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), TestStep(2, "TH reads from the DUT the ClusterRevision attribute"), @@ -59,7 +88,6 @@ def steps_TC_OPSTATE_BASE_1_1(self) -> list[TestStep]: ] return steps - async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1): cluster = self.test_info.cluster attribute = cluster.Attributes @@ -71,37 +99,18 @@ async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1): # STEP 2: TH reads from the DUT the ClusterRevision attribute self.implementer.step(2) - - attr_value = await self.implementer.read_single_attribute_check_success( - endpoint=endpoint, - cluster=cluster, - attribute=attribute.ClusterRevision) - logging.info("Cluster Revision: %s" % (attr_value)) - - asserts.assert_equal(attr_value, self.test_plan_config.cluster_revision, - "Cluster Revision not according to the Test Plan. Expected %d, received %d!" % - (self.test_plan_config.cluster_revision, attr_value)) + await self.read_and_expect_value(endpoint=endpoint, + attribute=attribute.ClusterRevision, + expected_value=self.test_plan_config.cluster_revision) # STEP 3: TH reads from the DUT the FeatureMap attribute self.implementer.step(3) - attr_value = await self.implementer.read_single_attribute_check_success( - endpoint=endpoint, - cluster=cluster, - attribute=attribute.FeatureMap) - logging.info("Feature Map: %s" % (attr_value)) - - # Check for feature map value - asserts.assert_equal(attr_value, self.test_plan_config.feature_map, - "Feature Map not according to the Test Plan. Expected %d, received %d!" % - (self.test_plan_config.feature_map, attr_value)) + await self.read_and_expect_value(endpoint=endpoint, + attribute=attribute.FeatureMap, + expected_value=self.test_plan_config.feature_map) # STEP 4: TH reads from the DUT the AttributeList attribute self.implementer.step(4) - attr_value = await self.implementer.read_single_attribute_check_success( - endpoint=endpoint, - cluster=cluster, - attribute=attribute.AttributeList) - expected_value = [ attribute.PhaseList.attribute_id, attribute.CurrentPhase.attribute_id, @@ -118,25 +127,13 @@ async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1): if self.implementer.check_pics(("%s.S.A0002" % self.test_info.pics_name)): expected_value.append(attribute.CountdownTime.attribute_id) - attr_value.sort() - expected_value.sort() - - logging.info("Current value: [%s]" % ','.join(map(str, attr_value))) - logging.info("Expected value: [%s]" % ','.join(map(str, expected_value))) - - for item in expected_value: - if item not in attr_value: - asserts.fail("""Attribute (%s), not found! The list SHALL include all the entries: [%s]!""" % - (item, ','.join(map(str, expected_value)))) + await self.read_and_expect_array_contains(endpoint=endpoint, + attribute=attribute.AttributeList, + expected_contains=expected_value) # STEP 5: TH reads from the DUT the EventList attribute self.implementer.step(5) if self.implementer.pics_guard(self.implementer.check_pics("PICS_EVENT_LIST_ENABLED")): - attr_value = await self.implementer.read_single_attribute_check_success( - endpoint=endpoint, - cluster=cluster, - attribute=attribute.EventList) - expected_value = [ events.OperationalError.event_id, ] @@ -144,24 +141,12 @@ async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1): if self.implementer.check_pics(("%s.S.E01" % self.test_info.pics_name)): expected_value.append(events.OperationCompletion.event_id) - attr_value.sort() - expected_value.sort() - - logging.info("Current value: [%s]" % ','.join(map(str, attr_value))) - logging.info("Expected value: [%s]" % ','.join(map(str, expected_value))) - - for item in expected_value: - if item not in attr_value: - asserts.fail("""Event (%s), not found! The list SHALL include all the entries: [%s]!""" % - (item, ','.join(map(str, expected_value)))) + await self.read_and_expect_array_contains(endpoint=endpoint, + attribute=attribute.EventList, + expected_contains=expected_value) # STEP 6: TH reads from the DUT the AcceptedCommandList attribute self.implementer.step(6) - attr_value = await self.implementer.read_single_attribute_check_success( - endpoint=endpoint, - cluster=cluster, - attribute=attribute.AcceptedCommandList) - expected_value = [] if self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_name)) or \ @@ -179,24 +164,12 @@ async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1): self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_name)): expected_value.append(commands.Resume.command_id) - attr_value.sort() - expected_value.sort() - - logging.info("Current value: [%s]" % ','.join(map(str, attr_value))) - logging.info("Expected value: [%s]" % ','.join(map(str, expected_value))) - - for item in expected_value: - if item not in attr_value: - asserts.fail("""Command (%s), not found! The list SHALL include all the entries: [%s]!""" % - (item, ','.join(map(str, expected_value)))) + await self.read_and_expect_array_contains(endpoint=endpoint, + attribute=attribute.AcceptedCommandList, + expected_contains=expected_value) # STEP 7: TH reads from the DUT the AcceptedCommandList attribute self.implementer.step(7) - attr_value = await self.implementer.read_single_attribute_check_success( - endpoint=endpoint, - cluster=cluster, - attribute=attribute.GeneratedCommandList) - expected_value = [] if self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_name)) or \ @@ -205,13 +178,7 @@ async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1): self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_name)): expected_value.append(commands.OperationalCommandResponse.command_id) - attr_value.sort() - expected_value.sort() + await self.read_and_expect_array_contains(endpoint=endpoint, + attribute=attribute.GeneratedCommandList, + expected_contains=expected_value) - logging.info("Current value: [%s]" % ','.join(map(str, attr_value))) - logging.info("Expected value: [%s]" % ','.join(map(str, expected_value))) - - for item in expected_value: - if item not in attr_value: - asserts.fail("""Command (%s), not found! The list SHALL include all the entries: [%s]!""" % - (item, ','.join(map(str, expected_value)))) \ No newline at end of file From 11ce3326c788cca788c992b7cecd749c2f3609ed Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Wed, 7 Feb 2024 14:43:10 -0300 Subject: [PATCH 49/89] update example app --- .../include/oven-operational-state-delegate.h | 29 +++------ .../src/oven-operational-state-delegate.cpp | 64 ++++++++++++++++++- 2 files changed, 70 insertions(+), 23 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h b/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h index 6d7338214f77ae..eca70cee66d09a 100644 --- a/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h +++ b/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h @@ -33,13 +33,16 @@ namespace OvenCavityOperationalState { class OvenCavityOperationalStateDelegate : public OperationalState::Delegate { private: - inline static const Clusters::OperationalState::GenericOperationalState mOperationalStateList[] = { + inline static const Clusters::OperationalState::GenericOperationalState opStateList[] = { OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped)), OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)), OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused)), OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kError)) }; + Span mOperationalStateList = Span(opStateList); + Span mOperationalPhaseList; + public: /** * Get the countdown time. This attribute is not supported in our example app. @@ -73,41 +76,25 @@ class OvenCavityOperationalStateDelegate : public OperationalState::Delegate * Handle Command Callback in application: Pause * @param[out] get operational error after callback. */ - void HandlePauseStateCallback(Clusters::OperationalState::GenericOperationalError & err) override - { - // This command in not supported. - err.Set(to_underlying(ErrorStateEnum::kCommandInvalidInState)); - }; + void HandlePauseStateCallback(Clusters::OperationalState::GenericOperationalError & err) override; /** * Handle Command Callback in application: Resume * @param[out] get operational error after callback. */ - void HandleResumeStateCallback(Clusters::OperationalState::GenericOperationalError & err) override - { - // This command in not supported. - err.Set(to_underlying(ErrorStateEnum::kCommandInvalidInState)); - }; + void HandleResumeStateCallback(Clusters::OperationalState::GenericOperationalError & err) override; /** * Handle Command Callback in application: Start * @param[out] get operational error after callback. */ - void HandleStartStateCallback(Clusters::OperationalState::GenericOperationalError & err) override - { - // This command in not supported. - err.Set(to_underlying(ErrorStateEnum::kCommandInvalidInState)); - }; + void HandleStartStateCallback(Clusters::OperationalState::GenericOperationalError & err) override; /** * Handle Command Callback in application: Stop * @param[out] get operational error after callback. */ - void HandleStopStateCallback(Clusters::OperationalState::GenericOperationalError & err) override - { - // This command in not supported. - err.Set(to_underlying(ErrorStateEnum::kCommandInvalidInState)); - }; + void HandleStopStateCallback(Clusters::OperationalState::GenericOperationalError & err) override; }; void Shutdown(); diff --git a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp index ecae5c88006ef4..32612146c335b5 100644 --- a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp @@ -58,7 +58,7 @@ CHIP_ERROR OvenCavityOperationalStateDelegate::GetOperationalStateAtIndex(size_t index, OperationalState::GenericOperationalState & operationalState) { - if (index >= ArraySize(mOperationalStateList)) + if (index >= mOperationalStateList.size()) { return CHIP_ERROR_NOT_FOUND; } @@ -69,5 +69,65 @@ OvenCavityOperationalStateDelegate::GetOperationalStateAtIndex(size_t index, CHIP_ERROR OvenCavityOperationalStateDelegate::GetOperationalPhaseAtIndex(size_t index, MutableCharSpan & operationalPhase) { - return CHIP_ERROR_NOT_FOUND; + if (index >= mOperationalPhaseList.size()) + { + return CHIP_ERROR_NOT_FOUND; + } + return CopyCharSpanToMutableCharSpan(mOperationalPhaseList[index], operationalPhase); +} + +void OvenCavityOperationalStateDelegate::HandlePauseStateCallback(OperationalState::GenericOperationalError & err) +{ + // placeholder implementation + auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused)); + if (error == CHIP_NO_ERROR) + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kNoError)); + } + else + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation)); + } +} + +void OvenCavityOperationalStateDelegate::HandleResumeStateCallback(OperationalState::GenericOperationalError & err) +{ + // placeholder implementation + auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)); + if (error == CHIP_NO_ERROR) + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kNoError)); + } + else + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation)); + } } + +void OvenCavityOperationalStateDelegate::HandleStartStateCallback(OperationalState::GenericOperationalError & err) +{ + // placeholder implementation + auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)); + if (error == CHIP_NO_ERROR) + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kNoError)); + } + else + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation)); + } +} + +void OvenCavityOperationalStateDelegate::HandleStopStateCallback(OperationalState::GenericOperationalError & err) +{ + // placeholder implementation + auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped)); + if (error == CHIP_NO_ERROR) + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kNoError)); + } + else + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation)); + } +} \ No newline at end of file From fb80b6b6930698c824dbeb600e33f4caf0eb5987 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Wed, 7 Feb 2024 14:44:31 -0300 Subject: [PATCH 50/89] improvements on ovenopstate --- src/python_testing/TC_OVENOPSTATE_1_1.py | 23 +- src/python_testing/TC_OVENOPSTATE_2_1.py | 157 ++----------- src/python_testing/TC_OpstateCommon.py | 285 +++++++++++++++++++---- 3 files changed, 264 insertions(+), 201 deletions(-) diff --git a/src/python_testing/TC_OVENOPSTATE_1_1.py b/src/python_testing/TC_OVENOPSTATE_1_1.py index 22d18de7230866..6f77264b7c533f 100644 --- a/src/python_testing/TC_OVENOPSTATE_1_1.py +++ b/src/python_testing/TC_OVENOPSTATE_1_1.py @@ -20,7 +20,7 @@ import chip.clusters as Clusters from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main from mobly import asserts -from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo, TestPlanConfig +from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo class TC_OVENOPSTATE_1_1(MatterBaseTest): @@ -28,21 +28,13 @@ def __init__(self, *args): super().__init__(*args) test_info = TestInfo( - pics_name="OVENOPSTATE", + pics_code="OVENOPSTATE", cluster=Clusters.OvenCavityOperationalState ) - test_plan_config = TestPlanConfig( - cluster_revision=1, - feature_map=0 - ) - self.TC_BASE = TC_OVENOPSTATE_BASE( implementer=self, - test_info=test_info, - test_plan_config=test_plan_config) - self.endpoint = 0 - + test_info=test_info) def steps_TC_OVENOPSTATE_1_1(self) -> list[TestStep]: return self.TC_BASE.steps_TC_OPSTATE_BASE_1_1() @@ -52,8 +44,13 @@ def pics_TC_OVENOPSTATE_1_1(self) -> list[str]: @async_test_body async def test_TC_OVENOPSTATE_1_1(self): - self.endpoint = self.matter_test_config.endpoint - tc_result = await self.TC_BASE.test_TC_OPSTATE_BASE_1_1(self.endpoint) + endpoint = self.matter_test_config.endpoint + cluster_revision = 1 + feature_map=0 + + await self.TC_BASE.test_TC_OPSTATE_BASE_1_1(endpoint=endpoint, + cluster_revision=cluster_revision, + feature_map=feature_map) if __name__ == "__main__": diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index 4fb816cf757ed9..99aa43010eedad 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -18,21 +18,12 @@ import logging import chip.clusters as Clusters -from chip.clusters.Types import NullValue -from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main from mobly import asserts - -# This test requires several additional command line arguments -# run with -# --int-arg PIXIT_ENDPOINT: - +from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo class TC_OVENOPSTATE_2_1(MatterBaseTest): - async def read_mod_attribute_expect_success(self, endpoint, attribute): - cluster = Clusters.Objects.OvenCavityOperationalState - return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) - async def read_and_validate_opstate(self, step, expected_state): self.print_step(step, "Read OperationalState attribute") operational_state = await self.read_mod_attribute_expect_success( @@ -49,138 +40,28 @@ async def read_and_validate_operror(self, step, expected_error): asserts.assert_equal(operational_error.errorStateID, expected_error, "errorStateID(%s) should equal %s" % (operational_error.errorStateID, expected_error)) - @async_test_body - async def test_TC_OVENOPSTATE_2_1(self): - - asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, - "PIXIT_ENDPOINT must be included on the command line in " - "the --int-arg flag as PIXIT_ENDPOINT:") - - self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] - - attributes = Clusters.OvenCavityOperationalState.Attributes - - self.print_step(1, "Commissioning, already done") - - if self.check_pics("OVENOPSTATE.S.A0000"): - self.print_step(2, "Read PhaseList attribute") - phase_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.PhaseList) - - if phase_list == NullValue: - logging.info("PhaseList is null") - else: - logging.info("PhaseList: %s" % (phase_list)) - - phase_list_len = len(phase_list) - - asserts.assert_less_equal(phase_list_len, 32, - "PhaseList length(%d) must be less than 32!" % phase_list_len) - - if self.check_pics("OVENOPSTATE.S.A0001"): - self.print_step(3, "Read CurrentPhase attribute") - current_phase = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentPhase) - logging.info("CurrentPhase: %s" % (current_phase)) - - if phase_list == NullValue: - asserts.assert_true(current_phase == NullValue, "CurrentPhase(%s) should be null" % current_phase) - else: - asserts.assert_true(0 <= current_phase and current_phase < phase_list_len, - "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) + def __init__(self, *args): + super().__init__(*args) - if self.check_pics("OVENOPSTATE.S.A0002"): - self.print_step(4, "Read CountdownTime attribute") - countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.CountdownTime) + test_info = TestInfo( + pics_code="OVENOPSTATE", + cluster=Clusters.OvenCavityOperationalState + ) - logging.info("CountdownTime: %s" % (countdown_time)) - if countdown_time is not NullValue: - asserts.assert_true(0 <= countdown_time <= 259200, - "CountdownTime(%s) must be between 0 and 259200" % countdown_time) + self.TC_BASE = TC_OVENOPSTATE_BASE( + implementer=self, + test_info=test_info) - if self.check_pics("OVENOPSTATE.S.A0003"): - self.print_step(5, "Read OperationalStateList attribute") - operational_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalStateList) + def steps_TC_OVENOPSTATE_2_1(self) -> list[TestStep]: + return self.TC_BASE.steps_TC_OPSTATE_BASE_2_1() - logging.info("OperationalStateList: %s" % (operational_state_list)) - - defined_states = [state.value for state in Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum - if state is not Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] - - for state in operational_state_list: - in_range = (0x80 <= state.operationalStateID <= 0xBF) - asserts.assert_true(state.operationalStateID in defined_states or in_range, - "Found a OperationalStateList entry with invalid ID value!") - if in_range: - asserts.assert_true(state.operationalStateLabel is not None, - "The OperationalStateLabel should be populated") - if state.operationalStateID == Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kError: - error_state_present = True - - asserts.assert_true(error_state_present, "The OperationalStateList does not have an ID entry of Error(0x03)") - - if self.check_pics("OVENOPSTATE.S.A0004"): - self.print_step(6, "Read OperationalState attribute") - operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - - logging.info("OperationalState: %s" % (operational_state)) - - in_range = (0x80 <= operational_state <= 0xBF) - asserts.assert_true(operational_state in defined_states or in_range, - "OperationalState has an invalid ID value!") - - if self.check_pics("OVENOPSTATE.S.M.ST_STOPPED"): - self.print_step("6a", "Manually put the device in the stopped state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6b", expected_state=Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kStopped) - if self.check_pics("OVENOPSTATE.S.M.ST_RUNNING"): - self.print_step("6c", "Manually put the device in the running state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6d", expected_state=Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning) - if self.check_pics("OVENOPSTATE.S.M.ST_PAUSED"): - self.print_step("6e", "Manually put the device in the paused state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6f", expected_state=Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kPaused) - if self.check_pics("OVENOPSTATE.S.M.ST_ERROR"): - self.print_step("6g", "Manually put the device in the error state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6h", expected_state=Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kError) - - if self.check_pics("OVENOPSTATE.S.A0005"): - self.print_step(7, "Read OperationalError attribute") - operational_error = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalError) - - logging.info("OperationalError: %s" % (operational_error)) - - # Defined Errors - defined_errors = [error.value for error in Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum - if error is not Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnknownEnumValue] - - in_range = (0x80 <= operational_error.errorStateID <= 0xBF) - asserts.assert_true(operational_error.errorStateID in defined_errors - or in_range, "OperationalError has an invalid ID value!") - if in_range: - asserts.assert_true(operational_error.errorStateLabel is not None, "ErrorStateLabel should be populated") - - if self.check_pics("OVENOPSTATE.S.M.ERR_NO_ERROR"): - self.print_step("7a", "Manually put the device in the no error state") - input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7b", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError) - if self.check_pics("OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME"): - self.print_step("7c", "Manually put the device in the unable to start or resume error state") - input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7d", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnableToStartOrResume) - if self.check_pics("OVENOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION"): - self.print_step("7e", "Manually put the device in the unable to complete operation error state") - input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7f", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnableToCompleteOperation) - if self.check_pics("OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE"): - self.print_step("7g", "Manually put the device in the command invalid error state") - input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7h", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState) + def pics_TC_OVENOPSTATE_2_1(self) -> list[str]: + return ["OVENOPSTATE.S"] + @async_test_body + async def test_TC_OVENOPSTATE_2_1(self): + endpoint = self.matter_test_config.endpoint + await self.TC_BASE.test_TC_OPSTATE_BASE_2_1(endpoint) if __name__ == "__main__": default_matter_test_main() diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index af389484b5ca07..90deda0bcb7f35 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -18,41 +18,36 @@ import logging import chip.clusters as Clusters +from chip.clusters.Types import NullValue from mobly import asserts from dataclasses import dataclass from matter_testing_support import TestStep @dataclass class TestInfo: - pics_name: str + pics_code: str cluster: Clusters -@dataclass -class TestPlanConfig: - cluster_revision: int - feature_map: int - - class TC_OVENOPSTATE_BASE(): - def __init__(self, implementer=None, test_info=None, test_plan_config=None): + def __init__(self, implementer=None, test_info=None): asserts.assert_true(implementer != None, "You shall define the instance of Operational State Test Case implementer") asserts.assert_true(test_info != None, "You shall define the test info!") - asserts.assert_true(test_plan_config != None, - "You shall define the test plan config!") - self.implementer = implementer self.test_info = test_info - self.test_plan_config = test_plan_config + + async def read_expect_success(self, endpoint, attribute): + return await self.implementer.read_single_attribute_check_success(endpoint=endpoint, + cluster=self.test_info.cluster, + attribute=attribute) async def read_and_expect_value(self, endpoint, attribute, expected_value): logging.info("\t##### Read %s" % attribute) - attr_value = await self.implementer.read_single_attribute_check_success( + attr_value = await self.read_expect_success( endpoint=endpoint, - cluster=self.test_info.cluster, attribute=attribute) logging.info("\t## %s: %s" % (attribute, attr_value)) @@ -62,9 +57,8 @@ async def read_and_expect_value(self, endpoint, attribute, expected_value): async def read_and_expect_array_contains(self, endpoint, attribute, expected_contains): logging.info("\t##### Read %s" % attribute) - attr_value = await self.implementer.read_single_attribute_check_success( + attr_value = await self.read_expect_success( endpoint=endpoint, - cluster=self.test_info.cluster, attribute=attribute) attr_value.sort() expected_contains.sort() @@ -88,9 +82,9 @@ def steps_TC_OPSTATE_BASE_1_1(self) -> list[TestStep]: ] return steps - async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1): + async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature_map=0): cluster = self.test_info.cluster - attribute = cluster.Attributes + attributes = cluster.Attributes events = cluster.Events commands = cluster.Commands @@ -100,35 +94,35 @@ async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1): # STEP 2: TH reads from the DUT the ClusterRevision attribute self.implementer.step(2) await self.read_and_expect_value(endpoint=endpoint, - attribute=attribute.ClusterRevision, - expected_value=self.test_plan_config.cluster_revision) + attribute=attributes.ClusterRevision, + expected_value=cluster_revision) # STEP 3: TH reads from the DUT the FeatureMap attribute self.implementer.step(3) await self.read_and_expect_value(endpoint=endpoint, - attribute=attribute.FeatureMap, - expected_value=self.test_plan_config.feature_map) + attribute=attributes.FeatureMap, + expected_value=feature_map) # STEP 4: TH reads from the DUT the AttributeList attribute self.implementer.step(4) expected_value = [ - attribute.PhaseList.attribute_id, - attribute.CurrentPhase.attribute_id, - attribute.OperationalStateList.attribute_id, - attribute.OperationalState.attribute_id, - attribute.OperationalError.attribute_id, - attribute.GeneratedCommandList.attribute_id, - attribute.AcceptedCommandList.attribute_id, - attribute.AttributeList.attribute_id, - attribute.FeatureMap.attribute_id, - attribute.ClusterRevision.attribute_id + attributes.PhaseList.attribute_id, + attributes.CurrentPhase.attribute_id, + attributes.OperationalStateList.attribute_id, + attributes.OperationalState.attribute_id, + attributes.OperationalError.attribute_id, + attributes.GeneratedCommandList.attribute_id, + attributes.AcceptedCommandList.attribute_id, + attributes.AttributeList.attribute_id, + attributes.FeatureMap.attribute_id, + attributes.ClusterRevision.attribute_id ] - if self.implementer.check_pics(("%s.S.A0002" % self.test_info.pics_name)): - expected_value.append(attribute.CountdownTime.attribute_id) + if self.implementer.check_pics(("%s.S.A0002" % self.test_info.pics_code)): + expected_value.append(attributes.CountdownTime.attribute_id) await self.read_and_expect_array_contains(endpoint=endpoint, - attribute=attribute.AttributeList, + attribute=attributes.AttributeList, expected_contains=expected_value) # STEP 5: TH reads from the DUT the EventList attribute @@ -138,47 +132,238 @@ async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1): events.OperationalError.event_id, ] - if self.implementer.check_pics(("%s.S.E01" % self.test_info.pics_name)): + if self.implementer.check_pics(("%s.S.E01" % self.test_info.pics_code)): expected_value.append(events.OperationCompletion.event_id) await self.read_and_expect_array_contains(endpoint=endpoint, - attribute=attribute.EventList, + attribute=attributes.EventList, expected_contains=expected_value) # STEP 6: TH reads from the DUT the AcceptedCommandList attribute self.implementer.step(6) expected_value = [] - if self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_name)) or \ - self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_name)): + if self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or \ + self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Pause.command_id) - if self.implementer.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_name)) or \ - self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_name)): + if self.implementer.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ + self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Stop.command_id) - if self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_name)): + if self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Start.command_id) - if self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_name)) or \ - self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_name)): + if self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)) or \ + self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Resume.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, - attribute=attribute.AcceptedCommandList, + attribute=attributes.AcceptedCommandList, expected_contains=expected_value) # STEP 7: TH reads from the DUT the AcceptedCommandList attribute self.implementer.step(7) expected_value = [] - if self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_name)) or \ - self.implementer.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_name)) or \ - self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_name)) or \ - self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_name)): + if self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or \ + self.implementer.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ + self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)) or \ + self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)): expected_value.append(commands.OperationalCommandResponse.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, - attribute=attribute.GeneratedCommandList, + attribute=attributes.GeneratedCommandList, expected_contains=expected_value) + def steps_TC_OPSTATE_BASE_2_1(self) -> list[TestStep]: + steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "TH reads from the DUT the PhaseList attribute"), + TestStep(3, "TH reads from the DUT the CurrentPhase attribute"), + TestStep(4, "TH reads from the DUT the CountdownTime attribute"), + TestStep(5, "TH reads from the DUT the OperationalStateList attribute"), + TestStep(6, "TH reads from the DUT the OperationalState attribute"), + TestStep("6a", "Manually put the device in the Stopped(0x00) operational state"), + TestStep("6b", "TH reads from the DUT the OperationalState attribute"), + TestStep("6c", "Manually put the device in the Running(0x01) operational state"), + TestStep("6d", "TH reads from the DUT the OperationalState attribute"), + TestStep("6e", "Manually put the device in the Paused(0x02) operational state"), + TestStep("6f", "TH reads from the DUT the OperationalState attribute"), + TestStep("6g", "Manually put the device in the Error(0x03) operational state"), + TestStep("6h", "TH reads from the DUT the OperationalState attribute") + # TestStep(7, "TH reads from the DUT the OperationalError attribute"), + # TestStep("7a", "Manually put the device in the NoError(0x00) error state"), + # TestStep("7b", "TH reads from the DUT the OperationalError attribute"), + # TestStep("7c", "Manually put the device in the UnableToStartOrResume(0x01) error state"), + # TestStep("7d", "TH reads from the DUT the OperationalError attribute"), + # TestStep("7e", "Manually put the device in the UnableToCompleteOperation(0x02) error state"), + # TestStep("7f", "TH reads from the DUT the OperationalError attribute"), + # TestStep("7g", "Manually put the device in the CommandInvalidInState(0x03) error state"), + # TestStep("7h", "TH reads from the DUT the OperationalError attribute") + ] + return steps + + + async def test_TC_OPSTATE_BASE_2_1(self, endpoint=1): + cluster = self.test_info.cluster + attributes = cluster.Attributes + events = cluster.Events + commands = cluster.Commands + + # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) + self.implementer.step(1) + + # STEP 2: TH reads from the DUT the PhaseList attribute + self.implementer.step(2) + if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.A0000" % self.test_info.pics_code))): + phase_list = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.PhaseList) + + logging.info("PhaseList: %s" % (phase_list)) + if phase_list is not NullValue: + phase_list_len = len(phase_list) + asserts.assert_less_equal(phase_list_len, 32, + "PhaseList length(%d) must be less than 32!" % phase_list_len) + + # STEP 3: TH reads from the DUT the CurrentPhase attribute + self.implementer.step(3) + if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.A0001" % self.test_info.pics_code))): + current_phase = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.CurrentPhase) + + logging.info("CurrentPhase: %s" % (current_phase)) + if (phase_list == NullValue) or (not phase_list): + asserts.assert_true(current_phase == NullValue, "CurrentPhase(%s) should be null" % current_phase) + else: + asserts.assert_true(0 <= current_phase and current_phase < phase_list_len, + "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) + + # STEP 4: TH reads from the DUT the CountdownTime attribute + self.implementer.step(4) + if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.A0002" % self.test_info.pics_code))): + countdown_time = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.CountdownTime) + + logging.info("CountdownTime: %s" % (countdown_time)) + if countdown_time is not NullValue: + asserts.assert_true(0 <= countdown_time <= 259200, + "CountdownTime(%s) must be between 0 and 259200" % countdown_time) + + # STEP 5: TH reads from the DUT the OperationalStateList attribute + self.implementer.step(5) + if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.A0003" % self.test_info.pics_code))): + operational_state_list = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.OperationalStateList) + + #logging.info("OperationalStateList: [%s]" % ','.join(map(str, operational_state_list))) + logging.info("OperationalStateList: %s" % operational_state_list) + + defined_states = [state.value for state in cluster.Enums.OperationalStateEnum + if state is not cluster.Enums.OperationalStateEnum.kUnknownEnumValue] + + for state in operational_state_list: + in_range = (0x80 <= state.operationalStateID <= 0xBF) + asserts.assert_true(state.operationalStateID in defined_states or in_range, + "Found a OperationalStateList entry with invalid ID value!") + if in_range: + asserts.assert_true(state.operationalStateLabel is not None, + "The OperationalStateLabel should be populated") + + if state.operationalStateID == cluster.Enums.OperationalStateEnum.kError: + error_state_present = True + + asserts.assert_true(error_state_present, "The OperationalStateList does not have an ID entry of Error(0x03)") + + # STEP 6: TH reads from the DUT the OperationalState attribute + self.implementer.step(6) + if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.A0004" % self.test_info.pics_code))): + operational_state = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.OperationalState) + + logging.info("OperationalState: %s" % (operational_state)) + + in_range = (0x80 <= operational_state <= 0xBF) + asserts.assert_true(operational_state in defined_states or in_range, + "OperationalState has an invalid ID value!") + + # STEP 6a: Manually put the device in the Stopped(0x00) operational state + self.implementer.step("6a") + if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.M.ST_STOPPED" % self.test_info.pics_code))): + input("Press Enter when done.\n") + # STEP 6b: TH reads from the DUT the OperationalState attribute + self.implementer.step("6b") + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kStopped) + else: + self.implementer.skip_step("6b") + + # STEP 6c: Manually put the device in the Running(0x01) operational state + self.implementer.step("6c") + if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.M.ST_RUNNING" % self.test_info.pics_code))): + input("Press Enter when done.\n") + # STEP 6d: TH reads from the DUT the OperationalState attribute + self.implementer.step("6d") + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kRunning) + else: + self.implementer.skip_step("6d") + + # STEP 6e: Manually put the device in the Paused(0x02) operational state + self.implementer.step("6e") + if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.M.ST_PAUSED" % self.test_info.pics_code))): + input("Press Enter when done.\n") + # STEP 6f: TH reads from the DUT the OperationalState attribute + self.implementer.step("6f") + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kPaused) + else: + self.implementer.skip_step("6f") + + # STEP 6g: Manually put the device in the Error(0x03) operational state + self.implementer.step("6g") + if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.M.ST_ERROR" % self.test_info.pics_code))): + input("Press Enter when done.\n") + # STEP 6h: TH reads from the DUT the OperationalState attribute + self.implementer.step("6h") + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kError) + else: + self.implementer.skip_step("6h") + + # if self.implementer.pics_guard(self.check_pics(("%s.S.A0005" % self.test_info.pics_code))): + # self.print_step(7, "Read OperationalError attribute") + # operational_error = await self.read_mod_attribute_expect_success(endpoint=endpoint, + # attribute=attributes.OperationalError) + + # logging.info("OperationalError: %s" % (operational_error)) + + # # Defined Errors + # defined_errors = [error.value for error in Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum + # if error is not Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnknownEnumValue] + + # in_range = (0x80 <= operational_error.errorStateID <= 0xBF) + # asserts.assert_true(operational_error.errorStateID in defined_errors + # or in_range, "OperationalError has an invalid ID value!") + # if in_range: + # asserts.assert_true(operational_error.errorStateLabel is not None, "ErrorStateLabel should be populated") + + # if self.implementer.pics_guard(self.check_pics(("%s.S.M.ERR_NO_ERROR" % self.test_info.pics_code))): + # self.print_step("7a", "Manually put the device in the no error state") + # input("Press Enter when done.\n") + # await self.read_and_validate_operror(step="7b", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError) + # if self.implementer.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code))): + # self.print_step("7c", "Manually put the device in the unable to start or resume error state") + # input("Press Enter when done.\n") + # await self.read_and_validate_operror(step="7d", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnableToStartOrResume) + # if self.implementer.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION" % self.test_info.pics_code))): + # self.print_step("7e", "Manually put the device in the unable to complete operation error state") + # input("Press Enter when done.\n") + # await self.read_and_validate_operror(step="7f", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnableToCompleteOperation) + # if self.implementer.pics_guard(self.check_pics(("%s.S.M.ERR_COMMAND_INVALID_IN_STATE" % self.test_info.pics_code))): + # self.print_step("7g", "Manually put the device in the command invalid error state") + # input("Press Enter when done.\n") + # await self.read_and_validate_operror(step="7h", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState) \ No newline at end of file From ee21dba30506b8658e432c4bfb6b1e70a7f27aaf Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Wed, 7 Feb 2024 14:44:55 -0300 Subject: [PATCH 51/89] ci pics update --- src/app/tests/suites/certification/ci-pics-values | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 8642dd3eae0769..86a3c2f5e49432 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -1867,7 +1867,7 @@ OVENOPSTATE.C=1 OVENOPSTATE.S.M.ST_STOPPED=1 OVENOPSTATE.S.M.ST_RUNNING=1 OVENOPSTATE.S.M.ST_PAUSED=1 -OVENOPSTATE.S.M.ST_ERROR=1 +OVENOPSTATE.S.M.ST_ERROR=0 OVENOPSTATE.S.M.ERR_NO_ERROR=1 OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME=1 OVENOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION=1 From 5ec0d002e8cec4788631c3fa387e10e50633b5c1 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Wed, 7 Feb 2024 14:45:41 -0300 Subject: [PATCH 52/89] ci pics updates --- src/app/tests/suites/certification/ci-pics-values | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 86a3c2f5e49432..1d0cf95bc76149 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -1864,14 +1864,14 @@ OVENOPSTATE.S=1 OVENOPSTATE.C=1 #ManuallyControlled -OVENOPSTATE.S.M.ST_STOPPED=1 -OVENOPSTATE.S.M.ST_RUNNING=1 -OVENOPSTATE.S.M.ST_PAUSED=1 +OVENOPSTATE.S.M.ST_STOPPED=0 +OVENOPSTATE.S.M.ST_RUNNING=0 +OVENOPSTATE.S.M.ST_PAUSED=0 OVENOPSTATE.S.M.ST_ERROR=0 -OVENOPSTATE.S.M.ERR_NO_ERROR=1 -OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME=1 -OVENOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION=1 -OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE=1 +OVENOPSTATE.S.M.ERR_NO_ERROR=0 +OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME=0 +OVENOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION=0 +OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE=0 # Server Attributes OVENOPSTATE.S.A0000=1 From 524c9a4cb9c65b91d39cff29c162affc199672ea Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Wed, 7 Feb 2024 14:52:06 -0300 Subject: [PATCH 53/89] fix matter testing support --- src/python_testing/matter_testing_support.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/matter_testing_support.py b/src/python_testing/matter_testing_support.py index 4ddb4ce50fdf0e..d87f8ce35b9c4b 100644 --- a/src/python_testing/matter_testing_support.py +++ b/src/python_testing/matter_testing_support.py @@ -904,6 +904,7 @@ def on_pass(self, record): def pics_guard(self, pics_condition: bool): if not pics_condition: self.mark_current_step_skipped() + return pics_condition def mark_current_step_skipped(self): try: From 828433e626529bc8e36bd515f21c4d79779ac971 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Fri, 9 Feb 2024 16:02:43 -0300 Subject: [PATCH 54/89] improvements on test cases --- src/python_testing/TC_OVENOPSTATE_1_1.py | 11 +- src/python_testing/TC_OVENOPSTATE_2_1.py | 27 +-- src/python_testing/TC_OpstateCommon.py | 262 +++++++++++++---------- 3 files changed, 153 insertions(+), 147 deletions(-) diff --git a/src/python_testing/TC_OVENOPSTATE_1_1.py b/src/python_testing/TC_OVENOPSTATE_1_1.py index 6f77264b7c533f..0b80931b66478a 100644 --- a/src/python_testing/TC_OVENOPSTATE_1_1.py +++ b/src/python_testing/TC_OVENOPSTATE_1_1.py @@ -23,7 +23,7 @@ from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo -class TC_OVENOPSTATE_1_1(MatterBaseTest): +class TC_OVENOPSTATE_1_1(MatterBaseTest, TC_OVENOPSTATE_BASE): def __init__(self, *args): super().__init__(*args) @@ -32,12 +32,10 @@ def __init__(self, *args): cluster=Clusters.OvenCavityOperationalState ) - self.TC_BASE = TC_OVENOPSTATE_BASE( - implementer=self, - test_info=test_info) + super().setup_base(test_info=test_info) def steps_TC_OVENOPSTATE_1_1(self) -> list[TestStep]: - return self.TC_BASE.steps_TC_OPSTATE_BASE_1_1() + return self.STEPS_TC_OPSTATE_BASE_1_1() def pics_TC_OVENOPSTATE_1_1(self) -> list[str]: return ["OVENOPSTATE.S"] @@ -48,10 +46,9 @@ async def test_TC_OVENOPSTATE_1_1(self): cluster_revision = 1 feature_map=0 - await self.TC_BASE.test_TC_OPSTATE_BASE_1_1(endpoint=endpoint, + await self.TEST_TC_OPSTATE_BASE_1_1(endpoint=endpoint, cluster_revision=cluster_revision, feature_map=feature_map) - if __name__ == "__main__": default_matter_test_main() diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index 99aa43010eedad..abc4e011f93980 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -22,24 +22,7 @@ from mobly import asserts from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo -class TC_OVENOPSTATE_2_1(MatterBaseTest): - - async def read_and_validate_opstate(self, step, expected_state): - self.print_step(step, "Read OperationalState attribute") - operational_state = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, expected_state, - "OperationalState(%s) should equal %s" % (operational_state, expected_state)) - - async def read_and_validate_operror(self, step, expected_error): - self.print_step(step, "Read OperationalError attribute") - operational_error = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalError) - logging.info("OperationalError: %s" % (operational_error)) - asserts.assert_equal(operational_error.errorStateID, expected_error, - "errorStateID(%s) should equal %s" % (operational_error.errorStateID, expected_error)) - +class TC_OVENOPSTATE_2_1(MatterBaseTest, TC_OVENOPSTATE_BASE): def __init__(self, *args): super().__init__(*args) @@ -48,12 +31,10 @@ def __init__(self, *args): cluster=Clusters.OvenCavityOperationalState ) - self.TC_BASE = TC_OVENOPSTATE_BASE( - implementer=self, - test_info=test_info) + super().setup_base(test_info=test_info) def steps_TC_OVENOPSTATE_2_1(self) -> list[TestStep]: - return self.TC_BASE.steps_TC_OPSTATE_BASE_2_1() + return self.STEPS_TC_OPSTATE_BASE_2_1() def pics_TC_OVENOPSTATE_2_1(self) -> list[str]: return ["OVENOPSTATE.S"] @@ -61,7 +42,7 @@ def pics_TC_OVENOPSTATE_2_1(self) -> list[str]: @async_test_body async def test_TC_OVENOPSTATE_2_1(self): endpoint = self.matter_test_config.endpoint - await self.TC_BASE.test_TC_OPSTATE_BASE_2_1(endpoint) + await self.TEST_TC_OPSTATE_BASE_2_1(endpoint) if __name__ == "__main__": default_matter_test_main() diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index 90deda0bcb7f35..7f109149750d64 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -29,34 +29,42 @@ class TestInfo: cluster: Clusters class TC_OVENOPSTATE_BASE(): - def __init__(self, implementer=None, test_info=None): - asserts.assert_true(implementer != None, - "You shall define the instance of Operational State Test Case implementer") + def setup_base(self, test_info=None): asserts.assert_true(test_info != None, "You shall define the test info!") - self.implementer = implementer self.test_info = test_info async def read_expect_success(self, endpoint, attribute): - return await self.implementer.read_single_attribute_check_success(endpoint=endpoint, + logging.info("\t##### Read %s" % attribute) + attr_value = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=self.test_info.cluster, attribute=attribute) + logging.info("\t## %s: %s" % (attribute, attr_value)) + + return attr_value async def read_and_expect_value(self, endpoint, attribute, expected_value): - logging.info("\t##### Read %s" % attribute) attr_value = await self.read_expect_success( endpoint=endpoint, attribute=attribute) - logging.info("\t## %s: %s" % (attribute, attr_value)) + + asserts.assert_equal(attr_value, expected_value, + "Current value not according expected. Expected %d, received %d!" % + (expected_value, attr_value)) + + async def read_and_expect_property_value(self, endpoint, attribute, attr_property, expected_value): + attr_value = await self.read_expect_success( + endpoint=endpoint, + attribute=attribute) + attr_value = getattr(attr_value, attr_property) asserts.assert_equal(attr_value, expected_value, "Current value not according expected. Expected %d, received %d!" % (expected_value, attr_value)) async def read_and_expect_array_contains(self, endpoint, attribute, expected_contains): - logging.info("\t##### Read %s" % attribute) attr_value = await self.read_expect_success( endpoint=endpoint, attribute=attribute) @@ -71,7 +79,7 @@ async def read_and_expect_array_contains(self, endpoint, attribute, expected_con asserts.fail("""Entry (%s), not found! The returned value SHALL include all the entries: [%s]!""" % (item, ','.join(map(str, expected_contains)))) - def steps_TC_OPSTATE_BASE_1_1(self) -> list[TestStep]: + def STEPS_TC_OPSTATE_BASE_1_1(self) -> list[TestStep]: steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), TestStep(2, "TH reads from the DUT the ClusterRevision attribute"), TestStep(3, "TH reads from the DUT the FeatureMap attribute"), @@ -82,29 +90,29 @@ def steps_TC_OPSTATE_BASE_1_1(self) -> list[TestStep]: ] return steps - async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature_map=0): + async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature_map=0): cluster = self.test_info.cluster attributes = cluster.Attributes events = cluster.Events commands = cluster.Commands # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) - self.implementer.step(1) + self.step(1) # STEP 2: TH reads from the DUT the ClusterRevision attribute - self.implementer.step(2) + self.step(2) await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.ClusterRevision, expected_value=cluster_revision) # STEP 3: TH reads from the DUT the FeatureMap attribute - self.implementer.step(3) + self.step(3) await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.FeatureMap, expected_value=feature_map) # STEP 4: TH reads from the DUT the AttributeList attribute - self.implementer.step(4) + self.step(4) expected_value = [ attributes.PhaseList.attribute_id, attributes.CurrentPhase.attribute_id, @@ -118,7 +126,7 @@ async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature attributes.ClusterRevision.attribute_id ] - if self.implementer.check_pics(("%s.S.A0002" % self.test_info.pics_code)): + if self.check_pics(("%s.S.A0002" % self.test_info.pics_code)): expected_value.append(attributes.CountdownTime.attribute_id) await self.read_and_expect_array_contains(endpoint=endpoint, @@ -126,13 +134,13 @@ async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature expected_contains=expected_value) # STEP 5: TH reads from the DUT the EventList attribute - self.implementer.step(5) - if self.implementer.pics_guard(self.implementer.check_pics("PICS_EVENT_LIST_ENABLED")): + self.step(5) + if self.pics_guard(self.check_pics("PICS_EVENT_LIST_ENABLED")): expected_value = [ events.OperationalError.event_id, ] - if self.implementer.check_pics(("%s.S.E01" % self.test_info.pics_code)): + if self.check_pics(("%s.S.E01" % self.test_info.pics_code)): expected_value.append(events.OperationCompletion.event_id) await self.read_and_expect_array_contains(endpoint=endpoint, @@ -140,22 +148,22 @@ async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature expected_contains=expected_value) # STEP 6: TH reads from the DUT the AcceptedCommandList attribute - self.implementer.step(6) + self.step(6) expected_value = [] - if self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or \ - self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)): + if self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or \ + self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Pause.command_id) - if self.implementer.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ - self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): + if self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ + self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Stop.command_id) - if self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): + if self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Start.command_id) - if self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)) or \ - self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)): + if self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)) or \ + self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Resume.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, @@ -163,20 +171,20 @@ async def test_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature expected_contains=expected_value) # STEP 7: TH reads from the DUT the AcceptedCommandList attribute - self.implementer.step(7) + self.step(7) expected_value = [] - if self.implementer.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or \ - self.implementer.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ - self.implementer.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)) or \ - self.implementer.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)): + if self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or \ + self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ + self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)) or \ + self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)): expected_value.append(commands.OperationalCommandResponse.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, attribute=attributes.GeneratedCommandList, expected_contains=expected_value) - def steps_TC_OPSTATE_BASE_2_1(self) -> list[TestStep]: + def STEPS_TC_OPSTATE_BASE_2_1(self) -> list[TestStep]: steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), TestStep(2, "TH reads from the DUT the PhaseList attribute"), TestStep(3, "TH reads from the DUT the CurrentPhase attribute"), @@ -190,48 +198,44 @@ def steps_TC_OPSTATE_BASE_2_1(self) -> list[TestStep]: TestStep("6e", "Manually put the device in the Paused(0x02) operational state"), TestStep("6f", "TH reads from the DUT the OperationalState attribute"), TestStep("6g", "Manually put the device in the Error(0x03) operational state"), - TestStep("6h", "TH reads from the DUT the OperationalState attribute") - # TestStep(7, "TH reads from the DUT the OperationalError attribute"), - # TestStep("7a", "Manually put the device in the NoError(0x00) error state"), - # TestStep("7b", "TH reads from the DUT the OperationalError attribute"), - # TestStep("7c", "Manually put the device in the UnableToStartOrResume(0x01) error state"), - # TestStep("7d", "TH reads from the DUT the OperationalError attribute"), - # TestStep("7e", "Manually put the device in the UnableToCompleteOperation(0x02) error state"), - # TestStep("7f", "TH reads from the DUT the OperationalError attribute"), - # TestStep("7g", "Manually put the device in the CommandInvalidInState(0x03) error state"), - # TestStep("7h", "TH reads from the DUT the OperationalError attribute") + TestStep("6h", "TH reads from the DUT the OperationalState attribute"), + TestStep(7, "TH reads from the DUT the OperationalError attribute"), + TestStep("7a", "Manually put the device in the NoError(0x00) error state"), + TestStep("7b", "TH reads from the DUT the OperationalError attribute"), + TestStep("7c", "Manually put the device in the UnableToStartOrResume(0x01) error state"), + TestStep("7d", "TH reads from the DUT the OperationalError attribute"), + TestStep("7e", "Manually put the device in the UnableToCompleteOperation(0x02) error state"), + TestStep("7f", "TH reads from the DUT the OperationalError attribute"), + TestStep("7g", "Manually put the device in the CommandInvalidInState(0x03) error state"), + TestStep("7h", "TH reads from the DUT the OperationalError attribute") ] return steps - async def test_TC_OPSTATE_BASE_2_1(self, endpoint=1): + async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): cluster = self.test_info.cluster attributes = cluster.Attributes events = cluster.Events commands = cluster.Commands # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) - self.implementer.step(1) + self.step(1) # STEP 2: TH reads from the DUT the PhaseList attribute - self.implementer.step(2) - if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.A0000" % self.test_info.pics_code))): + self.step(2) + if self.pics_guard(self.check_pics(("%s.S.A0000" % self.test_info.pics_code))): phase_list = await self.read_expect_success(endpoint=endpoint, attribute=attributes.PhaseList) - - logging.info("PhaseList: %s" % (phase_list)) if phase_list is not NullValue: phase_list_len = len(phase_list) asserts.assert_less_equal(phase_list_len, 32, "PhaseList length(%d) must be less than 32!" % phase_list_len) # STEP 3: TH reads from the DUT the CurrentPhase attribute - self.implementer.step(3) - if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.A0001" % self.test_info.pics_code))): + self.step(3) + if self.pics_guard(self.check_pics(("%s.S.A0001" % self.test_info.pics_code))): current_phase = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CurrentPhase) - - logging.info("CurrentPhase: %s" % (current_phase)) if (phase_list == NullValue) or (not phase_list): asserts.assert_true(current_phase == NullValue, "CurrentPhase(%s) should be null" % current_phase) else: @@ -239,25 +243,19 @@ async def test_TC_OPSTATE_BASE_2_1(self, endpoint=1): "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) # STEP 4: TH reads from the DUT the CountdownTime attribute - self.implementer.step(4) - if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.A0002" % self.test_info.pics_code))): + self.step(4) + if self.pics_guard(self.check_pics(("%s.S.A0002" % self.test_info.pics_code))): countdown_time = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime) - - logging.info("CountdownTime: %s" % (countdown_time)) if countdown_time is not NullValue: asserts.assert_true(0 <= countdown_time <= 259200, "CountdownTime(%s) must be between 0 and 259200" % countdown_time) # STEP 5: TH reads from the DUT the OperationalStateList attribute - self.implementer.step(5) - if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.A0003" % self.test_info.pics_code))): + self.step(5) + if self.pics_guard(self.check_pics(("%s.S.A0003" % self.test_info.pics_code))): operational_state_list = await self.read_expect_success(endpoint=endpoint, attribute=attributes.OperationalStateList) - - #logging.info("OperationalStateList: [%s]" % ','.join(map(str, operational_state_list))) - logging.info("OperationalStateList: %s" % operational_state_list) - defined_states = [state.value for state in cluster.Enums.OperationalStateEnum if state is not cluster.Enums.OperationalStateEnum.kUnknownEnumValue] @@ -275,95 +273,125 @@ async def test_TC_OPSTATE_BASE_2_1(self, endpoint=1): asserts.assert_true(error_state_present, "The OperationalStateList does not have an ID entry of Error(0x03)") # STEP 6: TH reads from the DUT the OperationalState attribute - self.implementer.step(6) - if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.A0004" % self.test_info.pics_code))): + self.step(6) + if self.pics_guard(self.check_pics(("%s.S.A0004" % self.test_info.pics_code))): operational_state = await self.read_expect_success(endpoint=endpoint, attribute=attributes.OperationalState) - - logging.info("OperationalState: %s" % (operational_state)) - in_range = (0x80 <= operational_state <= 0xBF) asserts.assert_true(operational_state in defined_states or in_range, "OperationalState has an invalid ID value!") # STEP 6a: Manually put the device in the Stopped(0x00) operational state - self.implementer.step("6a") - if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.M.ST_STOPPED" % self.test_info.pics_code))): + self.step("6a") + if self.pics_guard(self.check_pics(("%s.S.M.ST_STOPPED" % self.test_info.pics_code))): input("Press Enter when done.\n") # STEP 6b: TH reads from the DUT the OperationalState attribute - self.implementer.step("6b") + self.step("6b") await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kStopped) else: - self.implementer.skip_step("6b") + self.skip_step("6b") # STEP 6c: Manually put the device in the Running(0x01) operational state - self.implementer.step("6c") - if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.M.ST_RUNNING" % self.test_info.pics_code))): + self.step("6c") + if self.pics_guard(self.check_pics(("%s.S.M.ST_RUNNING" % self.test_info.pics_code))): input("Press Enter when done.\n") # STEP 6d: TH reads from the DUT the OperationalState attribute - self.implementer.step("6d") + self.step("6d") await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kRunning) else: - self.implementer.skip_step("6d") + self.skip_step("6d") # STEP 6e: Manually put the device in the Paused(0x02) operational state - self.implementer.step("6e") - if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.M.ST_PAUSED" % self.test_info.pics_code))): + self.step("6e") + if self.pics_guard(self.check_pics(("%s.S.M.ST_PAUSED" % self.test_info.pics_code))): input("Press Enter when done.\n") # STEP 6f: TH reads from the DUT the OperationalState attribute - self.implementer.step("6f") + self.step("6f") await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kPaused) else: - self.implementer.skip_step("6f") + self.skip_step("6f") # STEP 6g: Manually put the device in the Error(0x03) operational state - self.implementer.step("6g") - if self.implementer.pics_guard(self.implementer.check_pics(("%s.S.M.ST_ERROR" % self.test_info.pics_code))): + self.step("6g") + if self.pics_guard(self.check_pics(("%s.S.M.ST_ERROR" % self.test_info.pics_code))): input("Press Enter when done.\n") # STEP 6h: TH reads from the DUT the OperationalState attribute - self.implementer.step("6h") + self.step("6h") await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kError) else: - self.implementer.skip_step("6h") - - # if self.implementer.pics_guard(self.check_pics(("%s.S.A0005" % self.test_info.pics_code))): - # self.print_step(7, "Read OperationalError attribute") - # operational_error = await self.read_mod_attribute_expect_success(endpoint=endpoint, - # attribute=attributes.OperationalError) - - # logging.info("OperationalError: %s" % (operational_error)) - - # # Defined Errors - # defined_errors = [error.value for error in Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum - # if error is not Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnknownEnumValue] - - # in_range = (0x80 <= operational_error.errorStateID <= 0xBF) - # asserts.assert_true(operational_error.errorStateID in defined_errors - # or in_range, "OperationalError has an invalid ID value!") - # if in_range: - # asserts.assert_true(operational_error.errorStateLabel is not None, "ErrorStateLabel should be populated") - - # if self.implementer.pics_guard(self.check_pics(("%s.S.M.ERR_NO_ERROR" % self.test_info.pics_code))): - # self.print_step("7a", "Manually put the device in the no error state") - # input("Press Enter when done.\n") - # await self.read_and_validate_operror(step="7b", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError) - # if self.implementer.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code))): - # self.print_step("7c", "Manually put the device in the unable to start or resume error state") - # input("Press Enter when done.\n") - # await self.read_and_validate_operror(step="7d", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnableToStartOrResume) - # if self.implementer.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION" % self.test_info.pics_code))): - # self.print_step("7e", "Manually put the device in the unable to complete operation error state") - # input("Press Enter when done.\n") - # await self.read_and_validate_operror(step="7f", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kUnableToCompleteOperation) - # if self.implementer.pics_guard(self.check_pics(("%s.S.M.ERR_COMMAND_INVALID_IN_STATE" % self.test_info.pics_code))): - # self.print_step("7g", "Manually put the device in the command invalid error state") - # input("Press Enter when done.\n") - # await self.read_and_validate_operror(step="7h", expected_error=Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState) \ No newline at end of file + self.skip_step("6h") + + # STEP 7: TH reads from the DUT the OperationalError attribute + self.step(7) + if self.pics_guard(self.check_pics(("%s.S.A0005" % self.test_info.pics_code))): + operational_error = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.OperationalError) + # Defined Errors + defined_errors = [error.value for error in cluster.Enums.ErrorStateEnum + if error is not cluster.Enums.ErrorStateEnum.kUnknownEnumValue] + + in_range = (0x80 <= operational_error.errorStateID <= 0xBF) + asserts.assert_true(operational_error.errorStateID in defined_errors + or in_range, "OperationalError has an invalid ID value!") + if in_range: + asserts.assert_true(operational_error.errorStateLabel is not None, "ErrorStateLabel should be populated") + + # STEP 7a: Manually put the device in the NoError(0x00) error state + self.step("7a") + if self.pics_guard(self.check_pics(("%s.S.M.ERR_NO_ERROR" % self.test_info.pics_code))): + input("Press Enter when done.\n") + # STEP 7b: TH reads from the DUT the OperationalError attribute + self.step("7b") + await self.read_and_expect_property_value(endpoint=endpoint, + attribute=attributes.OperationalError, + attr_property="errorStateID", + expected_value=cluster.Enums.ErrorStateEnum.kNoError) + else: + self.skip_step("7b") + + # STEP 7c: Manually put the device in the UnableToStartOrResume(0x01) error state + self.step("7c") + if self.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code))): + input("Press Enter when done.\n") + # STEP 7d: TH reads from the DUT the OperationalError attribute + self.step("7d") + await self.read_and_expect_property_value(endpoint=endpoint, + attribute=attributes.OperationalError, + attr_property="errorStateID", + expected_value=cluster.Enums.ErrorStateEnum.kUnableToStartOrResume) + else: + self.skip_step("7d") + + # STEP 7e: Manually put the device in the UnableToCompleteOperation(0x02) error state + self.step("7e") + if self.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION" % self.test_info.pics_code))): + input("Press Enter when done.\n") + # STEP 7f: TH reads from the DUT the OperationalError attribute + self.step("7f") + await self.read_and_expect_property_value(endpoint=endpoint, + attribute=attributes.OperationalError, + attr_property="errorStateID", + expected_value=cluster.Enums.ErrorStateEnum.kUnableToCompleteOperation) + else: + self.skip_step("7f") + + # STEP 7g: Manually put the device in the CommandInvalidInState(0x03) error state + self.step("7g") + if self.pics_guard(self.check_pics(("%s.S.M.ERR_COMMAND_INVALID_IN_STATE" % self.test_info.pics_code))): + input("Press Enter when done.\n") + # STEP 7h: TH reads from the DUT the OperationalError attribute + self.step("7h") + await self.read_and_expect_property_value(endpoint=endpoint, + attribute=attributes.OperationalError, + attr_property="errorStateID", + expected_value=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) + else: + self.skip_step("7h") \ No newline at end of file From 72ab5cfdfb7369f654672a956ea23dceb6d8e6c8 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Fri, 9 Feb 2024 16:03:23 -0300 Subject: [PATCH 55/89] Adding commads for example app --- .../include/oven-operational-state-delegate.h | 2 + .../src/oven-operational-state-delegate.cpp | 7 ++- .../linux/AllClustersCommandDelegate.cpp | 62 +++++++++++++++++++ .../linux/AllClustersCommandDelegate.h | 5 ++ 4 files changed, 75 insertions(+), 1 deletion(-) diff --git a/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h b/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h index eca70cee66d09a..dc2bc4e72461dd 100644 --- a/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h +++ b/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h @@ -97,6 +97,8 @@ class OvenCavityOperationalStateDelegate : public OperationalState::Delegate void HandleStopStateCallback(Clusters::OperationalState::GenericOperationalError & err) override; }; +Instance * GetOperationalStateInstance(); + void Shutdown(); } // namespace OvenCavityOperationalState diff --git a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp index 32612146c335b5..41ff6e6d1d6497 100644 --- a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp @@ -22,9 +22,14 @@ using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::OvenCavityOperationalState; -static OperationalState::Instance * gOvenCavityOperationalStateInstance = nullptr; +static OvenCavityOperationalState::Instance * gOvenCavityOperationalStateInstance = nullptr; static OvenCavityOperationalStateDelegate * gOvenCavityOperationalStateDelegate = nullptr; +OvenCavityOperationalState::Instance * OvenCavityOperationalState::GetOperationalStateInstance() +{ + return gOvenCavityOperationalStateInstance; +} + void OvenCavityOperationalState::Shutdown() { if (gOvenCavityOperationalStateInstance != nullptr) diff --git a/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp b/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp index 2da7e0c8900f3d..3c0286020fc96e 100644 --- a/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp +++ b/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp @@ -32,6 +32,8 @@ #include #include #include +#include +#include using namespace chip; using namespace chip::app; @@ -179,6 +181,12 @@ void AllClustersAppCommandHandler::HandleCommand(intptr_t context) self->OnAirQualityChange(static_cast(jsonAirQualityEnum.asUInt())); } } + else if (name == "OperationalStateChange") + { + std::string device = self->mJsonValue["Device"].asString(); + std::string operation = self->mJsonValue["Operation"].asString(); + self->OnOperationalStateChange(device, operation, self->mJsonValue["Param"]); + } else { ChipLogError(NotSpecified, "Unhandled command: Should never happens"); @@ -429,6 +437,60 @@ void AllClustersAppCommandHandler::OnModeChangeHandler(std::string device, std:: } } +void AllClustersAppCommandHandler::OnOperationalStateChange(std::string device, std::string operation, Json::Value param) +{ + OperationalState::Instance * operationalStateInstance = nullptr; + if (device == "Generic") + { + operationalStateInstance = OperationalState::GetOperationalStateInstance(); + } + else if (device == "Oven") + { + operationalStateInstance = OvenCavityOperationalState::GetOperationalStateInstance(); + } + else + { + ChipLogDetail(NotSpecified, "Invalid device type : %s", device.c_str()); + return; + } + + if (operation == "Start" || operation == "Resume") + { + operationalStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)); + } + else if (operation == "Pause") + { + operationalStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused)); + } + else if (operation == "Stop") + { + operationalStateInstance->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped)); + } + else if (operation == "OnFault") + { + + uint8_t event_id = to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation); + if (!param.isNull()) + { + event_id = to_underlying(static_cast(param.asUInt())); + } + + OperationalState::GenericOperationalError err(event_id); + operationalStateInstance->OnOperationalErrorDetected(err); + } + else if (operation == "OnCompletion") + { + Optional> operationTime(DataModel::Nullable(100)); + Optional> pausedTime(DataModel::Nullable(10)); + operationalStateInstance->OnOperationCompletionDetected(0, operationTime, pausedTime); + } + else + { + ChipLogDetail(NotSpecified, "Invalid operation : %s", operation.c_str()); + return; + } +} + void AllClustersAppCommandHandler::OnAirQualityChange(uint32_t aNewValue) { AirQuality::Instance * airQualityInstance = AirQuality::GetInstance(); diff --git a/examples/all-clusters-app/linux/AllClustersCommandDelegate.h b/examples/all-clusters-app/linux/AllClustersCommandDelegate.h index 7998cd15581a74..4022b06e9f8565 100644 --- a/examples/all-clusters-app/linux/AllClustersCommandDelegate.h +++ b/examples/all-clusters-app/linux/AllClustersCommandDelegate.h @@ -98,6 +98,11 @@ class AllClustersAppCommandHandler * Should be called when it is necessary to change the air quality attribute. */ void OnAirQualityChange(uint32_t aEnum); + + /** + * Should be called when it is necessary to change the operational state as a manual operation. + */ + void OnOperationalStateChange(std::string device, std::string operation, Json::Value param); }; class AllClustersCommandDelegate : public NamedPipeCommandDelegate From 36540cdc5f842000723622b88172ef97d606415b Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 16:52:25 -0300 Subject: [PATCH 56/89] added TC 2.2 to the base test --- src/python_testing/TC_OVENOPSTATE_2_2.py | 189 ++------------- src/python_testing/TC_OpstateCommon.py | 280 ++++++++++++++++++++++- 2 files changed, 285 insertions(+), 184 deletions(-) diff --git a/src/python_testing/TC_OVENOPSTATE_2_2.py b/src/python_testing/TC_OVENOPSTATE_2_2.py index aeed4f949ba1ac..7fb26dcb87615c 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_2.py +++ b/src/python_testing/TC_OVENOPSTATE_2_2.py @@ -19,190 +19,33 @@ import time import chip.clusters as Clusters -from chip.clusters.Types import NullValue -from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main from mobly import asserts +from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo -# This test requires several additional command line arguments -# run with -# --int-arg PIXIT_ENDPOINT: +class TC_OVENOPSTATE_2_2(MatterBaseTest, TC_OVENOPSTATE_BASE): + def __init__(self, *args): + super().__init__(*args) -class TC_OVENOPSTATE_2_2(MatterBaseTest): + test_info = TestInfo( + pics_code="OVENOPSTATE", + cluster=Clusters.OvenCavityOperationalState + ) - async def read_mod_attribute_expect_success(self, endpoint, attribute): - cluster = Clusters.Objects.OvenCavityOperationalState - return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) - - async def send_start_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Start: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Start(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Start") - return ret - - async def send_pause_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Pause: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Pause(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Pause") - return ret + super().setup_base(test_info=test_info) - async def send_resume_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Resume: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Resume(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Resume") - return ret - - async def send_stop_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Stop: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Stop(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Stop") - return ret + def steps_TC_OVENOPSTATE_2_2(self) -> list[TestStep]: + return self.STEPS_TC_OPSTATE_BASE_2_2() - async def read_and_validate_opstate(self, step, expected_state): - self.print_step(step, "Read OperationalState attribute") - operational_state = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, expected_state, - "OperationalState(%s) should equal %s" % (operational_state, expected_state)) - - async def read_and_validate_operror(self, step, expected_error): - self.print_step(step, "Read OperationalError attribute") - operational_error = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalError) - logging.info("OperationalError: %s" % (operational_error)) - asserts.assert_equal(operational_error.errorStateID, expected_error, - "errorStateID(%s) should equal %s" % (operational_error.errorStateID, expected_error)) + def pics_TC_OVENOPSTATE_2_2(self) -> list[str]: + return ["OVENOPSTATE.S"] @async_test_body async def test_TC_OVENOPSTATE_2_2(self): + endpoint = self.matter_test_config.endpoint - asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, - "PIXIT_ENDPOINT must be included on the command line in " - "the --int-arg flag as PIXIT_ENDPOINT:") - - self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] - - attributes = Clusters.OvenCavityOperationalState.Attributes - - - self.print_step(1, "Commissioning, already done") - - self.print_step(2, "Manually put the DUT into a state wherein it can receive a Start Command") - input("Press Enter when done.\n") - - if self.check_pics("OVENOPSTATE.S.A0003"): - self.print_step(3, "Read OperationalStateList attribute") - OperationalState_List = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.OperationalStateList) - - if OperationalState_List == NullValue: - logging.info("OperationalStateList is null") - else: - logging.info("OperationalStateList: %s" % (OperationalState_List)) - temp=[0,1,2,3] - for i, state in enumerate(OperationalState_List): - asserts.assert_equal(state.operationalStateID,temp[i],"operationalStateID(%s) should equal %s" %(state.operationalStateID,temp[i])) - - if self.check_pics("OVENOPSTATE.S.C02.Rsp" and "OVENOPSTATE.S.C04.Tx"): - self.print_step(4, "Send Start command") - ret = await self.send_start_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - if self.check_pics("OVENOPSTATE.S.A0004"): - self.print_step(5, "Read operationalState Attribute") - operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, - "OperationalState ID should be Running(0x01)") - - if self.check_pics("OVENOPSTATE.S.A0005"): - self.print_step(6, "Read operationalError Attribute") - operational_error=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalError) - logging.info("OperationalState: %s" % (operational_error)) - asserts.assert_equal(operational_error, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kNoError, - "OperationalState ID should be NoError(0x00)") - - if self.check_pics("OVENOPSTATE.S.A0002"): - self.print_step(7, "Read CountdownTime attribute") - initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.CountdownTime) - logging.info("CountdownTime: %s" % (initial_countdown_time)) - if initial_countdown_time is not NullValue: - in_range = (1 <= initial_countdown_time <= 259200) - asserts.assert_true(initial_countdown_time is NullValue or in_range, - "invalid CountdownTime(%s). Must be in between 1 and 259200, or null " % initial_countdown_time) - - if self.check_pics("OVENOPSTATE.S.A0000"): - self.print_step(8, "Read PhaseList attribute") - phase_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.PhaseList) - - if phase_list == NullValue: - logging.info("PhaseList is null") - else: - logging.info("PhaseList: %s" % (phase_list)) - phase_list_len=len(phase_list) - - if self.check_pics("OVENOPSTATE.S.A0001" and phase_list_len): - self.print_step(9, "Read CurrentPhase attribute") - current_phase = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentPhase) - logging.info("CurrentPhase: %s" % (current_phase)) - asserts.assert_true(0 <= current_phase and current_phase < phase_list_len, - "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) - - if self.check_pics("OVENOPSTATE.S.A0002"): - self.print_step(10, "TH waits for a vendor defined wait time, this being a period of time less than the expected duration of the operation that has been started") - init_time=time.time() - input("Press enter when done. \n") - end_time=time.time()-init_time - - - if self.check_pics("OVENOPSTATE.S.A0002"): - self.print_step(11, "Read countdowntime Attribute") - countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.CountdownTime) - logging.info("CountdownTime: %s" % (countdown_time)) - asserts.assert_true(countdown_time is not NullValue or countdown_time>end_time or countdown_time>initial_countdown_time, - "invalid CountdownTime(%s). Must be in between end_time value and less than initial_countdown_time, or null " % countdown_time) - - if self.check_pics("OVENOPSTATE.S.C02.Rsp" and "OVENOPSTATE.S.C04.Tx"): - self.print_step(12, "Send Start command") - ret = await self.send_start_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - if self.check_pics("OVENOPSTATE.S.C01.Rsp" and "OVENOPSTATE.S.C04.Tx"): - self.print_step(13, "Send Stop command") - ret = await self.send_stop_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - if self.check_pics("OVENOPSTATE.S.A0004"): - self.print_step(14, "Read operationalState Attribute") - operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kStopped, - "OperationalState ID should be Stopped(0x00)") - - if self.check_pics("OVENOPSTATE.S.C01.Rsp" and "OVENOPSTATE.S.C04.Tx"): - self.print_step(15, "Send Stop command") - ret = await self.send_stop_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - if self.check_pics("OVENOPSTATE.M.ERR_UNABLE_TO_START_OR_RESUME"): - self.print_step(16, "Manually put the DUT into a state wherein it cannot receive a Start Command") - input("Press Enter when done.\n") - - if self.check_pics("OVENOPSTATE.M.ERR_UNABLE_TO_START_OR_RESUME" and "OVENOPSTATE.S.C02.Rsp" and "OVENOPSTATE.S.C04.Tx"): - self.print_step(17, "Send Start command") - ret = await self.send_start_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kError, - "errorStateID(%s) should be set to UnableToStartOrResume(0x01)" % ret.commandResponseState.errorStateID) - + await self.TEST_TC_OPSTATE_BASE_2_2(endpoint=endpoint) if __name__ == "__main__": default_matter_test_main() diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index 7f109149750d64..111c3d98cde5cc 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -16,12 +16,25 @@ # import logging +import time import chip.clusters as Clusters from chip.clusters.Types import NullValue +from chip.interaction_model import InteractionModelError, Status from mobly import asserts from dataclasses import dataclass from matter_testing_support import TestStep +import psutil + +def get_pid(name): + pid = None + + for proc in psutil.process_iter(): + if name in proc.name(): + pid = proc.pid + break + + return pid @dataclass class TestInfo: @@ -29,12 +42,62 @@ class TestInfo: cluster: Clusters class TC_OVENOPSTATE_BASE(): - def setup_base(self, test_info=None): + def setup_base(self, test_info=None, app_pipe="/tmp/chip_all_clusters_fifo_"): asserts.assert_true(test_info != None, "You shall define the test info!") self.test_info = test_info + self.app_pipe = app_pipe + + if self.test_info.cluster == Clusters.OperationalState: + self.device = "Generic" + elif self.test_info.cluster == Clusters.OvenCavityOperationalState: + self.device = "Oven" + else: + asserts.fail("Cluster not supported!") + + def init_test(self): + self.is_ci = self.check_pics("PICS_SDK_CI_ONLY") + if self.is_ci: + app_pid = self.matter_test_config.app_pid + if app_pid == 0: + app_pid = get_pid("chip-all-clusters-app") + if app_pid == None: + asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set") + self.app_pipe = self.app_pipe + str(app_pid) + + # Sends and out-of-band command to test-app + def write_to_app_pipe(self, command): + with open(self.app_pipe, "w") as app_pipe: + app_pipe.write(command + "\n") + + def send_manual_or_pipe_command(self, command): + if self.is_ci: + self.write_to_app_pipe(command) + else: + input("Press Enter when done.\n") + + async def send_cmd(self, endpoint, cmd, timedRequestTimeoutMs=None): + logging.info("\t##### Command %s" % cmd) + + try: + return await self.send_single_cmd(cmd=cmd, + endpoint=endpoint, + timedRequestTimeoutMs=timedRequestTimeoutMs) + + except InteractionModelError as e: + asserts.assert_equal(e.status, expected_status, "Unexpected error returned") + + async def send_cmd_expect_response(self, endpoint, cmd, expected_response, timedRequestTimeoutMs=None): + ret = await self.send_cmd(endpoint=endpoint, + cmd=cmd, + timedRequestTimeoutMs=timedRequestTimeoutMs) + + asserts.assert_equal(ret.commandResponseState.errorStateID, + expected_response, + "Current value not according expected. Expected %d, received %d!" % + (expected_response, ret.commandResponseState.errorStateID)) async def read_expect_success(self, endpoint, attribute): logging.info("\t##### Read %s" % attribute) @@ -79,6 +142,9 @@ async def read_and_expect_array_contains(self, endpoint, attribute, expected_con asserts.fail("""Entry (%s), not found! The returned value SHALL include all the entries: [%s]!""" % (item, ','.join(map(str, expected_contains)))) + ############################ + # TEST CASE 1.1 + ############################ def STEPS_TC_OPSTATE_BASE_1_1(self) -> list[TestStep]: steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), TestStep(2, "TH reads from the DUT the ClusterRevision attribute"), @@ -96,6 +162,8 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature events = cluster.Events commands = cluster.Commands + self.init_test() + # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) self.step(1) @@ -184,6 +252,10 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature attribute=attributes.GeneratedCommandList, expected_contains=expected_value) + + ############################ + # TEST CASE 2.1 + ############################ def STEPS_TC_OPSTATE_BASE_2_1(self) -> list[TestStep]: steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), TestStep(2, "TH reads from the DUT the PhaseList attribute"), @@ -211,13 +283,14 @@ def STEPS_TC_OPSTATE_BASE_2_1(self) -> list[TestStep]: ] return steps - async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): cluster = self.test_info.cluster attributes = cluster.Attributes events = cluster.Events commands = cluster.Commands + self.init_test() + # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) self.step(1) @@ -284,7 +357,7 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6a: Manually put the device in the Stopped(0x00) operational state self.step("6a") if self.pics_guard(self.check_pics(("%s.S.M.ST_STOPPED" % self.test_info.pics_code))): - input("Press Enter when done.\n") + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) # STEP 6b: TH reads from the DUT the OperationalState attribute self.step("6b") await self.read_and_expect_value(endpoint=endpoint, @@ -296,7 +369,7 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6c: Manually put the device in the Running(0x01) operational state self.step("6c") if self.pics_guard(self.check_pics(("%s.S.M.ST_RUNNING" % self.test_info.pics_code))): - input("Press Enter when done.\n") + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Start"}' % self.device) # STEP 6d: TH reads from the DUT the OperationalState attribute self.step("6d") await self.read_and_expect_value(endpoint=endpoint, @@ -308,7 +381,7 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6e: Manually put the device in the Paused(0x02) operational state self.step("6e") if self.pics_guard(self.check_pics(("%s.S.M.ST_PAUSED" % self.test_info.pics_code))): - input("Press Enter when done.\n") + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Pause"}' % self.device) # STEP 6f: TH reads from the DUT the OperationalState attribute self.step("6f") await self.read_and_expect_value(endpoint=endpoint, @@ -320,7 +393,7 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6g: Manually put the device in the Error(0x03) operational state self.step("6g") if self.pics_guard(self.check_pics(("%s.S.M.ST_ERROR" % self.test_info.pics_code))): - input("Press Enter when done.\n") + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) # STEP 6h: TH reads from the DUT the OperationalState attribute self.step("6h") await self.read_and_expect_value(endpoint=endpoint, @@ -347,7 +420,8 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 7a: Manually put the device in the NoError(0x00) error state self.step("7a") if self.pics_guard(self.check_pics(("%s.S.M.ERR_NO_ERROR" % self.test_info.pics_code))): - input("Press Enter when done.\n") + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % + (self.device, cluster.Enums.ErrorStateEnum.kNoError)) # STEP 7b: TH reads from the DUT the OperationalError attribute self.step("7b") await self.read_and_expect_property_value(endpoint=endpoint, @@ -360,7 +434,8 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 7c: Manually put the device in the UnableToStartOrResume(0x01) error state self.step("7c") if self.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code))): - input("Press Enter when done.\n") + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % + (self.device, cluster.Enums.ErrorStateEnum.kUnableToStartOrResume)) # STEP 7d: TH reads from the DUT the OperationalError attribute self.step("7d") await self.read_and_expect_property_value(endpoint=endpoint, @@ -373,7 +448,8 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 7e: Manually put the device in the UnableToCompleteOperation(0x02) error state self.step("7e") if self.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION" % self.test_info.pics_code))): - input("Press Enter when done.\n") + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % + (self.device, cluster.Enums.ErrorStateEnum.kUnableToCompleteOperation)) # STEP 7f: TH reads from the DUT the OperationalError attribute self.step("7f") await self.read_and_expect_property_value(endpoint=endpoint, @@ -386,7 +462,8 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 7g: Manually put the device in the CommandInvalidInState(0x03) error state self.step("7g") if self.pics_guard(self.check_pics(("%s.S.M.ERR_COMMAND_INVALID_IN_STATE" % self.test_info.pics_code))): - input("Press Enter when done.\n") + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % + (self.device, cluster.Enums.ErrorStateEnum.kCommandInvalidInState)) # STEP 7h: TH reads from the DUT the OperationalError attribute self.step("7h") await self.read_and_expect_property_value(endpoint=endpoint, @@ -394,4 +471,185 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): attr_property="errorStateID", expected_value=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) else: - self.skip_step("7h") \ No newline at end of file + self.skip_step("7h") + + ############################ + # TEST CASE 2.2 + ############################ + def STEPS_TC_OPSTATE_BASE_2_2(self) -> list[TestStep]: + steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Manually put the DUT into a state wherein it can receive a Start Command"), + TestStep(3, "TH reads from the DUT the OperationalStateList attribute"), + TestStep(4, "TH sends Start command to the DUT"), + TestStep(5, "TH reads from the DUT the OperationalState attribute"), + TestStep(6, "TH reads from the DUT the OperationalError attribute"), + TestStep(7, "TH reads from the DUT the CountdownTime attribute"), + TestStep(8, "TH reads from the DUT the PhaseList attribute"), + TestStep(9, "TH reads from the DUT the CurrentPhase attribute"), + TestStep(10, "TH waits for a vendor defined wait time, this being a period of time less than the expected duration of the operation that has been started"), + TestStep(11, "TH reads from the DUT the CountdownTime attribute"), + TestStep(12, "TH sends Start command to the DUT"), + TestStep(13, "TH sends Stop command to the DUT"), + TestStep(14, "TH reads from the DUT the OperationalState attribute"), + TestStep(15, "TH sends Stop command to the DUT"), + TestStep(16, "Manually put the DUT into a state wherein it cannot receive a Start Command"), + TestStep(17, "TH sends Start command to the DUT") + ] + return steps + + async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): + cluster = self.test_info.cluster + attributes = cluster.Attributes + events = cluster.Events + commands = cluster.Commands + + self.init_test() + + asserts.assert_true('PIXIT.WAITTIME' in self.matter_test_config.global_test_params, + "PIXIT.WAITTIME must be included on the command line in " + "the --int-arg flag as PIXIT.WAITTIME:") + + wait_time = self.matter_test_config.global_test_params['PIXIT.WAITTIME'] + + if wait_time == 0: + asserts.fail("PIXIT.WAITTIME shall be higher than 0.") + + # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) + self.step(1) + + # STEP 2: Manually put the DUT into a state wherein it can receive a Start Command + self.step(2) + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % + (self.device, cluster.Enums.ErrorStateEnum.kNoError)) + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) + + # STEP 3: TH reads from the DUT the OperationalStateList attribute + self.step(3) + if self.pics_guard(self.check_pics(("%s.S.A0003" % self.test_info.pics_code))): + operational_state_list = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.OperationalStateList) + + operational_state_list_ids = [op_state.operationalStateID for op_state in operational_state_list] + + defined_states = [state.value for state in cluster.Enums.OperationalStateEnum + if state is not cluster.Enums.OperationalStateEnum.kUnknownEnumValue] + + for state in defined_states: + if state not in operational_state_list_ids: + asserts.fail("The list shall include structs with the following OperationalStateIds: %s", defined_states) + + # STEP 4: TH sends Start command to the DUT + self.step(4) + if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + ret = await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Start(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 5: TH reads from the DUT the OperationalState attribute + self.step(5) + if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + operational_state = await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kRunning) + + # STEP 6: TH reads from the DUT the OperationalError attribute + self.step(6) + if self.pics_guard(self.check_pics("%s.S.A0005" % self.test_info.pics_code)): + operational_error = await self.read_and_expect_property_value(endpoint=endpoint, + attribute=attributes.OperationalError, + attr_property="errorStateID", + expected_value=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 7: TH reads from the DUT the CountdownTime attribute + self.step(7) + if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + initial_countdown_time = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.CountdownTime) + if initial_countdown_time is not NullValue: + asserts.assert_true(0 <= initial_countdown_time <= 259200, + "CountdownTime(%s) must be between 0 and 259200" % initial_countdown_time) + + # STEP 8: TH reads from the DUT the PhaseList attribute + self.step(8) + if self.pics_guard(self.check_pics("%s.S.A0000" % self.test_info.pics_code)): + phase_list = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.PhaseList) + phase_list_len = 0 + if phase_list is not NullValue: + phase_list_len = len(phase_list) + asserts.assert_less_equal(phase_list_len, 32, + "PhaseList length(%d) must be less than 32!" % phase_list_len) + + # STEP 9: TH reads from the DUT the CurrentPhase attribute + self.step(9) + if self.pics_guard(self.check_pics("%s.S.A0001" % self.test_info.pics_code) and phase_list_len): + current_phase = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.CurrentPhase) + if (phase_list == NullValue) or (not phase_list): + asserts.assert_true(current_phase == NullValue, "CurrentPhase(%s) should be null" % current_phase) + else: + asserts.assert_true(0 <= current_phase and current_phase < phase_list_len, + "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) + + # STEP 10: TH waits for a vendor defined wait time, this being a period of time less than the expected duration of the operation that has been started + self.step(10) + if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + time.sleep(wait_time) + + # STEP 11: TH reads from the DUT the CountdownTime attribute + self.step(11) + if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + countdown_time = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.CountdownTime) + + if (countdown_time is not NullValue) and (initial_countdown_time is not NullValue): + difference = (countdown_time - initial_countdown_time) + asserts.assert_greater(difference, wait_time, + "The countdown time shall have decreased at least %s since start command" % wait_time) + + # STEP 12: TH sends Start command to the DUT + self.step(12) + if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + ret = await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Start(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 13: TH sends Stop command to the DUT + self.step(13) + if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + ret = await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Stop(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 14: TH reads from the DUT the OperationalState attribute + self.step(14) + if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + operational_state = await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kStopped) + + # STEP 15: TH sends Stop command to the DUT + self.step(15) + if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + ret = await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Stop(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 16: Manually put the DUT into a state wherein it cannot receive a Start Command + self.step(16) + if self.pics_guard(self.check_pics("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code)): + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % + (self.device, cluster.Enums.ErrorStateEnum.kUnableToCompleteOperation)) + + # STEP 17: TH sends Start command to the DUT + self.step(17) + if self.pics_guard(self.check_pics("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + ret = await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Start(), + expected_response=cluster.Enums.ErrorStateEnum.kUnableToStartOrResume) \ No newline at end of file From 48639fa261d545f4eb254b34185cbfd5ebf54a2f Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 16:52:43 -0300 Subject: [PATCH 57/89] enabled all tests for oven cavity opstate --- .../tests/suites/certification/ci-pics-values | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/app/tests/suites/certification/ci-pics-values b/src/app/tests/suites/certification/ci-pics-values index 1d0cf95bc76149..8642dd3eae0769 100644 --- a/src/app/tests/suites/certification/ci-pics-values +++ b/src/app/tests/suites/certification/ci-pics-values @@ -1864,14 +1864,14 @@ OVENOPSTATE.S=1 OVENOPSTATE.C=1 #ManuallyControlled -OVENOPSTATE.S.M.ST_STOPPED=0 -OVENOPSTATE.S.M.ST_RUNNING=0 -OVENOPSTATE.S.M.ST_PAUSED=0 -OVENOPSTATE.S.M.ST_ERROR=0 -OVENOPSTATE.S.M.ERR_NO_ERROR=0 -OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME=0 -OVENOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION=0 -OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE=0 +OVENOPSTATE.S.M.ST_STOPPED=1 +OVENOPSTATE.S.M.ST_RUNNING=1 +OVENOPSTATE.S.M.ST_PAUSED=1 +OVENOPSTATE.S.M.ST_ERROR=1 +OVENOPSTATE.S.M.ERR_NO_ERROR=1 +OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME=1 +OVENOPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION=1 +OVENOPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE=1 # Server Attributes OVENOPSTATE.S.A0000=1 From 1de794899735ea8bfdd03becf22b91e91d95c8ae Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 16:53:04 -0300 Subject: [PATCH 58/89] added app id to the CI parameters --- scripts/tests/run_python_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tests/run_python_test.py b/scripts/tests/run_python_test.py index fdea7767037aa6..90a573a5d18788 100755 --- a/scripts/tests/run_python_test.py +++ b/scripts/tests/run_python_test.py @@ -137,7 +137,7 @@ def main(app: str, factoryreset: bool, factoryreset_app_only: bool, app_args: st log_cooking_threads, Fore.GREEN + "APP " + Style.RESET_ALL, app_process, log_queue) script_command = [script, "--paa-trust-store-path", os.path.join(DEFAULT_CHIP_ROOT, MATTER_DEVELOPMENT_PAA_ROOT_CERTS), - '--log-format', '%(message)s'] + shlex.split(script_args) + '--log-format', '%(message)s', "--app-id", str(app_process.pid)] + shlex.split(script_args) if script_gdb: # From 8268334e37aca38fcb86983a8543ad57ac9d1800 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 16:53:23 -0300 Subject: [PATCH 59/89] Blocking start when in fault --- .../src/oven-operational-state-delegate.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp index 41ff6e6d1d6497..8b72d77816e784 100644 --- a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp @@ -111,6 +111,15 @@ void OvenCavityOperationalStateDelegate::HandleResumeStateCallback(OperationalSt void OvenCavityOperationalStateDelegate::HandleStartStateCallback(OperationalState::GenericOperationalError & err) { + OperationalState::GenericOperationalError current_err(to_underlying(OperationalState::ErrorStateEnum::kNoError)); + GetInstance()->GetCurrentOperationalError(current_err); + + if(current_err.errorStateID != to_underlying(OperationalState::ErrorStateEnum::kNoError)) + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToStartOrResume)); + return; + } + // placeholder implementation auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)); if (error == CHIP_NO_ERROR) From 14daf27c5050a5bb235028ae1b6be946682d8691 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 16:58:35 -0300 Subject: [PATCH 60/89] added tests for CI --- .github/workflows/tests.yaml | 2 + .../Test_TC_OVENOPSTATE_2_2.yaml | 182 ------------------ 2 files changed, 2 insertions(+), 182 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 10318ab1f70511..fe3cc1d32e610d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -513,6 +513,8 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestSpecParsingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/TestTimeSyncTrustedTimeSourceRunner.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_1_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_2.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - name: Uploading core files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml deleted file mode 100644 index a0235aaa2e4cb1..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_2.yaml +++ /dev/null @@ -1,182 +0,0 @@ -# Copyright (c) 2023 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default - -name: 3.2.2. [TC-OVENOPSTATE-2.2] Start and Stop commands with DUT as Server - -PICS: - - OVENOPSTATE.S - -config: - nodeId: 0x12344321 - cluster: "Oven Cavity Operational State" - endpoint: 1 - -tests: - #- label: "Note" - # verification: | - # This is a simulated example log for instructional purposes only. In real scenarios, the actual log may vary depending on the feature implementation in Reference App. - # disabled: true - - - label: "Step 1: Commission DUT to TH" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: - "Step 2: Manually put the DUT into a state wherein it can receive a - Start Command" - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_USER_PROMPT - arguments: - values: - - name: "message" - value: "Please enter 'y' for success" - - name: "expectedValue" - value: "y" - - - label: "Step 3: TH reads from the DUT the OperationalStateList attribute" - PICS: OVENOPSTATE.S.A0003 - command: "readAttribute" - attribute: "OperationalStateList" - response: - value: - [ - { OperationalStateID: 0 }, - { OperationalStateID: 1 }, - { OperationalStateID: 2 }, - { OperationalStateID: 3 }, - ] - - constraints: - type: list - - - label: "Step 4: TH sends Start command to the DUT" - PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx - command: "Start" - response: - values: - - name: "CommandResponseState" - value: {ErrorStateID: 0} - - - label: "Step 5: TH reads from the DUT the OperationalState attribute" - PICS: OVENOPSTATE.S.A0004 - command: "readAttribute" - attribute: "OperationalState" - response: - value: 1 - constraints: - type: enum8 - - - label: "Step 6: TH reads from the DUT the OperationalError attribute" - PICS: OVENOPSTATE.S.A0005 - command: "readAttribute" - attribute: "OperationalError" - response: - value: {ErrorStateID: 0} - - - label: "Step 7: TH reads from the DUT the CountdownTime attribute" - PICS: OVENOPSTATE.S.A0002 - command: "readAttribute" - attribute: "CountdownTime" - response: - value: null - - - label: "Step 8: TH reads from the DUT the PhaseList attribute" - PICS: OVENOPSTATE.S.A0000 - command: "readAttribute" - attribute: "PhaseList" - response: - value: null - - - label: "Step 9: TH reads from the DUT the CurrentPhase attribute" - PICS: OVENOPSTATE.S.A0001 - command: "readAttribute" - attribute: "CurrentPhase" - response: - value: null - - - label: - "Step 10: TH waits for a vendor defined wait time, this being a period - of time less than the expected duration of the operation that has been - started" - verification: | - TH waits for a vendor defined wait time, this being a period of time less than the expected duration of the operation that has been started - disabled: true - - - label: "Step 11: TH reads from the DUT the CountdownTime attribute" - PICS: OVENOPSTATE.S.A0002 - command: "readAttribute" - attribute: "CountdownTime" - response: - value: null - - - label: "Step 12: TH sends Start command to the DUT" - PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx - command: "Start" - response: - values: - - name: "CommandResponseState" - value: { ErrorStateID: 0 } - - - label: "Step 13: TH sends Stop command to the DUT" - PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx - command: "Stop" - response: - values: - - name: "CommandResponseState" - value: { ErrorStateID: 0 } - - - label: "Step 14: TH reads from the DUT the OperationalState attribute" - PICS: OVENOPSTATE.S.A0004 - command: "readAttribute" - attribute: "OperationalState" - response: - value: 0 - constraints: - type: enum8 - - - label: "Step 15: TH sends Stop command to the DUT" - PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx - command: "Stop" - response: - values: - - name: "CommandResponseState" - value: { ErrorStateID: 0 } - - - label: - "Step 16: Manually put the DUT into a state wherein it cannot receive - a Start Command" - cluster: "LogCommands" - command: "UserPrompt" - PICS: PICS_USER_PROMPT && OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME - arguments: - values: - - name: "message" - value: "Please enter 'y' for success" - - name: "expectedValue" - value: "y" - - - label: "Step 17: TH sends Start command to the DUT" - PICS: - OVENOPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx - command: "Start" - response: - values: - - name: "CommandResponseState" - value: { ErrorStateID: 1 } \ No newline at end of file From 3235e90ef32ff95060e99f61202f345f6649f5f2 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 22:23:13 -0300 Subject: [PATCH 61/89] Fix lints --- src/python_testing/TC_OVENOPSTATE_1_1.py | 10 +++++----- src/python_testing/TC_OVENOPSTATE_2_1.py | 5 +++-- src/python_testing/TC_OVENOPSTATE_2_2.py | 6 +++--- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/src/python_testing/TC_OVENOPSTATE_1_1.py b/src/python_testing/TC_OVENOPSTATE_1_1.py index 0b80931b66478a..ec3b3bba629319 100644 --- a/src/python_testing/TC_OVENOPSTATE_1_1.py +++ b/src/python_testing/TC_OVENOPSTATE_1_1.py @@ -15,11 +15,9 @@ # limitations under the License. # -import logging import chip.clusters as Clusters from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main -from mobly import asserts from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo @@ -44,11 +42,13 @@ def pics_TC_OVENOPSTATE_1_1(self) -> list[str]: async def test_TC_OVENOPSTATE_1_1(self): endpoint = self.matter_test_config.endpoint cluster_revision = 1 - feature_map=0 + feature_map = 0 await self.TEST_TC_OPSTATE_BASE_1_1(endpoint=endpoint, - cluster_revision=cluster_revision, - feature_map=feature_map) + cluster_revision=cluster_revision, + feature_map=feature_map) + if __name__ == "__main__": default_matter_test_main() + diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index abc4e011f93980..539b5929dd517b 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -15,13 +15,12 @@ # limitations under the License. # -import logging import chip.clusters as Clusters from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main -from mobly import asserts from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo + class TC_OVENOPSTATE_2_1(MatterBaseTest, TC_OVENOPSTATE_BASE): def __init__(self, *args): super().__init__(*args) @@ -44,5 +43,7 @@ async def test_TC_OVENOPSTATE_2_1(self): endpoint = self.matter_test_config.endpoint await self.TEST_TC_OPSTATE_BASE_2_1(endpoint) + if __name__ == "__main__": default_matter_test_main() + diff --git a/src/python_testing/TC_OVENOPSTATE_2_2.py b/src/python_testing/TC_OVENOPSTATE_2_2.py index 7fb26dcb87615c..71cb06884dd3f5 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_2.py +++ b/src/python_testing/TC_OVENOPSTATE_2_2.py @@ -15,14 +15,12 @@ # limitations under the License. # -import logging -import time import chip.clusters as Clusters from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main -from mobly import asserts from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo + class TC_OVENOPSTATE_2_2(MatterBaseTest, TC_OVENOPSTATE_BASE): def __init__(self, *args): @@ -47,5 +45,7 @@ async def test_TC_OVENOPSTATE_2_2(self): await self.TEST_TC_OPSTATE_BASE_2_2(endpoint=endpoint) + if __name__ == "__main__": default_matter_test_main() + From 199d72eb8da75e98b2d50f51d748cdd977d45e0a Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 22:24:19 -0300 Subject: [PATCH 62/89] Added test 2.3 --- .github/workflows/tests.yaml | 1 + src/python_testing/TC_OVENOPSTATE_2_3.py | 267 ++++++++++---------- src/python_testing/TC_OpstateCommon.py | 304 ++++++++++++++++++----- 3 files changed, 383 insertions(+), 189 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index fe3cc1d32e610d..d6e103ce4e69ef 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -515,6 +515,7 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_1_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_2.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_3.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - name: Uploading core files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py index 1d0d94e7a3d69c..dbdee8edc66145 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_3.py +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -16,143 +16,158 @@ # import logging -import time import chip.clusters as Clusters -from chip.clusters.Types import NullValue -from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main from mobly import asserts +from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo -# This test requires several additional command line arguments -# run with -# --int-arg PIXIT_ENDPOINT: +class TC_OVENOPSTATE_2_3(MatterBaseTest, TC_OVENOPSTATE_BASE): + def __init__(self, *args): + super().__init__(*args) + test_info = TestInfo( + pics_code="OVENOPSTATE", + cluster=Clusters.OvenCavityOperationalState + ) -class TC_OVENOPSTATE_2_3(MatterBaseTest): + super().setup_base(test_info=test_info) - async def read_mod_attribute_expect_success(self, endpoint, attribute): - cluster = Clusters.Objects.OvenCavityOperationalState - return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + def steps_TC_OVENOPSTATE_2_3(self) -> list[TestStep]: + return self.STEPS_TC_OPSTATE_BASE_2_3() - async def send_pause_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Pause: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Pause(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Pause") - return ret - - async def send_resume_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Resume: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Resume(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Resume") - return ret + def pics_TC_OVENOPSTATE_2_3(self) -> list[str]: + return ["OVENOPSTATE.S"] @async_test_body async def test_TC_OVENOPSTATE_2_3(self): - - asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, - "PIXIT_ENDPOINT must be included on the command line in " - "the --int-arg flag as PIXIT_ENDPOINT:") - - self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] - - asserts.assert_true(self.check_pics("OVENOPSTATE.S.A0003"), "OVENOPSTATE.S.A0003 must be supported") - asserts.assert_true(self.check_pics("OVENOPSTATE.S.A0004"), "OVENOPSTATE.S.A0004 must be supported") - asserts.assert_true(self.check_pics("OVENOPSTATE.S.C00.Rsp"), "OVENOPSTATE.S.C00.Rsp must be supported") - asserts.assert_true(self.check_pics("OVENOPSTATE.S.C03.Rsp"), "OVENOPSTATE.S.C03.Rsp must be supported") - - attributes = Clusters.OvenCavityOperationalState.Attributes - - self.print_step(1, "Commissioning, already done") - - self.print_step(2, "Manually put the device in a state where it can receive a Pause command") - input("Press Enter when done.\n") - - self.print_step(3, "Read OperationalStateList attribute") - op_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalStateList) - - logging.info("OperationalStateList: %s" % (op_state_list)) - - defined_states = [state.value for state in Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum - if state is not Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] - - state_ids = set([s.operationalStateID for s in op_state_list]) - - asserts.assert_true(all(id in state_ids for id in defined_states), - "OperationalStateList is missing a required entry") - - self.print_step(4, "Send Pause command") - ret = await self.send_pause_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(5, "Read OperationalState attribute") - operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kPaused, - "OperationalState ID should be Paused(0x02)") - - if self.check_pics("OVENOPSTATE.S.A0002"): - self.print_step(6, "Read CountdownTime attribute") - initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.CountdownTime) - logging.info("CountdownTime: %s" % (initial_countdown_time)) - if initial_countdown_time is not NullValue: - in_range = (1 <= initial_countdown_time <= 259200) - asserts.assert_true(initial_countdown_time is NullValue or in_range, - "invalid CountdownTime(%s). Must be in between 1 and 259200, or null " % initial_countdown_time) - - self.print_step(7, "Waiting for 5 seconds") - time.sleep(5) - - self.print_step(8, "Read CountdownTime attribute") - countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CountdownTime) - logging.info("CountdownTime: %s" % (countdown_time)) - asserts.assert_true(countdown_time != 0 or countdown_time == NullValue, - "invalid CountdownTime(%s). Must be a non zero integer, or null" % countdown_time) - asserts.assert_equal(countdown_time, initial_countdown_time, "CountdownTime(%s) does not equal to the intial CountdownTime(%s)" - % (countdown_time, initial_countdown_time)) - - self.print_step(9, "Send Pause command") - ret = await self.send_pause_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(10, "Send Resume command") - ret = await self.send_resume_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(11, "Read OperationalState attribute") - operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, - "OperationalState(%s) should be Running(0x01)" % operational_state) - - self.print_step(12, "Send Resume command") - ret = await self.send_resume_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(13, "Manually put the device in a state where it cannot receive a Pause command") - input("Press Enter when done.\n") - - self.print_step(14, "Send Pause command") - ret = await self.send_pause_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, - Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, - "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) - - self.print_step(15, "Manually put the device in a state where it cannot receive a Resume command") - input("Press Enter when done.\n") - - self.print_step(16, "Send Resume command") - ret = await self.send_resume_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, - Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, - "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) + endpoint = self.matter_test_config.endpoint + + await self.TEST_TC_OPSTATE_BASE_2_3(endpoint=endpoint) + + # async def read_mod_attribute_expect_success(self, endpoint, attribute): + # cluster = Clusters.Objects.OvenCavityOperationalState + # return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + + # async def send_pause_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Pause: + # ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Pause(), endpoint=self.endpoint) + # asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), + # "Unexpected return type for Pause") + # return ret + + # async def send_resume_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Resume: + # ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Resume(), endpoint=self.endpoint) + # asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), + # "Unexpected return type for Resume") + # return ret + + # @async_test_body + # async def test_TC_OVENOPSTATE_2_3(self): + + # asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, + # "PIXIT_ENDPOINT must be included on the command line in " + # "the --int-arg flag as PIXIT_ENDPOINT:") + + # self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] + + # asserts.assert_true(self.check_pics("OVENOPSTATE.S.A0003"), "OVENOPSTATE.S.A0003 must be supported") + # asserts.assert_true(self.check_pics("OVENOPSTATE.S.A0004"), "OVENOPSTATE.S.A0004 must be supported") + # asserts.assert_true(self.check_pics("OVENOPSTATE.S.C00.Rsp"), "OVENOPSTATE.S.C00.Rsp must be supported") + # asserts.assert_true(self.check_pics("OVENOPSTATE.S.C03.Rsp"), "OVENOPSTATE.S.C03.Rsp must be supported") + + # attributes = Clusters.OvenCavityOperationalState.Attributes + + # self.print_step(1, "Commissioning, already done") + + # self.print_step(2, "Manually put the device in a state where it can receive a Pause command") + # input("Press Enter when done.\n") + + # self.print_step(3, "Read OperationalStateList attribute") + # op_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + # attribute=attributes.OperationalStateList) + + # logging.info("OperationalStateList: %s" % (op_state_list)) + + # defined_states = [state.value for state in Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum + # if state is not Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] + + # state_ids = set([s.operationalStateID for s in op_state_list]) + + # asserts.assert_true(all(id in state_ids for id in defined_states), + # "OperationalStateList is missing a required entry") + + # self.print_step(4, "Send Pause command") + # ret = await self.send_pause_cmd() + # asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + # "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + # self.print_step(5, "Read OperationalState attribute") + # operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + # attribute=attributes.OperationalState) + # logging.info("OperationalState: %s" % (operational_state)) + # asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kPaused, + # "OperationalState ID should be Paused(0x02)") + + # if self.check_pics("OVENOPSTATE.S.A0002"): + # self.print_step(6, "Read CountdownTime attribute") + # initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + # attribute=attributes.CountdownTime) + # logging.info("CountdownTime: %s" % (initial_countdown_time)) + # if initial_countdown_time is not NullValue: + # in_range = (1 <= initial_countdown_time <= 259200) + # asserts.assert_true(initial_countdown_time is NullValue or in_range, + # "invalid CountdownTime(%s). Must be in between 1 and 259200, or null " % initial_countdown_time) + + # self.print_step(7, "Waiting for 5 seconds") + # time.sleep(5) + + # self.print_step(8, "Read CountdownTime attribute") + # countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CountdownTime) + # logging.info("CountdownTime: %s" % (countdown_time)) + # asserts.assert_true(countdown_time != 0 or countdown_time == NullValue, + # "invalid CountdownTime(%s). Must be a non zero integer, or null" % countdown_time) + # asserts.assert_equal(countdown_time, initial_countdown_time, "CountdownTime(%s) does not equal to the intial CountdownTime(%s)" + # % (countdown_time, initial_countdown_time)) + + # self.print_step(9, "Send Pause command") + # ret = await self.send_pause_cmd() + # asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + # "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + # self.print_step(10, "Send Resume command") + # ret = await self.send_resume_cmd() + # asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + # "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + # self.print_step(11, "Read OperationalState attribute") + # operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, + # attribute=attributes.OperationalState) + # logging.info("OperationalState: %s" % (operational_state)) + # asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, + # "OperationalState(%s) should be Running(0x01)" % operational_state) + + # self.print_step(12, "Send Resume command") + # ret = await self.send_resume_cmd() + # asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, + # "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) + + # self.print_step(13, "Manually put the device in a state where it cannot receive a Pause command") + # input("Press Enter when done.\n") + + # self.print_step(14, "Send Pause command") + # ret = await self.send_pause_cmd() + # asserts.assert_equal(ret.commandResponseState.errorStateID, + # Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, + # "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) + + # self.print_step(15, "Manually put the device in a state where it cannot receive a Resume command") + # input("Press Enter when done.\n") + + # self.print_step(16, "Send Resume command") + # ret = await self.send_resume_cmd() + # asserts.assert_equal(ret.commandResponseState.errorStateID, + # Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, + # "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) if __name__ == "__main__": diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index 111c3d98cde5cc..784bf9354744ed 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -20,12 +20,13 @@ import chip.clusters as Clusters from chip.clusters.Types import NullValue -from chip.interaction_model import InteractionModelError, Status +from chip.interaction_model import InteractionModelError from mobly import asserts from dataclasses import dataclass from matter_testing_support import TestStep import psutil + def get_pid(name): pid = None @@ -36,15 +37,17 @@ def get_pid(name): return pid + @dataclass class TestInfo: pics_code: str cluster: Clusters + class TC_OVENOPSTATE_BASE(): def setup_base(self, test_info=None, app_pipe="/tmp/chip_all_clusters_fifo_"): - asserts.assert_true(test_info != None, + asserts.assert_true(test_info is not None, "You shall define the test info!") self.test_info = test_info @@ -63,7 +66,7 @@ def init_test(self): app_pid = self.matter_test_config.app_pid if app_pid == 0: app_pid = get_pid("chip-all-clusters-app") - if app_pid == None: + if app_pid is None: asserts.fail("The --app-pid flag must be set when PICS_SDK_CI_ONLY is set") self.app_pipe = self.app_pipe + str(app_pid) @@ -87,7 +90,7 @@ async def send_cmd(self, endpoint, cmd, timedRequestTimeoutMs=None): timedRequestTimeoutMs=timedRequestTimeoutMs) except InteractionModelError as e: - asserts.assert_equal(e.status, expected_status, "Unexpected error returned") + asserts.fail("Unexpected error returned: %s" % e.status) async def send_cmd_expect_response(self, endpoint, cmd, expected_response, timedRequestTimeoutMs=None): ret = await self.send_cmd(endpoint=endpoint, @@ -102,8 +105,8 @@ async def send_cmd_expect_response(self, endpoint, cmd, expected_response, timed async def read_expect_success(self, endpoint, attribute): logging.info("\t##### Read %s" % attribute) attr_value = await self.read_single_attribute_check_success(endpoint=endpoint, - cluster=self.test_info.cluster, - attribute=attribute) + cluster=self.test_info.cluster, + attribute=attribute) logging.info("\t## %s: %s" % (attribute, attr_value)) return attr_value @@ -170,14 +173,14 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature # STEP 2: TH reads from the DUT the ClusterRevision attribute self.step(2) await self.read_and_expect_value(endpoint=endpoint, - attribute=attributes.ClusterRevision, - expected_value=cluster_revision) + attribute=attributes.ClusterRevision, + expected_value=cluster_revision) # STEP 3: TH reads from the DUT the FeatureMap attribute self.step(3) await self.read_and_expect_value(endpoint=endpoint, - attribute=attributes.FeatureMap, - expected_value=feature_map) + attribute=attributes.FeatureMap, + expected_value=feature_map) # STEP 4: TH reads from the DUT the AttributeList attribute self.step(4) @@ -198,8 +201,8 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature expected_value.append(attributes.CountdownTime.attribute_id) await self.read_and_expect_array_contains(endpoint=endpoint, - attribute=attributes.AttributeList, - expected_contains=expected_value) + attribute=attributes.AttributeList, + expected_contains=expected_value) # STEP 5: TH reads from the DUT the EventList attribute self.step(5) @@ -212,8 +215,8 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature expected_value.append(events.OperationCompletion.event_id) await self.read_and_expect_array_contains(endpoint=endpoint, - attribute=attributes.EventList, - expected_contains=expected_value) + attribute=attributes.EventList, + expected_contains=expected_value) # STEP 6: TH reads from the DUT the AcceptedCommandList attribute self.step(6) @@ -221,22 +224,22 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature if self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or \ self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)): - expected_value.append(commands.Pause.command_id) + expected_value.append(commands.Pause.command_id) if self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): - expected_value.append(commands.Stop.command_id) + expected_value.append(commands.Stop.command_id) if self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Start.command_id) if self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)) or \ self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)): - expected_value.append(commands.Resume.command_id) + expected_value.append(commands.Resume.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, - attribute=attributes.AcceptedCommandList, - expected_contains=expected_value) + attribute=attributes.AcceptedCommandList, + expected_contains=expected_value) # STEP 7: TH reads from the DUT the AcceptedCommandList attribute self.step(7) @@ -244,14 +247,13 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature if self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or \ self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ - self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)) or \ - self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)): + self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)) or \ + self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)): expected_value.append(commands.OperationalCommandResponse.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, - attribute=attributes.GeneratedCommandList, - expected_contains=expected_value) - + attribute=attributes.GeneratedCommandList, + expected_contains=expected_value) ############################ # TEST CASE 2.1 @@ -286,8 +288,6 @@ def STEPS_TC_OPSTATE_BASE_2_1(self) -> list[TestStep]: async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): cluster = self.test_info.cluster attributes = cluster.Attributes - events = cluster.Events - commands = cluster.Commands self.init_test() @@ -338,7 +338,7 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): "Found a OperationalStateList entry with invalid ID value!") if in_range: asserts.assert_true(state.operationalStateLabel is not None, - "The OperationalStateLabel should be populated") + "The OperationalStateLabel should be populated") if state.operationalStateID == cluster.Enums.OperationalStateEnum.kError: error_state_present = True @@ -421,7 +421,7 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): self.step("7a") if self.pics_guard(self.check_pics(("%s.S.M.ERR_NO_ERROR" % self.test_info.pics_code))): self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kNoError)) + (self.device, cluster.Enums.ErrorStateEnum.kNoError)) # STEP 7b: TH reads from the DUT the OperationalError attribute self.step("7b") await self.read_and_expect_property_value(endpoint=endpoint, @@ -435,7 +435,7 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): self.step("7c") if self.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code))): self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kUnableToStartOrResume)) + (self.device, cluster.Enums.ErrorStateEnum.kUnableToStartOrResume)) # STEP 7d: TH reads from the DUT the OperationalError attribute self.step("7d") await self.read_and_expect_property_value(endpoint=endpoint, @@ -449,7 +449,7 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): self.step("7e") if self.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION" % self.test_info.pics_code))): self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kUnableToCompleteOperation)) + (self.device, cluster.Enums.ErrorStateEnum.kUnableToCompleteOperation)) # STEP 7f: TH reads from the DUT the OperationalError attribute self.step("7f") await self.read_and_expect_property_value(endpoint=endpoint, @@ -463,7 +463,7 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): self.step("7g") if self.pics_guard(self.check_pics(("%s.S.M.ERR_COMMAND_INVALID_IN_STATE" % self.test_info.pics_code))): self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kCommandInvalidInState)) + (self.device, cluster.Enums.ErrorStateEnum.kCommandInvalidInState)) # STEP 7h: TH reads from the DUT the OperationalError attribute self.step("7h") await self.read_and_expect_property_value(endpoint=endpoint, @@ -500,7 +500,6 @@ def STEPS_TC_OPSTATE_BASE_2_2(self) -> list[TestStep]: async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): cluster = self.test_info.cluster attributes = cluster.Attributes - events = cluster.Events commands = cluster.Commands self.init_test() @@ -520,7 +519,7 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): # STEP 2: Manually put the DUT into a state wherein it can receive a Start Command self.step(2) self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kNoError)) + (self.device, cluster.Enums.ErrorStateEnum.kNoError)) self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) # STEP 3: TH reads from the DUT the OperationalStateList attribute @@ -540,7 +539,7 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): # STEP 4: TH sends Start command to the DUT self.step(4) - if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): ret = await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Start(), @@ -549,17 +548,17 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): # STEP 5: TH reads from the DUT the OperationalState attribute self.step(5) if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): - operational_state = await self.read_and_expect_value(endpoint=endpoint, - attribute=attributes.OperationalState, - expected_value=cluster.Enums.OperationalStateEnum.kRunning) + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kRunning) # STEP 6: TH reads from the DUT the OperationalError attribute self.step(6) if self.pics_guard(self.check_pics("%s.S.A0005" % self.test_info.pics_code)): - operational_error = await self.read_and_expect_property_value(endpoint=endpoint, - attribute=attributes.OperationalError, - attr_property="errorStateID", - expected_value=cluster.Enums.ErrorStateEnum.kNoError) + await self.read_and_expect_property_value(endpoint=endpoint, + attribute=attributes.OperationalError, + attr_property="errorStateID", + expected_value=cluster.Enums.ErrorStateEnum.kNoError) # STEP 7: TH reads from the DUT the CountdownTime attribute self.step(7) @@ -610,46 +609,225 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): # STEP 12: TH sends Start command to the DUT self.step(12) - if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): - ret = await self.send_cmd_expect_response(endpoint=endpoint, - cmd=commands.Start(), - expected_response=cluster.Enums.ErrorStateEnum.kNoError) + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Start(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 13: TH sends Stop command to the DUT self.step(13) - if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): - ret = await self.send_cmd_expect_response(endpoint=endpoint, - cmd=commands.Stop(), - expected_response=cluster.Enums.ErrorStateEnum.kNoError) + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Stop(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 14: TH reads from the DUT the OperationalState attribute self.step(14) if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): - operational_state = await self.read_and_expect_value(endpoint=endpoint, - attribute=attributes.OperationalState, - expected_value=cluster.Enums.OperationalStateEnum.kStopped) + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kStopped) # STEP 15: TH sends Stop command to the DUT self.step(15) - if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and \ - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): - ret = await self.send_cmd_expect_response(endpoint=endpoint, - cmd=commands.Stop(), - expected_response=cluster.Enums.ErrorStateEnum.kNoError) + if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Stop(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 16: Manually put the DUT into a state wherein it cannot receive a Start Command self.step(16) if self.pics_guard(self.check_pics("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code)): self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kUnableToCompleteOperation)) + (self.device, cluster.Enums.ErrorStateEnum.kUnableToCompleteOperation)) # STEP 17: TH sends Start command to the DUT self.step(17) - if self.pics_guard(self.check_pics("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code) and \ - self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code) and + self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): - ret = await self.send_cmd_expect_response(endpoint=endpoint, - cmd=commands.Start(), - expected_response=cluster.Enums.ErrorStateEnum.kUnableToStartOrResume) \ No newline at end of file + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Start(), + expected_response=cluster.Enums.ErrorStateEnum.kUnableToStartOrResume) + + ############################ + # TEST CASE 2.3 + ############################ + def STEPS_TC_OPSTATE_BASE_2_3(self) -> list[TestStep]: + steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Manually put the DUT into a state wherein it can receive a Pause Command"), + TestStep(3, "TH reads from the DUT the OperationalStateList attribute"), + TestStep(4, "TH sends Pause command to the DUT"), + TestStep(5, "TH reads from the DUT the OperationalState attribute"), + TestStep(6, "TH reads from the DUT the CountdownTime attribute"), + TestStep(7, "TH waits for 5 seconds"), + TestStep(8, "TH reads from the DUT the CountdownTime attribute"), + TestStep(9, "TH sends Pause command to the DUT"), + TestStep(10, "TH sends Resume command to the DUT"), + TestStep(11, "TH reads from the DUT the OperationalState attribute"), + TestStep(12, "TH sends Resume command to the DUT"), + TestStep(13, "Manually put the device in the Stopped(0x00) operational state"), + TestStep(14, "TH sends Pause command to the DUT"), + TestStep(15, "TH sends Resume command to the DUT"), + TestStep(16, "Manually put the device in the Error(0x03) operational state"), + TestStep(17, "TH sends Pause command to the DUT"), + TestStep(18, "TH sends Resume command to the DUT") + ] + return steps + + async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): + cluster = self.test_info.cluster + attributes = cluster.Attributes + events = cluster.Events + commands = cluster.Commands + + self.init_test() + + asserts.assert_true('PIXIT.WAITTIME' in self.matter_test_config.global_test_params, + "PIXIT.WAITTIME must be included on the command line in " + "the --int-arg flag as PIXIT.WAITTIME:") + + wait_time = self.matter_test_config.global_test_params['PIXIT.WAITTIME'] + + if wait_time == 0: + asserts.fail("PIXIT.WAITTIME shall be higher than 0.") + + # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) + self.step(1) + + # STEP 2: Manually put the DUT into a state wherein it can receive a Pause Command + self.step(2) + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % + (self.device, cluster.Enums.ErrorStateEnum.kNoError)) + time.sleep(1) + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Start"}' % self.device) + + # STEP 3: TH reads from the DUT the OperationalStateList attribute + self.step(3) + if self.pics_guard(self.check_pics(("%s.S.A0003" % self.test_info.pics_code))): + operational_state_list = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.OperationalStateList) + + operational_state_list_ids = [op_state.operationalStateID for op_state in operational_state_list] + + defined_states = [state.value for state in cluster.Enums.OperationalStateEnum + if state is not cluster.Enums.OperationalStateEnum.kUnknownEnumValue] + + for state in defined_states: + if state not in operational_state_list_ids: + asserts.fail("The list shall include structs with the following OperationalStateIds: %s", defined_states) + + # STEP 4: TH sends Pause command to the DUT + self.step(4) + if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Pause(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 5: TH reads from the DUT the OperationalState attribute + self.step(5) + if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kPaused) + + # STEP 6: TH reads from the DUT the CountdownTime attribute + self.step(6) + if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + initial_countdown_time = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.CountdownTime) + if initial_countdown_time is not NullValue: + asserts.assert_true(0 <= initial_countdown_time <= 259200, + "CountdownTime(%s) must be between 0 and 259200" % initial_countdown_time) + + # STEP 7: TH waits for 5 seconds + self.step(7) + time.sleep(5) + + # STEP 8: TH reads from the DUT the CountdownTime attribute + self.step(8) + if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + countdown_time = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.CountdownTime) + + if (countdown_time is not NullValue) and (initial_countdown_time is not NullValue): + asserts.assert_equal(countdown_time, initial_countdown_time, + "The countdown time shall be equal since pause command") + + # STEP 9: TH sends Pause command to the DUT + self.step(9) + if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Pause(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 10: TH sends Resume command to the DUT + self.step(10) + if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Resume(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 11: TH reads from the DUT the OperationalState attribute + self.step(11) + if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kRunning) + + # STEP 12: TH sends Resume command to the DUT + self.step(12) + if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Resume(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 13: Manually put the device in the Stopped(0x00) operational state + self.step(13) + if self.pics_guard(self.check_pics(("%s.S.M.ST_STOPPED" % self.test_info.pics_code))): + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) + + # STEP 14: TH sends Pause command to the DUT + self.step(14) + if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Pause(), + expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) + + # STEP 15: TH sends Resume command to the DUT + self.step(15) + if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Resume(), + expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) + + # STEP 16: Manually put the device in the Error(0x03) operational state + self.step(16) + if self.pics_guard(self.check_pics(("%s.S.M.ST_ERROR" % self.test_info.pics_code))): + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) + + # STEP 17: TH sends Pause command to the DUT + self.step(17) + if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Pause(), + expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) + + # STEP 18: TH sends Resume command to the DUT + self.step(18) + if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and \ + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Resume(), + expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) + From 51e056e07dbdbac0cda0be6f1d66c1a7e7d40477 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 22:24:39 -0300 Subject: [PATCH 63/89] Updated business rules on application --- .../src/oven-operational-state-delegate.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp index 8b72d77816e784..9d07727b68f247 100644 --- a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp @@ -83,6 +83,14 @@ OvenCavityOperationalStateDelegate::GetOperationalPhaseAtIndex(size_t index, Mut void OvenCavityOperationalStateDelegate::HandlePauseStateCallback(OperationalState::GenericOperationalError & err) { + OperationalState::OperationalStateEnum state = static_cast(GetInstance()->GetCurrentOperationalState()); + + if(state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState)); + return; + } + // placeholder implementation auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused)); if (error == CHIP_NO_ERROR) @@ -97,6 +105,15 @@ void OvenCavityOperationalStateDelegate::HandlePauseStateCallback(OperationalSta void OvenCavityOperationalStateDelegate::HandleResumeStateCallback(OperationalState::GenericOperationalError & err) { + + OperationalState::OperationalStateEnum state = static_cast(GetInstance()->GetCurrentOperationalState()); + + if(state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState)); + return; + } + // placeholder implementation auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)); if (error == CHIP_NO_ERROR) From 2d54422d2d0e4fbe4d48825b83a75cb9d491c773 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 22:25:06 -0300 Subject: [PATCH 64/89] Added app pid parameter to mobile test script --- .../python/test/test_scripts/mobile-device-test.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/controller/python/test/test_scripts/mobile-device-test.py b/src/controller/python/test/test_scripts/mobile-device-test.py index 87e0a9acb6569b..9ceaa35d24c291 100755 --- a/src/controller/python/test/test_scripts/mobile-device-test.py +++ b/src/controller/python/test/test_scripts/mobile-device-test.py @@ -251,8 +251,12 @@ def do_tests(controller_nodeid, device_nodeid, address, timeout, discriminator, multiple=True, default=[], help="Trace location") +@click.option('--app-pid', + type=int, + default=0, + help="The PID of the app against which the test is going to run") def run(controller_nodeid, device_nodeid, address, timeout, discriminator, setup_pin, enable_test, disable_test, log_level, - log_format, print_test_list, paa_trust_store_path, trace_to): + log_format, print_test_list, paa_trust_store_path, trace_to, app_pid): coloredlogs.install(level=log_level, fmt=log_format, logger=logger) if print_test_list: From 0bab3a2773fa1b4388a3528e4e46ff906750af22 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 22:33:20 -0300 Subject: [PATCH 65/89] fix pipe --- src/python_testing/TC_OpstateCommon.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index 784bf9354744ed..d52c484df9cf58 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -520,6 +520,7 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): self.step(2) self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % (self.device, cluster.Enums.ErrorStateEnum.kNoError)) + time.sleep(1) self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) # STEP 3: TH reads from the DUT the OperationalStateList attribute From daa5d774fed9162a9b4545f8cde7cece02f2bbc4 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 22:35:45 -0300 Subject: [PATCH 66/89] fix lint --- src/python_testing/TC_OVENOPSTATE_2_3.py | 128 +---------------------- 1 file changed, 2 insertions(+), 126 deletions(-) diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py index dbdee8edc66145..d7fbc848630240 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_3.py +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -15,13 +15,12 @@ # limitations under the License. # -import logging import chip.clusters as Clusters from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main -from mobly import asserts from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo + class TC_OVENOPSTATE_2_3(MatterBaseTest, TC_OVENOPSTATE_BASE): def __init__(self, *args): super().__init__(*args) @@ -45,130 +44,7 @@ async def test_TC_OVENOPSTATE_2_3(self): await self.TEST_TC_OPSTATE_BASE_2_3(endpoint=endpoint) - # async def read_mod_attribute_expect_success(self, endpoint, attribute): - # cluster = Clusters.Objects.OvenCavityOperationalState - # return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) - - # async def send_pause_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Pause: - # ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Pause(), endpoint=self.endpoint) - # asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - # "Unexpected return type for Pause") - # return ret - - # async def send_resume_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Resume: - # ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Resume(), endpoint=self.endpoint) - # asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - # "Unexpected return type for Resume") - # return ret - - # @async_test_body - # async def test_TC_OVENOPSTATE_2_3(self): - - # asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, - # "PIXIT_ENDPOINT must be included on the command line in " - # "the --int-arg flag as PIXIT_ENDPOINT:") - - # self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] - - # asserts.assert_true(self.check_pics("OVENOPSTATE.S.A0003"), "OVENOPSTATE.S.A0003 must be supported") - # asserts.assert_true(self.check_pics("OVENOPSTATE.S.A0004"), "OVENOPSTATE.S.A0004 must be supported") - # asserts.assert_true(self.check_pics("OVENOPSTATE.S.C00.Rsp"), "OVENOPSTATE.S.C00.Rsp must be supported") - # asserts.assert_true(self.check_pics("OVENOPSTATE.S.C03.Rsp"), "OVENOPSTATE.S.C03.Rsp must be supported") - - # attributes = Clusters.OvenCavityOperationalState.Attributes - - # self.print_step(1, "Commissioning, already done") - - # self.print_step(2, "Manually put the device in a state where it can receive a Pause command") - # input("Press Enter when done.\n") - - # self.print_step(3, "Read OperationalStateList attribute") - # op_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - # attribute=attributes.OperationalStateList) - - # logging.info("OperationalStateList: %s" % (op_state_list)) - - # defined_states = [state.value for state in Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum - # if state is not Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] - - # state_ids = set([s.operationalStateID for s in op_state_list]) - - # asserts.assert_true(all(id in state_ids for id in defined_states), - # "OperationalStateList is missing a required entry") - - # self.print_step(4, "Send Pause command") - # ret = await self.send_pause_cmd() - # asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - # "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - # self.print_step(5, "Read OperationalState attribute") - # operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - # attribute=attributes.OperationalState) - # logging.info("OperationalState: %s" % (operational_state)) - # asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kPaused, - # "OperationalState ID should be Paused(0x02)") - - # if self.check_pics("OVENOPSTATE.S.A0002"): - # self.print_step(6, "Read CountdownTime attribute") - # initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - # attribute=attributes.CountdownTime) - # logging.info("CountdownTime: %s" % (initial_countdown_time)) - # if initial_countdown_time is not NullValue: - # in_range = (1 <= initial_countdown_time <= 259200) - # asserts.assert_true(initial_countdown_time is NullValue or in_range, - # "invalid CountdownTime(%s). Must be in between 1 and 259200, or null " % initial_countdown_time) - - # self.print_step(7, "Waiting for 5 seconds") - # time.sleep(5) - - # self.print_step(8, "Read CountdownTime attribute") - # countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CountdownTime) - # logging.info("CountdownTime: %s" % (countdown_time)) - # asserts.assert_true(countdown_time != 0 or countdown_time == NullValue, - # "invalid CountdownTime(%s). Must be a non zero integer, or null" % countdown_time) - # asserts.assert_equal(countdown_time, initial_countdown_time, "CountdownTime(%s) does not equal to the intial CountdownTime(%s)" - # % (countdown_time, initial_countdown_time)) - - # self.print_step(9, "Send Pause command") - # ret = await self.send_pause_cmd() - # asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - # "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - # self.print_step(10, "Send Resume command") - # ret = await self.send_resume_cmd() - # asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - # "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - # self.print_step(11, "Read OperationalState attribute") - # operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - # attribute=attributes.OperationalState) - # logging.info("OperationalState: %s" % (operational_state)) - # asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, - # "OperationalState(%s) should be Running(0x01)" % operational_state) - - # self.print_step(12, "Send Resume command") - # ret = await self.send_resume_cmd() - # asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - # "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - # self.print_step(13, "Manually put the device in a state where it cannot receive a Pause command") - # input("Press Enter when done.\n") - - # self.print_step(14, "Send Pause command") - # ret = await self.send_pause_cmd() - # asserts.assert_equal(ret.commandResponseState.errorStateID, - # Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, - # "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) - - # self.print_step(15, "Manually put the device in a state where it cannot receive a Resume command") - # input("Press Enter when done.\n") - - # self.print_step(16, "Send Resume command") - # ret = await self.send_resume_cmd() - # asserts.assert_equal(ret.commandResponseState.errorStateID, - # Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, - # "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) - if __name__ == "__main__": default_matter_test_main() + From d807f5e08f238e33d4e077ca8e1d02053aa14148 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 23:15:17 -0300 Subject: [PATCH 67/89] Added test 2.4 --- .github/workflows/tests.yaml | 1 + src/python_testing/TC_OVENOPSTATE_2_4.py | 50 +++++ src/python_testing/TC_OVENOPSTATE_2_5.py | 238 ----------------------- src/python_testing/TC_OpstateCommon.py | 123 +++++++++--- 4 files changed, 145 insertions(+), 267 deletions(-) create mode 100644 src/python_testing/TC_OVENOPSTATE_2_4.py delete mode 100644 src/python_testing/TC_OVENOPSTATE_2_5.py diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d6e103ce4e69ef..96677011889014 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -516,6 +516,7 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_2.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_3.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_4.py" --script-args "--endpoint 1 --int-arg PIXIT.OVENOPSTATE.ErrorEventGen:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - name: Uploading core files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} diff --git a/src/python_testing/TC_OVENOPSTATE_2_4.py b/src/python_testing/TC_OVENOPSTATE_2_4.py new file mode 100644 index 00000000000000..11edc463e3162e --- /dev/null +++ b/src/python_testing/TC_OVENOPSTATE_2_4.py @@ -0,0 +1,50 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +import chip.clusters as Clusters +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo + + +class TC_OVENOPSTATE_2_4(MatterBaseTest, TC_OVENOPSTATE_BASE): + def __init__(self, *args): + super().__init__(*args) + + test_info = TestInfo( + pics_code="OVENOPSTATE", + cluster=Clusters.OvenCavityOperationalState + ) + + super().setup_base(test_info=test_info) + + def steps_TC_OVENOPSTATE_2_4(self) -> list[TestStep]: + return self.STEPS_TC_OPSTATE_BASE_2_4() + + def pics_TC_OVENOPSTATE_2_4(self) -> list[str]: + return ["OVENOPSTATE.S"] + + @async_test_body + async def test_TC_OVENOPSTATE_2_4(self): + endpoint = self.matter_test_config.endpoint + + await self.TEST_TC_OPSTATE_BASE_2_4(endpoint=endpoint) + + +if __name__ == "__main__": + default_matter_test_main() + diff --git a/src/python_testing/TC_OVENOPSTATE_2_5.py b/src/python_testing/TC_OVENOPSTATE_2_5.py deleted file mode 100644 index a54d1da320a3ec..00000000000000 --- a/src/python_testing/TC_OVENOPSTATE_2_5.py +++ /dev/null @@ -1,238 +0,0 @@ -# -# Copyright (c) 2023 Project CHIP Authors -# All rights reserved. -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# - -import logging -import time - -import chip.clusters as Clusters -from chip.clusters.Types import NullValue -from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches -from mobly import asserts - -# This test requires several additional command line arguments -# run with -# --int-arg PIXIT_ENDPOINT: - -class TC_OVENOPSTATE_2_5(MatterBaseTest): - - async def read_mod_attribute_expect_success(self, endpoint, attribute): - cluster = Clusters.Objects.OvenCavityOperationalState - return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) - - async def send_start_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Start: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Start(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Start") - return ret - - async def send_pause_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Pause: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Pause(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Pause") - return ret - - async def send_resume_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Resume: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Resume(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Resume") - return ret - - async def send_stop_cmd(self) -> Clusters.Objects.OvenCavityOperationalState.Commands.Stop: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OvenCavityOperationalState.Commands.Stop(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OvenCavityOperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Stop") - return ret - - async def read_and_validate_opstate(self, step, expected_state): - self.print_step(step, "Read OperationalState attribute") - operational_state = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, expected_state, - "OperationalState(%s) should equal %s" % (operational_state, expected_state)) - - async def read_and_validate_operror(self, step, expected_error): - self.print_step(step, "Read OperationalError attribute") - operational_error = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OvenCavityOperationalState.Attributes.OperationalError) - logging.info("OperationalError: %s" % (operational_error)) - asserts.assert_equal(operational_error.errorStateID, expected_error, - "errorStateID(%s) should equal %s" % (operational_error.errorStateID, expected_error)) - - @async_test_body - async def test_TC_OVENOPSTATE_2_5(self): - - asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, - "PIXIT_ENDPOINT must be included on the command line in " - "the --int-arg flag as PIXIT_ENDPOINT:") - - self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] - - attributes = Clusters.OvenCavityOperationalState.Attributes - - - self.print_step(1, "Commissioning, already done") - - # step 2 set subscription to the OperationCompletion event - - if self.check_pics("OVENOPSTATE.A0004"): - self.print_step(3, "Read operationalState Attribute") - operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kNoError, - "OperationalState ID should be NoError(0x00)") - - self.print_step(4, "Manually put the DUT into a state wherein it can receive a Start Command") - input("press enter when done, \n") - - if self.check_pics("OVENOPSTATE.S.A0002"): - self.print_step(5, "Read CountdownTime attribute") - initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.CountdownTime) - logging.info("CountdownTime: %s" % (initial_countdown_time)) - if initial_countdown_time is not NullValue: - in_range = (1 > initial_countdown_time <= 3600) - in_range1=(initial_countdown_time > "PIXIT.COUNTDOWN.THRESHOLD") - - asserts.assert_true(initial_countdown_time is NullValue or in_range or in_range1, - "invalid CountdownTime(%s). Must be in between 1 and 1 hour, or null " % initial_countdown_time) - - if self.check_pics("OVENOPSTATE.S.C02.Rsp" and "OVENOPSTATE.S.C04.Tx"): - self.print_step(6, "Send Start command") - ret = await self.send_start_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(7, "TH Waits for PIXIT.WAITTIME") - time.sleep("PIXIT.WAITTIME") - - if self.check_pics("OVENOPSTATE.S.A0004"): - self.print_step(8, "Read operationalState Attribute") - operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, - "OperationalState ID should be Running(0x01)") - - self.print_step(9, "TH Waits for initial_countdown_time ") - time.sleep(initial_countdown_time) - - if self.check_pics("OVENOPSTATE.S.C01.Rsp" and "OVENOPSTATE.S.C04.Tx"): - self.print_step(10, "Send Stop command") - ret = await self.send_stop_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(11, "Operationalcompletion") - - - if self.check_pics("OVENOPSTATE.S.A0004"): - self.print_step(12, "Read operationalState Attribute") - operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kStopped, - "OperationalState ID should be Stopped (0x00)") - - self.print_step(13, "Manually RESTART THE DUT") - input("press enter when done, \n") - if self.check_pics("OVENOPSTATE.S.A0002"): - self.print_step(13, "Read CountdownTime attribute") - initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.CountdownTime) - logging.info("CountdownTime: %s" % (initial_countdown_time)) - if initial_countdown_time is not NullValue: - in_range = (1 > initial_countdown_time <= 3600) - in_range1=(initial_countdown_time > "PIXIT.COUNTDOWN.THRESHOLD") - - if self.check_pics("OVENOPSTATE.S.C02.Rsp" and "OVENOPSTATE.S.C04.Tx"): - self.print_step(14, "Send Start command") - ret = await self.send_start_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(15, "TH Waits for PIXIT.WAITTIME") - time.sleep("PIXIT.WAITTIME") - - if self.check_pics("OVENOPSTATE.S.A0004"): - self.print_step(16, "Read operationalState Attribute") - operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, - "OperationalState ID should be Running (0x01)") - - if self.check_pics("OVENOPSTATE.S.C00.Rsp" and "OVENOPSTATE.S.C04.Tx"): - self.print_step(17, "Send Pause command") - ret = await self.send_pause_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - if self.check_pics("OVENOPSTATE.S.A0004"): - self.print_step(18, "Read operationalState Attribute") - operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kPaused, - "OperationalState ID should be paused (0x02)") - - self.print_step(19, "TH Waits for half of initial_countdown_time ") - time.sleep(initial_countdown_time//2) - - if self.check_pics("OVENOPSTATE.S.C03.Rsp" and "OVENOPSTATE.S.C04.Tx"): - self.print_step(20, "Send Resume command") - ret = await self.send_resume_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - if self.check_pics("OVENOPSTATE.S.A0004"): - self.print_step(21, "Read operationalState Attribute") - operational_state=await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OvenCavityOperationalState.Enums.OperationalStateEnum.kRunning, - "OperationalState ID should be Running(0x01)") - - self.print_step(22, "TH Waits for initial_countdown_time") - time.sleep(initial_countdown_time) - - if self.check_pics("OVENOPSTATE.S.C01.Rsp" and "OVENOPSTATE.S.C04.Tx"): - self.print_step(23, "Send Stop command") - ret = await self.send_stop_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OvenCavityOperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(24, "Operationalcompletion") - -if __name__ == "__main__": - default_matter_test_main() - - - - - - - - - - - - - - - diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index d52c484df9cf58..5a3d78e5699744 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -23,7 +23,7 @@ from chip.interaction_model import InteractionModelError from mobly import asserts from dataclasses import dataclass -from matter_testing_support import TestStep +from matter_testing_support import TestStep, EventChangeCallback import psutil @@ -222,20 +222,20 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature self.step(6) expected_value = [] - if self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or \ - self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)): - expected_value.append(commands.Pause.command_id) + if (self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or + self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code))): + expected_value.append(commands.Pause.command_id) - if self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ - self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): - expected_value.append(commands.Stop.command_id) + if (self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ + self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code))): + expected_value.append(commands.Stop.command_id) if self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Start.command_id) - if self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)) or \ - self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)): - expected_value.append(commands.Resume.command_id) + if (self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)) or + self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code))): + expected_value.append(commands.Resume.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, attribute=attributes.AcceptedCommandList, @@ -245,10 +245,10 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature self.step(7) expected_value = [] - if self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or \ - self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ - self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)) or \ - self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)): + if (self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or + self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or + self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)) or + self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code))): expected_value.append(commands.OperationalCommandResponse.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, @@ -542,9 +542,9 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): self.step(4) if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): - ret = await self.send_cmd_expect_response(endpoint=endpoint, - cmd=commands.Start(), - expected_response=cluster.Enums.ErrorStateEnum.kNoError) + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Start(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 5: TH reads from the DUT the OperationalState attribute self.step(5) @@ -619,7 +619,7 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): # STEP 13: TH sends Stop command to the DUT self.step(13) if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Stop(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) @@ -682,7 +682,6 @@ def STEPS_TC_OPSTATE_BASE_2_3(self) -> list[TestStep]: async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): cluster = self.test_info.cluster attributes = cluster.Attributes - events = cluster.Events commands = cluster.Commands self.init_test() @@ -702,7 +701,7 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 2: Manually put the DUT into a state wherein it can receive a Pause Command self.step(2) self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kNoError)) + (self.device, cluster.Enums.ErrorStateEnum.kNoError)) time.sleep(1) self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Start"}' % self.device) @@ -723,7 +722,7 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 4: TH sends Pause command to the DUT self.step(4) - if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Pause(), @@ -757,11 +756,11 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): if (countdown_time is not NullValue) and (initial_countdown_time is not NullValue): asserts.assert_equal(countdown_time, initial_countdown_time, - "The countdown time shall be equal since pause command") + "The countdown time shall be equal since pause command") # STEP 9: TH sends Pause command to the DUT self.step(9) - if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Pause(), @@ -769,7 +768,7 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 10: TH sends Resume command to the DUT self.step(10) - if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Resume(), @@ -784,7 +783,7 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 12: TH sends Resume command to the DUT self.step(12) - if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Resume(), @@ -797,7 +796,7 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 14: TH sends Pause command to the DUT self.step(14) - if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Pause(), @@ -805,7 +804,7 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 15: TH sends Resume command to the DUT self.step(15) - if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Resume(), @@ -818,7 +817,7 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 17: TH sends Pause command to the DUT self.step(17) - if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Pause(), @@ -826,9 +825,75 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 18: TH sends Resume command to the DUT self.step(18) - if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and \ + if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Resume(), expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) + ############################ + # TEST CASE 2.4 + ############################ + def STEPS_TC_OPSTATE_BASE_2_4(self) -> list[TestStep]: + steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Set up a subscription to the OperationalError event"), + TestStep(3, "At the DUT take the vendor defined action to generate an OperationalError event"), + TestStep(4, "TH reads from the DUT the OperationalState attribute") + ] + return steps + + async def TEST_TC_OPSTATE_BASE_2_4(self, endpoint=1): + cluster = self.test_info.cluster + attributes = cluster.Attributes + events = cluster.Events + commands = cluster.Commands + + self.init_test() + + pixit_var_name = 'PIXIT.%s.ErrorEventGen' % self.test_info.pics_code + print(pixit_var_name in self.matter_test_config.global_test_params) + asserts.assert_true(pixit_var_name in self.matter_test_config.global_test_params, + "%s must be included on the command line in " + "the --int-arg flag as %s:<0 or 1>" % (pixit_var_name, pixit_var_name)) + + error_event_gen = self.matter_test_config.global_test_params[pixit_var_name] + + # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) + self.step(1) + + if self.pics_guard(error_event_gen): + # STEP 2: Set up a subscription to the OperationalError event + self.step(2) + # Subscribe to Events and when they are sent push them to a queue for checking later + events_callback = EventChangeCallback(cluster) + await events_callback.start(self.default_controller, + self.dut_node_id, + endpoint) + + # STEP 3: At the DUT take the vendor defined action to generate an OperationalError event + self.step(3) + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) + event_data = events_callback.wait_for_event_report(cluster.Events.OperationalError).errorState + + # Defined Errors + defined_errors = [error.value for error in cluster.Enums.ErrorStateEnum + if (error is not cluster.Enums.ErrorStateEnum.kUnknownEnumValue or + error is not cluster.Enums.ErrorStateEnum.kNoError)] + + in_range = (0x80 <= event_data.errorStateID <= 0xBF) + asserts.assert_true(event_data.errorStateID in defined_errors + or in_range, "Event has an invalid ID value!") + if in_range: + asserts.assert_true(event_data.errorStateLabel is not None, "ErrorStateLabel should be populated") + + # STEP 4: TH reads from the DUT the OperationalState attribute + self.step(4) + if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kError) + else: + self.skip_step(2) + self.skip_step(3) + self.skip_step(4) + From 7fcbf8fae8e0fa6acea7046213aae84db2985543 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 23:15:52 -0300 Subject: [PATCH 68/89] fixed parameter from run python script --- scripts/tests/run_python_test.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tests/run_python_test.py b/scripts/tests/run_python_test.py index 90a573a5d18788..e91d4d8505452e 100755 --- a/scripts/tests/run_python_test.py +++ b/scripts/tests/run_python_test.py @@ -137,7 +137,7 @@ def main(app: str, factoryreset: bool, factoryreset_app_only: bool, app_args: st log_cooking_threads, Fore.GREEN + "APP " + Style.RESET_ALL, app_process, log_queue) script_command = [script, "--paa-trust-store-path", os.path.join(DEFAULT_CHIP_ROOT, MATTER_DEVELOPMENT_PAA_ROOT_CERTS), - '--log-format', '%(message)s', "--app-id", str(app_process.pid)] + shlex.split(script_args) + '--log-format', '%(message)s', "--app-pid", str(app_process.pid)] + shlex.split(script_args) if script_gdb: # From 530390b54742da5221c11e25a9b00a7734962cc3 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Sun, 11 Feb 2024 23:30:02 -0300 Subject: [PATCH 69/89] Fixed Lint --- src/python_testing/TC_OVENOPSTATE_1_1.py | 4 ++-- src/python_testing/TC_OVENOPSTATE_2_1.py | 4 ++-- src/python_testing/TC_OVENOPSTATE_2_2.py | 4 ++-- src/python_testing/TC_OVENOPSTATE_2_3.py | 4 ++-- src/python_testing/TC_OVENOPSTATE_2_4.py | 4 ++-- src/python_testing/TC_OpstateCommon.py | 23 +++++++++++------------ 6 files changed, 21 insertions(+), 22 deletions(-) diff --git a/src/python_testing/TC_OVENOPSTATE_1_1.py b/src/python_testing/TC_OVENOPSTATE_1_1.py index ec3b3bba629319..0f0773522d47f6 100644 --- a/src/python_testing/TC_OVENOPSTATE_1_1.py +++ b/src/python_testing/TC_OVENOPSTATE_1_1.py @@ -18,10 +18,10 @@ import chip.clusters as Clusters from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main -from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo -class TC_OVENOPSTATE_1_1(MatterBaseTest, TC_OVENOPSTATE_BASE): +class TC_OVENOPSTATE_1_1(MatterBaseTest, TC_OPSTATE_BASE): def __init__(self, *args): super().__init__(*args) diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index 539b5929dd517b..e0a401354b0e18 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -18,10 +18,10 @@ import chip.clusters as Clusters from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main -from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo -class TC_OVENOPSTATE_2_1(MatterBaseTest, TC_OVENOPSTATE_BASE): +class TC_OVENOPSTATE_2_1(MatterBaseTest, TC_OPSTATE_BASE): def __init__(self, *args): super().__init__(*args) diff --git a/src/python_testing/TC_OVENOPSTATE_2_2.py b/src/python_testing/TC_OVENOPSTATE_2_2.py index 71cb06884dd3f5..d014e068a5e35d 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_2.py +++ b/src/python_testing/TC_OVENOPSTATE_2_2.py @@ -18,10 +18,10 @@ import chip.clusters as Clusters from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main -from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo -class TC_OVENOPSTATE_2_2(MatterBaseTest, TC_OVENOPSTATE_BASE): +class TC_OVENOPSTATE_2_2(MatterBaseTest, TC_OPSTATE_BASE): def __init__(self, *args): super().__init__(*args) diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py index d7fbc848630240..d26f15abdec3ee 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_3.py +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -18,10 +18,10 @@ import chip.clusters as Clusters from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main -from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo -class TC_OVENOPSTATE_2_3(MatterBaseTest, TC_OVENOPSTATE_BASE): +class TC_OVENOPSTATE_2_3(MatterBaseTest, TC_OPSTATE_BASE): def __init__(self, *args): super().__init__(*args) diff --git a/src/python_testing/TC_OVENOPSTATE_2_4.py b/src/python_testing/TC_OVENOPSTATE_2_4.py index 11edc463e3162e..5279e6ec70b796 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_4.py +++ b/src/python_testing/TC_OVENOPSTATE_2_4.py @@ -18,10 +18,10 @@ import chip.clusters as Clusters from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main -from TC_OpstateCommon import TC_OVENOPSTATE_BASE, TestInfo +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo -class TC_OVENOPSTATE_2_4(MatterBaseTest, TC_OVENOPSTATE_BASE): +class TC_OVENOPSTATE_2_4(MatterBaseTest, TC_OPSTATE_BASE): def __init__(self, *args): super().__init__(*args) diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index 5a3d78e5699744..bc3109c82ebd8f 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -44,7 +44,7 @@ class TestInfo: cluster: Clusters -class TC_OVENOPSTATE_BASE(): +class TC_OPSTATE_BASE(): def setup_base(self, test_info=None, app_pipe="/tmp/chip_all_clusters_fifo_"): asserts.assert_true(test_info is not None, @@ -224,18 +224,18 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature if (self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code))): - expected_value.append(commands.Pause.command_id) + expected_value.append(commands.Pause.command_id) - if (self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or \ + if (self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code))): - expected_value.append(commands.Stop.command_id) + expected_value.append(commands.Stop.command_id) if self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Start.command_id) if (self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)) or self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code))): - expected_value.append(commands.Resume.command_id) + expected_value.append(commands.Resume.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, attribute=attributes.AcceptedCommandList, @@ -249,7 +249,7 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)) or self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code))): - expected_value.append(commands.OperationalCommandResponse.command_id) + expected_value.append(commands.OperationalCommandResponse.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, attribute=attributes.GeneratedCommandList, @@ -846,7 +846,6 @@ async def TEST_TC_OPSTATE_BASE_2_4(self, endpoint=1): cluster = self.test_info.cluster attributes = cluster.Attributes events = cluster.Events - commands = cluster.Commands self.init_test() @@ -873,12 +872,12 @@ async def TEST_TC_OPSTATE_BASE_2_4(self, endpoint=1): # STEP 3: At the DUT take the vendor defined action to generate an OperationalError event self.step(3) self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) - event_data = events_callback.wait_for_event_report(cluster.Events.OperationalError).errorState + event_data = events_callback.wait_for_event_report(events.OperationalError).errorState # Defined Errors defined_errors = [error.value for error in cluster.Enums.ErrorStateEnum - if (error is not cluster.Enums.ErrorStateEnum.kUnknownEnumValue or - error is not cluster.Enums.ErrorStateEnum.kNoError)] + if (error is not cluster.Enums.ErrorStateEnum.kUnknownEnumValue or + error is not cluster.Enums.ErrorStateEnum.kNoError)] in_range = (0x80 <= event_data.errorStateID <= 0xBF) asserts.assert_true(event_data.errorStateID in defined_errors @@ -890,8 +889,8 @@ async def TEST_TC_OPSTATE_BASE_2_4(self, endpoint=1): self.step(4) if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): await self.read_and_expect_value(endpoint=endpoint, - attribute=attributes.OperationalState, - expected_value=cluster.Enums.OperationalStateEnum.kError) + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kError) else: self.skip_step(2) self.skip_step(3) From 8c16b38dc730429659871072f6bd0d2862e8ed09 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 05:25:04 -0300 Subject: [PATCH 70/89] Deleted OVENOPSTATE YAMLs --- .../Test_TC_OVENOPSTATE_2_4.yaml | 82 ------ .../Test_TC_OVENOPSTATE_2_5.yaml | 263 ------------------ 2 files changed, 345 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml delete mode 100644 src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml deleted file mode 100644 index a97c67d2d65fbb..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_4.yaml +++ /dev/null @@ -1,82 +0,0 @@ -# Copyright (c) 2023 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: 202.2.4. [TC-OVENOPSTATE-2.4] Mandatory Events with DUT as Server - -PICS: - - OVENOPSTATE.S - -config: - nodeId: 0x12344321 - cluster: "Oven Cavity Operational State" - endpoint: 1 - -tests: - - label: "Step 1: Commission DUT to TH" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Step 2: Set up a subscription to the OperationalError event" - PICS: OVENOPSTATE.S.E00 - command: "subscribeEvent" - event: "OperationalError" - minInterval: 10 - maxInterval: 5000 - - - label: - "Step 3: At the DUT take the vendor defined action to generate an - OperationalError event" - PICS: OVENOPSTATE.S.E00 && PICS_SKIP_SAMPLE_APP - verification: | - After the subscription interval via the TH (chip-tool) verify: - - reception of an OperationalError Event - - ErrorStateID is a defined error - - If the ErrorStateID is manufacturer specific, inclusion of an ErrorStateLabel, not present otherwise - - Optionally an ErrorStateDetails - - NOTE : There's a PIXIT value controlling the ability to execute that ({PIXIT_ERROREVENTGEN}), which as the test case notes, requires vendor specific actions to generated the error at the DUT. This is dependent on the vendor app supporting this. The SDK as it stands won't provide the error, this may be testable by some of the vendors depending on their implementations. - - - [1705871792686] [7030:7008415] [TOO] Endpoint: 1 Cluster: 0x0000_0048 Event 0x0000_0000 - [1705871792686] [7030:7008415] [TOO] Event number: 65541 - [1705871792686] [7030:7008415] [TOO] Priority: Critical - [1705871792686] [7030:7008415] [TOO] Timestamp: 1705871789411 - [1705871792686] [7030:7008415] [TOO] OperationalError: { - [1705871792686] [7030:7008415] [TOO] ErrorState: { - [1705871792686] [7030:7008415] [TOO] ErrorStateID: 3 - [1705871792686] [7030:7008415] [TOO] } - [1705871792686] [7030:7008415] [TOO] } - [1705871792686] [7030:7008415] [DMG] Refresh LivenessCheckTime for 14224 milliseconds with SubscriptionId = 0x6bdd9a34 Peer = 01:0000000000000001 - - cluster: "LogCommands" - command: "UserPrompt" - arguments: - values: - - name: "message" - value: "Enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: "Step 4: TH reads from the DUT the OperationalState attribute" - PICS: OVENOPSTATE.S.A0004 && PICS_SKIP_SAMPLE_APP - command: "readAttribute" - attribute: "OperationalState" - response: - value: 0x03 - constraints: - type: enum8 diff --git a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml b/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml deleted file mode 100644 index 5dee16ac47111a..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_OVENOPSTATE_2_5.yaml +++ /dev/null @@ -1,263 +0,0 @@ -# Copyright (c) 2023 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default - -name: 204.2.5. [TC-OVENOPSTATE-2.5] Optional Events with DUT as Server - -PICS: - - OVENOPSTATE.S - -config: - nodeId: 0x12344321 - cluster: "Oven Cavity Operational State" - endpoint: 0 - -tests: - - label: "Note" - verification: | - This test case can be continuted only when countdown-time read in step 5 is not null - disabled: true - - - label: "Step 1: Commission DUT to TH" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Step 2: Set up a subscription to the OperationCompletion event" - PICS: OVENOPSTATE.S.E01 - verification: | - ./chip-tool interactive start - - ovencavityoperationalstate read-event operation-completion 1 1 - - [1702376916.193452][4893:4896] CHIP:DMG: ReportDataMessage = - [1702376916.193461][4893:4896] CHIP:DMG: { - [1702376916.193469][4893:4896] CHIP:DMG: SubscriptionId = 0x85d7a607, - [1702376916.193497][4893:4896] CHIP:DMG: InteractionModelRevision = 11 - [1702376916.193504][4893:4896] CHIP:DMG: } - disabled: true - - - label: "Step 3: TH reads from the DUT the OperationalState attribute" - PICS: OVENOPSTATE.S.A0004 - command: "readAttribute" - attribute: "OperationalState" - response: - value: 0 - constraints: - type: enum8 - - - label: - "Step 4: Manually put the DUT into a state wherein it can receive a - Start Command" - verification: | - - disabled: true - - - label: "Step 5: TH reads from the DUT the CountdownTime attribute" - PICS: OVENOPSTATE.S.A0002 - verification: | - ./chip-tool ovencavityoperationalstate read countdown-time 1 1 - - Via the TH (chip-tool), verify: - - that CountdownTime attribute contains either null our a uint32 value - - if non-null, verify that the value is in the range 1 to 259200 - - store the value in 'initialcountdown-time' - - [1690457637.895405][18808:18810] CHIP:DMG: } - [1690457637.895474][18808:18810] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 4112784416 - [1690457637.895503][18808:18810] CHIP:TOO: CountdownTime: null - disabled: true - - - label: "Step 6: TH sends Start command to the DUT" - PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx - command: "Start" - response: - values: - - name: "CommandResponseState" - value: { ErrorStateID: 0 } - - - label: "Step 7: TH waits for {PIXIT.WAITTIME}" - verification: | - - disabled: true - - - label: "Step 8: TH reads from the DUT the OperationalState attribute" - PICS: OVENOPSTATE.S.A0004 - command: "readAttribute" - attribute: "OperationalState" - response: - value: 1 - constraints: - type: enum8 - - - label: "Step 9: TH waits for initial-countdown-time" - verification: | - As the initial-countdown-time in null this test cannot be executed further in case of RPI platform. - Note: The below log are for instructional purpose. In real scenarios, the actual log may vary depending on the feature implementation in the Reference App. - disabled: true - - - label: "Step 10: TH sends Stop command to the DUT" - PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx - command: "Stop" - response: - values: - - name: "CommandResponseState" - value: { ErrorStateID: 0 } - - - label: - "Step 11: erify TH receives an OperationCompletion event from the DUT - with the following fields populated as follows: 1)CompletionErrorCode - set to NoError(0x00) 2)TotalOperationalTime is approximately - initial-countdown-time or null 3)PausedTime is zero" - PICS: OVENOPSTATE.S.E01 - verification: | - ovencavityoperationalstate read-event operation-completion 1 1 - - [1657193007.841358][5422:5427] CHIP:TOO: Endpoint: 0 Endpoint: 1 Cluster: 0x0000_0060 Event 0x0000_0001 - [1657193007.841387][5422:5427] CHIP:TOO: Event number: 1 - [1657193007.841409][5422:5427] CHIP:TOO: Priority: INFO - [1657193007.841431][5422:5427] CHIP:TOO: Timestamp: 132146 - [1657193007.841531][5422:5427] CHIP:TOO: OperationCompletion: { - [1657193007.841570][5422:5427] CHIP:TOO: CompletionErrorCode: 0x00 - TotalOperationalTime: null - PausedTime: 0 - [1657193007.841594][5422:5427] CHIP:TOO: } - disabled: true - - - label: "Step 12: TH reads from the DUT the OperationalState attribute" - PICS: OVENOPSTATE.S.A0004 - command: "readAttribute" - attribute: "OperationalState" - response: - value: 0 - constraints: - type: enum8 - - - label: "Step 13: Restart DUT and repeat step 5" - verification: | - - disabled: true - - - label: "Step 14: TH sends Start command to the DUT" - PICS: OVENOPSTATE.S.C02.Rsp && OVENOPSTATE.S.C04.Tx - command: "Start" - response: - values: - - name: "CommandResponseState" - value: { ErrorStateID: 0 } - - - label: "Step 15: TH waits for {PIXIT.WAITTIME}" - verification: | - - disabled: true - - - label: "Step 16: TH reads from the DUT the OperationalState attribute" - PICS: OVENOPSTATE.S.A0004 - command: "readAttribute" - attribute: "OperationalState" - response: - value: 1 - constraints: - type: enum8 - - - label: "Step 17: TH sends Pause command to the DUT" - PICS: OVENOPSTATE.S.C00.Rsp && OVENOPSTATE.S.C04.Tx - command: "Pause" - response: - values: - - name: "CommandResponseState" - value: { ErrorStateID: 0 } - - - label: "Step 18: TH reads from the DUT the OperationalState attribute" - PICS: OVENOPSTATE.S.A0004 - command: "readAttribute" - attribute: "OperationalState" - response: - value: 2 - constraints: - type: enum8 - - - label: "Step 19: TH waits for half of initial-countdown-time" - verification: | - - disabled: true - - - label: "Step 20: TH sends Resume command to the DUT" - PICS: OVENOPSTATE.S.C03.Rsp && OVENOPSTATE.S.C04.Tx - command: "Resume" - response: - values: - - name: "CommandResponseState" - value: { ErrorStateID: 3} - - - label: "Step 21: TH reads from the DUT the OperationalState attribute" - PICS: OVENOPSTATE.S.A0004 - command: "readAttribute" - attribute: "OperationalState" - response: - value: 1 - constraints: - type: enum8 - - - label: "Step 22: TH waits for initial-countdown-time" - verification: | - TH waits for initial-countdown-time - disabled: true - - - label: "Step 23: TH sends Stop command to the DUT" - PICS: OVENOPSTATE.S.C01.Rsp && OVENOPSTATE.S.C04.Tx - command: "Stop" - response: - values: - - name: "CommandResponseState" - value: { ErrorStateID: 0 } - verification: | - ./chip-tool ovencavityoperationalstate stop 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674653.322963][17330:17332] CHIP:DMG: }, - [1689674653.322994][17330:17332] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674653.323014][17330:17332] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674653.323058][17330:17332] CHIP:TOO: OperationalCommandResponse: { - [1689674653.323066][17330:17332] CHIP:TOO: commandResponseState: { - [1689674653.323076][17330:17332] CHIP:TOO: ErrorStateID: 0 - [1689674653.323085][17330:17332] CHIP:TOO: } - [1689674653.323094][17330:17332] CHIP:TOO: } - disabled: true - - - label: - "Step 24: Verify TH receives an OperationCompletion event with the - following fields populated as follows: 1. CompletionErrorCode set to - NoError(0x00) 2. TotalOperationalTime is approximately 1.5 times the - initial-countdown-time or null 3. PausedTime is 0.5 times the - initial-countdown-time" - PICS: OVENOPSTATE.S.E01 - verification: | - ovencavityoperationalstate read-event operation-completion 1 1 - - [1657193007.841358][5422:5427] CHIP:TOO: Endpoint: 0 Endpoint: 1 Cluster: 0x0000_0060 Event 0x0000_0001 - [1657193007.841387][5422:5427] CHIP:TOO: Event number: 1 - [1657193007.841409][5422:5427] CHIP:TOO: Priority: INFO - [1657193007.841431][5422:5427] CHIP:TOO: Timestamp: 155146 - [1657193007.841531][5422:5427] CHIP:TOO: OperationCompletion: { - [1657193007.841570][5422:5427] CHIP:TOO: CompletionErrorCode: 0x00 - TotalOperationalTime: null - } - disabled: true From 471d5875b81c366f77457b797a2cf63a330aed45 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 05:31:05 -0300 Subject: [PATCH 71/89] Fix run python script --- scripts/tests/run_python_test.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/scripts/tests/run_python_test.py b/scripts/tests/run_python_test.py index e91d4d8505452e..529b3e2dc6ab08 100755 --- a/scripts/tests/run_python_test.py +++ b/scripts/tests/run_python_test.py @@ -136,8 +136,13 @@ def main(app: str, factoryreset: bool, factoryreset_app_only: bool, app_args: st DumpProgramOutputToQueue( log_cooking_threads, Fore.GREEN + "APP " + Style.RESET_ALL, app_process, log_queue) + if(app_process is not None): + app_pid = app_process.pid + else: + app_pid = 0 + script_command = [script, "--paa-trust-store-path", os.path.join(DEFAULT_CHIP_ROOT, MATTER_DEVELOPMENT_PAA_ROOT_CERTS), - '--log-format', '%(message)s', "--app-pid", str(app_process.pid)] + shlex.split(script_args) + '--log-format', '%(message)s', "--app-pid", str(app_pid)] + shlex.split(script_args) if script_gdb: # From cc78d1da927355dff74c6a16755d5c25494259a7 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 09:29:45 -0300 Subject: [PATCH 72/89] Fix lint --- scripts/tests/run_python_test.py | 8 +++----- src/python_testing/TC_OpstateCommon.py | 20 ++++++++++---------- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/scripts/tests/run_python_test.py b/scripts/tests/run_python_test.py index 529b3e2dc6ab08..1a9b54a3ad6736 100755 --- a/scripts/tests/run_python_test.py +++ b/scripts/tests/run_python_test.py @@ -125,6 +125,8 @@ def main(app: str, factoryreset: bool, factoryreset_app_only: bool, app_args: st log_cooking_threads = [] app_process = None + app_pid = 0 + if app: if not os.path.exists(app): if app is None: @@ -133,14 +135,10 @@ def main(app: str, factoryreset: bool, factoryreset_app_only: bool, app_args: st logging.info(f"Execute: {app_args}") app_process = subprocess.Popen( app_args, stdout=subprocess.PIPE, stderr=subprocess.PIPE, bufsize=0) + app_pid = app_process.pid DumpProgramOutputToQueue( log_cooking_threads, Fore.GREEN + "APP " + Style.RESET_ALL, app_process, log_queue) - if(app_process is not None): - app_pid = app_process.pid - else: - app_pid = 0 - script_command = [script, "--paa-trust-store-path", os.path.join(DEFAULT_CHIP_ROOT, MATTER_DEVELOPMENT_PAA_ROOT_CERTS), '--log-format', '%(message)s', "--app-pid", str(app_pid)] + shlex.split(script_args) diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index bc3109c82ebd8f..ef56b3a45ce932 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -223,19 +223,19 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature expected_value = [] if (self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code))): - expected_value.append(commands.Pause.command_id) + self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code))): + expected_value.append(commands.Pause.command_id) if (self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code))): - expected_value.append(commands.Stop.command_id) + self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code))): + expected_value.append(commands.Stop.command_id) if self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): expected_value.append(commands.Start.command_id) if (self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code))): - expected_value.append(commands.Resume.command_id) + self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code))): + expected_value.append(commands.Resume.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, attribute=attributes.AcceptedCommandList, @@ -246,10 +246,10 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature expected_value = [] if (self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code))): - expected_value.append(commands.OperationalCommandResponse.command_id) + self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or + self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)) or + self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code))): + expected_value.append(commands.OperationalCommandResponse.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, attribute=attributes.GeneratedCommandList, From 2e85db4def6a4d13bcc85ccce02dca6b45e1183e Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 09:38:52 -0300 Subject: [PATCH 73/89] Added opstate test cases --- src/python_testing/TC_OPSTATE_1_1.py | 54 +++++++++ src/python_testing/TC_OPSTATE_2_1.py | 169 +++------------------------ src/python_testing/TC_OPSTATE_2_2.py | 51 ++++++++ src/python_testing/TC_OPSTATE_2_3.py | 155 +++--------------------- src/python_testing/TC_OPSTATE_2_4.py | 50 ++++++++ 5 files changed, 185 insertions(+), 294 deletions(-) create mode 100644 src/python_testing/TC_OPSTATE_1_1.py create mode 100644 src/python_testing/TC_OPSTATE_2_2.py create mode 100644 src/python_testing/TC_OPSTATE_2_4.py diff --git a/src/python_testing/TC_OPSTATE_1_1.py b/src/python_testing/TC_OPSTATE_1_1.py new file mode 100644 index 00000000000000..1c5ff1f3f28781 --- /dev/null +++ b/src/python_testing/TC_OPSTATE_1_1.py @@ -0,0 +1,54 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +import chip.clusters as Clusters +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo + + +class TC_OPSTATE_1_1(MatterBaseTest, TC_OPSTATE_BASE): + def __init__(self, *args): + super().__init__(*args) + + test_info = TestInfo( + pics_code="OPSTATE", + cluster=Clusters.OperationalState + ) + + super().setup_base(test_info=test_info) + + def steps_TC_OPSTATE_1_1(self) -> list[TestStep]: + return self.STEPS_TC_OPSTATE_BASE_1_1() + + def pics_TC_OPSTATE_1_1(self) -> list[str]: + return ["OPSTATE.S"] + + @async_test_body + async def test_TC_OPSTATE_1_1(self): + endpoint = self.matter_test_config.endpoint + cluster_revision = 2 + feature_map = 0 + + await self.TEST_TC_OPSTATE_BASE_1_1(endpoint=endpoint, + cluster_revision=cluster_revision, + feature_map=feature_map) + + +if __name__ == "__main__": + default_matter_test_main() + diff --git a/src/python_testing/TC_OPSTATE_2_1.py b/src/python_testing/TC_OPSTATE_2_1.py index 98dbe83dc09057..3e0dc46c4ada23 100644 --- a/src/python_testing/TC_OPSTATE_2_1.py +++ b/src/python_testing/TC_OPSTATE_2_1.py @@ -15,174 +15,35 @@ # limitations under the License. # -import logging import chip.clusters as Clusters -from chip.clusters.Types import NullValue -from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main -from mobly import asserts +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo -# This test requires several additional command line arguments -# run with -# --int-arg PIXIT_ENDPOINT: +class TC_OPSTATE_2_1(MatterBaseTest, TC_OPSTATE_BASE): + def __init__(self, *args): + super().__init__(*args) -class TC_OPSTATE_2_1(MatterBaseTest): + test_info = TestInfo( + pics_code="OPSTATE", + cluster=Clusters.OperationalState + ) - async def read_mod_attribute_expect_success(self, endpoint, attribute): - cluster = Clusters.Objects.OperationalState - return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + super().setup_base(test_info=test_info) - async def read_and_validate_opstate(self, step, expected_state): - self.print_step(step, "Read OperationalState attribute") - operational_state = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OperationalState.Attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, expected_state, - "OperationalState(%s) should equal %s" % (operational_state, expected_state)) - - async def read_and_validate_operror(self, step, expected_error): - self.print_step(step, "Read OperationalError attribute") - operational_error = await self.read_mod_attribute_expect_success( - endpoint=self.endpoint, attribute=Clusters.OperationalState.Attributes.OperationalError) - logging.info("OperationalError: %s" % (operational_error)) - asserts.assert_equal(operational_error.errorStateID, expected_error, - "errorStateID(%s) should equal %s" % (operational_error.errorStateID, expected_error)) + def steps_TC_OPSTATE_2_1(self) -> list[TestStep]: + return self.STEPS_TC_OPSTATE_BASE_2_1() def pics_TC_OPSTATE_2_1(self) -> list[str]: return ["OPSTATE.S"] @async_test_body async def test_TC_OPSTATE_2_1(self): - - asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, - "PIXIT_ENDPOINT must be included on the command line in " - "the --int-arg flag as PIXIT_ENDPOINT:") - - self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] - - attributes = Clusters.OperationalState.Attributes - - self.print_step(1, "Commissioning, already done") - - if self.check_pics("OPSTATE.S.A0000"): - self.print_step(2, "Read PhaseList attribute") - phase_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.PhaseList) - - if phase_list == NullValue: - logging.info("PhaseList is null") - else: - logging.info("PhaseList: %s" % (phase_list)) - - phase_list_len = len(phase_list) - - asserts.assert_less_equal(phase_list_len, 32, - "PhaseList length(%d) must be less than 32!" % phase_list_len) - - if self.check_pics("OPSTATE.S.A0001"): - self.print_step(3, "Read CurrentPhase attribute") - current_phase = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CurrentPhase) - logging.info("CurrentPhase: %s" % (current_phase)) - - if phase_list == NullValue: - asserts.assert_true(current_phase == NullValue, "CurrentPhase(%s) should be null" % current_phase) - else: - asserts.assert_true(0 <= current_phase and current_phase < phase_list_len, - "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) - - if self.check_pics("OPSTATE.S.A0002"): - self.print_step(4, "Read CountdownTime attribute") - countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.CountdownTime) - - logging.info("CountdownTime: %s" % (countdown_time)) - if countdown_time is not NullValue: - asserts.assert_true(0 <= countdown_time <= 259200, - "CountdownTime(%s) must be between 0 and 259200" % countdown_time) - - if self.check_pics("OPSTATE.S.A0003"): - self.print_step(5, "Read OperationalStateList attribute") - operational_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalStateList) - - logging.info("OperationalStateList: %s" % (operational_state_list)) - - defined_states = [state.value for state in Clusters.OperationalState.Enums.OperationalStateEnum - if state is not Clusters.OperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] - - for state in operational_state_list: - in_range = (0x80 <= state.operationalStateID <= 0xBF) - asserts.assert_true(state.operationalStateID in defined_states or in_range, - "Found a OperationalStateList entry with invalid ID value!") - if in_range: - asserts.assert_true(state.operationalStateLabel is not None, - "The OperationalStateLabel should be populated") - if state.operationalStateID == Clusters.OperationalState.Enums.OperationalStateEnum.kError: - error_state_present = True - - asserts.assert_true(error_state_present, "The OperationalStateList does not have an ID entry of Error(0x03)") - - if self.check_pics("OPSTATE.S.A0004"): - self.print_step(6, "Read OperationalState attribute") - operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - - logging.info("OperationalState: %s" % (operational_state)) - - in_range = (0x80 <= operational_state <= 0xBF) - asserts.assert_true(operational_state in defined_states or in_range, "OperationalState has an invalid ID value!") - - if self.check_pics("OPSTATE.S.M.ST_STOPPED"): - self.print_step("6a", "Manually put the device in the stopped state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6b", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kStopped) - if self.check_pics("OPSTATE.S.M.ST_RUNNING"): - self.print_step("6c", "Manually put the device in the running state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6d", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kRunning) - if self.check_pics("OPSTATE.S.M.ST_PAUSED"): - self.print_step("6e", "Manually put the device in the paused state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6f", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kPaused) - if self.check_pics("OPSTATE.S.M.ST_ERROR"): - self.print_step("6g", "Manually put the device in the error state") - input("Press Enter when done.\n") - await self.read_and_validate_opstate(step="6h", expected_state=Clusters.OperationalState.Enums.OperationalStateEnum.kError) - - if self.check_pics("OPSTATE.S.A0005"): - self.print_step(7, "Read OperationalError attribute") - operational_error = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalError) - - logging.info("OperationalError: %s" % (operational_error)) - - # Defined Errors - defined_errors = [error.value for error in Clusters.OperationalState.Enums.ErrorStateEnum - if error is not Clusters.OperationalState.Enums.ErrorStateEnum.kUnknownEnumValue] - - in_range = (0x80 <= operational_error.errorStateID <= 0xBF) - asserts.assert_true(operational_error.errorStateID in defined_errors - or in_range, "OperationalError has an invalid ID value!") - if in_range: - asserts.assert_true(operational_error.errorStateLabel is not None, "ErrorStateLabel should be populated") - - if self.check_pics("OPSTATE.S.M.ERR_NO_ERROR"): - self.print_step("7a", "Manually put the device in the no error state") - input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7b", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kNoError) - if self.check_pics("OPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME"): - self.print_step("7c", "Manually put the device in the unable to start or resume error state") - input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7d", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kUnableToStartOrResume) - if self.check_pics("OPSTATE.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION"): - self.print_step("7e", "Manually put the device in the unable to complete operation error state") - input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7f", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kUnableToCompleteOperation) - if self.check_pics("OPSTATE.S.M.ERR_COMMAND_INVALID_IN_STATE"): - self.print_step("7g", "Manually put the device in the command invalid error state") - input("Press Enter when done.\n") - await self.read_and_validate_operror(step="7h", expected_error=Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState) + endpoint = self.matter_test_config.endpoint + await self.TEST_TC_OPSTATE_BASE_2_1(endpoint) if __name__ == "__main__": default_matter_test_main() + diff --git a/src/python_testing/TC_OPSTATE_2_2.py b/src/python_testing/TC_OPSTATE_2_2.py new file mode 100644 index 00000000000000..b490d71f9a28a3 --- /dev/null +++ b/src/python_testing/TC_OPSTATE_2_2.py @@ -0,0 +1,51 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +import chip.clusters as Clusters +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo + + +class TC_OPSTATE_2_2(MatterBaseTest, TC_OPSTATE_BASE): + + def __init__(self, *args): + super().__init__(*args) + + test_info = TestInfo( + pics_code="OPSTATE", + cluster=Clusters.OperationalState + ) + + super().setup_base(test_info=test_info) + + def steps_TC_OPSTATE_2_2(self) -> list[TestStep]: + return self.STEPS_TC_OPSTATE_BASE_2_2() + + def pics_TC_OPSTATE_2_2(self) -> list[str]: + return ["OPSTATE.S"] + + @async_test_body + async def test_TC_OPSTATE_2_2(self): + endpoint = self.matter_test_config.endpoint + + await self.TEST_TC_OPSTATE_BASE_2_2(endpoint=endpoint) + + +if __name__ == "__main__": + default_matter_test_main() + diff --git a/src/python_testing/TC_OPSTATE_2_3.py b/src/python_testing/TC_OPSTATE_2_3.py index 57189c60382f08..c7e30b4e814ab9 100644 --- a/src/python_testing/TC_OPSTATE_2_3.py +++ b/src/python_testing/TC_OPSTATE_2_3.py @@ -15,161 +15,36 @@ # limitations under the License. # -import logging -import time import chip.clusters as Clusters -from chip.clusters.Types import NullValue -from matter_testing_support import MatterBaseTest, async_test_body, default_matter_test_main, type_matches -from mobly import asserts +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo -# This test requires several additional command line arguments -# run with -# --int-arg PIXIT_ENDPOINT: +class TC_OPSTATE_2_3(MatterBaseTest, TC_OPSTATE_BASE): + def __init__(self, *args): + super().__init__(*args) -class TC_OPSTATE_2_3(MatterBaseTest): + test_info = TestInfo( + pics_code="OPSTATE", + cluster=Clusters.OperationalState + ) - async def read_mod_attribute_expect_success(self, endpoint, attribute): - cluster = Clusters.Objects.OperationalState - return await self.read_single_attribute_check_success(endpoint=endpoint, cluster=cluster, attribute=attribute) + super().setup_base(test_info=test_info) - async def send_pause_cmd(self) -> Clusters.Objects.OperationalState.Commands.Pause: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OperationalState.Commands.Pause(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Pause") - return ret - - async def send_resume_cmd(self) -> Clusters.Objects.OperationalState.Commands.Resume: - ret = await self.send_single_cmd(cmd=Clusters.Objects.OperationalState.Commands.Resume(), endpoint=self.endpoint) - asserts.assert_true(type_matches(ret, Clusters.Objects.OperationalState.Commands.OperationalCommandResponse), - "Unexpected return type for Resume") - return ret + def steps_TC_OPSTATE_2_3(self) -> list[TestStep]: + return self.STEPS_TC_OPSTATE_BASE_2_3() def pics_TC_OPSTATE_2_3(self) -> list[str]: return ["OPSTATE.S"] @async_test_body async def test_TC_OPSTATE_2_3(self): + endpoint = self.matter_test_config.endpoint - asserts.assert_true('PIXIT_ENDPOINT' in self.matter_test_config.global_test_params, - "PIXIT_ENDPOINT must be included on the command line in " - "the --int-arg flag as PIXIT_ENDPOINT:") - - self.endpoint = self.matter_test_config.global_test_params['PIXIT_ENDPOINT'] - - asserts.assert_true(self.check_pics("OPSTATE.S.A0003"), "OPSTATE.S.A0003 must be supported") - asserts.assert_true(self.check_pics("OPSTATE.S.A0004"), "OPSTATE.S.A0004 must be supported") - asserts.assert_true(self.check_pics("OPSTATE.S.C00.Rsp"), "OPSTATE.S.C00.Rsp must be supported") - asserts.assert_true(self.check_pics("OPSTATE.S.C03.Rsp"), "OPSTATE.S.C03.Rsp must be supported") - # This command SHALL be supported by an implementation if any of the other commands are supported (6.5) - asserts.assert_true(self.check_pics("OPSTATE.S.C04.Rsp"), "OPSTATE.S.C04.Rsp must be supported") - - attributes = Clusters.OperationalState.Attributes - - self.print_step(1, "Commissioning, already done") - - self.print_step(2, "Manually put the device in a state where it can receive a Pause command") - input("Press Enter when done.\n") - - self.print_step(3, "Read OperationalStateList attribute") - op_state_list = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalStateList) - - logging.info("OperationalStateList: %s" % (op_state_list)) - - defined_states = [state.value for state in Clusters.OperationalState.Enums.OperationalStateEnum - if state is not Clusters.OperationalState.Enums.OperationalStateEnum.kUnknownEnumValue] - - state_ids = set([s.operationalStateID for s in op_state_list]) - - asserts.assert_true(all(id in state_ids for id in defined_states), "OperationalStateList is missing a required entry") - - self.print_step(4, "Send Pause command") - ret = await self.send_pause_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(5, "Read OperationalState attribute") - operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OperationalState.Enums.OperationalStateEnum.kPaused, - "OperationalState ID should be Paused(0x02)") - - if self.check_pics("OPSTATE.S.A0002"): - self.print_step(6, "Read CountdownTime attribute") - initial_countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.CountdownTime) - logging.info("CountdownTime: %s" % (initial_countdown_time)) - if initial_countdown_time is not NullValue: - in_range = (1 <= initial_countdown_time <= 259200) - asserts.assert_true(initial_countdown_time is NullValue or in_range, - "invalid CountdownTime(%s). Must be in between 1 and 259200, or null " % initial_countdown_time) - - self.print_step(7, "Waiting for 5 seconds") - time.sleep(5) - - self.print_step(8, "Read CountdownTime attribute") - countdown_time = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, attribute=attributes.CountdownTime) - logging.info("CountdownTime: %s" % (countdown_time)) - asserts.assert_true(countdown_time != 0 or countdown_time == NullValue, - "invalid CountdownTime(%s). Must be a non zero integer, or null" % countdown_time) - asserts.assert_equal(countdown_time, initial_countdown_time, "CountdownTime(%s) does not equal to the intial CountdownTime(%s)" - % (countdown_time, initial_countdown_time)) - - self.print_step(9, "Send Pause command") - ret = await self.send_pause_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(10, "Send Resume command") - ret = await self.send_resume_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(11, "Read OperationalState attribute") - operational_state = await self.read_mod_attribute_expect_success(endpoint=self.endpoint, - attribute=attributes.OperationalState) - logging.info("OperationalState: %s" % (operational_state)) - asserts.assert_equal(operational_state, Clusters.OperationalState.Enums.OperationalStateEnum.kRunning, - "OperationalState(%s) should be Running(0x01)" % operational_state) - - self.print_step(12, "Send Resume command") - ret = await self.send_resume_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, Clusters.OperationalState.Enums.ErrorStateEnum.kNoError, - "errorStateID(%s) should be NoError(0x00)" % ret.commandResponseState.errorStateID) - - self.print_step(13, "Manually put the device in the Stopped(0x00) operational state") - input("Press Enter when done.\n") - - self.print_step(14, "Send Pause command") - ret = await self.send_pause_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, - Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, - "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) - - self.print_step(15, "Send Resume command") - ret = await self.send_resume_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, - Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, - "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) - - self.print_step(16, "Manually put the device in the Error(0x03) operational state") - input("Press Enter when done.\n") - - self.print_step(17, "Send Pause command") - ret = await self.send_pause_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, - Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, - "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) - - self.print_step(18, "Send Resume command") - ret = await self.send_resume_cmd() - asserts.assert_equal(ret.commandResponseState.errorStateID, - Clusters.OperationalState.Enums.ErrorStateEnum.kCommandInvalidInState, - "errorStateID(%s) should be CommandInvalidInState(0x03)" % ret.commandResponseState.errorStateID) + await self.TEST_TC_OPSTATE_BASE_2_3(endpoint=endpoint) if __name__ == "__main__": default_matter_test_main() + diff --git a/src/python_testing/TC_OPSTATE_2_4.py b/src/python_testing/TC_OPSTATE_2_4.py new file mode 100644 index 00000000000000..12ecf17e65387a --- /dev/null +++ b/src/python_testing/TC_OPSTATE_2_4.py @@ -0,0 +1,50 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +import chip.clusters as Clusters +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo + + +class TC_OPSTATE_2_4(MatterBaseTest, TC_OPSTATE_BASE): + def __init__(self, *args): + super().__init__(*args) + + test_info = TestInfo( + pics_code="OPSTATE", + cluster=Clusters.OperationalState + ) + + super().setup_base(test_info=test_info) + + def steps_TC_OPSTATE_2_4(self) -> list[TestStep]: + return self.STEPS_TC_OPSTATE_BASE_2_4() + + def pics_TC_OPSTATE_2_4(self) -> list[str]: + return ["OPSTATE.S"] + + @async_test_body + async def test_TC_OPSTATE_2_4(self): + endpoint = self.matter_test_config.endpoint + + await self.TEST_TC_OPSTATE_BASE_2_4(endpoint=endpoint) + + +if __name__ == "__main__": + default_matter_test_main() + From b76fbfef388a8942541316d4db831cd677e9d7ea Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 09:40:12 -0300 Subject: [PATCH 74/89] Fixed opstate app --- .../all-clusters-common/all-clusters-app.zap | 2 +- .../src/operational-state-delegate-impl.cpp | 25 +++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap index 14aa844c0a3975..7525e06449c6dd 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.zap @@ -11249,7 +11249,7 @@ "storageOption": "RAM", "singleton": 0, "bounded": 0, - "defaultValue": "1", + "defaultValue": "2", "reportable": 1, "minInterval": 1, "maxInterval": 65534, diff --git a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp index 3370d75bd65f35..bc847c7db51e95 100644 --- a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp @@ -44,6 +44,14 @@ CHIP_ERROR GenericOperationalStateDelegateImpl::GetOperationalPhaseAtIndex(size_ void GenericOperationalStateDelegateImpl::HandlePauseStateCallback(GenericOperationalError & err) { + OperationalState::OperationalStateEnum state = static_cast(GetInstance()->GetCurrentOperationalState()); + + if(state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState)); + return; + } + // placeholder implementation auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused)); if (error == CHIP_NO_ERROR) @@ -58,6 +66,14 @@ void GenericOperationalStateDelegateImpl::HandlePauseStateCallback(GenericOperat void GenericOperationalStateDelegateImpl::HandleResumeStateCallback(GenericOperationalError & err) { + OperationalState::OperationalStateEnum state = static_cast(GetInstance()->GetCurrentOperationalState()); + + if(state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState)); + return; + } + // placeholder implementation auto error = GetInstance()->SetOperationalState(to_underlying(OperationalStateEnum::kRunning)); if (error == CHIP_NO_ERROR) @@ -72,6 +88,15 @@ void GenericOperationalStateDelegateImpl::HandleResumeStateCallback(GenericOpera void GenericOperationalStateDelegateImpl::HandleStartStateCallback(GenericOperationalError & err) { + OperationalState::GenericOperationalError current_err(to_underlying(OperationalState::ErrorStateEnum::kNoError)); + GetInstance()->GetCurrentOperationalError(current_err); + + if(current_err.errorStateID != to_underlying(OperationalState::ErrorStateEnum::kNoError)) + { + err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToStartOrResume)); + return; + } + // placeholder implementation auto error = GetInstance()->SetOperationalState(to_underlying(OperationalStateEnum::kRunning)); if (error == CHIP_NO_ERROR) From acc54c3a410fd31fb1923c6065bf982e28c642d4 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 09:42:50 -0300 Subject: [PATCH 75/89] removed opstate from YAML --- scripts/tests/chiptest/__init__.py | 1 - .../certification/Test_TC_OPSTATE_1_1.yaml | 162 -------- .../certification/Test_TC_OPSTATE_2_2.yaml | 335 ----------------- .../certification/Test_TC_OPSTATE_2_4.yaml | 94 ----- .../certification/Test_TC_OPSTATE_2_5.yaml | 353 ------------------ src/app/tests/suites/ciTests.json | 1 - src/app/tests/suites/manualTests.json | 1 - 7 files changed, 947 deletions(-) delete mode 100644 src/app/tests/suites/certification/Test_TC_OPSTATE_1_1.yaml delete mode 100644 src/app/tests/suites/certification/Test_TC_OPSTATE_2_2.yaml delete mode 100644 src/app/tests/suites/certification/Test_TC_OPSTATE_2_4.yaml delete mode 100644 src/app/tests/suites/certification/Test_TC_OPSTATE_2_5.yaml diff --git a/scripts/tests/chiptest/__init__.py b/scripts/tests/chiptest/__init__.py index dba11f15d44c1e..1aa0f746936b67 100644 --- a/scripts/tests/chiptest/__init__.py +++ b/scripts/tests/chiptest/__init__.py @@ -202,7 +202,6 @@ def _GetDarwinFrameworkToolUnsupportedTests() -> Set[str]: "Test_TC_GRPKEY_2_1", # darwin-framework-tool does not support writing readonly attributes by name "Test_TC_LCFG_2_1", # darwin-framework-tool does not support writing readonly attributes by name "Test_TC_OPCREDS_3_7", # darwin-framework-tool does not support the GetCommissionerRootCertificate command. - "Test_TC_OPSTATE_2_4", # darwin-framework-tool does not currently support reading or subscribing to Events "Test_TC_SMOKECO_2_2", # darwin-framework-tool does not currently support reading or subscribing to Events "Test_TC_SMOKECO_2_3", # darwin-framework-tool does not currently support reading or subscribing to Events "Test_TC_SMOKECO_2_4", # darwin-framework-tool does not currently support reading or subscribing to Events diff --git a/src/app/tests/suites/certification/Test_TC_OPSTATE_1_1.yaml b/src/app/tests/suites/certification/Test_TC_OPSTATE_1_1.yaml deleted file mode 100644 index 21d6c7e9785e07..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_OPSTATE_1_1.yaml +++ /dev/null @@ -1,162 +0,0 @@ -# Copyright (c) 2023 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: 201.1.1. [TC-OPSTATE-1.1] Global Attributes with DUT as Server - -PICS: - - OPSTATE.S - -config: - nodeId: 0x12344321 - cluster: "Operational State" - endpoint: 1 - -tests: - - label: - "Step 1: Commission DUT to TH (can be skipped if done in a preceding - test)" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Step 2: TH reads from the DUT the ClusterRevision attribute" - command: "readAttribute" - attribute: "ClusterRevision" - response: - value: 1 - constraints: - type: int16u - - - label: "Step 3: TH reads from the DUT the FeatureMap attribute" - command: "readAttribute" - attribute: "FeatureMap" - response: - value: 0 - constraints: - type: bitmap32 - - - label: "Step 4a: TH reads from the DUT the AttributeList attribute" - PICS: PICS_EVENT_LIST_ENABLED - command: "readAttribute" - attribute: "AttributeList" - response: - constraints: - type: list - contains: - [0, 1, 3, 4, 5, 65528, 65529, 65530, 65531, 65532, 65533] - - - label: "Step 4a: TH reads from the DUT the AttributeList attribute" - PICS: "!PICS_EVENT_LIST_ENABLED" - command: "readAttribute" - attribute: "AttributeList" - response: - constraints: - type: list - contains: [0, 1, 3, 4, 5, 65528, 65529, 65531, 65532, 65533] - - - label: - "Step 4b: TH reads from the DUT the optional attribute(CountdownTime) - in the AttributeList from the DUT" - PICS: OPSTATE.S.A0002 - command: "readAttribute" - attribute: "AttributeList" - response: - constraints: - type: list - contains: [2] - - - label: "Step 5a: TH reads from the DUT the EventList attribute" - PICS: PICS_EVENT_LIST_ENABLED - command: "readAttribute" - attribute: "EventList" - response: - constraints: - type: list - contains: [0x00] - - - label: - "Step 5b: TH reads from the DUT the optional - event(OperationCompletion) in EventList." - PICS: PICS_EVENT_LIST_ENABLED && OPSTATE.S.E01 - command: "readAttribute" - attribute: "EventList" - response: - constraints: - type: list - contains: [0x01] - - - label: - "Step 6a: TH reads the optional command(Start) in AcceptedCommandList" - PICS: OPSTATE.S.C02.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [1, 2] - - - label: - "Step 6b: TH reads the optional command(Stop) in AcceptedCommandList" - PICS: OPSTATE.S.C01.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [1] - - - label: - "Step 6c: TH reads the optional command(Pause) in AcceptedCommandList" - PICS: OPSTATE.S.C00.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [0, 3] - - - label: - "Step 6d: TH reads the optional command(Resume) in AcceptedCommandList" - PICS: OPSTATE.S.C03.Rsp - command: "readAttribute" - attribute: "AcceptedCommandList" - response: - constraints: - type: list - contains: [0, 3] - - - label: "Step 7: TH reads from the DUT the AcceptedCommandList attribute" - PICS: - "!OPSTATE.S.C00.Rsp && !OPSTATE.S.C01.Rsp && !OPSTATE.S.C02.Rsp && - !OPSTATE.S.C03.Rsp" - command: "readAttribute" - attribute: "GeneratedCommandList" - response: - value: [] - constraints: - type: list - - - label: "Step 7: TH reads from the DUT the GeneratedCommandList attribute" - PICS: - (OPSTATE.S.C00.Rsp || OPSTATE.S.C01.Rsp || OPSTATE.S.C02.Rsp || - OPSTATE.S.C03.Rsp) - command: "readAttribute" - attribute: "GeneratedCommandList" - response: - constraints: - type: list - contains: [4] diff --git a/src/app/tests/suites/certification/Test_TC_OPSTATE_2_2.yaml b/src/app/tests/suites/certification/Test_TC_OPSTATE_2_2.yaml deleted file mode 100644 index 43dc0dda3dc01e..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_OPSTATE_2_2.yaml +++ /dev/null @@ -1,335 +0,0 @@ -# Copyright (c) 2023 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default - -name: 202.2.2. [TC-OPSTATE-2.2] Start and Stop commands with DUT as Server - -PICS: - - OPSTATE.S - -config: - nodeId: 0x12344321 - cluster: "Basic Information" - endpoint: 0 - -tests: - - label: "Note" - verification: | - This is a simulated example log for instructional purposes only. In real scenarios, the actual log may vary depending on the feature implementation in Reference App. - disabled: true - - - label: - "Step 1: Commission DUT to TH (can be skipped if done in a preceding - test)" - verification: | - - disabled: true - - - label: - "Step 2: Manually put the DUT into a state wherein it can receive a - Start Command" - verification: | - Manually put the DUT into a state wherein it can receive a Start Command - disabled: true - - - label: "Step 3: TH reads from the DUT the OperationalStateList attribute" - PICS: OPSTATE.S.A0003 - verification: | - ./chip-tool operationalstate read operational-state-list 1 1 - - Via the TH (chip-tool), verify: - - all entries include an ID (enum8) and a label (string) - - all provided IDs are in the allowed range - - the list includes IDs for Error (0x03), Running (0x01), and Stopped (0x00) - - [1689674049.504261][17222:17224] CHIP:DMG: } - [1689674049.504390][17222:17224] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0003 DataVersion: 2102885775 - [1689674049.504440][17222:17224] CHIP:TOO: OperationalStateList: 4 entries - [1689674049.504462][17222:17224] CHIP:TOO: [1]: { - [1689674049.504469][17222:17224] CHIP:TOO: OperationalStateID: 0 - [1689674049.504476][17222:17224] CHIP:TOO: } - [1689674049.504484][17222:17224] CHIP:TOO: [2]: { - [1689674049.504490][17222:17224] CHIP:TOO: OperationalStateID: 1 - [1689674049.504495][17222:17224] CHIP:TOO: } - [1689674049.504503][17222:17224] CHIP:TOO: [3]: { - [1689674049.504508][17222:17224] CHIP:TOO: OperationalStateID: 2 - [1689674049.504514][17222:17224] CHIP:TOO: } - [1689674049.504521][17222:17224] CHIP:TOO: [4]: { - [1689674049.504527][17222:17224] CHIP:TOO: OperationalStateID: 3 - [1689674049.504533][17222:17224] CHIP:TOO: } - [1689674049.504605][17222:17224] CHIP:EM: <<< [E:22830i S:37151 M:4250114 (Ack:140781365)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674049.504620][17222:17224] CHIP:IN: (S) Sending msg 4250114 on secure session with LSID: 37151 - disabled: true - - - label: "Step 4: TH sends Start command to the DUT" - PICS: OPSTATE.S.C02.Rsp && OPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674139.018639][17233:17235] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674139.018658][17233:17235] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674139.018704][17233:17235] CHIP:TOO: OperationalCommandResponse: { - [1689674139.018712][17233:17235] CHIP:TOO: commandResponseState: { - [1689674139.018719][17233:17235] CHIP:TOO: ErrorStateID: 0 - [1689674139.018726][17233:17235] CHIP:TOO: } - [1689674139.018732][17233:17235] CHIP:TOO: } - [1689674139.018755][17233:17235] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674139.018818][17233:17235] CHIP:EM: <<< [E:26021i S:33879 M:235550100 (Ack:58905970)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674139.018837][17233:17235] CHIP:IN: (S) Sending msg 235550100 on secure session with LSID: 33879 - [1689674139.018885][17233:17235] CHIP:EM: Flushed pending ack for MessageCounter:58905970 on exchange 26021i - disabled: true - - - label: "Step 5: TH reads from the DUT the OperationalState attribute" - PICS: OPSTATE.S.A0004 - verification: | - ./chip-tool operationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x01 (Running) - - [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 - [1689674196.878727][17249:17251] CHIP:DMG: } - [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { - [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 - [1689674196.878847][17249:17251] CHIP:TOO: } - [1689674196.878914][17249:17251] CHIP:EM: <<< [E:56939i S:28614 M:63040141 (Ack:57012545)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674196.878928][17249:17251] CHIP:IN: (S) Sending msg 63040141 on secure session with LSID: 28614 - disabled: true - - - label: "Step 6: TH reads from the DUT the OperationalError attribute" - PICS: OPSTATE.S.A0005 - verification: | - ./chip-tool operationalstate read operational-error 1 1 - - Via the TH (chip-tool), verify: - - the response contains the ErrorStateId set to NoError(0x00) - - [1689674342.832448][17274:17276] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0005 DataVersion: 2102885775 - [1689674342.832482][17274:17276] CHIP:TOO: OperationalError: { - [1689674342.832500][17274:17276] CHIP:TOO: ErrorStateID: 0 - [1689674342.832509][17274:17276] CHIP:TOO: } - [1689674342.832570][17274:17276] CHIP:EM: <<< [E:37158i S:10451 M:72875113 (Ack:195983315)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674342.832585][17274:17276] CHIP:IN: (S) Sending msg 72875113 on secure session with LSID: 10451 - [1689674342.832614][17274:17276] CHIP:EM: Flushed pending ack for MessageCounter:195983315 on exchange 37158i - disabled: true - - - label: "Step 7: TH reads from the DUT the CountdownTime attribute" - PICS: OPSTATE.S.A0002 - verification: | - ./chip-tool operationalstate read countdown-time 1 1 - - Via the TH (chip-tool), verify: - - that CountdownTime attribute contains either null our a uint32 value - - if non-null, verify that the value is in the range 1 to 259200 - - store the value in 'initialcountdown-time' - - [1689674384.271623][17278:17280] CHIP:DMG: InteractionModelRevision = 1 - [1689674384.271625][17278:17280] CHIP:DMG: } - [1689674384.271649][17278:17280] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 2102885775 - [1689674384.271662][17278:17280] CHIP:TOO: CountdownTime: null - [1689674384.271683][17278:17280] CHIP:EM: <<< [E:24665i S:47371 M:757241 (Ack:152992659)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674384.271687][17278:17280] CHIP:IN: (S) Sending msg 757241 on secure session with LSID: 47371 - [1689674384.271696][17278:17280] CHIP:EM: Flushed pending ack for MessageCounter:152992659 on exchange 24665i - disabled: true - - - label: "Step 8: TH reads from the DUT the PhaseList attribute" - PICS: OPSTATE.S.A0000 - verification: | - ./chip-tool operationalstate read phase-list 1 1 - - Via the TH (chip-tool), verify: - - that PhaseList attribute value contains either null or a list of strings. - - If not null, receord the number of entries in the list as 'phase-list-size'; execute step 7. - If null, go to step 8. - - [1689674447.761859][17290:17292] CHIP:DMG: InteractionModelRevision = 1 - [1689674447.761865][17290:17292] CHIP:DMG: } - [1689674447.761938][17290:17292] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0000 DataVersion: 2102885775 - [1689674447.761972][17290:17292] CHIP:TOO: PhaseList: null - [1689674447.762041][17290:17292] CHIP:EM: <<< [E:58737i S:13847 M:251354926 (Ack:137738036)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674447.762055][17290:17292] CHIP:IN: (S) Sending msg 251354926 on secure session with LSID: 13847 - [1689674447.762109][17290:17292] CHIP:EM: Flushed pending ack for MessageCounter:137738036 on exchange 58737i - disabled: true - - - label: "Step 9: TH reads from the DUT the CurrentPhase attribute" - PICS: OPSTATE.S.A0001 - verification: | - ./chip-tool operationalstate read current-phase 1 1 - - Via the TH (chip-tool), verify: - - that the CurrentPhase attribute value contains contains a uint8 value - - that the value is between 0 and 'phase-list-size - 1'. - - [1689674497.950563][17299:17301] CHIP:DMG: } - [1689674497.950635][17299:17301] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0001 DataVersion: 2102885775 - [1689674497.950664][17299:17301] CHIP:TOO: CurrentPhase: null - [1689674497.950737][17299:17301] CHIP:EM: <<< [E:64019i S:52010 M:245677798 (Ack:138696372)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674497.950752][17299:17301] CHIP:IN: (S) Sending msg 245677798 on secure session with LSID: 52010 - [1689674497.950798][17299:17301] CHIP:EM: Flushed pending ack for MessageCounter:138696372 on exchange 64019i - [1689674497.950899][17299:17299] CHIP:CTL: Shutting down the commissioner - disabled: true - - - label: - "Step 10: TH waits for a vendor defined wait time, this being a period - of time less than the expected duration of the operation that has been - started" - verification: | - TH waits for a vendor defined wait time, this being a period of time less than the expected duration of the operation that has been started - disabled: true - - - label: "Step 11: TH reads from the DUT the CountdownTime attribute" - PICS: OPSTATE.S.A0002 - verification: | - ./chip-tool operationalstate read countdown-time 1 1 - - - Via the TH (chip-tool), verify: - - that CountdownTime attribute contains either null our a uint32 value - - if non-null, verify that the value is in the range 1 to 259200 - - that the value is approximately 'initialcountdown-time minus the vendor defined wait time' - - - [1689674623.673661][17320:17322] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 2102885775 - [1689674623.673697][17320:17322] CHIP:TOO: CountdownTime: null - [1689674623.673755][17320:17322] CHIP:EM: <<< [E:42152i S:37580 M:19654175 (Ack:176515710)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674623.673768][17320:17322] CHIP:IN: (S) Sending msg 19654175 on secure session with LSID: 37580 - [1689674623.673795][17320:17322] CHIP:EM: Flushed pending ack for MessageCounter:176515710 on exchange 42152i - disabled: true - - - label: "Step 12: TH sends Start command to the DUT" - PICS: OPSTATE.S.C02.Rsp && OPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674637.555734][17326:17328] CHIP:DMG: - [1689674637.555742][17326:17328] CHIP:DMG: InteractionModelRevision = 1 - [1689674637.555751][17326:17328] CHIP:DMG: }, - [1689674637.555784][17326:17328] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674637.555805][17326:17328] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674637.555853][17326:17328] CHIP:TOO: OperationalCommandResponse: { - [1689674637.555862][17326:17328] CHIP:TOO: commandResponseState: { - [1689674637.555872][17326:17328] CHIP:TOO: ErrorStateID: 0 - [1689674637.555883][17326:17328] CHIP:TOO: } - [1689674637.555891][17326:17328] CHIP:TOO: } - [1689674637.555913][17326:17328] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674637.555956][17326:17328] CHIP:EM: <<< [E:28742i S:49023 M:139320570 (Ack:91983883)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674637.555971][17326:17328] CHIP:IN: (S) Sending msg 139320570 on secure session with LSID: 49023 - [1689674637.556001][17326:17328] CHIP:EM: Flushed pending ack for MessageCounter:91983883 on exchange 28742i - disabled: true - - - label: "Step 13: TH sends Stop command to the DUT" - PICS: OPSTATE.S.C01.Rsp && OPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate stop 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674653.322963][17330:17332] CHIP:DMG: }, - [1689674653.322994][17330:17332] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674653.323014][17330:17332] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674653.323058][17330:17332] CHIP:TOO: OperationalCommandResponse: { - [1689674653.323066][17330:17332] CHIP:TOO: commandResponseState: { - [1689674653.323076][17330:17332] CHIP:TOO: ErrorStateID: 0 - [1689674653.323085][17330:17332] CHIP:TOO: } - [1689674653.323094][17330:17332] CHIP:TOO: } - [1689674653.323113][17330:17332] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674653.323154][17330:17332] CHIP:EM: <<< [E:62878i S:64455 M:173921517 (Ack:216732582)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674653.323168][17330:17332] CHIP:IN: (S) Sending msg 173921517 on secure session with LSID: 64455 - [1689674653.323195][17330:17332] CHIP:EM: Flushed pending ack for MessageCounter:216732582 on exchange 62878i - [1689674653.323284][17330:17330] CHIP:CTL: Shutting down the commissioner - disabled: true - - - label: "Step 14: TH reads from the DUT the OperationalState attribute" - PICS: OPSTATE.S.A0004 - verification: | - ./chip-tool operationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x00 (Stopped) - - [1689674675.459656][17333:17335] CHIP:DMG: } - [1689674675.459738][17333:17335] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674675.459772][17333:17335] CHIP:TOO: OperationalState: { - [1689674675.459790][17333:17335] CHIP:TOO: OperationalStateID: 0 - [1689674675.459799][17333:17335] CHIP:TOO: } - [1689674675.459869][17333:17335] CHIP:EM: <<< [E:17771i S:16165 M:1572532 (Ack:102448631)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674675.459886][17333:17335] CHIP:IN: (S) Sending msg 1572532 on secure session with LSID: 16165 - [1689674675.459930][17333:17335] CHIP:EM: Flushed pending ack for MessageCounter:102448631 on exchange 17771i - disabled: true - - - label: "Step 15: TH sends Stop command to the DUT" - PICS: OPSTATE.S.C01.Rsp && OPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate stop 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674689.588712][17337:17339] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674689.588722][17337:17339] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674689.588745][17337:17339] CHIP:TOO: OperationalCommandResponse: { - [1689674689.588749][17337:17339] CHIP:TOO: commandResponseState: { - [1689674689.588757][17337:17339] CHIP:TOO: ErrorStateID: 0 - [1689674689.588762][17337:17339] CHIP:TOO: } - [1689674689.588765][17337:17339] CHIP:TOO: } - [1689674689.588775][17337:17339] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674689.588802][17337:17339] CHIP:EM: <<< [E:63921i S:35027 M:16881995 (Ack:220265764)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674689.588810][17337:17339] CHIP:IN: (S) Sending msg 16881995 on secure session with LSID: 35027 - disabled: true - - - label: - "Step 16: Manually put the DUT into a state wherein it cannot receive - a Start Command" - PICS: OPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME - verification: | - Manually put the DUT into a state wherein it cannot receive a Start Command - disabled: true - - - label: "Step 17: TH sends Start command to the DUT" - PICS: - OPSTATE.S.M.ERR_UNABLE_TO_START_OR_RESUME && OPSTATE.S.C02.Rsp && - OPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x01 (UnableToStartOrResume) - - [1689674700.385183][17340:17342] CHIP:DMG: }, - [1689674700.385214][17340:17342] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674700.385233][17340:17342] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674700.385266][17340:17342] CHIP:TOO: OperationalCommandResponse: { - [1689674700.385274][17340:17342] CHIP:TOO: commandResponseState: { - [1689674700.385281][17340:17342] CHIP:TOO: ErrorStateID: 1 - [1689674700.385289][17340:17342] CHIP:TOO: } - [1689674700.385295][17340:17342] CHIP:TOO: } - [1689674700.385311][17340:17342] CHIP:DMG: ICR moving to [AwaitingDe] - [1689674700.385361][17340:17342] CHIP:EM: <<< [E:55029i S:46795 M:80501191 (Ack:176711722)] (S) Msg TX to 1:0000000000000001 [BFDE] --- Type 0000:10 (SecureChannel:StandaloneAck) - [1689674700.385375][17340:17342] CHIP:IN: (S) Sending msg 80501191 on secure session with LSID: 46795 - [1689674700.385419][17340:17342] CHIP:EM: Flushed pending ack for MessageCounter:176711722 on exchange 55029i - disabled: true diff --git a/src/app/tests/suites/certification/Test_TC_OPSTATE_2_4.yaml b/src/app/tests/suites/certification/Test_TC_OPSTATE_2_4.yaml deleted file mode 100644 index f8d07da34446a9..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_OPSTATE_2_4.yaml +++ /dev/null @@ -1,94 +0,0 @@ -# Copyright (c) 2023 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. - -name: 202.2.4. [TC-OPSTATE-2.4] Mandatory Events with DUT as Server - -PICS: - - OPSTATE.S - -config: - nodeId: 0x12344321 - cluster: "Operational State" - endpoint: 1 - -tests: - - label: "Step 1: Commission DUT to TH" - cluster: "DelayCommands" - command: "WaitForCommissionee" - arguments: - values: - - name: "nodeId" - value: nodeId - - - label: "Step 2: Set up a subscription to the OperationalError event" - PICS: OPSTATE.S.E00 - command: "subscribeEvent" - event: "OperationalError" - minInterval: 10 - maxInterval: 5000 - - - label: - "Step 3: At the DUT take the vendor defined action to generate an - OperationalError event" - PICS: OPSTATE.S.E00 && PICS_SKIP_SAMPLE_APP - verification: | - After the subscription interval via the TH (chip-tool) verify: - - reception of an OperationalError Event - - ErrorStateID is a defined error - - If the ErrorStateID is manufacturer specific, inclusion of an ErrorStateLabel, not present otherwise - - Optionally an ErrorStateDetails - - NOTE : There's a PIXIT value controlling the ability to execute that ({PIXIT_ERROREVENTGEN}), which as the test case notes, requires vendor specific actions to generated the error at the DUT. This is dependent on the vendor app supporting this. The SDK as it stands won't provide the error, this may be testable by some of the vendors depending on their implementations. - - - [1692859386.707176][6658:6660] CHIP:EM: Rxd Ack; Removing MessageCounter:212756536 from Retrans Table on exchange 36888i - [1692859386.707295][6658:6660] CHIP:DMG: ReportDataMessage = - [1692859386.707360][6658:6660] CHIP:DMG: { - [1692859386.707416][6658:6660] CHIP:DMG: SubscriptionId = 0x97bb846c, - [1692859386.707477][6658:6660] CHIP:DMG: InteractionModelRevision = 10 - [1692859386.707533][6658:6660] CHIP:DMG: } - [1692859386.707621][6658:6660] CHIP:DMG: MoveToState ReadClient[0xffff80011a90]: Moving to [AwaitingSu] - [1692859386.707815][6658:6660] CHIP:EM: <<< [E:36888i S:54523 M:212756537 (Ack:12760634)] (S) Msg TX to 1:0000000000000001 [853D] --- Type 0001:01 (IM:StatusResponse) - [1692859386.707901][6658:6660] CHIP:IN: (S) Sending msg 212756537 on secure session with LSID: 54523 - [1692859386.708167][6658:6660] CHIP:DL: HandlePlatformSpecificBLEEvent 32793 - [1692859386.708237][6658:6660] CHIP:DL: HandlePlatformSpecificBLEEvent 32793 - [1692859386.749217][6658:6660] CHIP:EM: >>> [E:36888i S:54523 M:12760635 (Ack:212756537)] (S) Msg RX from 1:0000000000000001 [853D] --- Type 0001:04 (IM:SubscribeResponse) - [1692859386.749285][6658:6660] CHIP:EM: Found matching exchange: 36888i, Delegate: 0xffff80011aa0 - [1692859386.749350][6658:6660] CHIP:EM: Rxd Ack; Removing MessageCounter:212756537 from Retrans Table on exchange 36888i - [1692859386.749417][6658:6660] CHIP:DMG: SubscribeResponse is received - [1692859386.749489][6658:6660] CHIP:DMG: SubscribeResponseMessage = - [1692859386.749538][6658:6660] CHIP:DMG: { - [1692859386.749584][6658:6660] CHIP:DMG: SubscriptionId = 0x97bb846c, - [1692859386.749637][6658:6660] CHIP:DMG: MaxInterval = 0x6, - [1692859386.749687][6658:6660] CHIP:DMG: InteractionModelRevision = 10 - [1692859386.749734][6658:6660] CHIP:DMG: } - [1692859386.749787][6658:6660] CHIP:DMG: Subscription established with SubscriptionID = 0x97bb846c MinInterval = 5s MaxInterval = 6s Peer = 01:0000000000000001 - [1692859386.749843][6658:6660] CHIP:DMG: MoveToState ReadClient[0xffff80011a90]: Moving to [Subscripti] - cluster: "LogCommands" - command: "UserPrompt" - arguments: - values: - - name: "message" - value: "Enter 'y' after success" - - name: "expectedValue" - value: "y" - - - label: "Step 4: TH reads from the DUT the OperationalState attribute" - PICS: OPSTATE.S.A0004 && PICS_SKIP_SAMPLE_APP - command: "readAttribute" - attribute: "OperationalState" - response: - value: 0x03 - constraints: - type: enum8 diff --git a/src/app/tests/suites/certification/Test_TC_OPSTATE_2_5.yaml b/src/app/tests/suites/certification/Test_TC_OPSTATE_2_5.yaml deleted file mode 100644 index 6dcc447fbf3dd1..00000000000000 --- a/src/app/tests/suites/certification/Test_TC_OPSTATE_2_5.yaml +++ /dev/null @@ -1,353 +0,0 @@ -# Copyright (c) 2023 Project CHIP Authors -# -# Licensed under the Apache License, Version 2.0 (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, software -# distributed under the License is distributed on an "AS IS" BASIS, -# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -# See the License for the specific language governing permissions and -# limitations under the License. -# Auto-generated scripts for harness use only, please review before automation. The endpoints and cluster names are currently set to default - -name: 204.2.5. [TC-OPSTATE-2.5] Optional Events with DUT as Server - -PICS: - - OPSTATE.S - -config: - nodeId: 0x12344321 - cluster: "Basic Information" - endpoint: 0 - -tests: - - label: "Note" - verification: | - This test case can be continuted only when countdown-time read in step 5 is not null - disabled: true - - - label: "Step 1: Commission DUT to TH" - verification: | - - disabled: true - - - label: "Step 2: Set up a subscription to the OperationCompletion event" - PICS: OPSTATE.S.E01 - verification: | - ./chip-tool interactive start - - operationalstate read-event operation-completion 1 1 - - [1702376916.193452][4893:4896] CHIP:DMG: ReportDataMessage = - [1702376916.193461][4893:4896] CHIP:DMG: { - [1702376916.193469][4893:4896] CHIP:DMG: SubscriptionId = 0x85d7a607, - [1702376916.193497][4893:4896] CHIP:DMG: InteractionModelRevision = 11 - [1702376916.193504][4893:4896] CHIP:DMG: } - disabled: true - - - label: "Step 3: TH reads from the DUT the OperationalState attribute" - PICS: OPSTATE.S.A0004 - verification: | - ./chip-tool operationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response includes an ID (enum8) amd a label (string) - - the provided ID is found in the set provided in step 4 - - the provided ID is in the allowed range - - [1689673213.434610][16591:16593] CHIP:DMG: } - [1689673213.434686][16591:16593] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689673213.434721][16591:16593] CHIP:TOO: OperationalState: { - [1689673213.434728][16591:16593] CHIP:TOO: OperationalStateID: 0 - [1689673213.434735][16591:16593] CHIP:TOO: } - disabled: true - - - label: - "Step 4: Manually put the DUT into a state wherein it can receive a - Start Command" - verification: | - - disabled: true - - - label: "Step 5: TH reads from the DUT the CountdownTime attribute" - PICS: OPSTATE.S.A0002 - verification: | - ./chip-tool operationalstate read countdown-time 1 1 - - Via the TH (chip-tool), verify: - - that CountdownTime attribute contains either null our a uint32 value - - if non-null, verify that the value is in the range 1 to 259200 - - store the value in 'initialcountdown-time' - - [1690457637.895405][18808:18810] CHIP:DMG: } - [1690457637.895474][18808:18810] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0002 DataVersion: 4112784416 - [1690457637.895503][18808:18810] CHIP:TOO: CountdownTime: null - disabled: true - - - label: "Step 6: TH sends Start command to the DUT" - PICS: OPSTATE.S.C02.Rsp && OPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674637.555734][17326:17328] CHIP:DMG: - [1689674637.555742][17326:17328] CHIP:DMG: InteractionModelRevision = 1 - [1689674637.555751][17326:17328] CHIP:DMG: }, - [1689674637.555784][17326:17328] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674637.555805][17326:17328] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674637.555853][17326:17328] CHIP:TOO: OperationalCommandResponse: { - [1689674637.555862][17326:17328] CHIP:TOO: commandResponseState: { - [1689674637.555872][17326:17328] CHIP:TOO: ErrorStateID: 0 - [1689674637.555883][17326:17328] CHIP:TOO: } - disabled: true - - - label: "Step 7: TH waits for {PIXIT.WAITTIME}" - verification: | - - disabled: true - - - label: "Step 8: TH reads from the DUT the OperationalState attribute" - PICS: OPSTATE.S.A0004 - verification: | - ./chip-tool operationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x01 (Running) - - [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 - [1689674196.878727][17249:17251] CHIP:DMG: } - [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { - [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 - [1689674196.878847][17249:17251] CHIP:TOO: } - disabled: true - - - label: "Step 9: TH waits for initial-countdown-time" - verification: | - As the initial-countdown-time in null this test cannot be executed further in case of RPI platform. - Note: The below log are for instructional purpose. In real scenarios, the actual log may vary depending on the feature implementation in the Reference App. - disabled: true - - - label: "Step 10: TH sends Stop command to the DUT" - PICS: OPSTATE.S.C01.Rsp && OPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate stop 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674653.322963][17330:17332] CHIP:DMG: }, - [1689674653.322994][17330:17332] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674653.323014][17330:17332] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674653.323058][17330:17332] CHIP:TOO: OperationalCommandResponse: { - [1689674653.323066][17330:17332] CHIP:TOO: commandResponseState: { - [1689674653.323076][17330:17332] CHIP:TOO: ErrorStateID: 0 - [1689674653.323085][17330:17332] CHIP:TOO: } - [1689674653.323094][17330:17332] CHIP:TOO: } - disabled: true - - - label: - "Step 11: erify TH receives an OperationCompletion event from the DUT - with the following fields populated as follows: 1)CompletionErrorCode - set to NoError(0x00) 2)TotalOperationalTime is approximately - initial-countdown-time or null 3)PausedTime is zero" - PICS: OPSTATE.S.E01 - verification: | - operationalstate read-event operation-completion 1 1 - - [1657193007.841358][5422:5427] CHIP:TOO: Endpoint: 0 Endpoint: 1 Cluster: 0x0000_0060 Event 0x0000_0001 - [1657193007.841387][5422:5427] CHIP:TOO: Event number: 1 - [1657193007.841409][5422:5427] CHIP:TOO: Priority: INFO - [1657193007.841431][5422:5427] CHIP:TOO: Timestamp: 132146 - [1657193007.841531][5422:5427] CHIP:TOO: OperationCompletion: { - [1657193007.841570][5422:5427] CHIP:TOO: CompletionErrorCode: 0x00 - TotalOperationalTime: null - PausedTime: 0 - [1657193007.841594][5422:5427] CHIP:TOO: } - disabled: true - - - label: "Step 12: TH reads from the DUT the OperationalState attribute" - PICS: OPSTATE.S.A0004 - verification: | - ./chip-tool operationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x00 (Stopped) - - [1689674675.459656][17333:17335] CHIP:DMG: } - [1689674675.459738][17333:17335] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674675.459772][17333:17335] CHIP:TOO: OperationalState: { - [1689674675.459790][17333:17335] CHIP:TOO: OperationalStateID: 0 - [1689674675.459799][17333:17335] CHIP:TOO: } - disabled: true - - - label: "Step 13: Restart DUT and repeat step 5" - verification: | - - disabled: true - - - label: "Step 14: TH sends Start command to the DUT" - PICS: OPSTATE.S.C02.Rsp && OPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate start 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674637.555734][17326:17328] CHIP:DMG: - [1689674637.555742][17326:17328] CHIP:DMG: InteractionModelRevision = 1 - [1689674637.555751][17326:17328] CHIP:DMG: }, - [1689674637.555784][17326:17328] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674637.555805][17326:17328] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674637.555853][17326:17328] CHIP:TOO: OperationalCommandResponse: { - [1689674637.555862][17326:17328] CHIP:TOO: commandResponseState: { - [1689674637.555872][17326:17328] CHIP:TOO: ErrorStateID: 0 - [1689674637.555883][17326:17328] CHIP:TOO: } - [1689674637.555891][17326:17328] CHIP:TOO: } - disabled: true - - - label: "Step 15: TH waits for {PIXIT.WAITTIME}" - verification: | - - disabled: true - - - label: "Step 16: TH reads from the DUT the OperationalState attribute" - PICS: OPSTATE.S.A0004 - verification: | - ./chip-tool operationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x01 (Running) - - [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 - [1689674196.878727][17249:17251] CHIP:DMG: } - [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { - [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 - [1689674196.878847][17249:17251] CHIP:TOO: } - disabled: true - - - label: "Step 17: TH sends Pause command to the DUT" - PICS: OPSTATE.S.C00.Rsp && OPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate pause 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1690457565.893634][18795:18797] CHIP:DMG: }, - [1690457565.893663][18795:18797] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1690457565.893681][18795:18797] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1690457565.893714][18795:18797] CHIP:TOO: OperationalCommandResponse: { - [1690457565.893729][18795:18797] CHIP:TOO: commandResponseState: { - [1690457565.893736][18795:18797] CHIP:TOO: ErrorStateID: 0 - [1690457565.893744][18795:18797] CHIP:TOO: } - [1690457565.893750][18795:18797] CHIP:TOO: } - disabled: true - - - label: "Step 18: TH reads from the DUT the OperationalState attribute" - PICS: OPSTATE.S.A0004 - verification: | - ./chip-tool operationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x02 (Paused) - - [1690457601.103082][18800:18802] CHIP:DMG: InteractionModelRevision = 1 - [1690457601.103090][18800:18802] CHIP:DMG: } - [1690457601.103210][18800:18802] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 4112784416 - [1690457601.103259][18800:18802] CHIP:TOO: OperationalState: 2 - disabled: true - - - label: "Step 19: TH waits for half of initial-countdown-time" - verification: | - - disabled: true - - - label: "Step 20: TH sends Resume command to the DUT" - PICS: OPSTATE.S.C03.Rsp && OPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate resume 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x03 (CommandInvalidInState) - - [1690457852.049135][18877:18879] CHIP:DMG: }, - [1690457852.049164][18877:18879] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1690457852.049183][18877:18879] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1690457852.049217][18877:18879] CHIP:TOO: OperationalCommandResponse: { - [1690457852.049224][18877:18879] CHIP:TOO: commandResponseState: { - [1690457852.049238][18877:18879] CHIP:TOO: ErrorStateID: 3 - [1690457852.049246][18877:18879] CHIP:TOO: } - [1690457852.049252][18877:18879] CHIP:TOO: } - disabled: true - - - label: "Step 21: TH reads from the DUT the OperationalState attribute" - PICS: OPSTATE.S.A0004 - verification: | - ./chip-tool operationalstate read operational-state 1 1 - - Via the TH (chip-tool), verify: - - the response has an OperationalStateID field that is set to 0x01 (Running) - - [1689674196.878722][17249:17251] CHIP:DMG: InteractionModelRevision = 1 - [1689674196.878727][17249:17251] CHIP:DMG: } - [1689674196.878800][17249:17251] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Attribute 0x0000_0004 DataVersion: 2102885775 - [1689674196.878834][17249:17251] CHIP:TOO: OperationalState: { - [1689674196.878841][17249:17251] CHIP:TOO: OperationalStateID: 1 - [1689674196.878847][17249:17251] CHIP:TOO: } - disabled: true - - - label: "Step 22: TH waits for initial-countdown-time" - verification: | - TH waits for initial-countdown-time - disabled: true - - - label: "Step 23: TH sends Stop command to the DUT" - PICS: OPSTATE.S.C01.Rsp && OPSTATE.S.C04.Tx - verification: | - ./chip-tool operationalstate stop 1 1 - - Via the TH (chip-tool), verify: - - the response is an instance of OperationalCommandResponse - - The ErrorStateID field is set to 0x00 (NoError) - - [1689674653.322963][17330:17332] CHIP:DMG: }, - [1689674653.322994][17330:17332] CHIP:DMG: Received Command Response Data, Endpoint=1 Cluster=0x0000_0060 Command=0x0000_0004 - [1689674653.323014][17330:17332] CHIP:TOO: Endpoint: 1 Cluster: 0x0000_0060 Command 0x0000_0004 - [1689674653.323058][17330:17332] CHIP:TOO: OperationalCommandResponse: { - [1689674653.323066][17330:17332] CHIP:TOO: commandResponseState: { - [1689674653.323076][17330:17332] CHIP:TOO: ErrorStateID: 0 - [1689674653.323085][17330:17332] CHIP:TOO: } - [1689674653.323094][17330:17332] CHIP:TOO: } - disabled: true - - - label: - "Step 24: Verify TH receives an OperationCompletion event with the - following fields populated as follows: 1. CompletionErrorCode set to - NoError(0x00) 2. TotalOperationalTime is approximately 1.5 times the - initial-countdown-time or null 3. PausedTime is 0.5 times the - initial-countdown-time" - PICS: OPSTATE.S.E01 - verification: | - operationalstate read-event operation-completion 1 1 - - [1657193007.841358][5422:5427] CHIP:TOO: Endpoint: 0 Endpoint: 1 Cluster: 0x0000_0060 Event 0x0000_0001 - [1657193007.841387][5422:5427] CHIP:TOO: Event number: 1 - [1657193007.841409][5422:5427] CHIP:TOO: Priority: INFO - [1657193007.841431][5422:5427] CHIP:TOO: Timestamp: 155146 - [1657193007.841531][5422:5427] CHIP:TOO: OperationCompletion: { - [1657193007.841570][5422:5427] CHIP:TOO: CompletionErrorCode: 0x00 - TotalOperationalTime: null - } - disabled: true diff --git a/src/app/tests/suites/ciTests.json b/src/app/tests/suites/ciTests.json index 9594ea623d1717..cbd655299f8422 100644 --- a/src/app/tests/suites/ciTests.json +++ b/src/app/tests/suites/ciTests.json @@ -177,7 +177,6 @@ "Test_TC_OO_2_2", "Test_TC_OO_2_4" ], - "OperationalState": ["Test_TC_OPSTATE_1_1", "Test_TC_OPSTATE_2_4"], "PowerSource": ["Test_TC_PS_1_1", "Test_TC_PS_2_1"], "PressureMeasurement": [ "Test_TC_PRS_1_1", diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index 0263fc258b8db0..4053fe4192cade 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -276,7 +276,6 @@ "LevelControl": [], "LaundryWasherMode": ["Test_TC_LWM_1_2"], "OnOff": ["Test_TC_OO_2_3"], - "OperationalState": ["Test_TC_OPSTATE_2_2", "Test_TC_OPSTATE_2_5"], "RelativeHumidityMeasurement": ["Test_TC_RH_2_2"], "SmokeCOAlarm": [], "RefrigeratorAlarm": ["Test_TC_REFALM_2_2", "Test_TC_REFALM_2_3"], From fee6488f95e850dd8f153b45c12c2f43231dfde8 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 12:30:10 -0300 Subject: [PATCH 76/89] fixes according test plan update --- .github/workflows/tests.yaml | 4 +-- src/python_testing/TC_OpstateCommon.py | 40 ++++++++++++++------------ 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index 96677011889014..d5c64e3a0c459d 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -514,8 +514,8 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/TestTimeSyncTrustedTimeSourceRunner.py' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_1_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_2.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_3.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_2.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.COUNTDOWN:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_3.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.COUNTDOWN:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_4.py" --script-args "--endpoint 1 --int-arg PIXIT.OVENOPSTATE.ErrorEventGen:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - name: Uploading core files uses: actions/upload-artifact@v4 diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index ef56b3a45ce932..0f258857a997bc 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -486,7 +486,7 @@ def STEPS_TC_OPSTATE_BASE_2_2(self) -> list[TestStep]: TestStep(7, "TH reads from the DUT the CountdownTime attribute"), TestStep(8, "TH reads from the DUT the PhaseList attribute"), TestStep(9, "TH reads from the DUT the CurrentPhase attribute"), - TestStep(10, "TH waits for a vendor defined wait time, this being a period of time less than the expected duration of the operation that has been started"), + TestStep(10, "TH waits for {PIXIT.WAITTIME.COUNTDOWN}"), TestStep(11, "TH reads from the DUT the CountdownTime attribute"), TestStep(12, "TH sends Start command to the DUT"), TestStep(13, "TH sends Stop command to the DUT"), @@ -504,14 +504,14 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): self.init_test() - asserts.assert_true('PIXIT.WAITTIME' in self.matter_test_config.global_test_params, - "PIXIT.WAITTIME must be included on the command line in " - "the --int-arg flag as PIXIT.WAITTIME:") + asserts.assert_true('PIXIT.WAITTIME.COUNTDOWN' in self.matter_test_config.global_test_params, + "PIXIT.WAITTIME.COUNTDOWN must be included on the command line in " + "the --int-arg flag as PIXIT.WAITTIME.COUNTDOWN:") - wait_time = self.matter_test_config.global_test_params['PIXIT.WAITTIME'] + wait_time = self.matter_test_config.global_test_params['PIXIT.WAITTIME.COUNTDOWN'] if wait_time == 0: - asserts.fail("PIXIT.WAITTIME shall be higher than 0.") + asserts.fail("PIXIT.WAITTIME.COUNTDOWN shall be higher than 0.") # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) self.step(1) @@ -520,8 +520,9 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): self.step(2) self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % (self.device, cluster.Enums.ErrorStateEnum.kNoError)) - time.sleep(1) - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) + if self.is_ci: + time.sleep(1) + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) # STEP 3: TH reads from the DUT the OperationalStateList attribute self.step(3) @@ -592,7 +593,7 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): asserts.assert_true(0 <= current_phase and current_phase < phase_list_len, "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) - # STEP 10: TH waits for a vendor defined wait time, this being a period of time less than the expected duration of the operation that has been started + # STEP 10: TH waits for {PIXIT.WAITTIME.COUNTDOWN} self.step(10) if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): time.sleep(wait_time) @@ -664,7 +665,7 @@ def STEPS_TC_OPSTATE_BASE_2_3(self) -> list[TestStep]: TestStep(4, "TH sends Pause command to the DUT"), TestStep(5, "TH reads from the DUT the OperationalState attribute"), TestStep(6, "TH reads from the DUT the CountdownTime attribute"), - TestStep(7, "TH waits for 5 seconds"), + TestStep(7, "TH waits for {PIXIT.WAITTIME.COUNTDOWN}"), TestStep(8, "TH reads from the DUT the CountdownTime attribute"), TestStep(9, "TH sends Pause command to the DUT"), TestStep(10, "TH sends Resume command to the DUT"), @@ -686,14 +687,14 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): self.init_test() - asserts.assert_true('PIXIT.WAITTIME' in self.matter_test_config.global_test_params, - "PIXIT.WAITTIME must be included on the command line in " - "the --int-arg flag as PIXIT.WAITTIME:") + asserts.assert_true('PIXIT.WAITTIME.COUNTDOWN' in self.matter_test_config.global_test_params, + "PIXIT.WAITTIME.COUNTDOWN must be included on the command line in " + "the --int-arg flag as PIXIT.WAITTIME.COUNTDOWN:") - wait_time = self.matter_test_config.global_test_params['PIXIT.WAITTIME'] + wait_time = self.matter_test_config.global_test_params['PIXIT.WAITTIME.COUNTDOWN'] if wait_time == 0: - asserts.fail("PIXIT.WAITTIME shall be higher than 0.") + asserts.fail("PIXIT.WAITTIME.COUNTDOWN shall be higher than 0.") # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) self.step(1) @@ -702,8 +703,9 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): self.step(2) self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % (self.device, cluster.Enums.ErrorStateEnum.kNoError)) - time.sleep(1) - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Start"}' % self.device) + if self.is_ci: + time.sleep(1) + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Start"}' % self.device) # STEP 3: TH reads from the DUT the OperationalStateList attribute self.step(3) @@ -744,9 +746,9 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): asserts.assert_true(0 <= initial_countdown_time <= 259200, "CountdownTime(%s) must be between 0 and 259200" % initial_countdown_time) - # STEP 7: TH waits for 5 seconds + # STEP 7: TH waits for {PIXIT.WAITTIME.COUNTDOWN} self.step(7) - time.sleep(5) + time.sleep(wait_time) # STEP 8: TH reads from the DUT the CountdownTime attribute self.step(8) From c3631467814fbd5bde1966b914c7f36cf5bf248d Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 20:49:34 -0300 Subject: [PATCH 77/89] Fixed missing test errors --- .../all-clusters-common/all-clusters-app.matter | 2 +- src/app/tests/suites/manualTests.json | 1 - 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter index 6dfeb7aecb8c58..870acd3ecaaacf 100644 --- a/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter +++ b/examples/all-clusters-app/all-clusters-common/all-clusters-app.matter @@ -8085,7 +8085,7 @@ endpoint 1 { callback attribute acceptedCommandList; callback attribute attributeList; ram attribute featureMap default = 0; - ram attribute clusterRevision default = 1; + ram attribute clusterRevision default = 2; handle command Pause; handle command Stop; diff --git a/src/app/tests/suites/manualTests.json b/src/app/tests/suites/manualTests.json index 4053fe4192cade..1c66bfccfbb9b0 100644 --- a/src/app/tests/suites/manualTests.json +++ b/src/app/tests/suites/manualTests.json @@ -353,7 +353,6 @@ "LaundryWasherMode", "OnOff", "OvenMode", - "OperationalState", "OvenMode", "RelativeHumidityMeasurement", "SmokeCOAlarm", From 86d6fbf34da3910c03985bd6c5c978846d0d863f Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 22:01:25 -0300 Subject: [PATCH 78/89] added countdown behavior to opstate --- .../include/operational-state-delegate-impl.h | 27 +++++++- .../src/operational-state-delegate-impl.cpp | 61 +++++++++++++++++++ 2 files changed, 87 insertions(+), 1 deletion(-) diff --git a/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h index 0bcb76f324a1da..9bd3cde7e5e19b 100644 --- a/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h +++ b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h @@ -33,11 +33,15 @@ namespace OperationalState { class GenericOperationalStateDelegateImpl : public Delegate { public: + uint32_t mRunningTime = 0; + uint32_t mPausedTime = 0; + app::DataModel::Nullable mCountDownTime; + /** * Get the countdown time. This attribute is not used in this application. * @return The current countdown time. */ - app::DataModel::Nullable GetCountdownTime() override { return {}; }; + app::DataModel::Nullable GetCountdownTime() override; /** * Fills in the provided GenericOperationalState with the state at index `index` if there is one, @@ -104,11 +108,32 @@ class OperationalStateDelegate : public GenericOperationalStateDelegateImpl GenericOperationalState(to_underlying(OperationalStateEnum::kError)), }; + const uint32_t kExampleCountDown = 30; public: OperationalStateDelegate() { GenericOperationalStateDelegateImpl::mOperationalStateList = Span(opStateList); } + + /** + * Handle Command Callback in application: Start + * @param[out] get operational error after callback. + */ + void HandleStartStateCallback(GenericOperationalError & err) override + { + mCountDownTime.SetNonNull(static_cast(kExampleCountDown)); + GenericOperationalStateDelegateImpl::HandleStartStateCallback(err); + } + + /** + * Handle Command Callback in application: Stop + * @param[out] get operational error after callback. + */ + void HandleStopStateCallback(GenericOperationalError & err) override + { + GenericOperationalStateDelegateImpl::HandleStopStateCallback(err); + mCountDownTime.SetNull(); + } }; Instance * GetOperationalStateInstance(); diff --git a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp index bc847c7db51e95..c85c9a3bc88417 100644 --- a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp @@ -16,6 +16,7 @@ * limitations under the License. */ #include +#include using namespace chip; using namespace chip::app; @@ -23,6 +24,16 @@ using namespace chip::app::Clusters; using namespace chip::app::Clusters::OperationalState; using namespace chip::app::Clusters::RvcOperationalState; +static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data); + +DataModel::Nullable GenericOperationalStateDelegateImpl::GetCountdownTime() +{ + if(mCountDownTime.IsNull()) + return DataModel::NullNullable; + + return DataModel::MakeNullable((uint32_t)(mCountDownTime.Value() - mRunningTime)); +} + CHIP_ERROR GenericOperationalStateDelegateImpl::GetOperationalStateAtIndex(size_t index, GenericOperationalState & operationalState) { if (index >= mOperationalStateList.size()) @@ -101,6 +112,7 @@ void GenericOperationalStateDelegateImpl::HandleStartStateCallback(GenericOperat auto error = GetInstance()->SetOperationalState(to_underlying(OperationalStateEnum::kRunning)); if (error == CHIP_NO_ERROR) { + (void) DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(1), onOperationalStateTimerTick, this); err.Set(to_underlying(ErrorStateEnum::kNoError)); } else @@ -115,6 +127,20 @@ void GenericOperationalStateDelegateImpl::HandleStopStateCallback(GenericOperati auto error = GetInstance()->SetOperationalState(to_underlying(OperationalStateEnum::kStopped)); if (error == CHIP_NO_ERROR) { + (void) DeviceLayer::SystemLayer().CancelTimer(onOperationalStateTimerTick, this); + + OperationalState::GenericOperationalError current_err(to_underlying(OperationalState::ErrorStateEnum::kNoError)); + GetInstance()->GetCurrentOperationalError(current_err); + + Optional> totalTime((DataModel::Nullable(mRunningTime + mPausedTime))); + Optional> pausedTime((DataModel::Nullable(mPausedTime))); + + GetInstance()->OnOperationCompletionDetected(static_cast(current_err.errorStateID), + totalTime, + pausedTime); + + mRunningTime = 0; + mPausedTime = 0; err.Set(to_underlying(ErrorStateEnum::kNoError)); } else @@ -123,6 +149,41 @@ void GenericOperationalStateDelegateImpl::HandleStopStateCallback(GenericOperati } } + +static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data) +{ + GenericOperationalStateDelegateImpl * delegate = reinterpret_cast(data); + + OperationalState::Instance * instance = OperationalState::GetOperationalStateInstance(); + OperationalState::OperationalStateEnum state = static_cast(instance->GetCurrentOperationalState()); + + auto countdown_time = delegate->GetCountdownTime(); + + if(countdown_time.IsNull() || + (!countdown_time.IsNull() && countdown_time.Value() > 0)) + { + if(state == OperationalState::OperationalStateEnum::kRunning) + { + delegate->mRunningTime++; + } + else if(state == OperationalState::OperationalStateEnum::kPaused) + { + delegate->mPausedTime++; + } + } + + if (state == OperationalState::OperationalStateEnum::kRunning || + state == OperationalState::OperationalStateEnum::kPaused) + { + (void) DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(1), onOperationalStateTimerTick, delegate); + } + else + { + (void) DeviceLayer::SystemLayer().CancelTimer(onOperationalStateTimerTick, delegate); + } +} + + // Init Operational State cluster static OperationalState::Instance * gOperationalStateInstance = nullptr; From 4609f794d2c20f2ffe1e999b9041860d0da36669 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 22:15:37 -0300 Subject: [PATCH 79/89] clean up command line linux --- .../all-clusters-app/linux/AllClustersCommandDelegate.cpp | 6 ------ 1 file changed, 6 deletions(-) diff --git a/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp b/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp index 3c0286020fc96e..03a9713fa49317 100644 --- a/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp +++ b/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp @@ -478,12 +478,6 @@ void AllClustersAppCommandHandler::OnOperationalStateChange(std::string device, OperationalState::GenericOperationalError err(event_id); operationalStateInstance->OnOperationalErrorDetected(err); } - else if (operation == "OnCompletion") - { - Optional> operationTime(DataModel::Nullable(100)); - Optional> pausedTime(DataModel::Nullable(10)); - operationalStateInstance->OnOperationCompletionDetected(0, operationTime, pausedTime); - } else { ChipLogDetail(NotSpecified, "Invalid operation : %s", operation.c_str()); From d39466accc7a429683c4fddeab3399a7df1258b7 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 22:15:54 -0300 Subject: [PATCH 80/89] Added TC 2.5 automated --- src/python_testing/TC_OPSTATE_2_5.py | 50 ++++ src/python_testing/TC_OVENOPSTATE_2_5.py | 50 ++++ src/python_testing/TC_OpstateCommon.py | 291 ++++++++++++++++++++++- 3 files changed, 387 insertions(+), 4 deletions(-) create mode 100644 src/python_testing/TC_OPSTATE_2_5.py create mode 100644 src/python_testing/TC_OVENOPSTATE_2_5.py diff --git a/src/python_testing/TC_OPSTATE_2_5.py b/src/python_testing/TC_OPSTATE_2_5.py new file mode 100644 index 00000000000000..134e3d4b0ed11a --- /dev/null +++ b/src/python_testing/TC_OPSTATE_2_5.py @@ -0,0 +1,50 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +import chip.clusters as Clusters +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo + + +class TC_OPSTATE_2_5(MatterBaseTest, TC_OPSTATE_BASE): + def __init__(self, *args): + super().__init__(*args) + + test_info = TestInfo( + pics_code="OPSTATE", + cluster=Clusters.OperationalState + ) + + super().setup_base(test_info=test_info) + + def steps_TC_OPSTATE_2_5(self) -> list[TestStep]: + return self.STEPS_TC_OPSTATE_BASE_2_5() + + def pics_TC_OPSTATE_2_5(self) -> list[str]: + return ["OPSTATE.S"] + + @async_test_body + async def test_TC_OPSTATE_2_5(self): + endpoint = self.matter_test_config.endpoint + + await self.TEST_TC_OPSTATE_BASE_2_5(endpoint=endpoint) + + +if __name__ == "__main__": + default_matter_test_main() + diff --git a/src/python_testing/TC_OVENOPSTATE_2_5.py b/src/python_testing/TC_OVENOPSTATE_2_5.py new file mode 100644 index 00000000000000..1ff284f73906be --- /dev/null +++ b/src/python_testing/TC_OVENOPSTATE_2_5.py @@ -0,0 +1,50 @@ +# +# Copyright (c) 2023 Project CHIP Authors +# All rights reserved. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + + +import chip.clusters as Clusters +from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo + + +class TC_OVENOPSTATE_2_5(MatterBaseTest, TC_OPSTATE_BASE): + def __init__(self, *args): + super().__init__(*args) + + test_info = TestInfo( + pics_code="OVENOPSTATE", + cluster=Clusters.OvenCavityOperationalState + ) + + super().setup_base(test_info=test_info) + + def steps_TC_OVENOPSTATE_2_5(self) -> list[TestStep]: + return self.STEPS_TC_OPSTATE_BASE_2_5() + + def pics_TC_OVENOPSTATE_2_5(self) -> list[str]: + return ["OVENOPSTATE.S"] + + @async_test_body + async def test_TC_OVENOPSTATE_2_5(self): + endpoint = self.matter_test_config.endpoint + + await self.TEST_TC_OPSTATE_BASE_2_5(endpoint=endpoint) + + +if __name__ == "__main__": + default_matter_test_main() + diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index 0f258857a997bc..d3c1aabb1d8c86 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -17,10 +17,13 @@ import logging import time +import queue import chip.clusters as Clusters +from chip.clusters import ClusterObjects as ClusterObjects +from chip.clusters.Attribute import EventReadResult, SubscriptionTransaction from chip.clusters.Types import NullValue -from chip.interaction_model import InteractionModelError +from chip.interaction_model import InteractionModelError, Status from mobly import asserts from dataclasses import dataclass from matter_testing_support import TestStep, EventChangeCallback @@ -44,6 +47,43 @@ class TestInfo: cluster: Clusters +class EventSpecificChangeCallback: + def __init__(self, expected_event: ClusterObjects.ClusterEvent): + """This class creates a queue to store received event callbacks, that can be checked by the test script + expected_event: is the expected event + """ + self._q = queue.Queue() + self._expected_cluster_id = expected_event.cluster_id + self._expected_event = expected_event + + async def start(self, dev_ctrl, node_id: int, endpoint: int): + """This starts a subscription for events on the specified node_id and endpoint. The event is specified when the class instance is created.""" + self._subscription = await dev_ctrl.ReadEvent(node_id, + events=[(endpoint, self._expected_event, True)], reportInterval=(1, 5), + fabricFiltered=False, keepSubscriptions=True, autoResubscribe=False) + self._subscription.SetEventUpdateCallback(self.__call__) + + def __call__(self, res: EventReadResult, transaction: SubscriptionTransaction): + """This is the subscription callback when an event is received. + It checks the if the event is the expected one and then posts it into the queue for later processing.""" + if res.Status == Status.Success and res.Header.ClusterId == self._expected_cluster_id and res.Header.EventId == self._expected_event.event_id: + logging.info( + f'Got subscription report for event {self._expected_event.event_id} on cluster {self._expected_cluster_id}: {res.Data}') + self._q.put(res) + + def wait_for_event_report(self, timeout: int = 10): + """This function allows a test script to block waiting for the specific event to arrive with a timeout. + It returns the event data so that the values can be checked.""" + try: + res = self._q.get(block=True, timeout=timeout) + except queue.Empty: + asserts.fail("Failed to receive a report for the event {}".format(self._expected_event)) + + asserts.assert_equal(res.Header.ClusterId, self._expected_cluster_id, "Expected cluster ID not found in event report") + asserts.assert_equal(res.Header.EventId, self._expected_event.event_id, "Expected event ID not found in event report") + return res.Data + + class TC_OPSTATE_BASE(): def setup_base(self, test_info=None, app_pipe="/tmp/chip_all_clusters_fifo_"): @@ -605,9 +645,9 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): attribute=attributes.CountdownTime) if (countdown_time is not NullValue) and (initial_countdown_time is not NullValue): - difference = (countdown_time - initial_countdown_time) - asserts.assert_greater(difference, wait_time, - "The countdown time shall have decreased at least %s since start command" % wait_time) + difference = abs(countdown_time - initial_countdown_time) + asserts.assert_greater_equal(difference, wait_time, + "The countdown time shall have decreased at least %s since start command" % wait_time) # STEP 12: TH sends Start command to the DUT self.step(12) @@ -898,3 +938,246 @@ async def TEST_TC_OPSTATE_BASE_2_4(self, endpoint=1): self.skip_step(3) self.skip_step(4) + ############################ + # TEST CASE 2.5 + ############################ + def STEPS_TC_OPSTATE_BASE_2_5(self) -> list[TestStep]: + steps = [TestStep(1, "Commissioning, already done", is_commissioning=True), + TestStep(2, "Set up a subscription to the OperationCompletion event"), + TestStep(3, "Manually put the DUT into a state wherein it can receive a Start Command"), + TestStep(4, "TH sends Start command to the DUT"), + TestStep(5, "TH reads from the DUT the CountdownTime attribute"), + TestStep(6, "TH reads from the DUT the OperationalState attribute"), + TestStep(7, "TH waits for initial-countdown-time"), + TestStep(8, "TH sends Stop command to the DUT"), + TestStep(9, "TH waits for OperationCompletion event"), + TestStep(10, "TH reads from the DUT the OperationalState attribute"), + TestStep(11, "Restart DUT"), + TestStep(12, "TH waits for {PIXIT.WAITTIME.REBOOT}"), + TestStep(13, "TH sends Start command to the DUT"), + TestStep(14, "TH reads from the DUT the OperationalState attribute"), + TestStep(15, "TH sends Pause command to the DUT"), + TestStep(16, "TH reads from the DUT the OperationalState attribute"), + TestStep(17, "TH waits for half of initial-countdown-time"), + TestStep(18, "TH sends Resume command to the DUT"), + TestStep(19, "TH reads from the DUT the OperationalState attribute"), + TestStep(20, "TH waits for initial-countdown-time"), + TestStep(21, "TH sends Stop command to the DUT"), + TestStep(22, "TH waits for OperationCompletion event") + ] + return steps + + async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1): + cluster = self.test_info.cluster + attributes = cluster.Attributes + commands = cluster.Commands + events = cluster.Events + + self.init_test() + + asserts.assert_true('PIXIT.WAITTIME.REBOOT' in self.matter_test_config.global_test_params, + "PIXIT.WAITTIME.REBOOT must be included on the command line in " + "the --int-arg flag as PIXIT.WAITTIME.REBOOT:") + + wait_time_reboot = self.matter_test_config.global_test_params['PIXIT.WAITTIME.REBOOT'] + + if wait_time_reboot == 0: + asserts.fail("PIXIT.WAITTIME.REBOOT shall be higher than 0.") + + # STEP 1: Commission DUT to TH (can be skipped if done in a preceding test) + self.step(1) + + # STEP 2: Set up a subscription to the OperationCompletion event + self.step(2) + if self.pics_guard(self.check_pics("%s.S.E01" % self.test_info.pics_code)): + # Subscribe to Events and when they are sent push them to a queue for checking later + events_callback = EventSpecificChangeCallback(events.OperationCompletion) + await events_callback.start(self.default_controller, + self.dut_node_id, + endpoint) + + # STEP 3: Manually put the DUT into a state wherein it can receive a Start Command + self.step(3) + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % + (self.device, cluster.Enums.ErrorStateEnum.kNoError)) + if self.is_ci: + time.sleep(1) + self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) + + # STEP 4: TH sends Start command to the DUT + self.step(4) + if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Start(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 5: TH reads from the DUT the CountdownTime attribute + self.step(5) + if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + initial_countdown_time = await self.read_expect_success(endpoint=endpoint, + attribute=attributes.CountdownTime) + + if initial_countdown_time is not NullValue: + # STEP 6: TH reads from the DUT the OperationalState attribute + self.step(6) + if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kRunning) + + # STEP 7: TH waits for initial-countdown-time + self.step(7) + time.sleep(initial_countdown_time) + + # STEP 8: TH sends Stop command to the DUT + self.step(8) + if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Stop(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 9: TH waits for OperationCompletion event + self.step(9) + if self.pics_guard(self.check_pics("%s.S.E01" % self.test_info.pics_code)): + event_data = events_callback.wait_for_event_report() + + asserts.assert_equal(event_data.completionErrorCode, cluster.Enums.ErrorStateEnum.kNoError, + "Completion event error code different than expected. Expected %s, received %s" % + (cluster.Enums.ErrorStateEnum.kNoError, event_data.completionErrorCode)) + + if event_data.totalOperationalTime is not NullValue: + # Checks if the total operation time is close to initial_countdown_time + # 'close' is being determined by having a difference lower / equal 2 + difference = abs(event_data.totalOperationalTime - initial_countdown_time) + asserts.assert_less_equal(difference, 2, + "Total operation time (%s) shall be close to the initial coutdown time (%s)" % + (event_data.totalOperationalTime, initial_countdown_time)) + + asserts.assert_equal(event_data.pausedTime, 0, + "Completion event paused time expected to be zero, received %s" % + event_data.pausedTime) + + # STEP 10: TH reads from the DUT the OperationalState attribute + self.step(10) + if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kStopped) + + # STEP 11: Restart DUT + self.step(11) + # In CI environment, the STOP coommand (step 8) already resets the variables. Only ask for + # reboot outside CI environment. + if not self.is_ci: + input("Press Enter when done.\n") + + # STEP 12: TH waits for {PIXIT.WAITTIME.REBOOT} + self.step(12) + time.sleep(wait_time_reboot) + + # STEP 13: TH sends Start command to the DUT + self.step(13) + if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Start(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 14: TH reads from the DUT the OperationalState attribute + self.step(14) + if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kRunning) + + # STEP 15: TH sends Pause command to the DUT + self.step(15) + if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Pause(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 16: TH reads from the DUT the OperationalState attribute + self.step(16) + if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kPaused) + + # STEP 17: TH waits for half of initial-countdown-time + self.step(17) + time.sleep((initial_countdown_time / 2)) + + # STEP 18: TH sends Resume command to the DUT + self.step(18) + if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Resume(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 19: TH reads from the DUT the OperationalState attribute + self.step(19) + if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + await self.read_and_expect_value(endpoint=endpoint, + attribute=attributes.OperationalState, + expected_value=cluster.Enums.OperationalStateEnum.kRunning) + + # STEP 20: TH waits for initial-countdown-time + self.step(20) + time.sleep(initial_countdown_time) + + # STEP 21: TH sends Stop command to the DUT + self.step(21) + if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and + self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + await self.send_cmd_expect_response(endpoint=endpoint, + cmd=commands.Stop(), + expected_response=cluster.Enums.ErrorStateEnum.kNoError) + + # STEP 22: TH waits for OperationCompletion event + self.step(22) + if self.pics_guard(self.check_pics("%s.S.E01" % self.test_info.pics_code)): + event_data = events_callback.wait_for_event_report() + + asserts.assert_equal(event_data.completionErrorCode, cluster.Enums.ErrorStateEnum.kNoError, + "Completion event error code different than expected. Expected %s, received %s" % + (cluster.Enums.ErrorStateEnum.kNoError, event_data.completionErrorCode)) + + if event_data.totalOperationalTime is not NullValue: + # Checks if the total operation time is close to 1.5 * initial_countdown_time + # 'close' is being determined by having a difference lower / equal 2 + expected_value = (1.5 * initial_countdown_time) + difference = abs(event_data.totalOperationalTime - expected_value) + asserts.assert_less_equal(difference, 2, + "Total operation time (%s) shall be close to 1.5 times the initial coutdown time (%s)" % + (event_data.totalOperationalTime, initial_countdown_time)) + + # Checks if the paused operation time is close to 0.5 * initial_countdown_time + # 'close' is being determined by having a difference lower / equal 2 + expected_value = (0.5 * initial_countdown_time) + difference = abs(event_data.pausedTime - expected_value) + asserts.assert_less_equal(difference, 2, + "Paused time (%s) shall be close to half of the initial coutdown time (%s)" % + (event_data.pausedTime, expected_value)) + else: + self.skip_step(6) + self.skip_step(7) + self.skip_step(8) + self.skip_step(9) + self.skip_step(10) + self.skip_step(11) + self.skip_step(12) + self.skip_step(13) + self.skip_step(14) + self.skip_step(15) + self.skip_step(16) + self.skip_step(17) + self.skip_step(18) + self.skip_step(19) + self.skip_step(20) + self.skip_step(21) + self.skip_step(22) From ed94778b42ace16b3d48105a0b6ebc15b9c8b1c9 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 22:16:15 -0300 Subject: [PATCH 81/89] Added OPSTATE and OVENOPSTATE to CI --- .github/workflows/tests.yaml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/tests.yaml b/.github/workflows/tests.yaml index d5c64e3a0c459d..b76369356eaf8f 100644 --- a/.github/workflows/tests.yaml +++ b/.github/workflows/tests.yaml @@ -512,11 +512,18 @@ jobs: scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestMatterTestingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --script "src/python_testing/TestSpecParsingSupport.py" --script-args "--trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/TestTimeSyncTrustedTimeSourceRunner.py' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OPSTATE_1_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OPSTATE_2_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OPSTATE_2_2.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.COUNTDOWN:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OPSTATE_2_3.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.COUNTDOWN:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OPSTATE_2_4.py" --script-args "--endpoint 1 --int-arg PIXIT.OPSTATE.ErrorEventGen:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OPSTATE_2_5.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.REBOOT:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_1_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_1.py" --script-args "--endpoint 1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_2.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.COUNTDOWN:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_3.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.COUNTDOWN:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_4.py" --script-args "--endpoint 1 --int-arg PIXIT.OVENOPSTATE.ErrorEventGen:1 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' + scripts/run_in_python_env.sh out/venv './scripts/tests/run_python_test.py --app out/linux-x64-all-clusters-ipv6only-no-ble-no-wifi-tsan-clang-test/chip-all-clusters-app --factoryreset --app-args "--discriminator 1234 --KVS kvs1 --trace-to json:out/trace_data/app-{SCRIPT_BASE_NAME}.json" --script "src/python_testing/TC_OVENOPSTATE_2_5.py" --script-args "--endpoint 1 --int-arg PIXIT.WAITTIME.REBOOT:5 --storage-path admin_storage.json --commissioning-method on-network --discriminator 1234 --passcode 20202021 --PICS src/app/tests/suites/certification/ci-pics-values --trace-to json:out/trace_data/test-{SCRIPT_BASE_NAME}.json --trace-to perfetto:out/trace_data/test-{SCRIPT_BASE_NAME}.perfetto"' - name: Uploading core files uses: actions/upload-artifact@v4 if: ${{ failure() && !env.ACT }} From c0bbf43fa267737892a21b7ddc51df8da99415a6 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Mon, 12 Feb 2024 22:48:08 -0300 Subject: [PATCH 82/89] fixed according review --- .../src/oven-operational-state-delegate.cpp | 4 ---- src/python_testing/TC_OPSTATE_1_1.py | 2 +- src/python_testing/TC_OPSTATE_2_1.py | 2 +- src/python_testing/TC_OPSTATE_2_2.py | 2 +- src/python_testing/TC_OPSTATE_2_3.py | 2 +- src/python_testing/TC_OPSTATE_2_4.py | 2 +- src/python_testing/TC_OPSTATE_2_5.py | 2 +- src/python_testing/TC_OVENOPSTATE_1_1.py | 2 +- src/python_testing/TC_OVENOPSTATE_2_1.py | 2 +- src/python_testing/TC_OVENOPSTATE_2_2.py | 2 +- src/python_testing/TC_OVENOPSTATE_2_3.py | 2 +- src/python_testing/TC_OVENOPSTATE_2_4.py | 2 +- src/python_testing/TC_OVENOPSTATE_2_5.py | 2 +- src/python_testing/TC_OpstateCommon.py | 12 +++++++----- 14 files changed, 19 insertions(+), 21 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp index 9d07727b68f247..23f732bbe62d3a 100644 --- a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp @@ -91,7 +91,6 @@ void OvenCavityOperationalStateDelegate::HandlePauseStateCallback(OperationalSta return; } - // placeholder implementation auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kPaused)); if (error == CHIP_NO_ERROR) { @@ -114,7 +113,6 @@ void OvenCavityOperationalStateDelegate::HandleResumeStateCallback(OperationalSt return; } - // placeholder implementation auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)); if (error == CHIP_NO_ERROR) { @@ -137,7 +135,6 @@ void OvenCavityOperationalStateDelegate::HandleStartStateCallback(OperationalSta return; } - // placeholder implementation auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kRunning)); if (error == CHIP_NO_ERROR) { @@ -151,7 +148,6 @@ void OvenCavityOperationalStateDelegate::HandleStartStateCallback(OperationalSta void OvenCavityOperationalStateDelegate::HandleStopStateCallback(OperationalState::GenericOperationalError & err) { - // placeholder implementation auto error = GetInstance()->SetOperationalState(to_underlying(OperationalState::OperationalStateEnum::kStopped)); if (error == CHIP_NO_ERROR) { diff --git a/src/python_testing/TC_OPSTATE_1_1.py b/src/python_testing/TC_OPSTATE_1_1.py index 1c5ff1f3f28781..49f88ec54e4c8b 100644 --- a/src/python_testing/TC_OPSTATE_1_1.py +++ b/src/python_testing/TC_OPSTATE_1_1.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OPSTATE_2_1.py b/src/python_testing/TC_OPSTATE_2_1.py index 3e0dc46c4ada23..14dc08b23863c6 100644 --- a/src/python_testing/TC_OPSTATE_2_1.py +++ b/src/python_testing/TC_OPSTATE_2_1.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OPSTATE_2_2.py b/src/python_testing/TC_OPSTATE_2_2.py index b490d71f9a28a3..e2d17926ceb2a1 100644 --- a/src/python_testing/TC_OPSTATE_2_2.py +++ b/src/python_testing/TC_OPSTATE_2_2.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OPSTATE_2_3.py b/src/python_testing/TC_OPSTATE_2_3.py index c7e30b4e814ab9..27a3dae081eb21 100644 --- a/src/python_testing/TC_OPSTATE_2_3.py +++ b/src/python_testing/TC_OPSTATE_2_3.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OPSTATE_2_4.py b/src/python_testing/TC_OPSTATE_2_4.py index 12ecf17e65387a..5e86ac8118ca20 100644 --- a/src/python_testing/TC_OPSTATE_2_4.py +++ b/src/python_testing/TC_OPSTATE_2_4.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OPSTATE_2_5.py b/src/python_testing/TC_OPSTATE_2_5.py index 134e3d4b0ed11a..fd34bebaeca423 100644 --- a/src/python_testing/TC_OPSTATE_2_5.py +++ b/src/python_testing/TC_OPSTATE_2_5.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OVENOPSTATE_1_1.py b/src/python_testing/TC_OVENOPSTATE_1_1.py index 0f0773522d47f6..3b724a826f39aa 100644 --- a/src/python_testing/TC_OVENOPSTATE_1_1.py +++ b/src/python_testing/TC_OVENOPSTATE_1_1.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index e0a401354b0e18..9c353d2a7a3b9e 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OVENOPSTATE_2_2.py b/src/python_testing/TC_OVENOPSTATE_2_2.py index d014e068a5e35d..cbad9741410950 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_2.py +++ b/src/python_testing/TC_OVENOPSTATE_2_2.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py index d26f15abdec3ee..e3074cf0eef765 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_3.py +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OVENOPSTATE_2_4.py b/src/python_testing/TC_OVENOPSTATE_2_4.py index 5279e6ec70b796..41bacdeba7ae55 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_4.py +++ b/src/python_testing/TC_OVENOPSTATE_2_4.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OVENOPSTATE_2_5.py b/src/python_testing/TC_OVENOPSTATE_2_5.py index 1ff284f73906be..e8141bcb515717 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_5.py +++ b/src/python_testing/TC_OVENOPSTATE_2_5.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index d3c1aabb1d8c86..c3a714d9cb0d51 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -1,5 +1,5 @@ # -# Copyright (c) 2023 Project CHIP Authors +# Copyright (c) 2024 Project CHIP Authors # All rights reserved. # # Licensed under the Apache License, Version 2.0 (the "License"); @@ -624,14 +624,16 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): # STEP 9: TH reads from the DUT the CurrentPhase attribute self.step(9) - if self.pics_guard(self.check_pics("%s.S.A0001" % self.test_info.pics_code) and phase_list_len): + if self.pics_guard(self.check_pics("%s.S.A0001" % self.test_info.pics_code)): current_phase = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CurrentPhase) if (phase_list == NullValue) or (not phase_list): - asserts.assert_true(current_phase == NullValue, "CurrentPhase(%s) should be null" % current_phase) + asserts.assert_equal(current_phase, NullValue, "CurrentPhase(%s) should be null" % current_phase) else: - asserts.assert_true(0 <= current_phase and current_phase < phase_list_len, - "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) + asserts.assert_less_equal(0, current_phase, + "CurrentPhase(%s) must be greater or equal than 0" % current_phase) + asserts.assert_less(current_phase < phase_list_len, + "CurrentPhase(%s) must be less then %s" % (current_phase, (phase_list_len - 1))) # STEP 10: TH waits for {PIXIT.WAITTIME.COUNTDOWN} self.step(10) From 6581ab7d206f95fc7e649415e0fb152f3696a583 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 13 Feb 2024 01:48:42 +0000 Subject: [PATCH 83/89] Restyled by whitespace --- .../all-clusters-common/src/oven-operational-state-delegate.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp index 23f732bbe62d3a..d98e732788d7c6 100644 --- a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp @@ -157,4 +157,4 @@ void OvenCavityOperationalStateDelegate::HandleStopStateCallback(OperationalStat { err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToCompleteOperation)); } -} \ No newline at end of file +} From 018ba5d575525b46f844020eac015f69040d88b1 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 13 Feb 2024 01:48:44 +0000 Subject: [PATCH 84/89] Restyled by clang-format --- .../include/operational-state-delegate-impl.h | 3 +- .../include/oven-operational-state-delegate.h | 3 +- .../src/operational-state-delegate-impl.cpp | 37 +++++++++---------- .../src/oven-operational-state-delegate.cpp | 16 ++++---- .../linux/AllClustersCommandDelegate.cpp | 8 ++-- 5 files changed, 34 insertions(+), 33 deletions(-) diff --git a/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h index 9bd3cde7e5e19b..c4152ac8955120 100644 --- a/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h +++ b/examples/all-clusters-app/all-clusters-common/include/operational-state-delegate-impl.h @@ -34,7 +34,7 @@ class GenericOperationalStateDelegateImpl : public Delegate { public: uint32_t mRunningTime = 0; - uint32_t mPausedTime = 0; + uint32_t mPausedTime = 0; app::DataModel::Nullable mCountDownTime; /** @@ -109,6 +109,7 @@ class OperationalStateDelegate : public GenericOperationalStateDelegateImpl }; const uint32_t kExampleCountDown = 30; + public: OperationalStateDelegate() { diff --git a/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h b/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h index dc2bc4e72461dd..5a0b5cd0054a26 100644 --- a/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h +++ b/examples/all-clusters-app/all-clusters-common/include/oven-operational-state-delegate.h @@ -40,7 +40,8 @@ class OvenCavityOperationalStateDelegate : public OperationalState::Delegate OperationalState::GenericOperationalState(to_underlying(OperationalState::OperationalStateEnum::kError)) }; - Span mOperationalStateList = Span(opStateList); + Span mOperationalStateList = + Span(opStateList); Span mOperationalPhaseList; public: diff --git a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp index c85c9a3bc88417..2070e1b86754fe 100644 --- a/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/operational-state-delegate-impl.cpp @@ -28,10 +28,10 @@ static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data DataModel::Nullable GenericOperationalStateDelegateImpl::GetCountdownTime() { - if(mCountDownTime.IsNull()) + if (mCountDownTime.IsNull()) return DataModel::NullNullable; - return DataModel::MakeNullable((uint32_t)(mCountDownTime.Value() - mRunningTime)); + return DataModel::MakeNullable((uint32_t) (mCountDownTime.Value() - mRunningTime)); } CHIP_ERROR GenericOperationalStateDelegateImpl::GetOperationalStateAtIndex(size_t index, GenericOperationalState & operationalState) @@ -55,9 +55,10 @@ CHIP_ERROR GenericOperationalStateDelegateImpl::GetOperationalPhaseAtIndex(size_ void GenericOperationalStateDelegateImpl::HandlePauseStateCallback(GenericOperationalError & err) { - OperationalState::OperationalStateEnum state = static_cast(GetInstance()->GetCurrentOperationalState()); + OperationalState::OperationalStateEnum state = + static_cast(GetInstance()->GetCurrentOperationalState()); - if(state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) + if (state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) { err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState)); return; @@ -77,9 +78,10 @@ void GenericOperationalStateDelegateImpl::HandlePauseStateCallback(GenericOperat void GenericOperationalStateDelegateImpl::HandleResumeStateCallback(GenericOperationalError & err) { - OperationalState::OperationalStateEnum state = static_cast(GetInstance()->GetCurrentOperationalState()); + OperationalState::OperationalStateEnum state = + static_cast(GetInstance()->GetCurrentOperationalState()); - if(state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) + if (state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) { err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState)); return; @@ -102,7 +104,7 @@ void GenericOperationalStateDelegateImpl::HandleStartStateCallback(GenericOperat OperationalState::GenericOperationalError current_err(to_underlying(OperationalState::ErrorStateEnum::kNoError)); GetInstance()->GetCurrentOperationalError(current_err); - if(current_err.errorStateID != to_underlying(OperationalState::ErrorStateEnum::kNoError)) + if (current_err.errorStateID != to_underlying(OperationalState::ErrorStateEnum::kNoError)) { err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToStartOrResume)); return; @@ -135,12 +137,10 @@ void GenericOperationalStateDelegateImpl::HandleStopStateCallback(GenericOperati Optional> totalTime((DataModel::Nullable(mRunningTime + mPausedTime))); Optional> pausedTime((DataModel::Nullable(mPausedTime))); - GetInstance()->OnOperationCompletionDetected(static_cast(current_err.errorStateID), - totalTime, - pausedTime); + GetInstance()->OnOperationCompletionDetected(static_cast(current_err.errorStateID), totalTime, pausedTime); mRunningTime = 0; - mPausedTime = 0; + mPausedTime = 0; err.Set(to_underlying(ErrorStateEnum::kNoError)); } else @@ -149,31 +149,29 @@ void GenericOperationalStateDelegateImpl::HandleStopStateCallback(GenericOperati } } - static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data) { GenericOperationalStateDelegateImpl * delegate = reinterpret_cast(data); OperationalState::Instance * instance = OperationalState::GetOperationalStateInstance(); - OperationalState::OperationalStateEnum state = static_cast(instance->GetCurrentOperationalState()); + OperationalState::OperationalStateEnum state = + static_cast(instance->GetCurrentOperationalState()); auto countdown_time = delegate->GetCountdownTime(); - if(countdown_time.IsNull() || - (!countdown_time.IsNull() && countdown_time.Value() > 0)) + if (countdown_time.IsNull() || (!countdown_time.IsNull() && countdown_time.Value() > 0)) { - if(state == OperationalState::OperationalStateEnum::kRunning) + if (state == OperationalState::OperationalStateEnum::kRunning) { delegate->mRunningTime++; } - else if(state == OperationalState::OperationalStateEnum::kPaused) + else if (state == OperationalState::OperationalStateEnum::kPaused) { delegate->mPausedTime++; } } - if (state == OperationalState::OperationalStateEnum::kRunning || - state == OperationalState::OperationalStateEnum::kPaused) + if (state == OperationalState::OperationalStateEnum::kRunning || state == OperationalState::OperationalStateEnum::kPaused) { (void) DeviceLayer::SystemLayer().StartTimer(System::Clock::Seconds16(1), onOperationalStateTimerTick, delegate); } @@ -183,7 +181,6 @@ static void onOperationalStateTimerTick(System::Layer * systemLayer, void * data } } - // Init Operational State cluster static OperationalState::Instance * gOperationalStateInstance = nullptr; diff --git a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp index d98e732788d7c6..726f326afbb6f8 100644 --- a/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp +++ b/examples/all-clusters-app/all-clusters-common/src/oven-operational-state-delegate.cpp @@ -22,8 +22,8 @@ using namespace chip::app; using namespace chip::app::Clusters; using namespace chip::app::Clusters::OvenCavityOperationalState; -static OvenCavityOperationalState::Instance * gOvenCavityOperationalStateInstance = nullptr; -static OvenCavityOperationalStateDelegate * gOvenCavityOperationalStateDelegate = nullptr; +static OvenCavityOperationalState::Instance * gOvenCavityOperationalStateInstance = nullptr; +static OvenCavityOperationalStateDelegate * gOvenCavityOperationalStateDelegate = nullptr; OvenCavityOperationalState::Instance * OvenCavityOperationalState::GetOperationalStateInstance() { @@ -83,9 +83,10 @@ OvenCavityOperationalStateDelegate::GetOperationalPhaseAtIndex(size_t index, Mut void OvenCavityOperationalStateDelegate::HandlePauseStateCallback(OperationalState::GenericOperationalError & err) { - OperationalState::OperationalStateEnum state = static_cast(GetInstance()->GetCurrentOperationalState()); + OperationalState::OperationalStateEnum state = + static_cast(GetInstance()->GetCurrentOperationalState()); - if(state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) + if (state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) { err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState)); return; @@ -105,9 +106,10 @@ void OvenCavityOperationalStateDelegate::HandlePauseStateCallback(OperationalSta void OvenCavityOperationalStateDelegate::HandleResumeStateCallback(OperationalState::GenericOperationalError & err) { - OperationalState::OperationalStateEnum state = static_cast(GetInstance()->GetCurrentOperationalState()); + OperationalState::OperationalStateEnum state = + static_cast(GetInstance()->GetCurrentOperationalState()); - if(state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) + if (state == OperationalState::OperationalStateEnum::kStopped || state == OperationalState::OperationalStateEnum::kError) { err.Set(to_underlying(OperationalState::ErrorStateEnum::kCommandInvalidInState)); return; @@ -129,7 +131,7 @@ void OvenCavityOperationalStateDelegate::HandleStartStateCallback(OperationalSta OperationalState::GenericOperationalError current_err(to_underlying(OperationalState::ErrorStateEnum::kNoError)); GetInstance()->GetCurrentOperationalError(current_err); - if(current_err.errorStateID != to_underlying(OperationalState::ErrorStateEnum::kNoError)) + if (current_err.errorStateID != to_underlying(OperationalState::ErrorStateEnum::kNoError)) { err.Set(to_underlying(OperationalState::ErrorStateEnum::kUnableToStartOrResume)); return; diff --git a/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp b/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp index 03a9713fa49317..6a49d475f8acd7 100644 --- a/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp +++ b/examples/all-clusters-app/linux/AllClustersCommandDelegate.cpp @@ -30,10 +30,10 @@ #include #include #include -#include -#include #include +#include #include +#include using namespace chip; using namespace chip::app; @@ -183,8 +183,8 @@ void AllClustersAppCommandHandler::HandleCommand(intptr_t context) } else if (name == "OperationalStateChange") { - std::string device = self->mJsonValue["Device"].asString(); - std::string operation = self->mJsonValue["Operation"].asString(); + std::string device = self->mJsonValue["Device"].asString(); + std::string operation = self->mJsonValue["Operation"].asString(); self->OnOperationalStateChange(device, operation, self->mJsonValue["Param"]); } else From 2bcf892dbdc72aa5d3d37b3c75e1395c045697c9 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 13 Feb 2024 01:48:53 +0000 Subject: [PATCH 85/89] Restyled by autopep8 --- src/python_testing/TC_OPSTATE_1_1.py | 1 - src/python_testing/TC_OPSTATE_2_1.py | 1 - src/python_testing/TC_OPSTATE_2_2.py | 1 - src/python_testing/TC_OPSTATE_2_3.py | 1 - src/python_testing/TC_OPSTATE_2_4.py | 1 - src/python_testing/TC_OPSTATE_2_5.py | 1 - src/python_testing/TC_OVENOPSTATE_1_1.py | 1 - src/python_testing/TC_OVENOPSTATE_2_1.py | 1 - src/python_testing/TC_OVENOPSTATE_2_2.py | 1 - src/python_testing/TC_OVENOPSTATE_2_3.py | 1 - src/python_testing/TC_OVENOPSTATE_2_4.py | 1 - src/python_testing/TC_OVENOPSTATE_2_5.py | 1 - src/python_testing/TC_OpstateCommon.py | 30 ++++++++++++++---------- 13 files changed, 18 insertions(+), 24 deletions(-) diff --git a/src/python_testing/TC_OPSTATE_1_1.py b/src/python_testing/TC_OPSTATE_1_1.py index 49f88ec54e4c8b..03f82126b34a96 100644 --- a/src/python_testing/TC_OPSTATE_1_1.py +++ b/src/python_testing/TC_OPSTATE_1_1.py @@ -51,4 +51,3 @@ async def test_TC_OPSTATE_1_1(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OPSTATE_2_1.py b/src/python_testing/TC_OPSTATE_2_1.py index 14dc08b23863c6..cdfd7ff753300c 100644 --- a/src/python_testing/TC_OPSTATE_2_1.py +++ b/src/python_testing/TC_OPSTATE_2_1.py @@ -46,4 +46,3 @@ async def test_TC_OPSTATE_2_1(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OPSTATE_2_2.py b/src/python_testing/TC_OPSTATE_2_2.py index e2d17926ceb2a1..e65fa3b61ffb9a 100644 --- a/src/python_testing/TC_OPSTATE_2_2.py +++ b/src/python_testing/TC_OPSTATE_2_2.py @@ -48,4 +48,3 @@ async def test_TC_OPSTATE_2_2(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OPSTATE_2_3.py b/src/python_testing/TC_OPSTATE_2_3.py index 27a3dae081eb21..05a20b21a36714 100644 --- a/src/python_testing/TC_OPSTATE_2_3.py +++ b/src/python_testing/TC_OPSTATE_2_3.py @@ -47,4 +47,3 @@ async def test_TC_OPSTATE_2_3(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OPSTATE_2_4.py b/src/python_testing/TC_OPSTATE_2_4.py index 5e86ac8118ca20..6e09048b4a1709 100644 --- a/src/python_testing/TC_OPSTATE_2_4.py +++ b/src/python_testing/TC_OPSTATE_2_4.py @@ -47,4 +47,3 @@ async def test_TC_OPSTATE_2_4(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OPSTATE_2_5.py b/src/python_testing/TC_OPSTATE_2_5.py index fd34bebaeca423..9611ffb0b05a18 100644 --- a/src/python_testing/TC_OPSTATE_2_5.py +++ b/src/python_testing/TC_OPSTATE_2_5.py @@ -47,4 +47,3 @@ async def test_TC_OPSTATE_2_5(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OVENOPSTATE_1_1.py b/src/python_testing/TC_OVENOPSTATE_1_1.py index 3b724a826f39aa..8605535430abc8 100644 --- a/src/python_testing/TC_OVENOPSTATE_1_1.py +++ b/src/python_testing/TC_OVENOPSTATE_1_1.py @@ -51,4 +51,3 @@ async def test_TC_OVENOPSTATE_1_1(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index 9c353d2a7a3b9e..e7ca03136a6fb0 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -46,4 +46,3 @@ async def test_TC_OVENOPSTATE_2_1(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OVENOPSTATE_2_2.py b/src/python_testing/TC_OVENOPSTATE_2_2.py index cbad9741410950..1473d8301ca9dc 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_2.py +++ b/src/python_testing/TC_OVENOPSTATE_2_2.py @@ -48,4 +48,3 @@ async def test_TC_OVENOPSTATE_2_2(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py index e3074cf0eef765..a3096e48618151 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_3.py +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -47,4 +47,3 @@ async def test_TC_OVENOPSTATE_2_3(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OVENOPSTATE_2_4.py b/src/python_testing/TC_OVENOPSTATE_2_4.py index 41bacdeba7ae55..d048dbf8597897 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_4.py +++ b/src/python_testing/TC_OVENOPSTATE_2_4.py @@ -47,4 +47,3 @@ async def test_TC_OVENOPSTATE_2_4(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OVENOPSTATE_2_5.py b/src/python_testing/TC_OVENOPSTATE_2_5.py index e8141bcb515717..b50ad77c4424ee 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_5.py +++ b/src/python_testing/TC_OVENOPSTATE_2_5.py @@ -47,4 +47,3 @@ async def test_TC_OVENOPSTATE_2_5(self): if __name__ == "__main__": default_matter_test_main() - diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index c3a714d9cb0d51..2f252bc443ba54 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -153,8 +153,8 @@ async def read_expect_success(self, endpoint, attribute): async def read_and_expect_value(self, endpoint, attribute, expected_value): attr_value = await self.read_expect_success( - endpoint=endpoint, - attribute=attribute) + endpoint=endpoint, + attribute=attribute) asserts.assert_equal(attr_value, expected_value, "Current value not according expected. Expected %d, received %d!" % @@ -162,8 +162,8 @@ async def read_and_expect_value(self, endpoint, attribute, expected_value): async def read_and_expect_property_value(self, endpoint, attribute, attr_property, expected_value): attr_value = await self.read_expect_success( - endpoint=endpoint, - attribute=attribute) + endpoint=endpoint, + attribute=attribute) attr_value = getattr(attr_value, attr_property) asserts.assert_equal(attr_value, expected_value, @@ -172,8 +172,8 @@ async def read_and_expect_property_value(self, endpoint, attribute, attr_propert async def read_and_expect_array_contains(self, endpoint, attribute, expected_contains): attr_value = await self.read_expect_success( - endpoint=endpoint, - attribute=attribute) + endpoint=endpoint, + attribute=attribute) attr_value.sort() expected_contains.sort() @@ -397,7 +397,8 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6a: Manually put the device in the Stopped(0x00) operational state self.step("6a") if self.pics_guard(self.check_pics(("%s.S.M.ST_STOPPED" % self.test_info.pics_code))): - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) + self.send_manual_or_pipe_command( + '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) # STEP 6b: TH reads from the DUT the OperationalState attribute self.step("6b") await self.read_and_expect_value(endpoint=endpoint, @@ -409,7 +410,8 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6c: Manually put the device in the Running(0x01) operational state self.step("6c") if self.pics_guard(self.check_pics(("%s.S.M.ST_RUNNING" % self.test_info.pics_code))): - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Start"}' % self.device) + self.send_manual_or_pipe_command( + '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Start"}' % self.device) # STEP 6d: TH reads from the DUT the OperationalState attribute self.step("6d") await self.read_and_expect_value(endpoint=endpoint, @@ -421,7 +423,8 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6e: Manually put the device in the Paused(0x02) operational state self.step("6e") if self.pics_guard(self.check_pics(("%s.S.M.ST_PAUSED" % self.test_info.pics_code))): - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Pause"}' % self.device) + self.send_manual_or_pipe_command( + '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Pause"}' % self.device) # STEP 6f: TH reads from the DUT the OperationalState attribute self.step("6f") await self.read_and_expect_value(endpoint=endpoint, @@ -433,7 +436,8 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6g: Manually put the device in the Error(0x03) operational state self.step("6g") if self.pics_guard(self.check_pics(("%s.S.M.ST_ERROR" % self.test_info.pics_code))): - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) + self.send_manual_or_pipe_command( + '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) # STEP 6h: TH reads from the DUT the OperationalState attribute self.step("6h") await self.read_and_expect_value(endpoint=endpoint, @@ -857,7 +861,8 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 16: Manually put the device in the Error(0x03) operational state self.step(16) if self.pics_guard(self.check_pics(("%s.S.M.ST_ERROR" % self.test_info.pics_code))): - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) + self.send_manual_or_pipe_command( + '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) # STEP 17: TH sends Pause command to the DUT self.step(17) @@ -915,7 +920,8 @@ async def TEST_TC_OPSTATE_BASE_2_4(self, endpoint=1): # STEP 3: At the DUT take the vendor defined action to generate an OperationalError event self.step(3) - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) + self.send_manual_or_pipe_command( + '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) event_data = events_callback.wait_for_event_report(events.OperationalError).errorState # Defined Errors From bac8f4e04f3fdebe89dbb67ee14e4b6ebf25372c Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Tue, 13 Feb 2024 01:48:54 +0000 Subject: [PATCH 86/89] Restyled by isort --- src/python_testing/TC_OPSTATE_1_1.py | 2 +- src/python_testing/TC_OPSTATE_2_1.py | 2 +- src/python_testing/TC_OPSTATE_2_2.py | 2 +- src/python_testing/TC_OPSTATE_2_3.py | 2 +- src/python_testing/TC_OPSTATE_2_4.py | 2 +- src/python_testing/TC_OPSTATE_2_5.py | 2 +- src/python_testing/TC_OVENOPSTATE_1_1.py | 2 +- src/python_testing/TC_OVENOPSTATE_2_1.py | 2 +- src/python_testing/TC_OVENOPSTATE_2_2.py | 2 +- src/python_testing/TC_OVENOPSTATE_2_3.py | 2 +- src/python_testing/TC_OVENOPSTATE_2_4.py | 2 +- src/python_testing/TC_OVENOPSTATE_2_5.py | 2 +- src/python_testing/TC_OpstateCommon.py | 8 ++++---- 13 files changed, 16 insertions(+), 16 deletions(-) diff --git a/src/python_testing/TC_OPSTATE_1_1.py b/src/python_testing/TC_OPSTATE_1_1.py index 03f82126b34a96..67caefc85862b5 100644 --- a/src/python_testing/TC_OPSTATE_1_1.py +++ b/src/python_testing/TC_OPSTATE_1_1.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OPSTATE_2_1.py b/src/python_testing/TC_OPSTATE_2_1.py index cdfd7ff753300c..0827202af71c29 100644 --- a/src/python_testing/TC_OPSTATE_2_1.py +++ b/src/python_testing/TC_OPSTATE_2_1.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OPSTATE_2_2.py b/src/python_testing/TC_OPSTATE_2_2.py index e65fa3b61ffb9a..59d36b56cfa66d 100644 --- a/src/python_testing/TC_OPSTATE_2_2.py +++ b/src/python_testing/TC_OPSTATE_2_2.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OPSTATE_2_3.py b/src/python_testing/TC_OPSTATE_2_3.py index 05a20b21a36714..e05aef4f607263 100644 --- a/src/python_testing/TC_OPSTATE_2_3.py +++ b/src/python_testing/TC_OPSTATE_2_3.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OPSTATE_2_4.py b/src/python_testing/TC_OPSTATE_2_4.py index 6e09048b4a1709..7ad8fbccd9cd42 100644 --- a/src/python_testing/TC_OPSTATE_2_4.py +++ b/src/python_testing/TC_OPSTATE_2_4.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OPSTATE_2_5.py b/src/python_testing/TC_OPSTATE_2_5.py index 9611ffb0b05a18..ffaceaeb2863a0 100644 --- a/src/python_testing/TC_OPSTATE_2_5.py +++ b/src/python_testing/TC_OPSTATE_2_5.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OVENOPSTATE_1_1.py b/src/python_testing/TC_OVENOPSTATE_1_1.py index 8605535430abc8..3e6b0a27fbab5d 100644 --- a/src/python_testing/TC_OVENOPSTATE_1_1.py +++ b/src/python_testing/TC_OVENOPSTATE_1_1.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OVENOPSTATE_2_1.py b/src/python_testing/TC_OVENOPSTATE_2_1.py index e7ca03136a6fb0..e6847f22e94f39 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_1.py +++ b/src/python_testing/TC_OVENOPSTATE_2_1.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OVENOPSTATE_2_2.py b/src/python_testing/TC_OVENOPSTATE_2_2.py index 1473d8301ca9dc..7789f5076a7d0a 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_2.py +++ b/src/python_testing/TC_OVENOPSTATE_2_2.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OVENOPSTATE_2_3.py b/src/python_testing/TC_OVENOPSTATE_2_3.py index a3096e48618151..25434978320b46 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_3.py +++ b/src/python_testing/TC_OVENOPSTATE_2_3.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OVENOPSTATE_2_4.py b/src/python_testing/TC_OVENOPSTATE_2_4.py index d048dbf8597897..4bc2040638b820 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_4.py +++ b/src/python_testing/TC_OVENOPSTATE_2_4.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OVENOPSTATE_2_5.py b/src/python_testing/TC_OVENOPSTATE_2_5.py index b50ad77c4424ee..7754f0a624ffd3 100644 --- a/src/python_testing/TC_OVENOPSTATE_2_5.py +++ b/src/python_testing/TC_OVENOPSTATE_2_5.py @@ -17,7 +17,7 @@ import chip.clusters as Clusters -from matter_testing_support import TestStep, MatterBaseTest, async_test_body, default_matter_test_main +from matter_testing_support import MatterBaseTest, TestStep, async_test_body, default_matter_test_main from TC_OpstateCommon import TC_OPSTATE_BASE, TestInfo diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index 2f252bc443ba54..e71e72da7cac93 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -16,18 +16,18 @@ # import logging -import time import queue +import time +from dataclasses import dataclass import chip.clusters as Clusters +import psutil from chip.clusters import ClusterObjects as ClusterObjects from chip.clusters.Attribute import EventReadResult, SubscriptionTransaction from chip.clusters.Types import NullValue from chip.interaction_model import InteractionModelError, Status +from matter_testing_support import EventChangeCallback, TestStep from mobly import asserts -from dataclasses import dataclass -from matter_testing_support import TestStep, EventChangeCallback -import psutil def get_pid(name): From 261c7cdd71a4634d222141775fb217934a9ea2a7 Mon Sep 17 00:00:00 2001 From: LUCAS BECKER Date: Wed, 14 Feb 2024 14:53:58 -0300 Subject: [PATCH 87/89] Updates according review --- src/python_testing/TC_OpstateCommon.py | 423 +++++++++++++------------ 1 file changed, 224 insertions(+), 199 deletions(-) diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index e71e72da7cac93..f9b41561c56c9e 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -19,6 +19,8 @@ import queue import time from dataclasses import dataclass +import json +from typing import Any import chip.clusters as Clusters import psutil @@ -77,7 +79,7 @@ def wait_for_event_report(self, timeout: int = 10): try: res = self._q.get(block=True, timeout=timeout) except queue.Empty: - asserts.fail("Failed to receive a report for the event {}".format(self._expected_event)) + asserts.fail(f"Failed to receive a report for the event {self._expected_event}") asserts.assert_equal(res.Header.ClusterId, self._expected_cluster_id, "Expected cluster ID not found in event report") asserts.assert_equal(res.Header.EventId, self._expected_event.event_id, "Expected event ID not found in event report") @@ -98,7 +100,7 @@ def setup_base(self, test_info=None, app_pipe="/tmp/chip_all_clusters_fifo_"): elif self.test_info.cluster == Clusters.OvenCavityOperationalState: self.device = "Oven" else: - asserts.fail("Cluster not supported!") + asserts.fail(f"This provided cluster ({self.test_info.cluster}) is not supported!") def init_test(self): self.is_ci = self.check_pics("PICS_SDK_CI_ONLY") @@ -115,14 +117,27 @@ def write_to_app_pipe(self, command): with open(self.app_pipe, "w") as app_pipe: app_pipe.write(command + "\n") - def send_manual_or_pipe_command(self, command): + def send_raw_manual_or_pipe_command(self, command): if self.is_ci: self.write_to_app_pipe(command) + time.sleep(0.1) else: input("Press Enter when done.\n") + def send_manual_or_pipe_command(self, device: str, name: str, operation: str, param: Any = None): + command = { + "Name": name, + "Device": device, + "Operation": operation, + } + + if param is not None: + command["Param"] = param + + self.send_raw_manual_or_pipe_command(json.dumps(command)) + async def send_cmd(self, endpoint, cmd, timedRequestTimeoutMs=None): - logging.info("\t##### Command %s" % cmd) + logging.info(f"##### Command {cmd}") try: return await self.send_single_cmd(cmd=cmd, @@ -130,7 +145,7 @@ async def send_cmd(self, endpoint, cmd, timedRequestTimeoutMs=None): timedRequestTimeoutMs=timedRequestTimeoutMs) except InteractionModelError as e: - asserts.fail("Unexpected error returned: %s" % e.status) + asserts.fail(f"Unexpected error returned: {e.status}") async def send_cmd_expect_response(self, endpoint, cmd, expected_response, timedRequestTimeoutMs=None): ret = await self.send_cmd(endpoint=endpoint, @@ -139,15 +154,14 @@ async def send_cmd_expect_response(self, endpoint, cmd, expected_response, timed asserts.assert_equal(ret.commandResponseState.errorStateID, expected_response, - "Current value not according expected. Expected %d, received %d!" % - (expected_response, ret.commandResponseState.errorStateID)) + f"Command response ({ret.commandResponseState}) mismatched from expectation for {cmd} on {endpoint}") async def read_expect_success(self, endpoint, attribute): - logging.info("\t##### Read %s" % attribute) + logging.info(f"##### Read {attribute}") attr_value = await self.read_single_attribute_check_success(endpoint=endpoint, cluster=self.test_info.cluster, attribute=attribute) - logging.info("\t## %s: %s" % (attribute, attr_value)) + logging.info(f"## {attribute}: {attr_value}") return attr_value @@ -157,18 +171,16 @@ async def read_and_expect_value(self, endpoint, attribute, expected_value): attribute=attribute) asserts.assert_equal(attr_value, expected_value, - "Current value not according expected. Expected %d, received %d!" % - (expected_value, attr_value)) + f"Value mismatched from expectation for {attribute} on {endpoint}") async def read_and_expect_property_value(self, endpoint, attribute, attr_property, expected_value): attr_value = await self.read_expect_success( endpoint=endpoint, attribute=attribute) - attr_value = getattr(attr_value, attr_property) + field_value = getattr(attr_value, attr_property) - asserts.assert_equal(attr_value, expected_value, - "Current value not according expected. Expected %d, received %d!" % - (expected_value, attr_value)) + asserts.assert_equal(field_value, expected_value, + f"Property '{attr_property}' value mismatched from expectation for {attribute} on {endpoint}") async def read_and_expect_array_contains(self, endpoint, attribute, expected_contains): attr_value = await self.read_expect_success( @@ -177,13 +189,12 @@ async def read_and_expect_array_contains(self, endpoint, attribute, expected_con attr_value.sort() expected_contains.sort() - logging.info("\t## Current value: [%s]" % ','.join(map(str, attr_value))) - logging.info("\t## Expected value: [%s]" % ','.join(map(str, expected_contains))) + logging.info("## Current value: [%s]" % attr_value) + logging.info("## Expected value: [%s]" % expected_contains) for item in expected_contains: if item not in attr_value: - asserts.fail("""Entry (%s), not found! The returned value SHALL include all the entries: [%s]!""" % - (item, ','.join(map(str, expected_contains)))) + asserts.fail("Entry (%s), not found! The returned value SHALL include all the entries: [%s]!" % (item, expected_contains)) ############################ # TEST CASE 1.1 @@ -237,7 +248,7 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature attributes.ClusterRevision.attribute_id ] - if self.check_pics(("%s.S.A0002" % self.test_info.pics_code)): + if self.check_pics(f"{self.test_info.pics_code}.S.A0002"): expected_value.append(attributes.CountdownTime.attribute_id) await self.read_and_expect_array_contains(endpoint=endpoint, @@ -251,7 +262,7 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature events.OperationalError.event_id, ] - if self.check_pics(("%s.S.E01" % self.test_info.pics_code)): + if self.check_pics(f"{self.test_info.pics_code}.S.E01"): expected_value.append(events.OperationCompletion.event_id) await self.read_and_expect_array_contains(endpoint=endpoint, @@ -262,19 +273,19 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature self.step(6) expected_value = [] - if (self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code))): + if (self.check_pics(f"{self.test_info.pics_code}.S.C00.Rsp") or + self.check_pics(f"{self.test_info.pics_code}.S.C03.Rsp")): expected_value.append(commands.Pause.command_id) - if (self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code))): + if (self.check_pics(f"{self.test_info.pics_code}.S.C01.Rsp") or + self.check_pics(f"{self.test_info.pics_code}.S.C02.Rsp")): expected_value.append(commands.Stop.command_id) - if self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)): + if self.check_pics(f"{self.test_info.pics_code}.S.C02.Rsp"): expected_value.append(commands.Start.command_id) - if (self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code))): + if (self.check_pics(f"{self.test_info.pics_code}.S.C03.Rsp") or + self.check_pics(f"{self.test_info.pics_code}.S.C00.Rsp")): expected_value.append(commands.Resume.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, @@ -285,10 +296,10 @@ async def TEST_TC_OPSTATE_BASE_1_1(self, endpoint=1, cluster_revision=1, feature self.step(7) expected_value = [] - if (self.check_pics(("%s.S.C00.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C01.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C02.Rsp" % self.test_info.pics_code)) or - self.check_pics(("%s.S.C03.Rsp" % self.test_info.pics_code))): + if (self.check_pics(f"{self.test_info.pics_code}.S.C00.Rsp") or + self.check_pics(f"{self.test_info.pics_code}.S.C01.Rsp") or + self.check_pics(f"{self.test_info.pics_code}.S.C02.Rsp") or + self.check_pics(f"{self.test_info.pics_code}.S.C03.Rsp")): expected_value.append(commands.OperationalCommandResponse.command_id) await self.read_and_expect_array_contains(endpoint=endpoint, @@ -336,41 +347,41 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 2: TH reads from the DUT the PhaseList attribute self.step(2) - if self.pics_guard(self.check_pics(("%s.S.A0000" % self.test_info.pics_code))): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0000")): phase_list = await self.read_expect_success(endpoint=endpoint, attribute=attributes.PhaseList) if phase_list is not NullValue: phase_list_len = len(phase_list) asserts.assert_less_equal(phase_list_len, 32, - "PhaseList length(%d) must be less than 32!" % phase_list_len) + f"PhaseList length({phase_list_len}) must be less than 32!") # STEP 3: TH reads from the DUT the CurrentPhase attribute self.step(3) - if self.pics_guard(self.check_pics(("%s.S.A0001" % self.test_info.pics_code))): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0001")): current_phase = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CurrentPhase) if (phase_list == NullValue) or (not phase_list): - asserts.assert_true(current_phase == NullValue, "CurrentPhase(%s) should be null" % current_phase) + asserts.assert_true(current_phase == NullValue, f"CurrentPhase({current_phase}) should be null") else: asserts.assert_true(0 <= current_phase and current_phase < phase_list_len, - "CurrentPhase(%s) must be between 0 and %s" % (current_phase, (phase_list_len - 1))) + f"CurrentPhase({current_phase}) must be between 0 and {(phase_list_len - 1)}") # STEP 4: TH reads from the DUT the CountdownTime attribute self.step(4) - if self.pics_guard(self.check_pics(("%s.S.A0002" % self.test_info.pics_code))): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0002")): countdown_time = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime) if countdown_time is not NullValue: asserts.assert_true(0 <= countdown_time <= 259200, - "CountdownTime(%s) must be between 0 and 259200" % countdown_time) + f"CountdownTime({countdown_time}) must be between 0 and 259200") # STEP 5: TH reads from the DUT the OperationalStateList attribute self.step(5) - if self.pics_guard(self.check_pics(("%s.S.A0003" % self.test_info.pics_code))): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0003")): operational_state_list = await self.read_expect_success(endpoint=endpoint, attribute=attributes.OperationalStateList) defined_states = [state.value for state in cluster.Enums.OperationalStateEnum - if state is not cluster.Enums.OperationalStateEnum.kUnknownEnumValue] + if state != cluster.Enums.OperationalStateEnum.kUnknownEnumValue] for state in operational_state_list: in_range = (0x80 <= state.operationalStateID <= 0xBF) @@ -387,7 +398,7 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6: TH reads from the DUT the OperationalState attribute self.step(6) - if self.pics_guard(self.check_pics(("%s.S.A0004" % self.test_info.pics_code))): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0004")): operational_state = await self.read_expect_success(endpoint=endpoint, attribute=attributes.OperationalState) in_range = (0x80 <= operational_state <= 0xBF) @@ -396,9 +407,10 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6a: Manually put the device in the Stopped(0x00) operational state self.step("6a") - if self.pics_guard(self.check_pics(("%s.S.M.ST_STOPPED" % self.test_info.pics_code))): - self.send_manual_or_pipe_command( - '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_STOPPED")): + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="Stop") # STEP 6b: TH reads from the DUT the OperationalState attribute self.step("6b") await self.read_and_expect_value(endpoint=endpoint, @@ -409,9 +421,10 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6c: Manually put the device in the Running(0x01) operational state self.step("6c") - if self.pics_guard(self.check_pics(("%s.S.M.ST_RUNNING" % self.test_info.pics_code))): - self.send_manual_or_pipe_command( - '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Start"}' % self.device) + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_RUNNING")): + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="Start") # STEP 6d: TH reads from the DUT the OperationalState attribute self.step("6d") await self.read_and_expect_value(endpoint=endpoint, @@ -422,9 +435,10 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6e: Manually put the device in the Paused(0x02) operational state self.step("6e") - if self.pics_guard(self.check_pics(("%s.S.M.ST_PAUSED" % self.test_info.pics_code))): - self.send_manual_or_pipe_command( - '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Pause"}' % self.device) + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_PAUSED")): + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="Pause") # STEP 6f: TH reads from the DUT the OperationalState attribute self.step("6f") await self.read_and_expect_value(endpoint=endpoint, @@ -435,9 +449,11 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 6g: Manually put the device in the Error(0x03) operational state self.step("6g") - if self.pics_guard(self.check_pics(("%s.S.M.ST_ERROR" % self.test_info.pics_code))): - self.send_manual_or_pipe_command( - '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ST_ERROR")): + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="OnFault", + param=cluster.Enums.ErrorStateEnum.kUnableToStartOrResume) # STEP 6h: TH reads from the DUT the OperationalState attribute self.step("6h") await self.read_and_expect_value(endpoint=endpoint, @@ -448,12 +464,12 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 7: TH reads from the DUT the OperationalError attribute self.step(7) - if self.pics_guard(self.check_pics(("%s.S.A0005" % self.test_info.pics_code))): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0005")): operational_error = await self.read_expect_success(endpoint=endpoint, attribute=attributes.OperationalError) # Defined Errors defined_errors = [error.value for error in cluster.Enums.ErrorStateEnum - if error is not cluster.Enums.ErrorStateEnum.kUnknownEnumValue] + if error != cluster.Enums.ErrorStateEnum.kUnknownEnumValue] in_range = (0x80 <= operational_error.errorStateID <= 0xBF) asserts.assert_true(operational_error.errorStateID in defined_errors @@ -463,9 +479,11 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 7a: Manually put the device in the NoError(0x00) error state self.step("7a") - if self.pics_guard(self.check_pics(("%s.S.M.ERR_NO_ERROR" % self.test_info.pics_code))): - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kNoError)) + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ERR_NO_ERROR")): + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="OnFault", + param=cluster.Enums.ErrorStateEnum.kNoError) # STEP 7b: TH reads from the DUT the OperationalError attribute self.step("7b") await self.read_and_expect_property_value(endpoint=endpoint, @@ -477,9 +495,11 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 7c: Manually put the device in the UnableToStartOrResume(0x01) error state self.step("7c") - if self.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code))): - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kUnableToStartOrResume)) + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ERR_UNABLE_TO_START_OR_RESUME")): + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="OnFault", + param=cluster.Enums.ErrorStateEnum.kUnableToStartOrResume) # STEP 7d: TH reads from the DUT the OperationalError attribute self.step("7d") await self.read_and_expect_property_value(endpoint=endpoint, @@ -491,9 +511,11 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 7e: Manually put the device in the UnableToCompleteOperation(0x02) error state self.step("7e") - if self.pics_guard(self.check_pics(("%s.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION" % self.test_info.pics_code))): - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kUnableToCompleteOperation)) + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ERR_UNABLE_TO_COMPLETE_OPERATION")): + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="OnFault", + param=cluster.Enums.ErrorStateEnum.kUnableToCompleteOperation) # STEP 7f: TH reads from the DUT the OperationalError attribute self.step("7f") await self.read_and_expect_property_value(endpoint=endpoint, @@ -505,9 +527,11 @@ async def TEST_TC_OPSTATE_BASE_2_1(self, endpoint=1): # STEP 7g: Manually put the device in the CommandInvalidInState(0x03) error state self.step("7g") - if self.pics_guard(self.check_pics(("%s.S.M.ERR_COMMAND_INVALID_IN_STATE" % self.test_info.pics_code))): - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kCommandInvalidInState)) + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ERR_COMMAND_INVALID_IN_STATE")): + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="OnFault", + param=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) # STEP 7h: TH reads from the DUT the OperationalError attribute self.step("7h") await self.read_and_expect_property_value(endpoint=endpoint, @@ -562,45 +586,48 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): # STEP 2: Manually put the DUT into a state wherein it can receive a Start Command self.step(2) - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kNoError)) - if self.is_ci: - time.sleep(1) - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="OnFault", + param=cluster.Enums.ErrorStateEnum.kNoError) + + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="Stop") # STEP 3: TH reads from the DUT the OperationalStateList attribute self.step(3) - if self.pics_guard(self.check_pics(("%s.S.A0003" % self.test_info.pics_code))): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0003")): operational_state_list = await self.read_expect_success(endpoint=endpoint, attribute=attributes.OperationalStateList) operational_state_list_ids = [op_state.operationalStateID for op_state in operational_state_list] defined_states = [state.value for state in cluster.Enums.OperationalStateEnum - if state is not cluster.Enums.OperationalStateEnum.kUnknownEnumValue] + if state != cluster.Enums.OperationalStateEnum.kUnknownEnumValue] for state in defined_states: if state not in operational_state_list_ids: - asserts.fail("The list shall include structs with the following OperationalStateIds: %s", defined_states) + asserts.fail(f"The list shall include structs with the following OperationalStateIds: {defined_states}") # STEP 4: TH sends Start command to the DUT self.step(4) - if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C02.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Start(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 5: TH reads from the DUT the OperationalState attribute self.step(5) - if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0004")): await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kRunning) # STEP 6: TH reads from the DUT the OperationalError attribute self.step(6) - if self.pics_guard(self.check_pics("%s.S.A0005" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0005")): await self.read_and_expect_property_value(endpoint=endpoint, attribute=attributes.OperationalError, attr_property="errorStateID", @@ -608,95 +635,96 @@ async def TEST_TC_OPSTATE_BASE_2_2(self, endpoint=1): # STEP 7: TH reads from the DUT the CountdownTime attribute self.step(7) - if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0002")): initial_countdown_time = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime) if initial_countdown_time is not NullValue: asserts.assert_true(0 <= initial_countdown_time <= 259200, - "CountdownTime(%s) must be between 0 and 259200" % initial_countdown_time) + f"CountdownTime({initial_countdown_time}) must be between 0 and 259200") # STEP 8: TH reads from the DUT the PhaseList attribute self.step(8) - if self.pics_guard(self.check_pics("%s.S.A0000" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0000")): phase_list = await self.read_expect_success(endpoint=endpoint, attribute=attributes.PhaseList) phase_list_len = 0 if phase_list is not NullValue: phase_list_len = len(phase_list) asserts.assert_less_equal(phase_list_len, 32, - "PhaseList length(%d) must be less than 32!" % phase_list_len) + f"PhaseList length({phase_list_len}) must be less than 32!") # STEP 9: TH reads from the DUT the CurrentPhase attribute self.step(9) - if self.pics_guard(self.check_pics("%s.S.A0001" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0001")): current_phase = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CurrentPhase) if (phase_list == NullValue) or (not phase_list): - asserts.assert_equal(current_phase, NullValue, "CurrentPhase(%s) should be null" % current_phase) + asserts.assert_equal(current_phase, NullValue, f"CurrentPhase({current_phase}) should be null") else: asserts.assert_less_equal(0, current_phase, - "CurrentPhase(%s) must be greater or equal than 0" % current_phase) + f"CurrentPhase({current_phase}) must be greater or equal than 0") asserts.assert_less(current_phase < phase_list_len, - "CurrentPhase(%s) must be less then %s" % (current_phase, (phase_list_len - 1))) + f"CurrentPhase({current_phase}) must be less then {(phase_list_len - 1)}") # STEP 10: TH waits for {PIXIT.WAITTIME.COUNTDOWN} self.step(10) - if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0002")): time.sleep(wait_time) # STEP 11: TH reads from the DUT the CountdownTime attribute self.step(11) - if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0002")): countdown_time = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime) if (countdown_time is not NullValue) and (initial_countdown_time is not NullValue): - difference = abs(countdown_time - initial_countdown_time) - asserts.assert_greater_equal(difference, wait_time, - "The countdown time shall have decreased at least %s since start command" % wait_time) + asserts.assert_less_equal(countdown_time, (initial_countdown_time - wait_time), + f"The countdown time shall have decreased at least {wait_time:.1f} since start command") # STEP 12: TH sends Start command to the DUT self.step(12) - if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C02.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Start(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 13: TH sends Stop command to the DUT self.step(13) - if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C01.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Stop(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 14: TH reads from the DUT the OperationalState attribute self.step(14) - if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0004")): await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kStopped) # STEP 15: TH sends Stop command to the DUT self.step(15) - if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C01.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Stop(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 16: Manually put the DUT into a state wherein it cannot receive a Start Command self.step(16) - if self.pics_guard(self.check_pics("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code)): - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kUnableToCompleteOperation)) + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ERR_UNABLE_TO_START_OR_RESUME")): + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="OnFault", + param=cluster.Enums.ErrorStateEnum.kUnableToCompleteOperation) # STEP 17: TH sends Start command to the DUT self.step(17) - if self.pics_guard(self.check_pics("%s.S.M.ERR_UNABLE_TO_START_OR_RESUME" % self.test_info.pics_code) and - self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.M.ERR_UNABLE_TO_START_OR_RESUME") and + self.check_pics(f"{self.test_info.pics_code}.S.C02.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Start(), expected_response=cluster.Enums.ErrorStateEnum.kUnableToStartOrResume) @@ -747,50 +775,53 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 2: Manually put the DUT into a state wherein it can receive a Pause Command self.step(2) - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kNoError)) - if self.is_ci: - time.sleep(1) - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Start"}' % self.device) + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="OnFault", + param=cluster.Enums.ErrorStateEnum.kNoError) + + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="Start") # STEP 3: TH reads from the DUT the OperationalStateList attribute self.step(3) - if self.pics_guard(self.check_pics(("%s.S.A0003" % self.test_info.pics_code))): + if self.pics_guard(self.check_pics((f"{self.test_info.pics_code}.S.A0003"))): operational_state_list = await self.read_expect_success(endpoint=endpoint, attribute=attributes.OperationalStateList) operational_state_list_ids = [op_state.operationalStateID for op_state in operational_state_list] defined_states = [state.value for state in cluster.Enums.OperationalStateEnum - if state is not cluster.Enums.OperationalStateEnum.kUnknownEnumValue] + if state != cluster.Enums.OperationalStateEnum.kUnknownEnumValue] for state in defined_states: if state not in operational_state_list_ids: - asserts.fail("The list shall include structs with the following OperationalStateIds: %s", defined_states) + asserts.fail(f"The list shall include structs with the following OperationalStateIds: {defined_states}") # STEP 4: TH sends Pause command to the DUT self.step(4) - if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C00.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Pause(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 5: TH reads from the DUT the OperationalState attribute self.step(5) - if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0004")): await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kPaused) # STEP 6: TH reads from the DUT the CountdownTime attribute self.step(6) - if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0002")): initial_countdown_time = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime) if initial_countdown_time is not NullValue: asserts.assert_true(0 <= initial_countdown_time <= 259200, - "CountdownTime(%s) must be between 0 and 259200" % initial_countdown_time) + f"CountdownTime({initial_countdown_time}) must be between 0 and 259200") # STEP 7: TH waits for {PIXIT.WAITTIME.COUNTDOWN} self.step(7) @@ -798,7 +829,7 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 8: TH reads from the DUT the CountdownTime attribute self.step(8) - if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0002")): countdown_time = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime) @@ -808,74 +839,78 @@ async def TEST_TC_OPSTATE_BASE_2_3(self, endpoint=1): # STEP 9: TH sends Pause command to the DUT self.step(9) - if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C00.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Pause(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 10: TH sends Resume command to the DUT self.step(10) - if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C03.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Resume(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 11: TH reads from the DUT the OperationalState attribute self.step(11) - if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0004")): await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kRunning) # STEP 12: TH sends Resume command to the DUT self.step(12) - if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C03.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Resume(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 13: Manually put the device in the Stopped(0x00) operational state self.step(13) - if self.pics_guard(self.check_pics(("%s.S.M.ST_STOPPED" % self.test_info.pics_code))): - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) + if self.pics_guard(self.check_pics((f"{self.test_info.pics_code}.S.M.ST_STOPPED"))): + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="Stop") # STEP 14: TH sends Pause command to the DUT self.step(14) - if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C00.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Pause(), expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) # STEP 15: TH sends Resume command to the DUT self.step(15) - if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C03.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Resume(), expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) # STEP 16: Manually put the device in the Error(0x03) operational state self.step(16) - if self.pics_guard(self.check_pics(("%s.S.M.ST_ERROR" % self.test_info.pics_code))): - self.send_manual_or_pipe_command( - '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) + if self.pics_guard(self.check_pics((f"{self.test_info.pics_code}.S.M.ST_ERROR"))): + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="OnFault", + param=cluster.Enums.ErrorStateEnum.kUnableToStartOrResume) # STEP 17: TH sends Pause command to the DUT self.step(17) - if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C00.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Pause(), expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) # STEP 18: TH sends Resume command to the DUT self.step(18) - if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C03.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Resume(), expected_response=cluster.Enums.ErrorStateEnum.kCommandInvalidInState) @@ -898,11 +933,10 @@ async def TEST_TC_OPSTATE_BASE_2_4(self, endpoint=1): self.init_test() - pixit_var_name = 'PIXIT.%s.ErrorEventGen' % self.test_info.pics_code + pixit_var_name = f'PIXIT.{self.test_info.pics_code}.ErrorEventGen' print(pixit_var_name in self.matter_test_config.global_test_params) asserts.assert_true(pixit_var_name in self.matter_test_config.global_test_params, - "%s must be included on the command line in " - "the --int-arg flag as %s:<0 or 1>" % (pixit_var_name, pixit_var_name)) + f"{pixit_var_name} must be included on the command line in the --int-arg flag as {pixit_var_name}:<0 or 1>") error_event_gen = self.matter_test_config.global_test_params[pixit_var_name] @@ -920,14 +954,16 @@ async def TEST_TC_OPSTATE_BASE_2_4(self, endpoint=1): # STEP 3: At the DUT take the vendor defined action to generate an OperationalError event self.step(3) - self.send_manual_or_pipe_command( - '{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": 1}' % self.device) + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="OnFault", + param=cluster.Enums.ErrorStateEnum.kUnableToStartOrResume) event_data = events_callback.wait_for_event_report(events.OperationalError).errorState # Defined Errors defined_errors = [error.value for error in cluster.Enums.ErrorStateEnum - if (error is not cluster.Enums.ErrorStateEnum.kUnknownEnumValue or - error is not cluster.Enums.ErrorStateEnum.kNoError)] + if (error != cluster.Enums.ErrorStateEnum.kUnknownEnumValue or + error != cluster.Enums.ErrorStateEnum.kNoError)] in_range = (0x80 <= event_data.errorStateID <= 0xBF) asserts.assert_true(event_data.errorStateID in defined_errors @@ -937,7 +973,7 @@ async def TEST_TC_OPSTATE_BASE_2_4(self, endpoint=1): # STEP 4: TH reads from the DUT the OperationalState attribute self.step(4) - if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0004")): await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kError) @@ -997,7 +1033,7 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1): # STEP 2: Set up a subscription to the OperationCompletion event self.step(2) - if self.pics_guard(self.check_pics("%s.S.E01" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.E01")): # Subscribe to Events and when they are sent push them to a queue for checking later events_callback = EventSpecificChangeCallback(events.OperationCompletion) await events_callback.start(self.default_controller, @@ -1006,30 +1042,33 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1): # STEP 3: Manually put the DUT into a state wherein it can receive a Start Command self.step(3) - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"OnFault", "Param": %s}' % - (self.device, cluster.Enums.ErrorStateEnum.kNoError)) - if self.is_ci: - time.sleep(1) - self.send_manual_or_pipe_command('{"Name":"OperationalStateChange", "Device":"%s", "Operation":"Stop"}' % self.device) + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="OnFault", + param=cluster.Enums.ErrorStateEnum.kNoError) + + self.send_manual_or_pipe_command(name="OperationalStateChange", + device=self.device, + operation="Stop") # STEP 4: TH sends Start command to the DUT self.step(4) - if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C02.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Start(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 5: TH reads from the DUT the CountdownTime attribute self.step(5) - if self.pics_guard(self.check_pics("%s.S.A0002" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0002")): initial_countdown_time = await self.read_expect_success(endpoint=endpoint, attribute=attributes.CountdownTime) if initial_countdown_time is not NullValue: # STEP 6: TH reads from the DUT the OperationalState attribute self.step(6) - if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0004")): await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kRunning) @@ -1040,36 +1079,30 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1): # STEP 8: TH sends Stop command to the DUT self.step(8) - if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C01.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Stop(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 9: TH waits for OperationCompletion event self.step(9) - if self.pics_guard(self.check_pics("%s.S.E01" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.E01")): event_data = events_callback.wait_for_event_report() asserts.assert_equal(event_data.completionErrorCode, cluster.Enums.ErrorStateEnum.kNoError, - "Completion event error code different than expected. Expected %s, received %s" % - (cluster.Enums.ErrorStateEnum.kNoError, event_data.completionErrorCode)) + f"Completion event error code mismatched from expectation on endpoint {endpoint}.") if event_data.totalOperationalTime is not NullValue: - # Checks if the total operation time is close to initial_countdown_time - # 'close' is being determined by having a difference lower / equal 2 - difference = abs(event_data.totalOperationalTime - initial_countdown_time) - asserts.assert_less_equal(difference, 2, - "Total operation time (%s) shall be close to the initial coutdown time (%s)" % - (event_data.totalOperationalTime, initial_countdown_time)) + asserts.assert_less_equal(initial_countdown_time, event_data.totalOperationalTime, + f"The total operation time shall be at least {initial_countdown_time:.1f}") - asserts.assert_equal(event_data.pausedTime, 0, - "Completion event paused time expected to be zero, received %s" % - event_data.pausedTime) + asserts.assert_equal(0, event_data.pausedTime, + f"Paused time ({event_data.pausedTime}) shall be zero") # STEP 10: TH reads from the DUT the OperationalState attribute self.step(10) - if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0004")): await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kStopped) @@ -1087,30 +1120,30 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1): # STEP 13: TH sends Start command to the DUT self.step(13) - if self.pics_guard(self.check_pics("%s.S.C02.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C02.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Start(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 14: TH reads from the DUT the OperationalState attribute self.step(14) - if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0004")): await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kRunning) # STEP 15: TH sends Pause command to the DUT self.step(15) - if self.pics_guard(self.check_pics("%s.S.C00.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C00.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Pause(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 16: TH reads from the DUT the OperationalState attribute self.step(16) - if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0004")): await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kPaused) @@ -1121,15 +1154,15 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1): # STEP 18: TH sends Resume command to the DUT self.step(18) - if self.pics_guard(self.check_pics("%s.S.C03.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C03.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Resume(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 19: TH reads from the DUT the OperationalState attribute self.step(19) - if self.pics_guard(self.check_pics("%s.S.A0004" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.A0004")): await self.read_and_expect_value(endpoint=endpoint, attribute=attributes.OperationalState, expected_value=cluster.Enums.OperationalStateEnum.kRunning) @@ -1140,37 +1173,29 @@ async def TEST_TC_OPSTATE_BASE_2_5(self, endpoint=1): # STEP 21: TH sends Stop command to the DUT self.step(21) - if self.pics_guard(self.check_pics("%s.S.C01.Rsp" % self.test_info.pics_code) and - self.check_pics("%s.S.C04.Tx" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.C01.Rsp") and + self.check_pics(f"{self.test_info.pics_code}.S.C04.Tx")): await self.send_cmd_expect_response(endpoint=endpoint, cmd=commands.Stop(), expected_response=cluster.Enums.ErrorStateEnum.kNoError) # STEP 22: TH waits for OperationCompletion event self.step(22) - if self.pics_guard(self.check_pics("%s.S.E01" % self.test_info.pics_code)): + if self.pics_guard(self.check_pics(f"{self.test_info.pics_code}.S.E01")): event_data = events_callback.wait_for_event_report() asserts.assert_equal(event_data.completionErrorCode, cluster.Enums.ErrorStateEnum.kNoError, - "Completion event error code different than expected. Expected %s, received %s" % - (cluster.Enums.ErrorStateEnum.kNoError, event_data.completionErrorCode)) + f"Completion event error code mismatched from expectation on endpoint {endpoint}.") if event_data.totalOperationalTime is not NullValue: - # Checks if the total operation time is close to 1.5 * initial_countdown_time - # 'close' is being determined by having a difference lower / equal 2 expected_value = (1.5 * initial_countdown_time) - difference = abs(event_data.totalOperationalTime - expected_value) - asserts.assert_less_equal(difference, 2, - "Total operation time (%s) shall be close to 1.5 times the initial coutdown time (%s)" % - (event_data.totalOperationalTime, initial_countdown_time)) - # Checks if the paused operation time is close to 0.5 * initial_countdown_time - # 'close' is being determined by having a difference lower / equal 2 + asserts.assert_less_equal(expected_value, event_data.totalOperationalTime, + f"The total operation time shall be at least {expected_value:.1f}") + expected_value = (0.5 * initial_countdown_time) - difference = abs(event_data.pausedTime - expected_value) - asserts.assert_less_equal(difference, 2, - "Paused time (%s) shall be close to half of the initial coutdown time (%s)" % - (event_data.pausedTime, expected_value)) + asserts.assert_less_equal(expected_value, event_data.pausedTime, + f"Paused time ({event_data.pausedTime}) shall be at least {expected_value:.1f}") else: self.skip_step(6) self.skip_step(7) From 23e0eea283c54e6db087e5642afd1016cc5fc16f Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 14 Feb 2024 17:54:48 +0000 Subject: [PATCH 88/89] Restyled by autopep8 --- src/python_testing/TC_OpstateCommon.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index f9b41561c56c9e..7488c2f4dbcddf 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -194,7 +194,8 @@ async def read_and_expect_array_contains(self, endpoint, attribute, expected_con for item in expected_contains: if item not in attr_value: - asserts.fail("Entry (%s), not found! The returned value SHALL include all the entries: [%s]!" % (item, expected_contains)) + asserts.fail("Entry (%s), not found! The returned value SHALL include all the entries: [%s]!" % ( + item, expected_contains)) ############################ # TEST CASE 1.1 From 644a7084c763e3431136bfe43b3ce5c68f26eacd Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 14 Feb 2024 17:54:49 +0000 Subject: [PATCH 89/89] Restyled by isort --- src/python_testing/TC_OpstateCommon.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/python_testing/TC_OpstateCommon.py b/src/python_testing/TC_OpstateCommon.py index 7488c2f4dbcddf..9e32aac00ec846 100644 --- a/src/python_testing/TC_OpstateCommon.py +++ b/src/python_testing/TC_OpstateCommon.py @@ -15,11 +15,11 @@ # limitations under the License. # +import json import logging import queue import time from dataclasses import dataclass -import json from typing import Any import chip.clusters as Clusters